aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorColy Li <colyli@suse.de>2019-02-08 23:52:55 -0500
committerJens Axboe <axboe@kernel.dk>2019-02-09 09:18:31 -0500
commit926d19465b66cb6bde4ca28fde16de775af4e357 (patch)
treee195346be004f36236107c163b228176a705ea39 /drivers/md
parent83ff9318c44babe32da0947d81443bad82da2d44 (diff)
bcache: export backing_dev_name via sysfs
This patch export dc->backing_dev_name to sysfs file /sys/block/bcache<?>/bcache/backing_dev_name, then people or user space tools may know the backing device name of this bcache device. Of cause it can be done by parsing sysfs links, but this method can be much simpler to find the link between bcache device and backing device. Signed-off-by: Coly Li <colyli@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/bcache/sysfs.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index 557a8a3270a1..b9166ee027fa 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -67,6 +67,7 @@ read_attribute(written);
67read_attribute(btree_written); 67read_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);
70 71
71sysfs_time_stats_attribute(btree_gc, sec, ms); 72sysfs_time_stats_attribute(btree_gc, sec, ms);
72sysfs_time_stats_attribute(btree_split, sec, us); 73sysfs_time_stats_attribute(btree_split, sec, us);
@@ -243,6 +244,12 @@ SHOW(__bch_cached_dev)
243 return strlen(buf); 244 return strlen(buf);
244 } 245 }
245 246
247 if (attr == &sysfs_backing_dev_name) {
248 snprintf(buf, BDEVNAME_SIZE + 1, "%s", dc->backing_dev_name);
249 strcat(buf, "\n");
250 return strlen(buf);
251 }
252
246#undef var 253#undef var
247 return 0; 254 return 0;
248} 255}
@@ -452,6 +459,7 @@ static struct attribute *bch_cached_dev_files[] = {
452 &sysfs_verify, 459 &sysfs_verify,
453 &sysfs_bypass_torture_test, 460 &sysfs_bypass_torture_test,
454#endif 461#endif
462 &sysfs_backing_dev_name,
455 NULL 463 NULL
456}; 464};
457KTYPE(bch_cached_dev); 465KTYPE(bch_cached_dev);