Skip to contentSkip to conversation

xfs/288: use -d option of xfs_db write command for v5 XFS

PATCH In review Zorro Lang 3 participants 7 messages Jul 31, 2018 – Aug 6, 2018

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH v2 1/2 xfs/288: use -d option of xfs_db write command for v5 XFS

The commit b3cf8b72334fd35ef961869506e5a72ab398bc82 update xfs/288 to support v5 filesystem testing. That commit thought xfs_db write command can work well with -d option on V5 XFS. But the truth is the case doesn't use that option.

So turn to use _scratch_xfs_set_metadata_field, it will help to use proper options for xfs_db write command.

---

Hi,

This patch has been reviewed by Darrick J. Wong:
https://marc.info/?l=linux-xfs&m=153287978423915&w=2

I sent this patch again only because it's related with next [2/2] patch.

Thanks,
Zorro

 tests/xfs/288 | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tests/xfs/288 +2 -3
index bccdb6fc..f4165b6c 100755
@@ -56,9 +56,8 @@ $SETFATTR_PROG -n "user.testattr${seq}" \
 
 _scratch_unmount
 # manually corrupt the XFS, by set the header count of attr to 0
-_scratch_xfs_db -x -c "inode $inum" \
-		   -c "ablock 0" \
-		   -c "write hdr.count 0" >> $seqres.full
+_scratch_xfs_set_metadata_field "hdr.count" "0" \
+				"inode $inum" "ablock 0" >> $seqres.full
 
 # make sure xfs_repair can find above corruption. If it can't, that
 # means we need to fix this bug on current xfs_repair
Signature · 1 line
2.14.4
author
#1 lore raw

PATCH v2 2/2 xfs/288: _notrun if xfs_db can't write values into dir or attr

Commit b3cf8b72334fd35ef961869506e5a72ab398bc82 help xfs/288 to support v5 filesystems testing, but there're still some old distributions don't support xfs_db write '-d' option, or can't write values into dir/attr of v5 filesystems.

For compatible with older versions, skip this test on v5 xfs if xfs_db write can't write v5 XFS dir/attr.

---

Hi,

Xiao found v1 can't work well on xfsprogs-4.9, due to 'write -d' can't write vaules into dir/attr of v5 filesystems before xfsprogs-4.13.

Only check "if write command has -d option" is not enough. So I write a function _require_xfs_db_write_da() to make sure current xfs_db can write dir/attr (not only on v5, but especially for v5).

Thanks,
Zorro

 common/xfs    | 28 ++++++++++++++++++++++++++++
 tests/xfs/288 |  1 +
 2 files changed, 29 insertions(+)
common/xfs +28 -0
index d971b4a8..95dcfd59 100644
@@ -720,6 +720,34 @@ _require_xfs_db_write_array()
 	[ $supported -eq 0 ] && _notrun "xfs_db write can't support array"
 }
 
+# Before xfsprogs commit 89baf918(xfs_db: write values into dir/attr blocks and
+# recalculate CRCs), xfs_db write command can't write invalid data into dir/attr
+# field of v5 filesystems. For some cases need to write dir/attr (especially crc
+# enabled), use this _require at first.
+_require_xfs_db_write_da()
+{
+	local inum
+	local count
+
+	_require_scratch
+
+	_scratch_mkfs > /dev/null 2>&1
+	_scratch_mount
+	mkdir $SCRATCH_MNT/$seq.dir
+	inum=$(stat -c '%i' $SCRATCH_MNT/$seq.dir)
+	$SETFATTR_PROG -n "user.testda" \
+		       -v "$(perl -e "print 'v' x 65536;")" \
+		       $SCRATCH_MNT/$seq.dir
+	_scratch_unmount
+	_scratch_xfs_set_metadata_field "hdr.count" "0" \
+					"inode $inum" "ablock 0" >/dev/null 2>&1
+	count=$(_scratch_xfs_get_metadata_field "hdr.count" \
+						"inode $inum" "ablock 0")
+	if [ "$count" != "0" ]; then
+		_notrun "xfs_db write can't write values into dir/attr blocks"
+	fi
+}
+
 _require_xfs_spaceman_command()
 {
 	if [ -z "$1" ]; then
tests/xfs/288 +1 -0
index f4165b6c..e9589fd5 100755
@@ -35,6 +35,7 @@ _supported_fs xfs
 _supported_os Linux
 _require_scratch
 _require_attrs
+_require_xfs_db_write_da
 
 # get block size ($dbsize) from the mkfs output
 _scratch_mkfs_xfs 2>/dev/null | _filter_mkfs 2>$tmp.mkfs >/dev/null
Signature · 1 line
2.14.4
#2 lore raw

Re: [PATCH v2 2/2] xfs/288: _notrun if xfs_db can't write values into dir or attr

Quoted 45 lines · Zorro Lang

Commit b3cf8b72334fd35ef961869506e5a72ab398bc82 help xfs/288 to support v5 filesystems testing, but there're still some old distributions don't support xfs_db write '-d' option, or can't write values into dir/attr of v5 filesystems.

For compatible with older versions, skip this test on v5 xfs if xfs_db write can't write v5 XFS dir/attr.

---

Hi,

Xiao found v1 can't work well on xfsprogs-4.9, due to 'write -d' can't write vaules into dir/attr of v5 filesystems before xfsprogs-4.13.

Only check "if write command has -d option" is not enough. So I write a function _require_xfs_db_write_da() to make sure current xfs_db can write dir/attr (not only on v5, but especially for v5).

Thanks,
Zorro

 common/xfs    | 28 ++++++++++++++++++++++++++++
 tests/xfs/288 |  1 +
 2 files changed, 29 insertions(+)
common/xfs +10 -0
index d971b4a8..95dcfd59 100644
@@ -720,6 +720,34 @@ _require_xfs_db_write_array()
 	[ $supported -eq 0 ] && _notrun "xfs_db write can't support array"
 }
 
