* [PATCH] btrfs: Add test 154 [not found] <20201207153237.1073887-1-nborisov@suse.com> @ 2020-12-07 15:34 ` Nikolay Borisov 2020-12-07 16:19 ` [RESEND PATCH] " Nikolay Borisov 1 sibling, 0 replies; 3+ messages in thread From: Nikolay Borisov @ 2020-12-07 15:34 UTC (permalink / raw) To: linux-btrfs; +Cc: fstests, Nikolay Borisov This test verifies btrfs' free objectid management. I.e it ensures that the first objectid is always 256 in an fs tree. Signed-off-by: Nikolay Borisov <nborisov@suse.com> --- tests/btrfs/154 | 80 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/154.out | 2 ++ tests/btrfs/group | 1 + 3 files changed, 83 insertions(+) create mode 100755 tests/btrfs/154 create mode 100644 tests/btrfs/154.out diff --git a/tests/btrfs/154 b/tests/btrfs/154 new file mode 100755 index 000000000000..6aee204e05cb --- /dev/null +++ b/tests/btrfs/154 @@ -0,0 +1,80 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 154 +# +# Test correct operation of free objectid related functionality +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# 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 btrfs +_require_scratch + + +_scratch_mkfs > /dev/null +_scratch_mount + +# create a new subvolume to validate its objectid is initialized accordingly +$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/newvol >> $seqres.full 2>&1 \ + || _fail "couldn't create subvol" + +$BTRFS_UTIL_PROG inspect-internal dump-tree -t1 $SCRATCH_DEV \ + | grep -q "256 ROOT_ITEM" || _fail "First subvol with id 256 doesn't exist" + +# create new file in the new subvolume to validate its objectid is set as +# expected +touch $SCRATCH_MNT/newvol/file1 + +# ensure we have consistent view on-disk +sync + +# get output related to the new root's dir entry +output=$($BTRFS_UTIL_PROG inspect-internal dump-tree -t5 $SCRATCH_DEV | grep -A2 "256 DIR_ITEM 1903355334") + +# get the objectid of the new root +new_root_id=$(echo "$output" | awk '/location key/{printf $3}' | tr -d '(') +[ $new_root_id -eq 256 ] || _fail "New root id not equal to 256" + +# the given root should always be item number 2, since it's the only item +item_seq=$(echo "$output" | awk '/item/ {printf $2}') +[ $item_seq -eq 2 ] || _fail "New root not at item idx 2" + +# now parse the structure of the new subvol's tree +output=$($BTRFS_UTIL_PROG inspect-internal dump-tree -t256 $SCRATCH_DEV) + +# this is the subvol's own ino +first_ino=$(echo "$output" | awk '/item 0/{printf $4}' | tr -d '(') +[ $first_ino -eq 256 ] || _fail "First ino objectid in subvol not 256" + +# this is ino of first file in subvol +second_ino=$(echo "$output" | awk '/item 4/{printf $4}' | tr -d '(') +[ $second_ino -eq 257 ] || _fail "Second ino objectid in subvol not 257" + +# success, all done +echo "Silence is golden" +status=0 +exit diff --git a/tests/btrfs/154.out b/tests/btrfs/154.out new file mode 100644 index 000000000000..a18c304305c4 --- /dev/null +++ b/tests/btrfs/154.out @@ -0,0 +1,2 @@ +QA output created by 154 +Silence is golden diff --git a/tests/btrfs/group b/tests/btrfs/group index d18450c7552e..44d33222def0 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -156,6 +156,7 @@ 151 auto quick volume 152 auto quick metadata qgroup send 153 auto quick qgroup limit +154 auto quick 155 auto quick send 156 auto quick trim balance 157 auto quick raid -- 2.17.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [RESEND PATCH] btrfs: Add test 154 [not found] <20201207153237.1073887-1-nborisov@suse.com> 2020-12-07 15:34 ` [PATCH] btrfs: Add test 154 Nikolay Borisov @ 2020-12-07 16:19 ` Nikolay Borisov 2020-12-20 14:32 ` Eryu Guan 1 sibling, 1 reply; 3+ messages in thread From: Nikolay Borisov @ 2020-12-07 16:19 UTC (permalink / raw) To: linux-btrfs; +Cc: fstests, Nikolay Borisov This test verifies btrfs' free objectid management. I.e it ensures that the first objectid is always 256 in an fs tree. Signed-off-by: Nikolay Borisov <nborisov@suse.com> --- Resend it as I fudged btrfs' mailing list address so the patch didn't get to it. tests/btrfs/154 | 80 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/154.out | 2 ++ tests/btrfs/group | 1 + 3 files changed, 83 insertions(+) create mode 100755 tests/btrfs/154 create mode 100644 tests/btrfs/154.out diff --git a/tests/btrfs/154 b/tests/btrfs/154 new file mode 100755 index 000000000000..6aee204e05cb --- /dev/null +++ b/tests/btrfs/154 @@ -0,0 +1,80 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 154 +# +# Test correct operation of free objectid related functionality +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# 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 btrfs +_require_scratch + + +_scratch_mkfs > /dev/null +_scratch_mount + +# create a new subvolume to validate its objectid is initialized accordingly +$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/newvol >> $seqres.full 2>&1 \ + || _fail "couldn't create subvol" + +$BTRFS_UTIL_PROG inspect-internal dump-tree -t1 $SCRATCH_DEV \ + | grep -q "256 ROOT_ITEM" || _fail "First subvol with id 256 doesn't exist" + +# create new file in the new subvolume to validate its objectid is set as +# expected +touch $SCRATCH_MNT/newvol/file1 + +# ensure we have consistent view on-disk +sync + +# get output related to the new root's dir entry +output=$($BTRFS_UTIL_PROG inspect-internal dump-tree -t5 $SCRATCH_DEV | grep -A2 "256 DIR_ITEM 1903355334") + +# get the objectid of the new root +new_root_id=$(echo "$output" | awk '/location key/{printf $3}' | tr -d '(') +[ $new_root_id -eq 256 ] || _fail "New root id not equal to 256" + +# the given root should always be item number 2, since it's the only item +item_seq=$(echo "$output" | awk '/item/ {printf $2}') +[ $item_seq -eq 2 ] || _fail "New root not at item idx 2" + +# now parse the structure of the new subvol's tree +output=$($BTRFS_UTIL_PROG inspect-internal dump-tree -t256 $SCRATCH_DEV) + +# this is the subvol's own ino +first_ino=$(echo "$output" | awk '/item 0/{printf $4}' | tr -d '(') +[ $first_ino -eq 256 ] || _fail "First ino objectid in subvol not 256" + +# this is ino of first file in subvol +second_ino=$(echo "$output" | awk '/item 4/{printf $4}' | tr -d '(') +[ $second_ino -eq 257 ] || _fail "Second ino objectid in subvol not 257" + +# success, all done +echo "Silence is golden" +status=0 +exit diff --git a/tests/btrfs/154.out b/tests/btrfs/154.out new file mode 100644 index 000000000000..a18c304305c4 --- /dev/null +++ b/tests/btrfs/154.out @@ -0,0 +1,2 @@ +QA output created by 154 +Silence is golden diff --git a/tests/btrfs/group b/tests/btrfs/group index d18450c7552e..44d33222def0 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -156,6 +156,7 @@ 151 auto quick volume 152 auto quick metadata qgroup send 153 auto quick qgroup limit +154 auto quick 155 auto quick send 156 auto quick trim balance 157 auto quick raid -- 2.17.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RESEND PATCH] btrfs: Add test 154 2020-12-07 16:19 ` [RESEND PATCH] " Nikolay Borisov @ 2020-12-20 14:32 ` Eryu Guan 0 siblings, 0 replies; 3+ messages in thread From: Eryu Guan @ 2020-12-20 14:32 UTC (permalink / raw) To: Nikolay Borisov; +Cc: linux-btrfs, fstests On Mon, Dec 07, 2020 at 06:19:00PM +0200, Nikolay Borisov wrote: > This test verifies btrfs' free objectid management. I.e it ensures that > the first objectid is always 256 in an fs tree. > > Signed-off-by: Nikolay Borisov <nborisov@suse.com> Some minor issues below, but I'd like btrfs folks to help review to see if the free objectid management test is reasonable. > --- > > Resend it as I fudged btrfs' mailing list address so the patch didn't get to it. > tests/btrfs/154 | 80 +++++++++++++++++++++++++++++++++++++++++++++ > tests/btrfs/154.out | 2 ++ > tests/btrfs/group | 1 + > 3 files changed, 83 insertions(+) > create mode 100755 tests/btrfs/154 > create mode 100644 tests/btrfs/154.out > > diff --git a/tests/btrfs/154 b/tests/btrfs/154 > new file mode 100755 > index 000000000000..6aee204e05cb > --- /dev/null > +++ b/tests/btrfs/154 > @@ -0,0 +1,80 @@ > +#! /bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved. > +# > +# FS QA Test 154 > +# > +# Test correct operation of free objectid related functionality > +# > +seq=`basename $0` > +seqres=$RESULT_DIR/$seq > +echo "QA output created by $seq" > + > +here=`pwd` > +tmp=/tmp/$$ > +status=1 # failure is the default! > +trap "_cleanup; exit \$status" 0 1 2 3 15 > + > +_cleanup() > +{ > + cd / > + rm -f $tmp.* > +} > + > +# 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 btrfs > +_require_scratch > + > + > +_scratch_mkfs > /dev/null > +_scratch_mount > + > +# create a new subvolume to validate its objectid is initialized accordingly > +$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/newvol >> $seqres.full 2>&1 \ > + || _fail "couldn't create subvol" > + > +$BTRFS_UTIL_PROG inspect-internal dump-tree -t1 $SCRATCH_DEV \ > + | grep -q "256 ROOT_ITEM" || _fail "First subvol with id 256 doesn't exist" This also requires _require_btrfs_command inspect-internal dump-tree And it's better to explain why '256' is the expected value, where does it come from. > + > +# create new file in the new subvolume to validate its objectid is set as > +# expected > +touch $SCRATCH_MNT/newvol/file1 > + > +# ensure we have consistent view on-disk > +sync > + > +# get output related to the new root's dir entry > +output=$($BTRFS_UTIL_PROG inspect-internal dump-tree -t5 $SCRATCH_DEV | grep -A2 "256 DIR_ITEM 1903355334") > + > +# get the objectid of the new root > +new_root_id=$(echo "$output" | awk '/location key/{printf $3}' | tr -d '(') I'd dump the output to a tmp file (and the following outputs in the test), as saving the output in a variable may cause unexpected results, something like ignoring "\n", and make it harder to debug. > +[ $new_root_id -eq 256 ] || _fail "New root id not equal to 256" > + > +# the given root should always be item number 2, since it's the only item > +item_seq=$(echo "$output" | awk '/item/ {printf $2}') $AWK_PROG Thanks, Eryu > +[ $item_seq -eq 2 ] || _fail "New root not at item idx 2" > + > +# now parse the structure of the new subvol's tree > +output=$($BTRFS_UTIL_PROG inspect-internal dump-tree -t256 $SCRATCH_DEV) > + > +# this is the subvol's own ino > +first_ino=$(echo "$output" | awk '/item 0/{printf $4}' | tr -d '(') > +[ $first_ino -eq 256 ] || _fail "First ino objectid in subvol not 256" > + > +# this is ino of first file in subvol > +second_ino=$(echo "$output" | awk '/item 4/{printf $4}' | tr -d '(') > +[ $second_ino -eq 257 ] || _fail "Second ino objectid in subvol not 257" > + > +# success, all done > +echo "Silence is golden" > +status=0 > +exit > diff --git a/tests/btrfs/154.out b/tests/btrfs/154.out > new file mode 100644 > index 000000000000..a18c304305c4 > --- /dev/null > +++ b/tests/btrfs/154.out > @@ -0,0 +1,2 @@ > +QA output created by 154 > +Silence is golden > diff --git a/tests/btrfs/group b/tests/btrfs/group > index d18450c7552e..44d33222def0 100644 > --- a/tests/btrfs/group > +++ b/tests/btrfs/group > @@ -156,6 +156,7 @@ > 151 auto quick volume > 152 auto quick metadata qgroup send > 153 auto quick qgroup limit > +154 auto quick > 155 auto quick send > 156 auto quick trim balance > 157 auto quick raid > -- > 2.17.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-20 14:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20201207153237.1073887-1-nborisov@suse.com>
2020-12-07 15:34 ` [PATCH] btrfs: Add test 154 Nikolay Borisov
2020-12-07 16:19 ` [RESEND PATCH] " Nikolay Borisov
2020-12-20 14:32 ` Eryu Guan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox