[PATCH] bcache-tools: fix incorrect id to find cache dev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In function 'show_bdevs_detail' of 'show.c', the code traverse all
bcache dev collected, then call 'cset_to_devname' for backing dev to
get the name of the related cache dev into 'attachdev':

/* show.c begin */
...
INIT_LIST_HEAD(&head);
...
ret = list_bdevs(&head);
...
list_for_each_entry_safe(devs, n, &head, dev_list) {
    ...
    char attachdev[30];

    if (strlen(devs->attachuuid) == 36) {
        cset_to_devname(&head, devs->cset, attachdev);
...
/* show.c end */

/* lib.c begin */
int cset_to_devname(struct list_head *head, char *cset, char *devname)
...
/* lib.c end */

'cset_to_devname' scan all cache dev from the first argument 'head', and
 copy the name of the cache dev that matches against the second argument
 'cset' into the third argument 'devname'.

But in above code, the passed second argument is the 'cset' of the
backing dev itself, rather than the 'cset' of the cache dev.

This patch fix this error, call the 'cset_to_devname' with the second
argument of 'devs->attachuuid', rather than 'devs->cset'. Otherwise, if
the backing dev of the bcache is the first device in 'head', then the
'attachdev' can be a untouched status because the 'cset_to_devname' can
not match any the 'cset' of cache dev with a 'cset' from backing dev, so
 the 'printf' for 'attachdev' can be nonsense.

Signed-off-by: Xiaole He <hexiaole@xxxxxxxxxx>
---
 show.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/show.c b/show.c
index abd068e..f69fd10 100644
--- a/show.c
+++ b/show.c
@@ -73,7 +73,7 @@ int show_bdevs_detail(void)
 		char attachdev[30];
 
 		if (strlen(devs->attachuuid) == 36) {
-			cset_to_devname(&head, devs->cset, attachdev);
+			cset_to_devname(&head, devs->attachuuid, attachdev);
 		} else if (devs->version == BCACHE_SB_VERSION_CDEV
 			   || devs->version == BCACHE_SB_VERSION_CDEV_WITH_UUID
 			   || devs->version ==
-- 
2.27.0




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux ARM Kernel]     [Linux Filesystem Development]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux