Skip to contentSkip to conversation

btrfs/237: adjust uuid heuristics

PATCH Superseded Luis Chamberlain 2 participants 2 messages Feb 12, 2022 – Feb 14, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs/237: adjust uuid heuristics

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.

---
 tests/btrfs/237 | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
tests/btrfs/237 +8 -1
index 5168777e..07c07e8e 100755
@@ -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 '{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))
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Luis Chamberlain

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.

Quoted 4 lines

Thanks!
Minior nit below, otherwise

Quoted 9 lines
---
 tests/btrfs/237 | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
tests/btrfs/237 +0 -0
index 5168777e..07c07e8e 100755

tests/btrfs/237 zonesize=$((zonesize << 9)) · line 45

Quoted 6 lines
tests/btrfs/237 +2 -1
@@ -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 '{print $NF}')

Think that should be $AWK_PROG