diff mbox series

[v2,1/3] btrfs/237: adjust uuid heuristics

Message ID 20220215014845.4164719-2-mcgrof@kernel.org (mailing list archive)
State New, archived
Headers show
Series adjust btrfs/237 uuid heuristics and use AWK_PROG | expand

Commit Message

Luis Chamberlain Feb. 15, 2022, 1:48 a.m. UTC
Using $(findmnt -n -o UUID mount-directory) only works on
util-linux v2.38, not on 2.37. Even debian-testing has util-linux
v2.37, so use a mechanism which has worked for longer to fetch the
UUID.

Without this the test fails on permission failure on accessing
the file /sys/fs/btrfs/"$uuid"/bg_reclaim_threshold as $uuid is
empty. So while at it, add a check to ensure the UUID is never
empty.

Use $AWK_PROG in case the preferred awk program is not the
preferred awk program.

Cc: Karel Zak <kzak@redhat.com>
Cc: Pankaj Raghav <p.raghav@samsung.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 tests/btrfs/237 | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Johannes Thumshirn Feb. 15, 2022, 3:51 p.m. UTC | #1
Looks good to me, thanks
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Adam Manzanares Feb. 17, 2022, 6:25 a.m. UTC | #2
On Mon, Feb 14, 2022 at 05:48:43PM -0800, Luis Chamberlain wrote:
> Using $(findmnt -n -o UUID mount-directory) only works on
> util-linux v2.38, not on 2.37. Even debian-testing has util-linux
> v2.37, so use a mechanism which has worked for longer to fetch the
> UUID.
> 
> Without this the test fails on permission failure on accessing
> the file /sys/fs/btrfs/"$uuid"/bg_reclaim_threshold as $uuid is
> empty. So while at it, add a check to ensure the UUID is never
> empty.
> 
> Use $AWK_PROG in case the preferred awk program is not the
> preferred awk program.
> 
> Cc: Karel Zak <kzak@redhat.com>
> Cc: Pankaj Raghav <p.raghav@samsung.com>
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> ---
>  tests/btrfs/237 | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/btrfs/237 b/tests/btrfs/237
> index 5168777e..96940549 100755
> --- a/tests/btrfs/237
> +++ b/tests/btrfs/237
> @@ -41,7 +41,14 @@ zonesize=$((zonesize << 9))
>  _scratch_mkfs >/dev/null 2>&1
>  _scratch_mount -o commit=1 # 1s commit time to speed up test
>  
> -uuid=$(findmnt -n -o UUID "$SCRATCH_MNT")
> +uuid=$($BTRFS_UTIL_PROG filesystem show $SCRATCH_DEV |grep uuid: |\
> +        $AWK_PROG '{print $NF}')
> +
> +if [[ "$uuid" == "" ]]; then
> +	echo "UUID for $SCRATCH_DEV is empty, this is not expected"
> +	exit 1
> +fi
> +
>  reclaim_threshold=75
>  echo $reclaim_threshold > /sys/fs/btrfs/"$uuid"/bg_reclaim_threshold
>  fill_percent=$((reclaim_threshold + 2))
> -- 
> 2.34.1
> 

Looks good.

Tested by: Adam Manzanares <a.manzanares@samsung.com>
diff mbox series

Patch

diff --git a/tests/btrfs/237 b/tests/btrfs/237
index 5168777e..96940549 100755
--- a/tests/btrfs/237
+++ b/tests/btrfs/237
@@ -41,7 +41,14 @@  zonesize=$((zonesize << 9))
 _scratch_mkfs >/dev/null 2>&1
 _scratch_mount -o commit=1 # 1s commit time to speed up test
 
-uuid=$(findmnt -n -o UUID "$SCRATCH_MNT")
+uuid=$($BTRFS_UTIL_PROG filesystem show $SCRATCH_DEV |grep uuid: |\
+        $AWK_PROG '{print $NF}')
+
+if [[ "$uuid" == "" ]]; then
+	echo "UUID for $SCRATCH_DEV is empty, this is not expected"
+	exit 1
+fi
+
 reclaim_threshold=75
 echo $reclaim_threshold > /sys/fs/btrfs/"$uuid"/bg_reclaim_threshold
 fill_percent=$((reclaim_threshold + 2))