Skip to contentSkip to conversation

btrfs-progs: Check for metadata uuid feature in misc-tests/034-metadata-uuid

PATCH Applied Nikolay Borisov 3 participants 5 messages Aug 5, 2019 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: Check for metadata uuid feature in misc-tests/034-metadata-uuid

Instead of checking the kernel version, explicitly check for the presence of metadata_uuid file in sysfs. This allows the test to be run on older kernels that might have this feature backported.

---
 tests/misc-tests/034-metadata-uuid/test.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/misc-tests/034-metadata-uuid/test.sh +2 -2
index 3ef110cda823..6ac55b1cacfa 100755
@@ -10,8 +10,8 @@ check_prereq btrfs-image
 setup_root_helper
 prepare_test_dev
 
-if ! check_min_kernel_version 5.0; then
-	_not_run "kernel too old, METADATA_UUID support needed"
+if [ ! -f /sys/fs/btrfs/features/metadata_uuid ] ; then
+	_not_run "METADATA_UUID feature not supported"
 fi
 
 read_fsid() {
Signature · 1 line
2.17.1
#1 lore raw
Quoted 5 lines · Nikolay Borisov

Instead of checking the kernel version, explicitly check for the presence of metadata_uuid file in sysfs. This allows the test to be run on older kernels that might have this feature backported.

The idea is pretty good, as sysfs is way more accurate.

But /sys/fs/btrfs/features is not ensured to exist, e.g btrfs module not loaded yet.

Can we fallback to regular kernel version check if /sys/fs/btrfs/features not exist?

Thanks,
Qu

Quoted 20 lines
---
 tests/misc-tests/034-metadata-uuid/test.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/misc-tests/034-metadata-uuid/test.sh +2 -2
index 3ef110cda823..6ac55b1cacfa 100755
@@ -10,8 +10,8 @@ check_prereq btrfs-image
 setup_root_helper
 prepare_test_dev
 
-if ! check_min_kernel_version 5.0; then
-	_not_run "kernel too old, METADATA_UUID support needed"
+if [ ! -f /sys/fs/btrfs/features/metadata_uuid ] ; then
+	_not_run "METADATA_UUID feature not supported"
 fi
 
 read_fsid() {
#2 lore raw
Quoted 9 lines · Qu Wenruo
Quoted 5 lines · Nikolay Borisov

Instead of checking the kernel version, explicitly check for the presence of metadata_uuid file in sysfs. This allows the test to be run on older kernels that might have this feature backported.

Quoted 7 lines

The idea is pretty good, as sysfs is way more accurate.

But /sys/fs/btrfs/features is not ensured to exist, e.g btrfs module not loaded yet.

Can we fallback to regular kernel version check if /sys/fs/btrfs/features not exist?

The top-level test runned (misc-tests.sh in this case) already calls check_kernel_support which ensures the module is loaded. So such fallback is unnecessary.

Quoted 25 lines

Thanks,
Qu

Quoted 20 lines
---
 tests/misc-tests/034-metadata-uuid/test.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/misc-tests/034-metadata-uuid/test.sh +2 -2
index 3ef110cda823..6ac55b1cacfa 100755
@@ -10,8 +10,8 @@ check_prereq btrfs-image
 setup_root_helper
 prepare_test_dev
 
-if ! check_min_kernel_version 5.0; then
-	_not_run "kernel too old, METADATA_UUID support needed"
+if [ ! -f /sys/fs/btrfs/features/metadata_uuid ] ; then
+	_not_run "METADATA_UUID feature not supported"
 fi
 
 read_fsid() {
Reviewed-by
#3 lore raw
Quoted 17 lines · Nikolay Borisov
Quoted 14 lines · Qu Wenruo
Quoted 5 lines · Nikolay Borisov

Instead of checking the kernel version, explicitly check for the presence of metadata_uuid file in sysfs. This allows the test to be run on older kernels that might have this feature backported.

The idea is pretty good, as sysfs is way more accurate.

But /sys/fs/btrfs/features is not ensured to exist, e.g btrfs module not loaded yet.

Quoted 6 lines
Quoted 2 lines

Can we fallback to regular kernel version check if /sys/fs/btrfs/features not exist?

The top-level test runned (misc-tests.sh in this case) already calls check_kernel_support which ensures the module is loaded. So such fallback is unnecessary.

Oh, forgot that.

Thanks,
Qu

Quoted 26 lines
Quoted 26 lines

Thanks,
Qu

Quoted 20 lines
---
 tests/misc-tests/034-metadata-uuid/test.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/misc-tests/034-metadata-uuid/test.sh +2 -2
index 3ef110cda823..6ac55b1cacfa 100755
@@ -10,8 +10,8 @@ check_prereq btrfs-image
 setup_root_helper
 prepare_test_dev
 
-if ! check_min_kernel_version 5.0; then
-	_not_run "kernel too old, METADATA_UUID support needed"
+if [ ! -f /sys/fs/btrfs/features/metadata_uuid ] ; then
+	_not_run "METADATA_UUID feature not supported"
 fi
 
 read_fsid() {