+# Before xfsprogs commit 89baf918(xfs_db: write values into dir/attr blocks and
+# recalculate CRCs), xfs_db write command can't write invalid data into dir/attr
+# field of v5 filesystems. For some cases need to write dir/attr (especially crc
+# enabled), use this _require at first.
+_require_xfs_db_write_da()
+{
+	local inum
+	local count
+
+	_require_scratch

common/xfs _require_xfs_db_write_array() · line 742

Quoted 10 lines
common/xfs +10 -0
+
+	_scratch_mkfs > /dev/null 2>&1
+	_scratch_mount
+	mkdir $SCRATCH_MNT/$seq.dir
+	inum=$(stat -c '%i' $SCRATCH_MNT/$seq.dir)
+	$SETFATTR_PROG -n "user.testda" \
+		       -v "$(perl -e "print 'v' x 65536;")" \
+		       $SCRATCH_MNT/$seq.dir
+	_scratch_unmount
+	_scratch_xfs_set_metadata_field "hdr.count" "0" \

Just FYI an upcoming change to the attr block verifier in 4.19 will break this because it rejects hdr.count == 0. Can you please set this to 1 instead of 0?

common/xfs _require_xfs_db_write_array() · line 746

Quoted 4 lines
common/xfs +4 -0
+					"inode $inum" "ablock 0" >/dev/null 2>&1
+	count=$(_scratch_xfs_get_metadata_field "hdr.count" \
+						"inode $inum" "ablock 0")
+	if [ "$count" != "0" ]; then

And update the test here?

--D

Quoted 26 lines
common/xfs +4 -0
+		_notrun "xfs_db write can't write values into dir/attr blocks"
+	fi
+}
+
 _require_xfs_spaceman_command()
 {
 	if [ -z "$1" ]; then
tests/xfs/288 +1 -0
index f4165b6c..e9589fd5 100755
@@ -35,6 +35,7 @@ _supported_fs xfs
 _supported_os Linux
 _require_scratch
 _require_attrs
+_require_xfs_db_write_da
 
 # get block size ($dbsize) from the mkfs output
 _scratch_mkfs_xfs 2>/dev/null | _filter_mkfs 2>$tmp.mkfs >/dev/null
Signature · 6 lines
2.14.4

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

Re: [PATCH v2 2/2] xfs/288: _notrun if xfs_db can't write values into dir or attr

Quoted 61 lines · Darrick J. Wong
Quoted 45 lines · Zorro Lang

Commit b3cf8b72334fd35ef961869506e5a72ab398bc82 help xfs/288 to support v5 filesystems testing, but there're still some old distributions don't support xfs_db write '-d' option, or can't write values into dir/attr of v5 filesystems.

For compatible with older versions, skip this test on v5 xfs if xfs_db write can't write v5 XFS dir/attr.

---

Hi,

Xiao found v1 can't work well on xfsprogs-4.9, due to 'write -d' can't write vaules into dir/attr of v5 filesystems before xfsprogs-4.13.

Only check "if write command has -d option" is not enough. So I write a function _require_xfs_db_write_da() to make sure current xfs_db can write dir/attr (not only on v5, but especially for v5).

Thanks,
Zorro

 common/xfs    | 28 ++++++++++++++++++++++++++++
 tests/xfs/288 |  1 +
 2 files changed, 29 insertions(+)
common/xfs +10 -0
index d971b4a8..95dcfd59 100644
@@ -720,6 +720,34 @@ _require_xfs_db_write_array()
 	[ $supported -eq 0 ] && _notrun "xfs_db write can't support array"
 }
 
+# Before xfsprogs commit 89baf918(xfs_db: write values into dir/attr blocks and
+# recalculate CRCs), xfs_db write command can't write invalid data into dir/attr
+# field of v5 filesystems. For some cases need to write dir/attr (especially crc
+# enabled), use this _require at first.
+_require_xfs_db_write_da()
+{
+	local inum
+	local count
+
+	_require_scratch

common/xfs _require_xfs_db_write_array() · line 742

Quoted 10 lines
common/xfs +10 -0
+
+	_scratch_mkfs > /dev/null 2>&1
+	_scratch_mount
+	mkdir $SCRATCH_MNT/$seq.dir
+	inum=$(stat -c '%i' $SCRATCH_MNT/$seq.dir)
+	$SETFATTR_PROG -n "user.testda" \
+		       -v "$(perl -e "print 'v' x 65536;")" \
+		       $SCRATCH_MNT/$seq.dir
+	_scratch_unmount
+	_scratch_xfs_set_metadata_field "hdr.count" "0" \

Just FYI an upcoming change to the attr block verifier in 4.19 will break this because it rejects hdr.count == 0. Can you please set this to 1 instead of 0?

Quoted 6 lines

common/xfs _require_xfs_db_write_array() · line 746

Quoted 4 lines
common/xfs +4 -0
+					"inode $inum" "ablock 0" >/dev/null 2>&1
+	count=$(_scratch_xfs_get_metadata_field "hdr.count" \
+						"inode $inum" "ablock 0")
+	if [ "$count" != "0" ]; then

And update the test here?

Sure, I can change the 0 to 1. BTW, does it affect xfs/288? Because xfs/288 set hdr.count to 0 too.

Thanks,
Zorro

Quoted 33 lines

--D

Quoted 26 lines
common/xfs +4 -0
+		_notrun "xfs_db write can't write values into dir/attr blocks"
+	fi
+}
+
 _require_xfs_spaceman_command()
 {
 	if [ -z "$1" ]; then
tests/xfs/288 +1 -0
index f4165b6c..e9589fd5 100755
@@ -35,6 +35,7 @@ _supported_fs xfs
 _supported_os Linux
 _require_scratch
 _require_attrs
+_require_xfs_db_write_da
 
 # get block size ($dbsize) from the mkfs output
 _scratch_mkfs_xfs 2>/dev/null | _filter_mkfs 2>$tmp.mkfs >/dev/null
Signature · 6 lines
2.14.4

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

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

#4 lore raw

Re: [PATCH v2 2/2] xfs/288: _notrun if xfs_db can't write values into dir or attr

Quoted 69 lines · Zorro Lang
Quoted 61 lines · Darrick J. Wong
Quoted 45 lines · Zorro Lang

Commit b3cf8b72334fd35ef961869506e5a72ab398bc82 help xfs/288 to support v5 filesystems testing, but there're still some old distributions don't support xfs_db write '-d' option, or can't write values into dir/attr of v5 filesystems.

For compatible with older versions, skip this test on v5 xfs if xfs_db write can't write v5 XFS dir/attr.

---

Hi,

Xiao found v1 can't work well on xfsprogs-4.9, due to 'write -d' can't write vaules into dir/attr of v5 filesystems before xfsprogs-4.13.

Only check "if write command has -d option" is not enough. So I write a function _require_xfs_db_write_da() to make sure current xfs_db can write dir/attr (not only on v5, but especially for v5).

Thanks,
Zorro

 common/xfs    | 28 ++++++++++++++++++++++++++++
 tests/xfs/288 |  1 +
 2 files changed, 29 insertions(+)
common/xfs +10 -0
index d971b4a8..95dcfd59 100644
@@ -720,6 +720,34 @@ _require_xfs_db_write_array()
 	[ $supported -eq 0 ] && _notrun "xfs_db write can't support array"
 }
 
