Skip to content

Commit

Permalink
xfs: pass full xfs_dqblk to repair during quotacheck
Browse files Browse the repository at this point in the history
It's a bit dicey to pass in the smaller xfs_disk_dquot and then cast it to
something larger; pass in the full xfs_dqblk so we know the caller has sent
us the right thing.  Rename the function to xfs_dqblk_repair for
clarity.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
  • Loading branch information
Eric Sandeen authored and Darrick J. Wong committed May 9, 2018
1 parent 57ab324 commit 48fa1db
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
21 changes: 9 additions & 12 deletions fs/xfs/libxfs/xfs_dquot_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,29 +104,26 @@ xfs_dquot_verify(
* Do some primitive error checking on ondisk dquot data structures.
*/
int
xfs_dquot_repair(
xfs_dqblk_repair(
struct xfs_mount *mp,
struct xfs_disk_dquot *ddq,
struct xfs_dqblk *dqb,
xfs_dqid_t id,
uint type)
{
struct xfs_dqblk *d = (struct xfs_dqblk *)ddq;


/*
* Typically, a repair is only requested by quotacheck.
*/
ASSERT(id != -1);
memset(d, 0, sizeof(xfs_dqblk_t));
memset(dqb, 0, sizeof(xfs_dqblk_t));

d->dd_diskdq.d_magic = cpu_to_be16(XFS_DQUOT_MAGIC);
d->dd_diskdq.d_version = XFS_DQUOT_VERSION;
d->dd_diskdq.d_flags = type;
d->dd_diskdq.d_id = cpu_to_be32(id);
dqb->dd_diskdq.d_magic = cpu_to_be16(XFS_DQUOT_MAGIC);
dqb->dd_diskdq.d_version = XFS_DQUOT_VERSION;
dqb->dd_diskdq.d_flags = type;
dqb->dd_diskdq.d_id = cpu_to_be32(id);

if (xfs_sb_version_hascrc(&mp->m_sb)) {
uuid_copy(&d->dd_uuid, &mp->m_sb.sb_meta_uuid);
xfs_update_cksum((char *)d, sizeof(struct xfs_dqblk),
uuid_copy(&dqb->dd_uuid, &mp->m_sb.sb_meta_uuid);
xfs_update_cksum((char *)dqb, sizeof(struct xfs_dqblk),
XFS_DQUOT_CRC_OFF);
}

Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/libxfs/xfs_quota_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ typedef uint16_t xfs_qwarncnt_t;
extern xfs_failaddr_t xfs_dquot_verify(struct xfs_mount *mp,
struct xfs_disk_dquot *ddq, xfs_dqid_t id, uint type);
extern int xfs_calc_dquots_per_chunk(unsigned int nbblks);
extern int xfs_dquot_repair(struct xfs_mount *mp, struct xfs_disk_dquot *ddq,
extern int xfs_dqblk_repair(struct xfs_mount *mp, struct xfs_dqblk *dqb,
xfs_dqid_t id, uint type);

#endif /* __XFS_QUOTA_H__ */
2 changes: 1 addition & 1 deletion fs/xfs/xfs_qm.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ xfs_qm_reset_dqcounts(
*/
fa = xfs_dquot_verify(mp, ddq, id + j, type);
if (fa)
xfs_dquot_repair(mp, ddq, id + j, type);
xfs_dqblk_repair(mp, &dqb[j], id + j, type);

/*
* Reset type in case we are reusing group quota file for
Expand Down

0 comments on commit 48fa1db

Please sign in to comment.