On Thu, Sep 24, 2020 at 01:08:13PM +0800, Qu Wenruo wrote: > > > On 2020/9/24 下午12:11, Sidong Yang wrote: > > This new test will test btrfs's qgroup assign functionality. The > > test has 3 cases. > > > > - assign, no shared extents > > - assign, shared extents > > - snapshot -i, shared extents > > > > Each cases create subvolumes and assign qgroup in their own way > > and check with the command "btrfs check". > > > > Cc: Qu Wenruo <wqu@xxxxxxxx> > > Cc: Eryu Guan <guan@xxxxxxx> > > > > Signed-off-by: Sidong Yang <realwakka@xxxxxxxxx> > > This version is much better overall. Thanks to you. > > The remaining small problems are mostly fstests related then. > ... > > +# Test assign qgroup for submodule with shared extents by reflink > > +assign_shared_test() > > +{ > > + _scratch_mkfs > /dev/null 2>&1 > > + _scratch_mount > > + > > + echo "=== qgroup assign shared test ===" >> $seqres.full > > + $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT > > + $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full > > + > > + $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full > > + $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/b >> $seqres.full > > + > > + _ddt of="$SCRATCH_MNT"/a/file1 bs=1M count=1 >> $seqres.full 2>&1 > > + cp --reflink=always "$SCRATCH_MNT"/a/file1 "$SCRATCH_MNT"/b/file1 > > + > > + $BTRFS_UTIL_PROG qgroup create 1/100 $SCRATCH_MNT > > + $BTRFS_UTIL_PROG qgroup assign $SCRATCH_MNT/a 1/100 $SCRATCH_MNT > > + $BTRFS_UTIL_PROG qgroup assign $SCRATCH_MNT/b 1/100 $SCRATCH_MNT > > + > > + _scratch_unmount > > + $BTRFS_UTIL_PROG check $SCRATCH_DEV >> $seqres.full 2>&1 > > We have _check_scratch_fs() function to do it properly already. Okay! > > > + [ $? -eq 0 ] || _fail "btrfs check failed" > > +} > > + > > +# Test assign qgroup for submodule without shared extents > > +assign_no_shared_test() > > +{ > > + _scratch_mkfs > /dev/null 2>&1 > > + _scratch_mount > > + > > + echo "=== qgroup assign no shared test ===" >> $seqres.full > > + $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT > > It's recommended to call "quota rescan -w" to ensure we finished rescan. > > As fast enough system can go to next command before the auto rescan even > finished. Yeah, I need to call "quota rescan -w" after enabling quota. > > Not sure if Eryu would have extra comments. I'm continuously ccing Eryu. I'll write a new v4 patch. Thanks! Sidong > > Thanks, > Qu > > > + $BTRFS_UTIL_PROG qgroup create 1/100 $SCRATCH_MNT > > + > > + $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full > > + $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/b >> $seqres.full > > + > > + $BTRFS_UTIL_PROG qgroup assign $SCRATCH_MNT/a 1/100 $SCRATCH_MNT > > + $BTRFS_UTIL_PROG qgroup assign $SCRATCH_MNT/b 1/100 $SCRATCH_MNT > > + _scratch_unmount > > + > > + $BTRFS_UTIL_PROG check $SCRATCH_DEV >> $seqres.full 2>&1 > > + [ $? -eq 0 ] || _fail "btrfs check failed" > > +} > > + > > +# Test snapshot with assigning qgroup for submodule > > +snapshot_test() > > +{ > > + _scratch_mkfs > /dev/null 2>&1 > > + _scratch_mount > > + > > + echo "=== qgroup snapshot test ===" >> $seqres.full > > + $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT > > + $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full > > + > > + $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full > > + _ddt of="$SCRATCH_MNT"/a/file1 bs=1M count=1 >> $seqres.full 2>&1 > > + subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a) > > + $BTRFS_UTIL_PROG subvolume snapshot -i 0/$subvolid $SCRATCH_MNT/a $SCRATCH_MNT/b >> $seqres.full > > + _scratch_unmount > > + > > + $BTRFS_UTIL_PROG check $SCRATCH_DEV >> $seqres.full 2>&1 > > + [ $? -eq 0 ] || _fail "btrfs check failed" > > +} > > + > > + > > +assign_no_shared_test > > + > > +assign_shared_test > > + > > +snapshot_test > > + > > +# success, all done > > +echo "Silence is golden" > > +status=0 > > +exit > > diff --git a/tests/btrfs/221.out b/tests/btrfs/221.out > > new file mode 100644 > > index 00000000..aa4351cd > > --- /dev/null > > +++ b/tests/btrfs/221.out > > @@ -0,0 +1,2 @@ > > +QA output created by 221 > > +Silence is golden > > diff --git a/tests/btrfs/group b/tests/btrfs/group > > index 1b5fa695..cdda38f3 100644 > > --- a/tests/btrfs/group > > +++ b/tests/btrfs/group > > @@ -222,3 +222,4 @@ > > 218 auto quick volume > > 219 auto quick volume > > 220 auto quick > > +221 auto quick qgroup > > >