common/xfs: Add _scratch_get_sfdir_prefix function
PATCH 1/2 common/xfs: Add _scratch_get_sfdir_prefix function
Move get_sfdir_prefix function from xfs/278 to commom/xfs and rename it to _scratch_get_sfdir_prefix so it can be used in other xfs tests.
This commit also changes xfs/278 to make use of_scratch_get_sfdir_prefix instead previous one.
--- common/xfs | 15 +++++++++++++++ tests/xfs/278 | 16 +--------------- 2 files changed, 16 insertions(+), 15 deletions(-)
common/xfs +15 -0
@@ -760,3 +760,18 @@ _require_xfs_spaceman_command() _notrun "xfs_spaceman $command doesn't support $param" fi } + +_scratch_get_sfdir_prefix() { + local dir_ino="$1" + + for prefix in "u.sfdir3" "u.sfdir2" "u3.sfdir3"; do + if [ -n "$(_scratch_xfs_get_metadata_field \ + "${prefix}.hdr.parent.i4" \ + "inode ${dir_ino}")" ]; then + echo "${prefix}" + return 0 + fi + done + _scratch_xfs_db -c "inode ${dir_ino}" -c 'p' >> $seqres.full + return 1 +}
tests/xfs/278 +1 -15
@@ -46,25 +46,11 @@ _scratch_unmount echo "Silence is goodness..." -get_sfdir_prefix() { - local dir_ino="$1" - - for prefix in "u.sfdir3" "u.sfdir2" "u3.sfdir3"; do - if [ -n "$(_scratch_xfs_get_metadata_field \ - "${prefix}.hdr.parent.i4" \ - "inode ${dir_ino}")" ]; then - echo "${prefix}" - return 0 - fi - done - _scratch_xfs_db -c "inode ${dir_ino}" -c 'p' >> $seqres.full - return 1 -} set_ifield() { _scratch_xfs_set_metadata_field "$1" 0 "inode $2" >> $seqres.full } -sfdir_prefix="$(get_sfdir_prefix "$DIR_INO" || \ +sfdir_prefix="$(_scratch_get_sfdir_prefix "$DIR_INO" || \ _fail "Cannot determine sfdir prefix")" # Corrupt DIR
Signature · 1 line
2.9.5
PATCH 2/2 xfstests: Test root inode parent pointer repairing
Recently we found out xfs_repair were not repairing root inode parent pointer when root inode is on short-form and parent points to an invalid inode number (refer to:
"xfs_repair: Fix root inode's parent when it's bogus for sf directory" on xfs-devel list).
This test checks if xfs_repair successfully repair the filesystem in the scenario mentioned before.
--- tests/xfs/450 | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/450.out | 1 + tests/xfs/group | 1 + 3 files changed, 55 insertions(+) create mode 100755 tests/xfs/450 create mode 100644 tests/xfs/450.out
tests/xfs/450 new file +53 -0
@@ -0,0 +1,53 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat Inc. All Rights Reserved. +# +# FS QA Test 450 +# +# Make sure xfs_repair can repair root inode parent's pointer +# when it contains a bogus ino when it's using shot form directory +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs xfs +_supported_os Linux +_require_scratch + + +_scratch_mkfs >> /dev/null 2>&1 + +rootino=$(_scratch_xfs_get_metadata_field 'rootino' 'sb 0') + +prefix=$(_scratch_get_sfdir_prefix ${rootino} || \ + _fail "Cannot determine sfdir prefix") + + +# Corrupt root inode parent pointer +_scratch_xfs_set_metadata_field "${prefix}.hdr.parent.i4" 0 "inode ${rootino}"\ + >> $seqres.full + +_scratch_xfs_repair >> $seqres.full 2>&1 + +_scratch_xfs_repair -n >> $seqres.full 2>&1 + +if [ $? -eq 1 ] +then + _fail "xfs_repair failed to repair filesystem" +fi + +echo "OK" +status=0 +exit
tests/xfs/450.out new file +1 -0
@@ -0,0 +1 @@ +OK
tests/xfs/group +1 -0
@@ -447,3 +447,4 @@ 447 auto mount 448 auto quick fuzzers 449 auto quick +450 auto quick
Signature · 1 line
2.9.5
Re: [PATCH 2/2] xfstests: Test root inode parent pointer repairing
Quoted 10 lines · Marco Benatto
Recently we found out
xfs_repairwere not repairing root inode parent pointer when root inode is on short-form and parent points to an invalid inode number (refer to:
"xfs_repair: Fix root inode's parent when it's bogus for sf directory" on xfs-devel list).This test checks if
xfs_repairsuccessfully repair the filesystem in the scenario mentioned before.Signed-off-by Marco Benatto <[email protected]>
Looks ok, I think...
--D
Quoted 90 lines
--- tests/xfs/450 | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/450.out | 1 + tests/xfs/group | 1 + 3 files changed, 55 insertions(+) create mode 100755 tests/xfs/450 create mode 100644 tests/xfs/450.outtests/xfs/450 new file +53
-0@@ -0,0 +1,53 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat Inc. All Rights Reserved. +# +# FS QA Test 450 +# +# Make sure xfs_repair can repair root inode parent's pointer +# when it contains a bogus ino when it's using shot form directory +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs xfs +_supported_os Linux +_require_scratch + + +_scratch_mkfs >> /dev/null 2>&1 + +rootino=$(_scratch_xfs_get_metadata_field 'rootino' 'sb 0') + +prefix=$(_scratch_get_sfdir_prefix ${rootino} || \ + _fail "Cannot determine sfdir prefix") + + +# Corrupt root inode parent pointer +_scratch_xfs_set_metadata_field "${prefix}.hdr.parent.i4" 0 "inode ${rootino}"\ + >> $seqres.full + +_scratch_xfs_repair >> $seqres.full 2>&1 + +_scratch_xfs_repair -n >> $seqres.full 2>&1 + +if [ $? -eq 1 ] +then + _fail "xfs_repair failed to repair filesystem" +fi + +echo "OK" +status=0 +exittests/xfs/450.out new file +1
-0@@ -0,0 +1 @@ +OKtests/xfs/group +1
-0@@ -447,3 +447,4 @@ 447 auto mount 448 auto quick fuzzers 449 auto quick +450 auto quickSignature · 6 lines
2.9.5 -- 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
Re: [PATCH 2/2] xfstests: Test root inode parent pointer repairing
In reply to Marco BenattoQuoted 63 lines · Marco Benatto
Recently we found out
xfs_repairwere not repairing root inode parent pointer when root inode is on short-form and parent points to an invalid inode number (refer to:
"xfs_repair: Fix root inode's parent when it's bogus for sf directory" on xfs-devel list).This test checks if
xfs_repairsuccessfully repair the filesystem in the scenario mentioned before.Signed-off-by Marco Benatto <[email protected]>--- tests/xfs/450 | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/450.out | 1 + tests/xfs/group | 1 + 3 files changed, 55 insertions(+) create mode 100755 tests/xfs/450 create mode 100644 tests/xfs/450.outtests/xfs/450 new file +39
-0@@ -0,0 +1,53 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat Inc. All Rights Reserved. +# +# FS QA Test 450 +# +# Make sure xfs_repair can repair root inode parent's pointer +# when it contains a bogus ino when it's using shot form directory +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs xfs +_supported_os Linux +_require_scratch + + +_scratch_mkfs >> /dev/null 2>&1 + +rootino=$(_scratch_xfs_get_metadata_field 'rootino' 'sb 0') + +prefix=$(_scratch_get_sfdir_prefix ${rootino} || \ + _fail "Cannot determine sfdir prefix") + + +# Corrupt root inode parent pointer +_scratch_xfs_set_metadata_field "${prefix}.hdr.parent.i4" 0 "inode ${rootino}"\
tests/xfs/450 line 49
Quoted 10 lines
tests/xfs/450 new file +10
-0+ >> $seqres.full + +_scratch_xfs_repair >> $seqres.full 2>&1 + +_scratch_xfs_repair -n >> $seqres.full 2>&1 + +if [ $? -eq 1 ] +then + _fail "xfs_repair failed to repair filesystem" +fi
Isn't this last "filesystem is not corrupt" check run by the harness via _check_scratch_fs()?
(Also, "if [ .. ]; then" is the preferred fstests style)
tests/xfs/450 line 51
Quoted 2 lines
tests/xfs/450 new file +2
-0+ +echo "OK"
There's no test output, so the normal thing to do is this after setting up the test:
echo "Silence is golden"
We do that early on so that when something goes wrong the bad output file immediately tells you that no output was expected.
tests/xfs/450 line 450
Quoted 5 lines
tests/xfs/450 new file +1
-0@@ -447,3 +447,4 @@ 447 auto mount 448 auto quick fuzzers 449 auto quick +450 auto quick
also the metadata and repair groups should be added here.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 2/2] xfstests: Test root inode parent pointer repairing
In reply to Marco BenattoQuoted 27 lines · Marco Benatto
Recently we found out
xfs_repairwere not repairing root inode parent pointer when root inode is on short-form and parent points to an invalid inode number (refer to:
"xfs_repair: Fix root inode's parent when it's bogus for sf directory" on xfs-devel list).This test checks if
xfs_repairsuccessfully repair the filesystem in the scenario mentioned before.Signed-off-by Marco Benatto <[email protected]>--- tests/xfs/450 | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/450.out | 1 + tests/xfs/group | 1 + 3 files changed, 55 insertions(+) create mode 100755 tests/xfs/450 create mode 100644 tests/xfs/450.outtests/xfs/450 new file +3
-0@@ -0,0 +1,53 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat Inc. All Rights Reserved.
tests/xfs/450 line 13
Quoted 10 lines
tests/xfs/450 new file +10
-0+# +# FS QA Test 450 +# +# Make sure xfs_repair can repair root inode parent's pointer +# when it contains a bogus ino when it's using shot form directory +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +status=1 # failure is the default!
Apart from Dave's comments, there're some common definitions missing too, e.g. 'tmp' and 'here', please use './new xfs' to generate new test template.
BTW, I've applied the first patch, no need to resend it in v2.
Thanks,
Eryu
Re: [PATCH 2/2] xfstests: Test root inode parent pointer repairing
Quoted 34 lines · Eryu Guan
Quoted 33 lines · Marco Benatto
Recently we found out
xfs_repairwere not repairing root inode parent pointer when root inode is on short-form and parent points to an invalid inode number (refer to:
"xfs_repair: Fix root inode's parent when it's bogus for sf directory" on xfs-devel list).This test checks if
xfs_repairsuccessfully repair the filesystem in the scenario mentioned before.Signed-off-by Marco Benatto <[email protected]>--- tests/xfs/450 | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/450.out | 1 + tests/xfs/group | 1 + 3 files changed, 55 insertions(+) create mode 100755 tests/xfs/450 create mode 100644 tests/xfs/450.outtests/xfs/450 new file +9
-0@@ -0,0 +1,53 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat Inc. All Rights Reserved. +# +# FS QA Test 450 +# +# Make sure xfs_repair can repair root inode parent's pointer +# when it contains a bogus ino when it's using shot form directory +#
Quoted 8 lines
tests/xfs/450 line 13
Quoted 4 lines
tests/xfs/450 new file +4
-0+seq=`basename $0` +seqres=$RESULT_DIR/$seq + +status=1 # failure is the default!Apart from Dave's comments, there're some common definitions missing too, e.g. 'tmp' and 'here', please use './new xfs' to generate new test template.
Eryu, I think I suggested that Marco could remove the "tmp" definition because it's not used in the script. Is there some reason to keep it? The script did start out with a "./new xfs" generation template.
Oh, I bet some helpers depend on it... sorry, my mistake. Oops.
(though maybe tmp should just get hoisted to the harness and not be required in every script, but I digress ...)
Thanks,
-Eric
Quoted 5 lines
BTW, I've applied the first patch, no need to resend it in v2.
Thanks,
Eryu
Re: [PATCH 2/2] xfstests: Test root inode parent pointer repairing
Quoted 44 lines · Eric Sandeen
Quoted 34 lines · Eryu Guan
Quoted 33 lines · Marco Benatto
Recently we found out
xfs_repairwere not repairing root inode parent pointer when root inode is on short-form and parent points to an invalid inode number (refer to:
"xfs_repair: Fix root inode's parent when it's bogus for sf directory" on xfs-devel list).This test checks if
xfs_repairsuccessfully repair the filesystem in the scenario mentioned before.Signed-off-by Marco Benatto <[email protected]>--- tests/xfs/450 | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/450.out | 1 + tests/xfs/group | 1 + 3 files changed, 55 insertions(+) create mode 100755 tests/xfs/450 create mode 100644 tests/xfs/450.outtests/xfs/450 new file +9
-0@@ -0,0 +1,53 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat Inc. All Rights Reserved. +# +# FS QA Test 450 +# +# Make sure xfs_repair can repair root inode parent's pointer +# when it contains a bogus ino when it's using shot form directory +#Quoted 8 lines
tests/xfs/450 line 13
Quoted 4 lines
tests/xfs/450 new file +4
-0+seq=`basename $0` +seqres=$RESULT_DIR/$seq + +status=1 # failure is the default!Apart from Dave's comments, there're some common definitions missing too, e.g. 'tmp' and 'here', please use './new xfs' to generate new test template.
Quoted 8 lines
Eryu, I think I suggested that Marco could remove the "tmp" definition because it's not used in the script. Is there some reason to keep it? The script did start out with a "./new xfs" generation template.
Oh, I bet some helpers depend on it... sorry, my mistake. Oops.
(though maybe tmp should just get hoisted to the harness and not be required in every script, but I digress ...)
You mean like I proposed a couple of weeks ago along with the spdx license tag updates?
https://www.spinics.net/lists/fstests/msg09849.html
that's next on my list of "Big cleanups for fstests To Do" list.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 2/2] xfstests: Test root inode parent pointer repairing
Hi Eryuy et al,
firstly thanks for the reviews.
OK, I'll resend just the test itself (without the one which hoist the helper function for sfdir format).
Given Eric's and Dave's updates, should I re-include the common definitions even those being unused within
this test scope?
If those are used by helpers or any other flow on xfstest I do agree with Eric and Dave about hoist it.
Thanks,
Quoted 67 lines · Dave Chinner
Quoted 44 lines · Eric Sandeen
Quoted 34 lines · Eryu Guan
Quoted 33 lines · Marco Benatto
Recently we found out
xfs_repairwere not repairing root inode parent pointer when root inode is on short-form and parent points to an invalid inode number (refer to:
"xfs_repair: Fix root inode's parent when it's bogus for sf directory" on xfs-devel list).This test checks if
xfs_repairsuccessfully repair the filesystem in the scenario mentioned before.Signed-off-by Marco Benatto <[email protected]>--- tests/xfs/450 | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/450.out | 1 + tests/xfs/group | 1 + 3 files changed, 55 insertions(+) create mode 100755 tests/xfs/450 create mode 100644 tests/xfs/450.outtests/xfs/450 new file +9
-0@@ -0,0 +1,53 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat Inc. All Rights Reserved. +# +# FS QA Test 450 +# +# Make sure xfs_repair can repair root inode parent's pointer +# when it contains a bogus ino when it's using shot form directory +#Quoted 8 lines
tests/xfs/450 line 13
Quoted 4 lines
tests/xfs/450 new file +4
-0+seq=`basename $0` +seqres=$RESULT_DIR/$seq + +status=1 # failure is the default!Apart from Dave's comments, there're some common definitions missing too, e.g. 'tmp' and 'here', please use './new xfs' to generate new test template.
Quoted 8 lines
Eryu, I think I suggested that Marco could remove the "tmp" definition because it's not used in the script. Is there some reason to keep it? The script did start out with a "./new xfs" generation template.
Oh, I bet some helpers depend on it... sorry, my mistake. Oops.
(though maybe tmp should just get hoisted to the harness and not be required in every script, but I digress ...)
You mean like I proposed a couple of weeks ago along with the spdx license tag updates?
https://www.spinics.net/lists/fstests/msg09849.html
that's next on my list of "Big cleanups for fstests To Do" list.
Cheers,
Dave.
--
Dave Chinner
[email protected]
Signature · 5 lines
Marco Benatto Senior Software Maintenance Engineer | Red Hat Brasil T: +55 11 35246161 | M: +55 41 9 88504051 Av. Brigadeiro Faria Lima 3900, 8° Andar. São Paulo, Brasil. RED HAT | TRIED. TESTED. TRUSTED. Saiba porque em redhat.com
Re: [PATCH 2/2] xfstests: Test root inode parent pointer repairing
Hello all,
just FYI just sent out v2 covering Dave's and Eryu's suggestions.
Thanks,
Quoted 95 lines · Marco Benatto
Hi Eryuy et al,
firstly thanks for the reviews.
OK, I'll resend just the test itself (without the one which hoist the helper function for sfdir format).
Given Eric's and Dave's updates, should I re-include the common definitions even those being unused within
this test scope?If those are used by helpers or any other flow on xfstest I do agree with Eric and Dave about hoist it.
Thanks,
Quoted 59 lines · Dave Chinner
Quoted 44 lines · Eric Sandeen
Quoted 34 lines · Eryu Guan
Quoted 33 lines · Marco Benatto
Recently we found out
xfs_repairwere not repairing root inode parent pointer when root inode is on short-form and parent points to an invalid inode number (refer to:
"xfs_repair: Fix root inode's parent when it's bogus for sf directory" on xfs-devel list).This test checks if
xfs_repairsuccessfully repair the filesystem in the scenario mentioned before.Signed-off-by Marco Benatto <[email protected]>--- tests/xfs/450 | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/450.out | 1 + tests/xfs/group | 1 + 3 files changed, 55 insertions(+) create mode 100755 tests/xfs/450 create mode 100644 tests/xfs/450.outtests/xfs/450 new file +9
-0@@ -0,0 +1,53 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat Inc. All Rights Reserved. +# +# FS QA Test 450 +# +# Make sure xfs_repair can repair root inode parent's pointer +# when it contains a bogus ino when it's using shot form directory +#Quoted 8 lines
tests/xfs/450 line 13
Quoted 4 lines
tests/xfs/450 new file +4
-0+seq=`basename $0` +seqres=$RESULT_DIR/$seq + +status=1 # failure is the default!Apart from Dave's comments, there're some common definitions missing too, e.g. 'tmp' and 'here', please use './new xfs' to generate new test template.
Quoted 8 lines
Eryu, I think I suggested that Marco could remove the "tmp" definition because it's not used in the script. Is there some reason to keep it? The script did start out with a "./new xfs" generation template.
Oh, I bet some helpers depend on it... sorry, my mistake. Oops.
(though maybe tmp should just get hoisted to the harness and not be required in every script, but I digress ...)
You mean like I proposed a couple of weeks ago along with the spdx license tag updates?
Quoted 8 lines
that's next on my list of "Big cleanups for fstests To Do" list.
Cheers,
Dave.
--
Dave Chinner
[email protected]--
Marco Benatto
Senior Software Maintenance Engineer | Red Hat Brasil
T: +55 11 35246161 | M: +55 41 9 88504051
Av. Brigadeiro Faria Lima 3900, 8° Andar. São Paulo, Brasil. RED HAT | TRIED. TESTED. TRUSTED. Saiba porque em redhat.com
Signature · 5 lines
Marco Benatto Senior Software Maintenance Engineer | Red Hat Brasil T: +55 11 35246161 | M: +55 41 9 88504051 Av. Brigadeiro Faria Lima 3900, 8° Andar. São Paulo, Brasil. RED HAT | TRIED. TESTED. TRUSTED. Saiba porque em redhat.com
Quoted 8 lines · Marco Benatto
Move
get_sfdir_prefixfunction from xfs/278 to commom/xfs and rename it to_scratch_get_sfdir_prefixso it can be used in other xfs tests.This commit also changes xfs/278 to make use of
_scratch_get_sfdir_prefixinstead previous one.Signed-off-by Marco Benatto <[email protected]>
Looks ok,
--D
Quoted 66 lines
--- common/xfs | 15 +++++++++++++++ tests/xfs/278 | 16 +--------------- 2 files changed, 16 insertions(+), 15 deletions(-)common/xfs +15
-0@@ -760,3 +760,18 @@ _require_xfs_spaceman_command() _notrun "xfs_spaceman $command doesn't support $param" fi } + +_scratch_get_sfdir_prefix() { + local dir_ino="$1" + + for prefix in "u.sfdir3" "u.sfdir2" "u3.sfdir3"; do + if [ -n "$(_scratch_xfs_get_metadata_field \ + "${prefix}.hdr.parent.i4" \ + "inode ${dir_ino}")" ]; then + echo "${prefix}" + return 0 + fi + done + _scratch_xfs_db -c "inode ${dir_ino}" -c 'p' >> $seqres.full + return 1 +}tests/xfs/278 +1
-15@@ -46,25 +46,11 @@ _scratch_unmount echo "Silence is goodness..." -get_sfdir_prefix() { - local dir_ino="$1" - - for prefix in "u.sfdir3" "u.sfdir2" "u3.sfdir3"; do - if [ -n "$(_scratch_xfs_get_metadata_field \ - "${prefix}.hdr.parent.i4" \ - "inode ${dir_ino}")" ]; then - echo "${prefix}" - return 0 - fi - done - _scratch_xfs_db -c "inode ${dir_ino}" -c 'p' >> $seqres.full - return 1 -} set_ifield() { _scratch_xfs_set_metadata_field "$1" 0 "inode $2" >> $seqres.full } -sfdir_prefix="$(get_sfdir_prefix "$DIR_INO" || \ +sfdir_prefix="$(_scratch_get_sfdir_prefix "$DIR_INO" || \ _fail "Cannot determine sfdir prefix")" # Corrupt DIRSignature · 6 lines
2.9.5 -- 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