+# Before xfsprogs commit 89baf918(xfs_db: write values into dir/attr blocks and
+# recalculate CRCs), xfs_db write command can't write invalid data into dir/attr
+# field of v5 filesystems. For some cases need to write dir/attr (especially crc
+# enabled), use this _require at first.
+_require_xfs_db_write_da()
+{
+	local inum
+	local count
+
+	_require_scratch

common/xfs _require_xfs_db_write_array() · line 742

Quoted 10 lines
common/xfs +10 -0
+
+	_scratch_mkfs > /dev/null 2>&1
+	_scratch_mount
+	mkdir $SCRATCH_MNT/$seq.dir
+	inum=$(stat -c '%i' $SCRATCH_MNT/$seq.dir)
+	$SETFATTR_PROG -n "user.testda" \
+		       -v "$(perl -e "print 'v' x 65536;")" \
+		       $SCRATCH_MNT/$seq.dir
+	_scratch_unmount
+	_scratch_xfs_set_metadata_field "hdr.count" "0" \

Just FYI an upcoming change to the attr block verifier in 4.19 will break this because it rejects hdr.count == 0. Can you please set this to 1 instead of 0?

Quoted 6 lines

common/xfs _require_xfs_db_write_array() · line 746

Quoted 4 lines
common/xfs +4 -0
+					"inode $inum" "ablock 0" >/dev/null 2>&1
+	count=$(_scratch_xfs_get_metadata_field "hdr.count" \
+						"inode $inum" "ablock 0")
+	if [ "$count" != "0" ]; then

And update the test here?

Quoted 2 lines

Sure, I can change the 0 to 1. BTW, does it affect xfs/288? Because xfs/288 set hdr.count to 0 too.

IIUC, xfs/288 deliberately sets hdr.count to 0 to test how the code handles the (corrupt) attr header, so that use is fine.

--D

Quoted 40 lines

Thanks,
Zorro

Quoted 25 lines

--D

Quoted 22 lines
common/xfs +4 -0
+		_notrun "xfs_db write can't write values into dir/attr blocks"
+	fi
+}
+
 _require_xfs_spaceman_command()
 {
 	if [ -z "$1" ]; then
tests/xfs/288 +1 -0
index f4165b6c..e9589fd5 100755
@@ -35,6 +35,7 @@ _supported_fs xfs
 _supported_os Linux
 _require_scratch
 _require_attrs
+_require_xfs_db_write_da
 
 # get block size ($dbsize) from the mkfs output
 _scratch_mkfs_xfs 2>/dev/null | _filter_mkfs 2>$tmp.mkfs >/dev/null
Signature · 1 line
2.14.4
Quoted 8 lines
Quoted 4 lines

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

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

--
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

author
#5 lore raw

Re: [PATCH v2 2/2] xfs/288: _notrun if xfs_db can't write values into dir or attr

Quoted 70 lines · Darrick J. Wong
Quoted 69 lines · Zorro Lang
Quoted 67 lines · Darrick J. Wong
Quoted 45 lines · Zorro Lang

Commit b3cf8b72334fd35ef961869506e5a72ab398bc82 help xfs/288 to support v5 filesystems testing, but there're still some old distributions don't support xfs_db write '-d' option, or can't write values into dir/attr of v5 filesystems.

For compatible with older versions, skip this test on v5 xfs if xfs_db write can't write v5 XFS dir/attr.

---

Hi,

Xiao found v1 can't work well on xfsprogs-4.9, due to 'write -d' can't write vaules into dir/attr of v5 filesystems before xfsprogs-4.13.

Only check "if write command has -d option" is not enough. So I write a function _require_xfs_db_write_da() to make sure current xfs_db can write dir/attr (not only on v5, but especially for v5).

Thanks,
Zorro

 common/xfs    | 28 ++++++++++++++++++++++++++++
 tests/xfs/288 |  1 +
 2 files changed, 29 insertions(+)
common/xfs +10 -0
index d971b4a8..95dcfd59 100644
@@ -720,6 +720,34 @@ _require_xfs_db_write_array()
 	[ $supported -eq 0 ] && _notrun "xfs_db write can't support array"
 }
 
