From e1d3178a2a1f3d2123d7856471ce271a57c10827 Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Thu, 28 Jun 2018 15:11:54 -0500 Subject: [PATCH] xfs: pass full xfs_dqblk to repair during quotacheck Source kernel commit: 48fa1db87f730da1aed2d3df0cc8c33c7c133b4b 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 Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Eric Sandeen --- libxfs/libxfs_api_defs.h | 2 +- libxfs/xfs_dquot_buf.c | 21 +++++++++------------ libxfs/xfs_quota_defs.h | 2 +- repair/dinode.c | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 63bf27eac..a98483bf4 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -128,7 +128,7 @@ #define xfs_calc_dquots_per_chunk libxfs_calc_dquots_per_chunk #define xfs_dquot_verify libxfs_dquot_verify -#define xfs_dquot_repair libxfs_dquot_repair +#define xfs_dqblk_repair libxfs_dqblk_repair #define xfs_symlink_blocks libxfs_symlink_blocks #define xfs_symlink_hdr_ok libxfs_symlink_hdr_ok diff --git a/libxfs/xfs_dquot_buf.c b/libxfs/xfs_dquot_buf.c index 50da0191d..414fbc7bb 100644 --- a/libxfs/xfs_dquot_buf.c +++ b/libxfs/xfs_dquot_buf.c @@ -102,29 +102,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); } diff --git a/libxfs/xfs_quota_defs.h b/libxfs/xfs_quota_defs.h index eeccffec3..9b5c3e454 100644 --- a/libxfs/xfs_quota_defs.h +++ b/libxfs/xfs_quota_defs.h @@ -156,7 +156,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__ */ diff --git a/repair/dinode.c b/repair/dinode.c index de89c0f40..d36338f69 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -1411,7 +1411,7 @@ bad: do_warn(_("Would correct.\n")); else { do_warn(_("Corrected.\n")); - libxfs_dquot_repair(mp, &dqb->dd_diskdq, + libxfs_dqblk_repair(mp, dqb, dqid, quota_type); writebuf = 1; } -- 2.47.2