btrfs/124: add balance --full-balance option
PATCH 1/1 btrfs/124: add balance --full-balance option
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 adds _btrfs_full_balance_option() to the common/btrfs file.
--- common/btrfs | 13 +++++++++++++ tests/btrfs/124 | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-)
common/btrfs +13 -0
@@ -356,3 +356,16 @@ _btrfs_compression_algos() echo "${feature#/sys/fs/btrfs/features/compress_}" done } + +#btrfs-progs adds required --full-balance option since v4.6 so check for +#that and then return the required option. +_btrfs_full_balance_option() +{ + ver=$($BTRFS_UTIL_PROG --version|awk '{print $2}'|cut -d"-" -f1 | cut -d"v" -f2) + tup1=$(echo $ver| cut -d"." -f1) + tup2=$(echo $ver| cut -d"." -f2) + + RET="" + (("$tup1" > "4")) && RET="--full-balance" + (("$tup1" == "4")) && (("tup2" >= "6")) && RET="--full-balance" +}
tests/btrfs/124 +2 -1
@@ -129,7 +129,8 @@ _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} +_btrfs_full_balance_option +_run_btrfs_util_prog balance start $RET ${SCRATCH_MNT} checkpoint2=`md5sum $SCRATCH_MNT/tf2` echo $checkpoint2 >> $seqres.full 2>&1
Signature · 1 line
2.15.0
Quoted 17 lines · Anand Jain
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 adds
_btrfs_full_balance_option()to the common/btrfs file.Signed-off-by Anand Jain <[email protected]>--- common/btrfs | 13 +++++++++++++ tests/btrfs/124 | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-)common/btrfs +0
-0
common/btrfs _btrfs_compression_algos() · line 364
Quoted 9 lines
common/btrfs +6
-0@@ -356,3 +356,16 @@ _btrfs_compression_algos() echo "${feature#/sys/fs/btrfs/features/compress_}" done } + +#btrfs-progs adds required --full-balance option since v4.6 so check for +#that and then return the required option. +_btrfs_full_balance_option() +{ + ver=$($BTRFS_UTIL_PROG --version|awk '{print $2}'|cut -d"-" -f1 | cut -d"v" -f2)
I'm never a fan of version check.
Backporting or modified package version can easily screw this up.
Why not directly checking the help message of "btrfs balance start"?
Thanks,
Qu
Quoted 22 lines
common/btrfs +7
-0+ tup1=$(echo $ver| cut -d"." -f1) + tup2=$(echo $ver| cut -d"." -f2) + + RET="" + (("$tup1" > "4")) && RET="--full-balance" + (("$tup1" == "4")) && (("tup2" >= "6")) && RET="--full-balance" +}tests/btrfs/124 +2
-1@@ -129,7 +129,8 @@ _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} +_btrfs_full_balance_option +_run_btrfs_util_prog balance start $RET ${SCRATCH_MNT} checkpoint2=`md5sum $SCRATCH_MNT/tf2` echo $checkpoint2 >> $seqres.full 2>&1
Quoted 24 lines · Qu Wenruo
Quoted 21 lines · Anand Jain
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 adds
_btrfs_full_balance_option()to the common/btrfs file.Signed-off-by Anand Jain <[email protected]>--- common/btrfs | 13 +++++++++++++ tests/btrfs/124 | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-)common/btrfs +1
-0@@ -356,3 +356,16 @@ _btrfs_compression_algos() echo "${feature#/sys/fs/btrfs/features/compress_}" done } +
Quoted 8 lines
common/btrfs _btrfs_compression_algos() · line 364
Quoted 5 lines
common/btrfs +5
-0+#btrfs-progs adds required --full-balance option since v4.6 so check for +#that and then return the required option. +_btrfs_full_balance_option() +{ + ver=$($BTRFS_UTIL_PROG --version|awk '{print $2}'|cut -d"-" -f1 | cut -d"v" -f2)I'm never a fan of version check.
Backporting or modified package version can easily screw this up.
Agreed, avoid version checking if possible.
Quoted 8 lines
Why not directly checking the help message of "btrfs balance start"?
Thanks,
Qucommon/btrfs _btrfs_compression_algos() · line 366
Quoted 2 lines
common/btrfs +2
-0+ tup1=$(echo $ver| cut -d"." -f1) + tup2=$(echo $ver| cut -d"." -f2)
And please declare local variables as 'local'.
Quoted 8 lines
Quoted 8 lines
common/btrfs +5
-0+ + RET="" + (("$tup1" > "4")) && RET="--full-balance" + (("$tup1" == "4")) && (("tup2" >= "6")) && RET="--full-balance" +}tests/btrfs/124 +0
-1--- a/tests/btrfs/124
Quoted 8 lines
tests/btrfs/124 _run_btrfs_util_prog device scan · line 133
Quoted 8 lines
+++ b/tests/btrfs/124
tests/btrfs/124 +2
-1@@ -129,7 +129,8 @@ _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} +_btrfs_full_balance_option +_run_btrfs_util_prog balance start $RET ${SCRATCH_MNT}
This usage depends on the implicit global variable RET, which seems a bit hard to follow. How about let the new helper return the expected option string, and use that string in test, either assign it to a local var or use it in command line directly.
Think about it more, perhaps we can introduce a new helper, e.g. _run_btrfs_balance, and hide all these details, just call balance with --full-balance when possible?
Thanks,
Eryu
Quoted 5 lines
Quoted 4 lines
tests/btrfs/124 +0
-0checkpoint2=`md5sum $SCRATCH_MNT/tf2` echo $checkpoint2 >> $seqres.full 2>&1
Quoted 33 lines · Qu Wenruo
Quoted 17 lines · Anand Jain
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 adds
_btrfs_full_balance_option()to the common/btrfs file.Signed-off-by Anand Jain <[email protected]>--- common/btrfs | 13 +++++++++++++ tests/btrfs/124 | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-)common/btrfs +0
-0common/btrfs _btrfs_compression_algos() · line 364
Quoted 9 lines
common/btrfs +6
-0@@ -356,3 +356,16 @@ _btrfs_compression_algos() echo "${feature#/sys/fs/btrfs/features/compress_}" done } + +#btrfs-progs adds required --full-balance option since v4.6 so check for +#that and then return the required option. +_btrfs_full_balance_option() +{ + ver=$($BTRFS_UTIL_PROG --version|awk '{print $2}'|cut -d"-" -f1 | cut -d"v" -f2)I'm never a fan of version check.
Backporting or modified package version can easily screw this up.
Quoted 1 line
Why not directly checking the help message of "btrfs balance start"?
Agreed. Will do.
Thanks, Anand
Quoted 26 lines
Thanks,
QuQuoted 22 lines
common/btrfs +7
-0+ tup1=$(echo $ver| cut -d"." -f1) + tup2=$(echo $ver| cut -d"." -f2) + + RET="" + (("$tup1" > "4")) && RET="--full-balance" + (("$tup1" == "4")) && (("tup2" >= "6")) && RET="--full-balance" +}tests/btrfs/124 +2
-1@@ -129,7 +129,8 @@ _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} +_btrfs_full_balance_option +_run_btrfs_util_prog balance start $RET ${SCRATCH_MNT} checkpoint2=`md5sum $SCRATCH_MNT/tf2` echo $checkpoint2 >> $seqres.full 2>&1
Quoted 39 lines · Eryu Guan
Quoted 24 lines · Qu Wenruo
Quoted 21 lines · Anand Jain
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 adds
_btrfs_full_balance_option()to the common/btrfs file.Signed-off-by Anand Jain <[email protected]>--- common/btrfs | 13 +++++++++++++ tests/btrfs/124 | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-)common/btrfs +1
-0@@ -356,3 +356,16 @@ _btrfs_compression_algos() echo "${feature#/sys/fs/btrfs/features/compress_}" done } +Quoted 8 lines
common/btrfs _btrfs_compression_algos() · line 364
Quoted 5 lines
common/btrfs +5
-0+#btrfs-progs adds required --full-balance option since v4.6 so check for +#that and then return the required option. +_btrfs_full_balance_option() +{ + ver=$($BTRFS_UTIL_PROG --version|awk '{print $2}'|cut -d"-" -f1 | cut -d"v" -f2)I'm never a fan of version check.
Backporting or modified package version can easily screw this up.Agreed, avoid version checking if possible.
Quoted 3 lines
Why not directly checking the help message of "btrfs balance start"?
Quoted 7 lines
Quoted 5 lines
Thanks,
Qucommon/btrfs _btrfs_compression_algos() · line 366
Quoted 2 lines
common/btrfs +2
-0+ tup1=$(echo $ver| cut -d"." -f1) + tup2=$(echo $ver| cut -d"." -f2)And please declare local variables as 'local'.
ok.
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
common/btrfs +5
-0+ + RET="" + (("$tup1" > "4")) && RET="--full-balance" + (("$tup1" == "4")) && (("tup2" >= "6")) && RET="--full-balance" +}tests/btrfs/124 +0
-1--- a/tests/btrfs/124Quoted 8 lines
tests/btrfs/124 _run_btrfs_util_prog device scan · line 133
Quoted 8 lines
+++ b/tests/btrfs/124
tests/btrfs/124 +2
-1@@ -129,7 +129,8 @@ _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} +_btrfs_full_balance_option +_run_btrfs_util_prog balance start $RET ${SCRATCH_MNT}This usage depends on the implicit global variable RET, which seems a bit hard to follow. How about let the new helper return the expected option string, and use that string in test, either assign it to a local var or use it in command line directly.
Quoted 3 lines
Think about it more, perhaps we can introduce a new helper, e.g.
_run_btrfs_balance, and hide all these details, just call balance with --full-balance when possible?
Ah. That's much better. Will do.
Thanks, Anand
Quoted 16 lines
Thanks,
EryuQuoted 5 lines
tests/btrfs/124 _run_btrfs_util_prog device scan
Quoted 4 lines
tests/btrfs/124 +0
-0checkpoint2=`md5sum $SCRATCH_MNT/tf2` echo $checkpoint2 >> $seqres.full 2>&1--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/1 btrfs/124: add balance --full-balance option
In reply to Anand Jainbtrfs 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.
---
v2: Use help to find if --full-balance is supported
Make a local variable
run the balance instead of getting the options
common/btrfs | 11 +++++++++++ tests/btrfs/124 | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-)
common/btrfs +11 -0
@@ -356,3 +356,14 @@ _btrfs_compression_algos() echo "${feature#/sys/fs/btrfs/features/compress_}" done } + +#runs 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 $* +}
tests/btrfs/124 +1 -1
@@ -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
Signature · 1 line
2.15.0