common/f2fs: introduce _require_inject_f2fs_command()
PATCH 1/1 common/f2fs: introduce _require_inject_f2fs_command()
Introduce _require_inject_f2fs_command() to check whether inject.f2fs supports specific metaarea and member parameters.
--- common/f2fs | 25 +++++++++++++++++++++++++ tests/f2fs/009 | 2 ++ tests/f2fs/012 | 2 ++ tests/f2fs/019 | 2 ++ tests/f2fs/020 | 2 ++ tests/f2fs/022 | 2 ++ 6 files changed, 35 insertions(+)
common/f2fs +25 -0
@@ -25,3 +25,28 @@ _require_scratch_f2fs_compression() _scratch_unmount fi } + +# check that inject.f2fs supports to inject specific field in specific meta area +_require_inject_f2fs_command() +{ + if [ $# -ne 2 ]; then + echo "Usage: _require_inject_f2fs_command metaarea member" 1>&2 + _exit 1 + fi + metaarea=$1 + member=$2 + + case $metaarea in + sb|cp|nat|sit) + val=0 + ;; + ssa|node|dent) + ;; + *) + _notrun "unsupport metaarea: $metaarea" + ;; + esac + + $F2FS_INJECT_PROG "--$metaarea" "$val" "-h" | grep "$member:" > /dev/null || \ + _notrun "--$metaarea --mb $member support is missing" +}
tests/f2fs/009 +2 -0
@@ -9,10 +9,12 @@ # and expects fsck.f2fs can detect such corruption and do the repair. # . ./common/preamble +. ./common/f2fs _begin_fstest auto quick _require_scratch _require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_inject_f2fs_command node i_links _require_command "$(type -P socket)" socket _fixed_by_git_commit f2fs-tools 958cd6e \
tests/f2fs/012 +2 -0
@@ -12,6 +12,7 @@ # 4.enable linear lookup, expect lookup succeed # . ./common/preamble +. ./common/f2fs _begin_fstest auto quick casefold _fixed_by_kernel_commit 91b587ba79e1 \
@@ -21,6 +22,7 @@ export LC_ALL=C.UTF-8 _require_scratch_nocheck _require_command "$F2FS_IO_PROG" f2fs_io _require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_inject_f2fs_command dent d_hash #check whether f2fs supports "lookup_mode=x" mount option mntopt=""
tests/f2fs/019 +2 -0
@@ -12,6 +12,7 @@ # corruption in the file # . ./common/preamble +. ./common/f2fs _begin_fstest auto quick rw _fixed_by_kernel_commit 77de19b6867f \
@@ -19,6 +20,7 @@ _fixed_by_kernel_commit 77de19b6867f \ _require_scratch_nocheck _require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_inject_f2fs_command node addr # remove all mkfs options to avoid layout change of on-disk inode export MKFS_OPTIONS=""
tests/f2fs/020 +2 -0
@@ -12,6 +12,7 @@ # corruption in the file # . ./common/preamble +. ./common/f2fs _begin_fstest auto quick rw . ./common/attr
@@ -21,6 +22,7 @@ _fixed_by_kernel_commit 061cf3a84bde \ _require_scratch_nocheck _require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_inject_f2fs_command node i_xattr_nid _require_attrs user # remove all mkfs options to avoid layout change of on-disk inode
tests/f2fs/022 +2 -0
@@ -11,6 +11,7 @@ # 4. fpunch in foo w/ specified range # . ./common/preamble +. ./common/f2fs _begin_fstest auto quick rw . ./common/attr
@@ -20,6 +21,7 @@ _fixed_by_kernel_commit xxxxxxxxxxxx \ _require_scratch_nocheck _require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_inject_f2fs_command node i_nid # remove all mkfs options to avoid layout change of on-disk inode export MKFS_OPTIONS=""
Signature · 1 line
2.40.1
common/f2fs
Quoted 15 lines · Chao Yu
Introduce
_require_inject_f2fs_command()to check whether inject.f2fs supports specific metaarea and member parameters.Cc Jaegeuk Kim <[email protected]>Signed-off-by Chao Yu <[email protected]>--- common/f2fs | 25 +++++++++++++++++++++++++ tests/f2fs/009 | 2 ++ tests/f2fs/012 | 2 ++ tests/f2fs/019 | 2 ++ tests/f2fs/020 | 2 ++ tests/f2fs/022 | 2 ++ 6 files changed, 35 insertions(+)common/f2fs +0
-0
You remind me that there's a common/f2fs file, you can move f2fs specific functions to common/f2fs (e.g. _check_f2fs_filesystem) later :)
Quoted 37 lines
index
1b39d8ce..4b01e032100644common/f2fs +25
-0@@ -25,3 +25,28 @@ _require_scratch_f2fs_compression() _scratch_unmount fi } + +# check that inject.f2fs supports to inject specific field in specific meta area +_require_inject_f2fs_command() +{ + if [ $# -ne 2 ]; then + echo "Usage: _require_inject_f2fs_command metaarea member" 1>&2 + _exit 1 + fi + metaarea=$1 + member=$2 + + case $metaarea in + sb|cp|nat|sit) + val=0 + ;; + ssa|node|dent) + ;; + *) + _notrun "unsupport metaarea: $metaarea" + ;; + esac + + $F2FS_INJECT_PROG "--$metaarea" "$val" "-h" | grep "$member:" > /dev/null || \ + _notrun "--$metaarea --mb $member support is missing" +}tests/f2fs/009 +0
-0
tests/f2fs/009 line 12
Quoted 4 lines
tests/f2fs/009 +1
-0@@ -9,10 +9,12 @@ # and expects fsck.f2fs can detect such corruption and do the repair. # . ./common/preamble +. ./common/f2fs
The common/f2fs can be imported by common/config:_source_specific_fs() automatically, so we don't need this line at here.
(Same below)
tests/f2fs/009 line 17
Quoted 5 lines
tests/f2fs/009 +1
-0_begin_fstest auto quick _require_scratch _require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_inject_f2fs_command node i_links
If the "_require_command $F2FS_INJECT_PROG inject.f2fs" is always required before _require_inject_f2fs_command, how about call it at the beginning of _require_inject_f2fs_command ?
(same below)
Thanks,
Zorro
Quoted 86 lines
tests/f2fs/009 +0
-0_require_command "$(type -P socket)" socket _fixed_by_git_commit f2fs-tools 958cd6e \tests/f2fs/012 +2
-0@@ -12,6 +12,7 @@ # 4.enable linear lookup, expect lookup succeed # . ./common/preamble +. ./common/f2fs _begin_fstest auto quick casefold _fixed_by_kernel_commit 91b587ba79e1 \@@ -21,6 +22,7 @@ export LC_ALL=C.UTF-8 _require_scratch_nocheck _require_command "$F2FS_IO_PROG" f2fs_io _require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_inject_f2fs_command dent d_hash #check whether f2fs supports "lookup_mode=x" mount option mntopt=""tests/f2fs/019 +2
-0@@ -12,6 +12,7 @@ # corruption in the file # . ./common/preamble +. ./common/f2fs _begin_fstest auto quick rw _fixed_by_kernel_commit 77de19b6867f \@@ -19,6 +20,7 @@ _fixed_by_kernel_commit 77de19b6867f \ _require_scratch_nocheck _require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_inject_f2fs_command node addr # remove all mkfs options to avoid layout change of on-disk inode export MKFS_OPTIONS=""tests/f2fs/020 +2
-0@@ -12,6 +12,7 @@ # corruption in the file # . ./common/preamble +. ./common/f2fs _begin_fstest auto quick rw . ./common/attr@@ -21,6 +22,7 @@ _fixed_by_kernel_commit 061cf3a84bde \ _require_scratch_nocheck _require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_inject_f2fs_command node i_xattr_nid _require_attrs user # remove all mkfs options to avoid layout change of on-disk inodetests/f2fs/022 +2
-0@@ -11,6 +11,7 @@ # 4. fpunch in foo w/ specified range # . ./common/preamble +. ./common/f2fs _begin_fstest auto quick rw . ./common/attr@@ -20,6 +21,7 @@ _fixed_by_kernel_commit xxxxxxxxxxxx \ _require_scratch_nocheck _require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_inject_f2fs_command node i_nid # remove all mkfs options to avoid layout change of on-disk inode export MKFS_OPTIONS=""Signature · 1 line
2.40.1
Quoted 15 lines · Zorro Lang
Quoted 14 lines · Chao Yu
Introduce
_require_inject_f2fs_command()to check whether inject.f2fs supports specific metaarea and member parameters.Cc Jaegeuk Kim <[email protected]>Signed-off-by Chao Yu <[email protected]>--- common/f2fs | 25 +++++++++++++++++++++++++ tests/f2fs/009 | 2 ++ tests/f2fs/012 | 2 ++ tests/f2fs/019 | 2 ++ tests/f2fs/020 | 2 ++ tests/f2fs/022 | 2 ++ 6 files changed, 35 insertions(+)
Quoted 4 lines
common/f2fs
Quoted 1 line
common/f2fs +0
-0You remind me that there's a common/f2fs file, you can move f2fs specific functions to common/f2fs (e.g.
_check_f2fs_filesystem) later :)
Okay.
Quoted 37 lines
Quoted 37 lines
index
1b39d8ce..4b01e032100644common/f2fs +25
-0@@ -25,3 +25,28 @@ _require_scratch_f2fs_compression() _scratch_unmount fi } + +# check that inject.f2fs supports to inject specific field in specific meta area +_require_inject_f2fs_command() +{ + if [ $# -ne 2 ]; then + echo "Usage: _require_inject_f2fs_command metaarea member" 1>&2 + _exit 1 + fi + metaarea=$1 + member=$2 + + case $metaarea in + sb|cp|nat|sit) + val=0 + ;; + ssa|node|dent) + ;; + *) + _notrun "unsupport metaarea: $metaarea" + ;; + esac + + $F2FS_INJECT_PROG "--$metaarea" "$val" "-h" | grep "$member:" > /dev/null || \ + _notrun "--$metaarea --mb $member support is missing" +}tests/f2fs/009 +0
-0
Quoted 8 lines
tests/f2fs/009 line 12
Quoted 5 lines
tests/f2fs/009 +1
-0@@ -9,10 +9,12 @@ # and expects fsck.f2fs can detect such corruption and do the repair. # . ./common/preamble +. ./common/f2fsThe common/f2fs can be imported by common/config:_source_specific_fs() automatically, so we don't need this line at here.
Oh, so we may missed to add such line for f2fs in common/config:_source_specific_fs(), let me add a separated patch for this, and then we can remove ". ./common/f2fs" for f2fs/002.
Quoted 5 lines
(Same below)
Quoted 2 lines
tests/f2fs/009 +0
-0_begin_fstest auto quick
Quoted 7 lines
tests/f2fs/009 line 17
Quoted 3 lines
tests/f2fs/009 +1
-0_require_scratch _require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_inject_f2fs_command node i_linksIf the "
_require_command$F2FS_INJECT_PROG inject.f2fs" is always required before_require_inject_f2fs_command, how about call it at the beginning of_require_inject_f2fs_command?
Yeah, that's better. :)
Thanks,
Quoted 93 lines
(same below)
Thanks,
ZorroQuoted 86 lines
tests/f2fs/009 +0
-0_require_command "$(type -P socket)" socket _fixed_by_git_commit f2fs-tools 958cd6e \tests/f2fs/012 +2
-0@@ -12,6 +12,7 @@ # 4.enable linear lookup, expect lookup succeed # . ./common/preamble +. ./common/f2fs _begin_fstest auto quick casefold _fixed_by_kernel_commit 91b587ba79e1 \@@ -21,6 +22,7 @@ export LC_ALL=C.UTF-8 _require_scratch_nocheck _require_command "$F2FS_IO_PROG" f2fs_io _require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_inject_f2fs_command dent d_hash #check whether f2fs supports "lookup_mode=x" mount option mntopt=""tests/f2fs/019 +2
-0@@ -12,6 +12,7 @@ # corruption in the file # . ./common/preamble +. ./common/f2fs _begin_fstest auto quick rw _fixed_by_kernel_commit 77de19b6867f \@@ -19,6 +20,7 @@ _fixed_by_kernel_commit 77de19b6867f \ _require_scratch_nocheck _require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_inject_f2fs_command node addr # remove all mkfs options to avoid layout change of on-disk inode export MKFS_OPTIONS=""tests/f2fs/020 +2
-0@@ -12,6 +12,7 @@ # corruption in the file # . ./common/preamble +. ./common/f2fs _begin_fstest auto quick rw . ./common/attr@@ -21,6 +22,7 @@ _fixed_by_kernel_commit 061cf3a84bde \ _require_scratch_nocheck _require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_inject_f2fs_command node i_xattr_nid _require_attrs user # remove all mkfs options to avoid layout change of on-disk inodetests/f2fs/022 +2
-0@@ -11,6 +11,7 @@ # 4. fpunch in foo w/ specified range # . ./common/preamble +. ./common/f2fs _begin_fstest auto quick rw . ./common/attr@@ -20,6 +21,7 @@ _fixed_by_kernel_commit xxxxxxxxxxxx \ _require_scratch_nocheck _require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_inject_f2fs_command node i_nid # remove all mkfs options to avoid layout change of on-disk inode export MKFS_OPTIONS=""Signature · 1 line
2.40.1