]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_db: make write/fuzz -c and -d work on non-crc filesystems
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 18 Aug 2017 17:00:03 +0000 (12:00 -0500)
committerEric Sandeen <sandeen@redhat.com>
Fri, 18 Aug 2017 17:00:03 +0000 (12:00 -0500)
For a non-crc filesystem, make write/fuzz -c and -d work properly
instead of bailing out.  Since there's no checksum to update, both
cases collapse to setting the field value without calling the write
verifier.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/fuzz.c
db/write.c

index 76dbf940a9a7a41201527fe7b5964f29a0040e7b..53cedbc69ecb32262f49efa02cb9a7be8e37f2a3 100644 (file)
--- a/db/fuzz.c
+++ b/db/fuzz.c
@@ -125,7 +125,9 @@ fuzz_f(
                return 0;
        }
 
-       if (invalid_data && iocur_top->typ->crc_off == TYP_F_NO_CRC_OFF) {
+       if (invalid_data &&
+           iocur_top->typ->crc_off == TYP_F_NO_CRC_OFF &&
+           xfs_sb_version_hascrc(&mp->m_sb)) {
                dbprintf(_("Cannot recalculate CRCs on this type of object\n"));
                return 0;
        }
@@ -149,7 +151,9 @@ fuzz_f(
        local_ops.verify_read = stashed_ops->verify_read;
        iocur_top->bp->b_ops = &local_ops;
 
-       if (corrupt) {
+       if (!xfs_sb_version_hascrc(&mp->m_sb)) {
+               local_ops.verify_write = xfs_dummy_verify;
+       } else if (corrupt) {
                local_ops.verify_write = xfs_dummy_verify;
                dbprintf(_("Allowing fuzz of corrupted data and bad CRC\n"));
        } else if (iocur_top->typ->crc_off == TYP_F_CRC_FUNC) {
index 9fc6d8eea58b3ef458809a399c6f5e1e450aa68e..5ef76bcd23852cd57f1dcec6600e52cf4abe237d 100644 (file)
@@ -138,7 +138,8 @@ write_f(
        }
 
        if (invalid_data &&
-           iocur_top->typ->crc_off == TYP_F_NO_CRC_OFF) {
+           iocur_top->typ->crc_off == TYP_F_NO_CRC_OFF &&
+           xfs_sb_version_hascrc(&mp->m_sb)) {
                dbprintf(_("Cannot recalculate CRCs on this type of object\n"));
                return 0;
        }
@@ -162,7 +163,9 @@ write_f(
        local_ops.verify_read = stashed_ops->verify_read;
        iocur_top->bp->b_ops = &local_ops;
 
-       if (corrupt) {
+       if (!xfs_sb_version_hascrc(&mp->m_sb)) {
+               local_ops.verify_write = xfs_dummy_verify;
+       } else if (corrupt) {
                local_ops.verify_write = xfs_dummy_verify;
                dbprintf(_("Allowing write of corrupted data and bad CRC\n"));
        } else if (iocur_top->typ->crc_off == TYP_F_CRC_FUNC) {