Message ID | 167096072838.1750373.11954125201906427521.stgit@magnolia (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | fstests: fix broken fuzzing xfs_mdrestore calls | expand |
On Tue, Dec 13, 2022 at 11:45:28AM -0800, Darrick J. Wong wrote: > From: Darrick J. Wong <djwong@kernel.org> > > Move the metadump decompression code to the per-filesystem mdrestore > commands so that everyone can take advantage of them. This enables the > XFS and ext4 _mdrestore helpers to handle metadata dumps compressed with > their respective _metadump helpers. > > In turn, this means that the xfs fuzz tests can now handle the > compressed metadumps created by the _scratch_populate_cached helper. > This is key to unbreaking fuzz testing for xfs. > > Signed-off-by: Darrick J. Wong <djwong@kernel.org> > --- > common/ext4 | 13 ++++++++++++- > common/fuzzy | 2 +- > common/populate | 15 ++------------- > common/xfs | 15 +++++++++++++-- > 4 files changed, 28 insertions(+), 17 deletions(-) > > > diff --git a/common/ext4 b/common/ext4 > index dc2e4e59cc..cadf1a7974 100644 > --- a/common/ext4 > +++ b/common/ext4 > @@ -129,9 +129,20 @@ _ext4_mdrestore() > { > local metadump="$1" > local device="$2" > - shift; shift > + local compressopt="$3" I didn't see this variable is used in this function, do I missed something? > + shift; shift; shift > local options="$@" > > + # If we're configured for compressed dumps and there isn't already an > + # uncompressed dump, see if we can use DUMP_COMPRESSOR to decompress > + # something. > + if [ ! -e "$metadump" ] && [ -n "$DUMP_COMPRESSOR" ]; then > + for compr in "$metadump".*; do > + [ -e "$compr" ] && $DUMP_COMPRESSOR -d -f -k "$compr" && break > + done > + fi > + test -r "$metadump" || return 1 > + > $E2IMAGE_PROG $options -r "${metadump}" "${SCRATCH_DEV}" > } > > diff --git a/common/fuzzy b/common/fuzzy > index fad79124e5..e634815eec 100644 > --- a/common/fuzzy > +++ b/common/fuzzy > @@ -159,7 +159,7 @@ __scratch_xfs_fuzz_mdrestore() > test -e "${POPULATE_METADUMP}" || _fail "Need to set POPULATE_METADUMP" > > __scratch_xfs_fuzz_unmount > - _xfs_mdrestore "${POPULATE_METADUMP}" "${SCRATCH_DEV}" > + _xfs_mdrestore "${POPULATE_METADUMP}" "${SCRATCH_DEV}" compress > } > > __fuzz_notify() { > diff --git a/common/populate b/common/populate > index f382c40aca..96866ee4cf 100644 > --- a/common/populate > +++ b/common/populate > @@ -848,20 +848,9 @@ _scratch_populate_cache_tag() { > _scratch_populate_restore_cached() { > local metadump="$1" > > - # If we're configured for compressed dumps and there isn't already an > - # uncompressed dump, see if we can use DUMP_COMPRESSOR to decompress > - # something. > - if [ -n "$DUMP_COMPRESSOR" ]; then > - for compr in "$metadump".*; do > - [ -e "$compr" ] && $DUMP_COMPRESSOR -d -f -k "$compr" && break > - done > - fi > - > - test -r "$metadump" || return 1 > - > case "${FSTYP}" in > "xfs") > - _xfs_mdrestore "${metadump}" "${SCRATCH_DEV}" > + _xfs_mdrestore "${metadump}" "${SCRATCH_DEV}" compress > res=$? > test $res -ne 0 && return $res > > @@ -876,7 +865,7 @@ _scratch_populate_restore_cached() { > return $res > ;; > "ext2"|"ext3"|"ext4") > - _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}" > + _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}" compress > ret=$? > test $ret -ne 0 && return $ret > > diff --git a/common/xfs b/common/xfs > index 216dab3bcd..833c2f4368 100644 > --- a/common/xfs > +++ b/common/xfs > @@ -641,9 +641,20 @@ _xfs_metadump() { > _xfs_mdrestore() { > local metadump="$1" > local device="$2" > - shift; shift > + local compressopt="$3" I didn't see this variable is used in this function either. > + shift; shift; shift > local options="$@" > > + # If we're configured for compressed dumps and there isn't already an > + # uncompressed dump, see if we can use DUMP_COMPRESSOR to decompress > + # something. > + if [ ! -e "$metadump" ] && [ -n "$DUMP_COMPRESSOR" ]; then > + for compr in "$metadump".*; do > + [ -e "$compr" ] && $DUMP_COMPRESSOR -d -f -k "$compr" && break > + done > + fi > + test -r "$metadump" || return 1 > + > $XFS_MDRESTORE_PROG $options "${metadump}" "${device}" > } > > @@ -666,7 +677,7 @@ _scratch_xfs_mdrestore() > local metadump=$1 > shift > > - _xfs_mdrestore "$metadump" "$SCRATCH_DEV" "$@" > + _xfs_mdrestore "$metadump" "$SCRATCH_DEV" nocompress "$@" > } > > # run xfs_check and friends on a FS. >
On Sat, Dec 17, 2022 at 02:50:15PM +0800, Zorro Lang wrote: > On Tue, Dec 13, 2022 at 11:45:28AM -0800, Darrick J. Wong wrote: > > From: Darrick J. Wong <djwong@kernel.org> > > > > Move the metadump decompression code to the per-filesystem mdrestore > > commands so that everyone can take advantage of them. This enables the > > XFS and ext4 _mdrestore helpers to handle metadata dumps compressed with > > their respective _metadump helpers. > > > > In turn, this means that the xfs fuzz tests can now handle the > > compressed metadumps created by the _scratch_populate_cached helper. > > This is key to unbreaking fuzz testing for xfs. > > > > Signed-off-by: Darrick J. Wong <djwong@kernel.org> > > --- > > common/ext4 | 13 ++++++++++++- > > common/fuzzy | 2 +- > > common/populate | 15 ++------------- > > common/xfs | 15 +++++++++++++-- > > 4 files changed, 28 insertions(+), 17 deletions(-) > > > > > > diff --git a/common/ext4 b/common/ext4 > > index dc2e4e59cc..cadf1a7974 100644 > > --- a/common/ext4 > > +++ b/common/ext4 > > @@ -129,9 +129,20 @@ _ext4_mdrestore() > > { > > local metadump="$1" > > local device="$2" > > - shift; shift > > + local compressopt="$3" > > I didn't see this variable is used in this function, do I missed something? Oops. I missed that this variable isn't necessary at all. :( --D > > + shift; shift; shift > > local options="$@" > > > > + # If we're configured for compressed dumps and there isn't already an > > + # uncompressed dump, see if we can use DUMP_COMPRESSOR to decompress > > + # something. > > + if [ ! -e "$metadump" ] && [ -n "$DUMP_COMPRESSOR" ]; then > > + for compr in "$metadump".*; do > > + [ -e "$compr" ] && $DUMP_COMPRESSOR -d -f -k "$compr" && break > > + done > > + fi > > + test -r "$metadump" || return 1 > > + > > $E2IMAGE_PROG $options -r "${metadump}" "${SCRATCH_DEV}" > > } > > > > diff --git a/common/fuzzy b/common/fuzzy > > index fad79124e5..e634815eec 100644 > > --- a/common/fuzzy > > +++ b/common/fuzzy > > @@ -159,7 +159,7 @@ __scratch_xfs_fuzz_mdrestore() > > test -e "${POPULATE_METADUMP}" || _fail "Need to set POPULATE_METADUMP" > > > > __scratch_xfs_fuzz_unmount > > - _xfs_mdrestore "${POPULATE_METADUMP}" "${SCRATCH_DEV}" > > + _xfs_mdrestore "${POPULATE_METADUMP}" "${SCRATCH_DEV}" compress > > } > > > > __fuzz_notify() { > > diff --git a/common/populate b/common/populate > > index f382c40aca..96866ee4cf 100644 > > --- a/common/populate > > +++ b/common/populate > > @@ -848,20 +848,9 @@ _scratch_populate_cache_tag() { > > _scratch_populate_restore_cached() { > > local metadump="$1" > > > > - # If we're configured for compressed dumps and there isn't already an > > - # uncompressed dump, see if we can use DUMP_COMPRESSOR to decompress > > - # something. > > - if [ -n "$DUMP_COMPRESSOR" ]; then > > - for compr in "$metadump".*; do > > - [ -e "$compr" ] && $DUMP_COMPRESSOR -d -f -k "$compr" && break > > - done > > - fi > > - > > - test -r "$metadump" || return 1 > > - > > case "${FSTYP}" in > > "xfs") > > - _xfs_mdrestore "${metadump}" "${SCRATCH_DEV}" > > + _xfs_mdrestore "${metadump}" "${SCRATCH_DEV}" compress > > res=$? > > test $res -ne 0 && return $res > > > > @@ -876,7 +865,7 @@ _scratch_populate_restore_cached() { > > return $res > > ;; > > "ext2"|"ext3"|"ext4") > > - _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}" > > + _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}" compress > > ret=$? > > test $ret -ne 0 && return $ret > > > > diff --git a/common/xfs b/common/xfs > > index 216dab3bcd..833c2f4368 100644 > > --- a/common/xfs > > +++ b/common/xfs > > @@ -641,9 +641,20 @@ _xfs_metadump() { > > _xfs_mdrestore() { > > local metadump="$1" > > local device="$2" > > - shift; shift > > + local compressopt="$3" > > I didn't see this variable is used in this function either. > > > + shift; shift; shift > > local options="$@" > > > > + # If we're configured for compressed dumps and there isn't already an > > + # uncompressed dump, see if we can use DUMP_COMPRESSOR to decompress > > + # something. > > + if [ ! -e "$metadump" ] && [ -n "$DUMP_COMPRESSOR" ]; then > > + for compr in "$metadump".*; do > > + [ -e "$compr" ] && $DUMP_COMPRESSOR -d -f -k "$compr" && break > > + done > > + fi > > + test -r "$metadump" || return 1 > > + > > $XFS_MDRESTORE_PROG $options "${metadump}" "${device}" > > } > > > > @@ -666,7 +677,7 @@ _scratch_xfs_mdrestore() > > local metadump=$1 > > shift > > > > - _xfs_mdrestore "$metadump" "$SCRATCH_DEV" "$@" > > + _xfs_mdrestore "$metadump" "$SCRATCH_DEV" nocompress "$@" > > } > > > > # run xfs_check and friends on a FS. > > >
diff --git a/common/ext4 b/common/ext4 index dc2e4e59cc..cadf1a7974 100644 --- a/common/ext4 +++ b/common/ext4 @@ -129,9 +129,20 @@ _ext4_mdrestore() { local metadump="$1" local device="$2" - shift; shift + local compressopt="$3" + shift; shift; shift local options="$@" + # If we're configured for compressed dumps and there isn't already an + # uncompressed dump, see if we can use DUMP_COMPRESSOR to decompress + # something. + if [ ! -e "$metadump" ] && [ -n "$DUMP_COMPRESSOR" ]; then + for compr in "$metadump".*; do + [ -e "$compr" ] && $DUMP_COMPRESSOR -d -f -k "$compr" && break + done + fi + test -r "$metadump" || return 1 + $E2IMAGE_PROG $options -r "${metadump}" "${SCRATCH_DEV}" } diff --git a/common/fuzzy b/common/fuzzy index fad79124e5..e634815eec 100644 --- a/common/fuzzy +++ b/common/fuzzy @@ -159,7 +159,7 @@ __scratch_xfs_fuzz_mdrestore() test -e "${POPULATE_METADUMP}" || _fail "Need to set POPULATE_METADUMP" __scratch_xfs_fuzz_unmount - _xfs_mdrestore "${POPULATE_METADUMP}" "${SCRATCH_DEV}" + _xfs_mdrestore "${POPULATE_METADUMP}" "${SCRATCH_DEV}" compress } __fuzz_notify() { diff --git a/common/populate b/common/populate index f382c40aca..96866ee4cf 100644 --- a/common/populate +++ b/common/populate @@ -848,20 +848,9 @@ _scratch_populate_cache_tag() { _scratch_populate_restore_cached() { local metadump="$1" - # If we're configured for compressed dumps and there isn't already an - # uncompressed dump, see if we can use DUMP_COMPRESSOR to decompress - # something. - if [ -n "$DUMP_COMPRESSOR" ]; then - for compr in "$metadump".*; do - [ -e "$compr" ] && $DUMP_COMPRESSOR -d -f -k "$compr" && break - done - fi - - test -r "$metadump" || return 1 - case "${FSTYP}" in "xfs") - _xfs_mdrestore "${metadump}" "${SCRATCH_DEV}" + _xfs_mdrestore "${metadump}" "${SCRATCH_DEV}" compress res=$? test $res -ne 0 && return $res @@ -876,7 +865,7 @@ _scratch_populate_restore_cached() { return $res ;; "ext2"|"ext3"|"ext4") - _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}" + _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}" compress ret=$? test $ret -ne 0 && return $ret diff --git a/common/xfs b/common/xfs index 216dab3bcd..833c2f4368 100644 --- a/common/xfs +++ b/common/xfs @@ -641,9 +641,20 @@ _xfs_metadump() { _xfs_mdrestore() { local metadump="$1" local device="$2" - shift; shift + local compressopt="$3" + shift; shift; shift local options="$@" + # If we're configured for compressed dumps and there isn't already an + # uncompressed dump, see if we can use DUMP_COMPRESSOR to decompress + # something. + if [ ! -e "$metadump" ] && [ -n "$DUMP_COMPRESSOR" ]; then + for compr in "$metadump".*; do + [ -e "$compr" ] && $DUMP_COMPRESSOR -d -f -k "$compr" && break + done + fi + test -r "$metadump" || return 1 + $XFS_MDRESTORE_PROG $options "${metadump}" "${device}" } @@ -666,7 +677,7 @@ _scratch_xfs_mdrestore() local metadump=$1 shift - _xfs_mdrestore "$metadump" "$SCRATCH_DEV" "$@" + _xfs_mdrestore "$metadump" "$SCRATCH_DEV" nocompress "$@" } # run xfs_check and friends on a FS.