Message ID | CA+NNRhHpArYXt7YofXcH0h8yhcPvFhWC9ZKnRTcPhXziSPDHPg@mail.gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | bcache: add a command to show bcache topology | expand |
Hello Junhui, Thursday, September 20, 2018, 8:26:58 PM, you wrote: > From 647ac21a0068df1fafb038a628791d2fcc135462 Mon Sep 17 00:00:00 2001 > From: Tang Junhui <tang.junhui.linux@gmail.com> > Date: Fri, 21 Sep 2018 04:52:20 +0800 > Subject: [PATCH] bcache: add a command to show bcache topology > This patch add a command to show bcache topology as bellow: > [root@ceph x86_64]# cat /sys/fs/bcache/show "show" doesn't look like a good file name here, it's vague and doesn't convey the meaning. Maybe just use "topology" instead? > ( sdb ) : ( sdg:bcache4 sdf:bcache3 sde:bcache2 sdd:bcache1 sdc:bcache0 ) > ( sdh ) : ( sdm:bcache9 sdl:bcache8 sdk:bcache7 sdj:bcache6 sdi:bcache5 ) > In the output result, each line shows cache devices in the first () and > its cached devices in the second (). By this command, we can be easily > to know cached device bcache4 base on backing device sdg and cache device > sdb, we also can see bcache0 bcache1 bcache2 bcache3 and bcache4 are in > the same cache set. > (patch skipped) Pavel Goran
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index 05f82ff6..52ef9b3 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h @@ -881,6 +881,9 @@ static inline uint8_t bucket_gc_gen(struct bucket *b) #define kobj_attribute_write(n, fn) \ static struct kobj_attribute ksysfs_##n = __ATTR(n, S_IWUSR, NULL, fn) +#define kobj_attribute_read(n, fn) \ + static struct kobj_attribute ksysfs_##n = __ATTR(n, 0400, fn, NULL) + #define kobj_attribute_rw(n, show, store) \ static struct kobj_attribute ksysfs_##n = \ __ATTR(n, S_IWUSR|S_IRUSR, show, store) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 55a3764..d0d5484 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -2129,8 +2129,11 @@ static int register_cache(struct cache_sb *sb, struct page *sb_page, static ssize_t register_bcache(struct kobject *, struct kobj_attribute *, const char *, size_t); +static ssize_t show_bcache(struct kobject *, struct kobj_attribute *, + char *); kobj_attribute_write(register, register_bcache); +kobj_attribute_read(show, show_bcache); kobj_attribute_write(register_quiet, register_bcache);