Skip to contentSkip to conversation

tst_find_backing_dev() fixes

PATCH In review Petr Vorel 2 participants 6 messages Nov 10, 2022 – Nov 14, 2022 Library code

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

cover tst_find_backing_dev() fixes

Hi,

"tst_find_backing_dev: fix stat fails /dev/root" patchset needs cleanup of left unused function and strange wording in docs. Although fixes are trivial, sending in case I overlooked something.

Also, the Btrfs part deserves putting into its own function; code now has too long lines, too many indents, function is too long.

Kind regards,
Petr

https://lore.kernel.org/ltp/[email protected]/
https://patchwork.ozlabs.org/project/ltp/list/?series=327409&state=*

Petr Vorel (2):
lib/tst_device: Remove unused count_match_len() doc/c-test-api.txt: Improve tst_find_backing_dev() doc

 doc/c-test-api.txt |  9 +++------
 lib/tst_device.c   | 10 ----------
 2 files changed, 3 insertions(+), 16 deletions(-)
Signature · 5 lines
2.38.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#1 lore raw

PATCH 1/2 lib/tst_device: Remove unused count_match_len()

Fixes e1b1ae66b ("tst_find_backing_dev: Get dev name from /sys/dev/block/*/uevent")

---
Hi,

obviously correct, but not merging it without ack there are changes and function is actually needed.

Kind regards,
Petr

 lib/tst_device.c | 10 ----------
 1 file changed, 10 deletions(-)
lib/tst_device.c +0 -10
index db5c2ab8f..48d7e3ab6 100644
@@ -510,16 +510,6 @@ unsigned long tst_dev_bytes_written(const char *dev)
 	return dev_bytes_written;
 }
 
-static int count_match_len(const char *first, const char *second)
-{
-	int len = 0;
-
-	while (*first && *first++ == *second++)
-		len++;
-
-	return len;
-}
-
 __attribute__((nonnull))
 void tst_find_backing_dev(const char *path, char *dev)
 {
Signature · 5 lines
2.38.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Acked-by on v1 1/2
#2 lore raw

Re: [LTP] [PATCH 1/2] lib/tst_device: Remove unused count_match_len()

Hello,

Quoted 3 lines · Petr Vorel
Fixes e1b1ae66b ("tst_find_backing_dev: Get dev name from /sys/dev/block/*/uevent")

Yup, my mistake.

Quoted 33 lines

---
Hi,

obviously correct, but not merging it without ack there are changes and function is actually needed.

Kind regards,
Petr

 lib/tst_device.c | 10 ----------
 1 file changed, 10 deletions(-)
lib/tst_device.c +0 -10
index db5c2ab8f..48d7e3ab6 100644
@@ -510,16 +510,6 @@ unsigned long tst_dev_bytes_written(const char *dev)
 	return dev_bytes_written;
 }
 
-static int count_match_len(const char *first, const char *second)
-{
-	int len = 0;
-
-	while (*first && *first++ == *second++)
-		len++;
-
-	return len;
-}
-
 __attribute__((nonnull))
 void tst_find_backing_dev(const char *path, char *dev)
 {
Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#3 lore raw

PATCH 2/2 doc/c-test-api.txt: Improve tst_find_backing_dev() doc

In reply to Petr Vorel

Doc added in 606903cf8 was too complicated. Also there was repeating sentence, typo 'unevent'.

While at it, fix also 'voud' typo from 9343d0486.

Fixes 606903cf8 ("c-test-api: Documentation updated")
Fixes 9343d0486 ("tst_device: Add new api tst_find_backing_dev(path, dev)")
---
 doc/c-test-api.txt | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
doc/c-test-api.txt +3 -6
index 8844d9f2f..834a342fd 100644
@@ -1075,12 +1075,9 @@ is created for that intention.
 void tst_find_backing_dev(const char *path, char *dev);
 -------------------------------------------------------------------------------
 
-This function finds the block dev that this path belongs to, it uses stat function
-to get the major/minor number of the path.
-This function finds the block dev that this path belongs to, it uses the unevent
-file in sysfs to find the device name. It needs to discriminate between btrfs
-and not btrfs. For non btrfs filesystems it uses the minor, major numbers. For
-btrfs it uses the fs uuid.
+This function finds the block dev that this path belongs to, using uevent in sysfs.
+For Btrfs it uses '/sys/fs/btrfs/UUID/devices/DEV_NAME/uevent'; for other
+filesystems it uses '/sys/dev/block/MAJOR:MINOR/uevent'.
 
 [source,c]
 -------------------------------------------------------------------------------
Signature · 5 lines
2.38.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Acked-by on v1 2/2
#4 lore raw

Re: [LTP] [PATCH 2/2] doc/c-test-api.txt: Improve tst_find_backing_dev() doc

Hello,

Quoted 9 lines · Petr Vorel

Doc added in 606903cf8 was too complicated. Also there was repeating sentence, typo 'unevent'.

While at it, fix also 'voud' typo from 9343d0486.

Fixes 606903cf8 ("c-test-api: Documentation updated")
Fixes 9343d0486 ("tst_device: Add new api tst_find_backing_dev(path, dev)")

Thanks

Quoted 24 lines
---
 doc/c-test-api.txt | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
doc/c-test-api.txt +3 -6
index 8844d9f2f..834a342fd 100644
@@ -1075,12 +1075,9 @@ is created for that intention.
 void tst_find_backing_dev(const char *path, char *dev);
 -------------------------------------------------------------------------------
 
-This function finds the block dev that this path belongs to, it uses stat function
-to get the major/minor number of the path.
-This function finds the block dev that this path belongs to, it uses the unevent
-file in sysfs to find the device name. It needs to discriminate between btrfs
-and not btrfs. For non btrfs filesystems it uses the minor, major numbers. For
-btrfs it uses the fs uuid.
+This function finds the block dev that this path belongs to, using uevent in sysfs.
+For Btrfs it uses '/sys/fs/btrfs/UUID/devices/DEV_NAME/uevent'; for other
+filesystems it uses '/sys/dev/block/MAJOR:MINOR/uevent'.
 
 [source,c]
 -------------------------------------------------------------------------------
Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#5 lore raw

Re: [LTP] [PATCH 2/2] doc/c-test-api.txt: Improve tst_find_backing_dev() doc

Hi Richard,

thanks for your review, merged!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp