Skip to contentSkip to conversation

xfs_db: make write/fuzz -c and -d work on non-crc filesystems

PATCH In review Darrick J. Wong 3 participants 3 messages Aug 17, 2017 – Aug 18, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_db: make write/fuzz -c and -d work on non-crc filesystems

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.

---
 db/fuzz.c  |    8 ++++++--
 db/write.c |    7 +++++--
 2 files changed, 11 insertions(+), 4 deletions(-)
db/fuzz.c +6 -2
index 76dbf94..53cedbc 100644
@@ -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) {
db/write.c +5 -2
index 9fc6d8e..5ef76bc 100644
@@ -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) {
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Darrick J. Wong

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.

Quoted 57 lines
---
 db/fuzz.c  |    8 ++++++--
 db/write.c |    7 +++++--
 2 files changed, 11 insertions(+), 4 deletions(-)
db/fuzz.c +6 -2
index 76dbf94..53cedbc 100644
@@ -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) {
db/write.c +5 -2
index 9fc6d8e..5ef76bc 100644
@@ -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) {
Reviewed-by on v1 1/1
#2 lore raw
In reply to Darrick J. Wong
Quoted 6 lines · Darrick J. Wong

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.

Quoted 60 lines
---
 db/fuzz.c  |    8 ++++++--
 db/write.c |    7 +++++--
 2 files changed, 11 insertions(+), 4 deletions(-)
db/fuzz.c +6 -2
index 76dbf94..53cedbc 100644
@@ -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) {
db/write.c +5 -3
index 9fc6d8e..5ef76bc 100644
@@ -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) {
--

To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Carlos