aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache
diff options
context:
space:
mode:
authorColy Li <colyli@suse.de>2019-02-08 23:52:56 -0500
committerJens Axboe <axboe@kernel.dk>2019-02-09 09:18:31 -0500
commitd4610456cfa412811b749f6215b9adae976ab4c3 (patch)
treeaed9005a0d5c2bfb10c9c4d19814e1cad54cb76d /drivers/md/bcache
parent926d19465b66cb6bde4ca28fde16de775af4e357 (diff)
bcache: export backing_dev_uuid via sysfs
When there are multiple bcache devices, after a reboot the name of bcache devices may change (e.g. current /dev/bcache1 was /dev/bcache0 before reboot). Therefore we need the backing device UUID (sb.uuid) to identify each bcache device. Backing device uuid can be found by program bcache-super-show, but directly exporting backing_dev_uuid by sysfs file /sys/block/bcache<?>/bcache/backing_dev_uuid is a much simpler method. With backing_dev_uuid, and partition uuids from /dev/disk/by-partuuid/, now we can identify each bcache device and its partitions conveniently. Signed-off-by: Coly Li <colyli@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/md/bcache')
-rw-r--r--drivers/md/bcache/sysfs.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index b9166ee027fa..9be27b26d300 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -68,6 +68,7 @@ read_attribute(btree_written);
68read_attribute(metadata_written); 68read_attribute(metadata_written);
69read_attribute(active_journal_entries); 69read_attribute(active_journal_entries);
70read_attribute(backing_dev_name); 70read_attribute(backing_dev_name);
71read_attribute(backing_dev_uuid);
71 72
72sysfs_time_stats_attribute(btree_gc, sec, ms); 73sysfs_time_stats_attribute(btree_gc, sec, ms);
73sysfs_time_stats_attribute(btree_split, sec, us); 74sysfs_time_stats_attribute(btree_split, sec, us);
@@ -250,6 +251,13 @@ SHOW(__bch_cached_dev)
250 return strlen(buf); 251 return strlen(buf);
251 } 252 }
252 253
254 if (attr == &sysfs_backing_dev_uuid) {
255 /* convert binary uuid into 36-byte string plus '\0' */
256 snprintf(buf, 36+1, "%pU", dc->sb.uuid);
257 strcat(buf, "\n");
258 return strlen(buf);
259 }
260
253#undef var 261#undef var
254 return 0; 262 return 0;
255} 263}
@@ -460,6 +468,7 @@ static struct attribute *bch_cached_dev_files[] = {
460 &sysfs_bypass_torture_test, 468 &sysfs_bypass_torture_test,
461#endif 469#endif
462 &sysfs_backing_dev_name, 470 &sysfs_backing_dev_name,
471 &sysfs_backing_dev_uuid,
463 NULL 472 NULL
464}; 473};
465KTYPE(bch_cached_dev); 474KTYPE(bch_cached_dev);