+# Before xfsprogs commit 89baf918(xfs_db: write values into dir/attr blocks and
+# recalculate CRCs), xfs_db write command can't write invalid data into dir/attr
+# field of v5 filesystems. For some cases need to write dir/attr (especially crc
+# enabled), use this _require at first.
+_require_xfs_db_write_da()
+{
+	local inum
+	local count
+
+	_require_scratch

common/xfs _require_xfs_db_write_array() · line 742

Quoted 10 lines
common/xfs +10 -0
+
+	_scratch_mkfs > /dev/null 2>&1
+	_scratch_mount
+	mkdir $SCRATCH_MNT/$seq.dir
+	inum=$(stat -c '%i' $SCRATCH_MNT/$seq.dir)
+	$SETFATTR_PROG -n "user.testda" \
+		       -v "$(perl -e "print 'v' x 65536;")" \
+		       $SCRATCH_MNT/$seq.dir
+	_scratch_unmount
+	_scratch_xfs_set_metadata_field "hdr.count" "0" \

Just FYI an upcoming change to the attr block verifier in 4.19 will break this because it rejects hdr.count == 0. Can you please set this to 1 instead of 0?

common/xfs _require_xfs_db_write_array() · line 746

Quoted 4 lines
common/xfs +4 -0
+					"inode $inum" "ablock 0" >/dev/null 2>&1
+	count=$(_scratch_xfs_get_metadata_field "hdr.count" \
+						"inode $inum" "ablock 0")
+	if [ "$count" != "0" ]; then

And update the test here?

Quoted 5 lines
Quoted 2 lines

Sure, I can change the 0 to 1. BTW, does it affect xfs/288? Because xfs/288 set hdr.count to 0 too.

IIUC, xfs/288 deliberately sets hdr.count to 0 to test how the code handles the (corrupt) attr header, so that use is fine.

Hmm... sorry I'm confused now, can you show me the patch which will "rejects hdr.count == 0"?

xfs/288 trys to check how xfs_repair deal with hdr.count=0. If "write (-d) hdr.count 0" will be rejected directly, that's another issue. If it won't affect xfs_db "write", why I can't write 0 in this patch?

Thanks,
Zorro

Quoted 47 lines

--D

Quoted 36 lines

Thanks,
Zorro

Quoted 25 lines

--D

Quoted 22 lines
common/xfs +4 -0
+		_notrun "xfs_db write can't write values into dir/attr blocks"
+	fi
+}
+
 _require_xfs_spaceman_command()
 {
 	if [ -z "$1" ]; then
tests/xfs/288 +1 -0
index f4165b6c..e9589fd5 100755
@@ -35,6 +35,7 @@ _supported_fs xfs
 _supported_os Linux
 _require_scratch
 _require_attrs
+_require_xfs_db_write_da
 
 # get block size ($dbsize) from the mkfs output
 _scratch_mkfs_xfs 2>/dev/null | _filter_mkfs 2>$tmp.mkfs >/dev/null
Signature · 1 line
2.14.4
Quoted 8 lines
Quoted 4 lines

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

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

Quoted 4 lines

--
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

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

#6 lore raw

Re: [PATCH v2 2/2] xfs/288: _notrun if xfs_db can't write values into dir or attr

In reply to Zorro Lang
Quoted 35 lines · Zorro Lang

Commit b3cf8b72334fd35ef961869506e5a72ab398bc82 help xfs/288 to support v5 filesystems testing, but there're still some old distributions don't support xfs_db write '-d' option, or can't write values into dir/attr of v5 filesystems.

For compatible with older versions, skip this test on v5 xfs if xfs_db write can't write v5 XFS dir/attr.

---

Hi,

Xiao found v1 can't work well on xfsprogs-4.9, due to 'write -d' can't write vaules into dir/attr of v5 filesystems before xfsprogs-4.13.

Only check "if write command has -d option" is not enough. So I write a function _require_xfs_db_write_da() to make sure current xfs_db can write dir/attr (not only on v5, but especially for v5).

Thanks,
Zorro

 common/xfs    | 28 ++++++++++++++++++++++++++++
 tests/xfs/288 |  1 +
 2 files changed, 29 insertions(+)
common/xfs +0 -0
index d971b4a8..95dcfd59 100644
@@ -720,6 +720,34 @@ _require_xfs_db_write_array()
 	[ $supported -eq 0 ] && _notrun "xfs_db write can't support array"
 }
 

common/xfs _require_xfs_db_write_array() · line 732

Quoted 10 lines
common/xfs +10 -0
+# Before xfsprogs commit 89baf918(xfs_db: write values into dir/attr blocks and
+# recalculate CRCs), xfs_db write command can't write invalid data into dir/attr
+# field of v5 filesystems. For some cases need to write dir/attr (especially crc
+# enabled), use this _require at first.
+_require_xfs_db_write_da()
+{
+	local inum
+	local count
+
+	_require_scratch

Hiding this inside a another requires rule is kinda nasty. If the test already used _require_scratch_nocheck, this will now cause the test to check the scratch device at the end of the test.

And vice-versa - if you use _require_scratch_nocheck here, it will break tests that have already called _require_scratch....

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]