On 1.09.20 г. 2:05 ч., Boris Burkov wrote: > btrfs/131 covers a solid variety of free space tree scenarios, but it > does not cover remount scenarios. We are adding remount support for read > only btrfs filesystems to move to the free space tree, so add a few test > cases covering that workflow as well. Refactor out some common free > space tree code from btrfs/131 into common/btrfs. > > Signed-off-by: Boris Burkov <boris@xxxxxx> Overall looks good, for a couple of minor cleanup suggestions see below. Still: Reviewed-by: Nikolay Borisov <nborisov@xxxxxxxx> > --- > common/btrfs | 12 +++++++++ > tests/btrfs/131 | 29 +++++++------------- > tests/btrfs/219 | 65 +++++++++++++++++++++++++++++++++++++++++++++ > tests/btrfs/219.out | 9 +++++++ > tests/btrfs/group | 1 + > 5 files changed, 96 insertions(+), 20 deletions(-) > create mode 100755 tests/btrfs/219 > create mode 100644 tests/btrfs/219.out > > diff --git a/common/btrfs b/common/btrfs > index 6d452d4d..9517c0a4 100644 > --- a/common/btrfs > +++ b/common/btrfs <snip> > diff --git a/tests/btrfs/131 b/tests/btrfs/131 > index 3de7eef8..93ff59f4 100755 > --- a/tests/btrfs/131 > +++ b/tests/btrfs/131 > @@ -52,17 +52,6 @@ mkfs_v2() > _scratch_unmount <snip> > # success, all done > diff --git a/tests/btrfs/219 b/tests/btrfs/219 > new file mode 100755 > index 00000000..1b889b78 > --- /dev/null > +++ b/tests/btrfs/219 > @@ -0,0 +1,65 @@ > +#! /bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (c) 2020 Facebook. All Rights Reserved. > +# > +# FS QA Test 219 > +# > +# Test free space tree remount scenarios. > +# > +seq=`basename $0` > +seqres=$RESULT_DIR/$seq > +echo "QA output created by $seq" <snip> \ > +# Remount: > +# -o space_cache=v1; -o remount,space_cache=v2: error > +# -o space_cache=v1,ro; -o remount,space_cache=v2: success > +echo "Trying to remount with free space tree" > +_scratch_mkfs >/dev/null 2>&1 > +_scratch_mount -o clear_cache,space_cache=v1 > +_btrfs_free_space_tree_enabled > +_try_scratch_mount -o remount,space_cache=v2 >/dev/null 2>&1 || echo "remount failed" nit: _scratch_remount space_cache=v2 || echo "remount failed" it will save you typing "-o remount" ;D > +_scratch_unmount > + > +echo "Remount read only fs with free space tree" > +_scratch_mkfs >/dev/null 2>&1 > +_scratch_mount -o clear_cache,space_cache=v1 > +_btrfs_free_space_tree_enabled > +_scratch_mount -o remount,ro,space_cache=v1 ditto > +_btrfs_free_space_tree_enabled > +_scratch_mount -o remount,space_cache=v2 ditto > +_btrfs_free_space_tree_enabled > +# ensure the free space tree is sticky across reboot > +_scratch_unmount > +_scratch_mount _scratch_cycle_mount > +_btrfs_free_space_tree_enabled > +_scratch_unmount > + > +# success, all done > +status=0 > +exit > diff --git a/tests/btrfs/219.out b/tests/btrfs/219.out > new file mode 100644 > index 00000000..0b22e258 > --- /dev/null > +++ b/tests/btrfs/219.out > @@ -0,0 +1,9 @@ > +QA output created by 219 > +Trying to remount with free space tree > +free space tree is disabled > +remount failed > +Remount read only fs with free space tree > +free space tree is disabled > +free space tree is disabled > +free space tree is enabled > +free space tree is enabled > diff --git a/tests/btrfs/group b/tests/btrfs/group > index 3295856d..f4dbfafb 100644 > --- a/tests/btrfs/group > +++ b/tests/btrfs/group > @@ -221,3 +221,4 @@ > 216 auto quick seed > 217 auto quick trim dangerous > 218 auto quick volume > +219 auto quick >