btrfs/124: add balance --full-balance option
authorAnand Jain <anand.jain@oracle.com>
Tue, 5 Dec 2017 11:36:32 +0000 (19:36 +0800)
committerEryu Guan <eguan@redhat.com>
Wed, 6 Dec 2017 08:05:29 +0000 (16:05 +0800)
btrfs balance needs --full-balance option since 4.6, so check the
version and then use it.

As this may be useful for other btrfs tests as well, so this patch
also adds _run_btrfs_balance_start() to the common/btrfs file.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/btrfs
tests/btrfs/124

index c09206c6f29240b27fc2af40341dab018122057f..79c687f73376e06784e5d972edc1abe3e1f0e2db 100644 (file)
@@ -356,3 +356,14 @@ _btrfs_compression_algos()
                echo "${feature#/sys/fs/btrfs/features/compress_}"
        done
 }
+
+# run btrfs balance start with required --full-balance if available.
+_run_btrfs_balance_start()
+{
+       local bal_opt=""
+
+       $BTRFS_UTIL_PROG balance start --help | grep -q "full-balance"
+       (( $? == 0 )) && bal_opt="--full-balance"
+
+       run_check $BTRFS_UTIL_PROG balance start $bal_opt $*
+}
index a6486270a972d51b164e5ceb9a3b4230368019a0..94c35fe1ede8b4f02c8d881416439d0e83808db2 100755 (executable)
@@ -129,7 +129,7 @@ _run_btrfs_util_prog device scan
 _scratch_mount >> $seqres.full 2>&1
 _run_btrfs_util_prog filesystem show
 echo >> $seqres.full
-_run_btrfs_util_prog balance start ${SCRATCH_MNT}
+_run_btrfs_balance_start ${SCRATCH_MNT}
 
 checkpoint2=`md5sum $SCRATCH_MNT/tf2`
 echo $checkpoint2 >> $seqres.full 2>&1