diff options
author | Eric Sandeen <sandeen@redhat.com> | 2017-08-04 16:33:52 -0500 |
---|---|---|
committer | Eric Sandeen <sandeen@redhat.com> | 2017-08-04 16:33:52 -0500 |
commit | 1e9c13c58d5cd6c7b83987b6189e47671863b65f (patch) | |
tree | 890212df18ed6a825648813b17c31f59e87d160a | |
parent | 984af2e129d044fff80b8203721733e0cc7354f4 (diff) | |
download | xfsprogs-dev-1e9c13c58d5cd6c7b83987b6189e47671863b65f.tar.gz |
xfs_db: use TYP_F_CRC_FUNC for inodes & dquots
Now that typ_t has a ->set_crc method, use it for inodes & dquots
as well, rather than recognizing them as special types and calling
their crc functions directly by name.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r-- | db/dquot.c | 11 | ||||
-rw-r--r-- | db/dquot.h | 1 | ||||
-rw-r--r-- | db/fuzz.c | 9 | ||||
-rw-r--r-- | db/inode.c | 11 | ||||
-rw-r--r-- | db/inode.h | 1 | ||||
-rw-r--r-- | db/io.c | 35 | ||||
-rw-r--r-- | db/io.h | 2 | ||||
-rw-r--r-- | db/type.c | 8 | ||||
-rw-r--r-- | db/write.c | 10 |
9 files changed, 35 insertions, 53 deletions
diff --git a/db/dquot.c b/db/dquot.c index 061eca5dfd..4e35df42b8 100644 --- a/db/dquot.c +++ b/db/dquot.c @@ -171,6 +171,17 @@ dquot_f( } void +xfs_dquot_set_crc( + struct xfs_buf *bp) +{ + ASSERT((iocur_top->dquot_buf)); + ASSERT(iocur_top->bp == bp); + + xfs_update_cksum(iocur_top->data, sizeof(struct xfs_dqblk), + XFS_DQUOT_CRC_OFF); +} + +void dquot_init(void) { add_command(&dquot_cmd); diff --git a/db/dquot.h b/db/dquot.h index 83a51189c9..12a7244689 100644 --- a/db/dquot.h +++ b/db/dquot.h @@ -20,4 +20,5 @@ extern const struct field disk_dquot_flds[]; extern const struct field dqblk_flds[]; extern const struct field dqblk_hfld[]; +extern void xfs_dquot_set_crc(struct xfs_buf *); extern void dquot_init(void); @@ -125,8 +125,7 @@ fuzz_f( return 0; } - if (invalid_data && iocur_top->typ->crc_off == TYP_F_NO_CRC_OFF && - !iocur_top->ino_buf && !iocur_top->dquot_buf) { + if (invalid_data && iocur_top->typ->crc_off == TYP_F_NO_CRC_OFF) { dbprintf(_("Cannot recalculate CRCs on this type of object\n")); return 0; } @@ -153,12 +152,6 @@ fuzz_f( if (corrupt) { local_ops.verify_write = xfs_dummy_verify; dbprintf(_("Allowing fuzz of corrupted data and bad CRC\n")); - } else if (iocur_top->ino_buf) { - local_ops.verify_write = xfs_verify_recalc_inode_crc; - dbprintf(_("Allowing fuzz of corrupted inode with good CRC\n")); - } else if (iocur_top->dquot_buf) { - local_ops.verify_write = xfs_verify_recalc_dquot_crc; - dbprintf(_("Allowing fuzz of corrupted dquot with good CRC\n")); } else if (iocur_top->typ->crc_off == TYP_F_CRC_FUNC) { local_ops.verify_write = iocur_top->typ->set_crc; dbprintf(_("Allowing fuzz of corrupted data with good CRC\n")); diff --git a/db/inode.c b/db/inode.c index 6cc47d6a7f..6f971c63aa 100644 --- a/db/inode.c +++ b/db/inode.c @@ -711,3 +711,14 @@ _("Metadata CRC error detected for ino %lld\n"), /* track updated info in ring */ ring_add(); } + +void +xfs_inode_set_crc( + struct xfs_buf *bp) +{ + ASSERT(iocur_top->ino_buf); + ASSERT(iocur_top->bp == bp); + + libxfs_dinode_calc_crc(mp, iocur_top->data); + iocur_top->ino_crc_ok = 1; +} diff --git a/db/inode.h b/db/inode.h index 1624f1d58d..d79b0a4c7c 100644 --- a/db/inode.h +++ b/db/inode.h @@ -33,4 +33,5 @@ extern void inode_init(void); extern typnm_t inode_next_type(void); extern int inode_size(void *obj, int startoff, int idx); extern int inode_u_size(void *obj, int startoff, int idx); +extern void xfs_inode_set_crc(struct xfs_buf *); extern void set_cur_inode(xfs_ino_t ino); @@ -22,6 +22,7 @@ #include "faddr.h" #include "fprint.h" #include "field.h" +#include "dquot.h" #include "inode.h" #include "io.h" #include "output.h" @@ -466,28 +467,6 @@ xfs_dummy_verify( } void -xfs_verify_recalc_inode_crc( - struct xfs_buf *bp) -{ - ASSERT(iocur_top->ino_buf); - ASSERT(iocur_top->bp == bp); - - libxfs_dinode_calc_crc(mp, iocur_top->data); - iocur_top->ino_crc_ok = 1; -} - -void -xfs_verify_recalc_dquot_crc( - struct xfs_buf *bp) -{ - ASSERT((iocur_top->dquot_buf)); - ASSERT(iocur_top->bp == bp); - - xfs_update_cksum(iocur_top->data, sizeof(struct xfs_dqblk), - XFS_DQUOT_CRC_OFF); -} - -void xfs_verify_recalc_crc( struct xfs_buf *bp) { @@ -510,14 +489,10 @@ write_cur(void) skip_crc = true; if (!skip_crc) { - if (iocur_top->ino_buf) { - libxfs_dinode_calc_crc(mp, iocur_top->data); - iocur_top->ino_crc_ok = 1; - } else if (iocur_top->dquot_buf) { - xfs_update_cksum(iocur_top->data, - sizeof(struct xfs_dqblk), - XFS_DQUOT_CRC_OFF); - } + if (iocur_top->ino_buf) + xfs_inode_set_crc(iocur_top->bp); + else if (iocur_top->dquot_buf) + xfs_dquot_set_crc(iocur_top->bp); } if (iocur_top->bbmap) write_cur_bbs(); @@ -64,8 +64,6 @@ extern void set_cur(const struct typ *type, xfs_daddr_t blknum, extern void ring_add(void); extern void set_iocur_type(const struct typ *type); extern void xfs_dummy_verify(struct xfs_buf *bp); -extern void xfs_verify_recalc_inode_crc(struct xfs_buf *bp); -extern void xfs_verify_recalc_dquot_crc(struct xfs_buf *bp); extern void xfs_verify_recalc_crc(struct xfs_buf *bp); /* @@ -105,12 +105,12 @@ static const typ_t __typtab_crc[] = { { TYP_DIR2, "dir3", handle_struct, dir3_hfld, &xfs_dir3_db_buf_ops, TYP_F_CRC_FUNC, xfs_dir3_set_crc }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld, - &xfs_dquot_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_dquot_buf_ops, TYP_F_CRC_FUNC, xfs_dquot_set_crc }, { TYP_INOBT, "inobt", handle_struct, inobt_crc_hfld, &xfs_inobt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_INODATA, "inodata", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_INODE, "inode", handle_struct, inode_crc_hfld, - &xfs_inode_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_inode_buf_ops, TYP_F_CRC_FUNC, xfs_inode_set_crc }, { TYP_LOG, "log", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTBITMAP, "rtbitmap", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTSUMMARY, "rtsummary", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, @@ -149,12 +149,12 @@ static const typ_t __typtab_spcrc[] = { { TYP_DIR2, "dir3", handle_struct, dir3_hfld, &xfs_dir3_db_buf_ops, TYP_F_CRC_FUNC, xfs_dir3_set_crc }, { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld, - &xfs_dquot_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_dquot_buf_ops, TYP_F_CRC_FUNC, xfs_dquot_set_crc }, { TYP_INOBT, "inobt", handle_struct, inobt_spcrc_hfld, &xfs_inobt_buf_ops, XFS_BTREE_SBLOCK_CRC_OFF }, { TYP_INODATA, "inodata", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_INODE, "inode", handle_struct, inode_crc_hfld, - &xfs_inode_buf_ops, TYP_F_NO_CRC_OFF }, + &xfs_inode_buf_ops, TYP_F_CRC_FUNC, xfs_inode_set_crc }, { TYP_LOG, "log", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTBITMAP, "rtbitmap", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, { TYP_RTSUMMARY, "rtsummary", NULL, NULL, NULL, TYP_F_NO_CRC_OFF }, diff --git a/db/write.c b/db/write.c index 266bde470a..9fc6d8eea5 100644 --- a/db/write.c +++ b/db/write.c @@ -138,9 +138,7 @@ write_f( } if (invalid_data && - iocur_top->typ->crc_off == TYP_F_NO_CRC_OFF && - !iocur_top->ino_buf && - !iocur_top->dquot_buf) { + iocur_top->typ->crc_off == TYP_F_NO_CRC_OFF) { dbprintf(_("Cannot recalculate CRCs on this type of object\n")); return 0; } @@ -167,12 +165,6 @@ write_f( if (corrupt) { local_ops.verify_write = xfs_dummy_verify; dbprintf(_("Allowing write of corrupted data and bad CRC\n")); - } else if (iocur_top->ino_buf) { - local_ops.verify_write = xfs_verify_recalc_inode_crc; - dbprintf(_("Allowing write of corrupted inode with good CRC\n")); - } else if (iocur_top->dquot_buf) { - local_ops.verify_write = xfs_verify_recalc_dquot_crc; - dbprintf(_("Allowing write of corrupted dquot with good CRC\n")); } else if (iocur_top->typ->crc_off == TYP_F_CRC_FUNC) { local_ops.verify_write = iocur_top->typ->set_crc; dbprintf(_("Allowing write of corrupted data with good CRC\n")); |