diff options
Diffstat (limited to 'drivers/md/bcache/sysfs.c')
| -rw-r--r-- | drivers/md/bcache/sysfs.c | 68 |
1 files changed, 45 insertions, 23 deletions
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index 4d9cca47e4c6..12a2c2846f99 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c | |||
| @@ -9,7 +9,9 @@ | |||
| 9 | #include "sysfs.h" | 9 | #include "sysfs.h" |
| 10 | #include "btree.h" | 10 | #include "btree.h" |
| 11 | #include "request.h" | 11 | #include "request.h" |
| 12 | #include "writeback.h" | ||
| 12 | 13 | ||
| 14 | #include <linux/blkdev.h> | ||
| 13 | #include <linux/sort.h> | 15 | #include <linux/sort.h> |
| 14 | 16 | ||
| 15 | static const char * const cache_replacement_policies[] = { | 17 | static const char * const cache_replacement_policies[] = { |
| @@ -79,6 +81,9 @@ rw_attribute(writeback_rate_p_term_inverse); | |||
| 79 | rw_attribute(writeback_rate_d_smooth); | 81 | rw_attribute(writeback_rate_d_smooth); |
| 80 | read_attribute(writeback_rate_debug); | 82 | read_attribute(writeback_rate_debug); |
| 81 | 83 | ||
| 84 | read_attribute(stripe_size); | ||
| 85 | read_attribute(partial_stripes_expensive); | ||
| 86 | |||
| 82 | rw_attribute(synchronous); | 87 | rw_attribute(synchronous); |
| 83 | rw_attribute(journal_delay_ms); | 88 | rw_attribute(journal_delay_ms); |
| 84 | rw_attribute(discard); | 89 | rw_attribute(discard); |
| @@ -127,7 +132,7 @@ SHOW(__bch_cached_dev) | |||
| 127 | char derivative[20]; | 132 | char derivative[20]; |
| 128 | char target[20]; | 133 | char target[20]; |
| 129 | bch_hprint(dirty, | 134 | bch_hprint(dirty, |
| 130 | atomic_long_read(&dc->disk.sectors_dirty) << 9); | 135 | bcache_dev_sectors_dirty(&dc->disk) << 9); |
| 131 | bch_hprint(derivative, dc->writeback_rate_derivative << 9); | 136 | bch_hprint(derivative, dc->writeback_rate_derivative << 9); |
| 132 | bch_hprint(target, dc->writeback_rate_target << 9); | 137 | bch_hprint(target, dc->writeback_rate_target << 9); |
| 133 | 138 | ||
| @@ -143,7 +148,10 @@ SHOW(__bch_cached_dev) | |||
| 143 | } | 148 | } |
| 144 | 149 | ||
| 145 | sysfs_hprint(dirty_data, | 150 | sysfs_hprint(dirty_data, |
| 146 | atomic_long_read(&dc->disk.sectors_dirty) << 9); | 151 | bcache_dev_sectors_dirty(&dc->disk) << 9); |
| 152 | |||
| 153 | sysfs_hprint(stripe_size, (1 << dc->disk.stripe_size_bits) << 9); | ||
| 154 | var_printf(partial_stripes_expensive, "%u"); | ||
| 147 | 155 | ||
| 148 | var_printf(sequential_merge, "%i"); | 156 | var_printf(sequential_merge, "%i"); |
| 149 | var_hprint(sequential_cutoff); | 157 | var_hprint(sequential_cutoff); |
| @@ -170,6 +178,7 @@ STORE(__cached_dev) | |||
| 170 | disk.kobj); | 178 | disk.kobj); |
| 171 | unsigned v = size; | 179 | unsigned v = size; |
| 172 | struct cache_set *c; | 180 | struct cache_set *c; |
| 181 | struct kobj_uevent_env *env; | ||
| 173 | 182 | ||
| 174 | #define d_strtoul(var) sysfs_strtoul(var, dc->var) | 183 | #define d_strtoul(var) sysfs_strtoul(var, dc->var) |
| 175 | #define d_strtoi_h(var) sysfs_hatoi(var, dc->var) | 184 | #define d_strtoi_h(var) sysfs_hatoi(var, dc->var) |
| @@ -214,6 +223,7 @@ STORE(__cached_dev) | |||
| 214 | } | 223 | } |
| 215 | 224 | ||
| 216 | if (attr == &sysfs_label) { | 225 | if (attr == &sysfs_label) { |
| 226 | /* note: endlines are preserved */ | ||
| 217 | memcpy(dc->sb.label, buf, SB_LABEL_SIZE); | 227 | memcpy(dc->sb.label, buf, SB_LABEL_SIZE); |
| 218 | bch_write_bdev_super(dc, NULL); | 228 | bch_write_bdev_super(dc, NULL); |
| 219 | if (dc->disk.c) { | 229 | if (dc->disk.c) { |
| @@ -221,6 +231,15 @@ STORE(__cached_dev) | |||
| 221 | buf, SB_LABEL_SIZE); | 231 | buf, SB_LABEL_SIZE); |
| 222 | bch_uuid_write(dc->disk.c); | 232 | bch_uuid_write(dc->disk.c); |
| 223 | } | 233 | } |
| 234 | env = kzalloc(sizeof(struct kobj_uevent_env), GFP_KERNEL); | ||
| 235 | if (!env) | ||
| 236 | return -ENOMEM; | ||
| 237 | add_uevent_var(env, "DRIVER=bcache"); | ||
| 238 | add_uevent_var(env, "CACHED_UUID=%pU", dc->sb.uuid), | ||
| 239 | add_uevent_var(env, "CACHED_LABEL=%s", buf); | ||
| 240 | kobject_uevent_env( | ||
| 241 | &disk_to_dev(dc->disk.disk)->kobj, KOBJ_CHANGE, env->envp); | ||
| 242 | kfree(env); | ||
| 224 | } | 243 | } |
| 225 | 244 | ||
| 226 | if (attr == &sysfs_attach) { | 245 | if (attr == &sysfs_attach) { |
| @@ -284,6 +303,8 @@ static struct attribute *bch_cached_dev_files[] = { | |||
| 284 | &sysfs_writeback_rate_d_smooth, | 303 | &sysfs_writeback_rate_d_smooth, |
| 285 | &sysfs_writeback_rate_debug, | 304 | &sysfs_writeback_rate_debug, |
| 286 | &sysfs_dirty_data, | 305 | &sysfs_dirty_data, |
| 306 | &sysfs_stripe_size, | ||
| 307 | &sysfs_partial_stripes_expensive, | ||
| 287 | &sysfs_sequential_cutoff, | 308 | &sysfs_sequential_cutoff, |
| 288 | &sysfs_sequential_merge, | 309 | &sysfs_sequential_merge, |
| 289 | &sysfs_clear_stats, | 310 | &sysfs_clear_stats, |
| @@ -665,12 +686,10 @@ SHOW(__bch_cache) | |||
| 665 | int cmp(const void *l, const void *r) | 686 | int cmp(const void *l, const void *r) |
| 666 | { return *((uint16_t *) r) - *((uint16_t *) l); } | 687 | { return *((uint16_t *) r) - *((uint16_t *) l); } |
| 667 | 688 | ||
| 668 | /* Number of quantiles we compute */ | ||
| 669 | const unsigned nq = 31; | ||
| 670 | |||
| 671 | size_t n = ca->sb.nbuckets, i, unused, btree; | 689 | size_t n = ca->sb.nbuckets, i, unused, btree; |
| 672 | uint64_t sum = 0; | 690 | uint64_t sum = 0; |
| 673 | uint16_t q[nq], *p, *cached; | 691 | /* Compute 31 quantiles */ |
| 692 | uint16_t q[31], *p, *cached; | ||
| 674 | ssize_t ret; | 693 | ssize_t ret; |
| 675 | 694 | ||
| 676 | cached = p = vmalloc(ca->sb.nbuckets * sizeof(uint16_t)); | 695 | cached = p = vmalloc(ca->sb.nbuckets * sizeof(uint16_t)); |
| @@ -703,26 +722,29 @@ SHOW(__bch_cache) | |||
| 703 | if (n) | 722 | if (n) |
| 704 | do_div(sum, n); | 723 | do_div(sum, n); |
| 705 | 724 | ||
| 706 | for (i = 0; i < nq; i++) | 725 | for (i = 0; i < ARRAY_SIZE(q); i++) |
| 707 | q[i] = INITIAL_PRIO - cached[n * (i + 1) / (nq + 1)]; | 726 | q[i] = INITIAL_PRIO - cached[n * (i + 1) / |
| 727 | (ARRAY_SIZE(q) + 1)]; | ||
| 708 | 728 | ||
| 709 | vfree(p); | 729 | vfree(p); |
| 710 | 730 | ||
| 711 | ret = snprintf(buf, PAGE_SIZE, | 731 | ret = scnprintf(buf, PAGE_SIZE, |
| 712 | "Unused: %zu%%\n" | 732 | "Unused: %zu%%\n" |
| 713 | "Metadata: %zu%%\n" | 733 | "Metadata: %zu%%\n" |
| 714 | "Average: %llu\n" | 734 | "Average: %llu\n" |
| 715 | "Sectors per Q: %zu\n" | 735 | "Sectors per Q: %zu\n" |
| 716 | "Quantiles: [", | 736 | "Quantiles: [", |
| 717 | unused * 100 / (size_t) ca->sb.nbuckets, | 737 | unused * 100 / (size_t) ca->sb.nbuckets, |
| 718 | btree * 100 / (size_t) ca->sb.nbuckets, sum, | 738 | btree * 100 / (size_t) ca->sb.nbuckets, sum, |
| 719 | n * ca->sb.bucket_size / (nq + 1)); | 739 | n * ca->sb.bucket_size / (ARRAY_SIZE(q) + 1)); |
| 720 | 740 | ||
| 721 | for (i = 0; i < nq && ret < (ssize_t) PAGE_SIZE; i++) | 741 | for (i = 0; i < ARRAY_SIZE(q); i++) |
| 722 | ret += snprintf(buf + ret, PAGE_SIZE - ret, | 742 | ret += scnprintf(buf + ret, PAGE_SIZE - ret, |
| 723 | i < nq - 1 ? "%u " : "%u]\n", q[i]); | 743 | "%u ", q[i]); |
| 724 | 744 | ret--; | |
| 725 | buf[PAGE_SIZE - 1] = '\0'; | 745 | |
| 746 | ret += scnprintf(buf + ret, PAGE_SIZE - ret, "]\n"); | ||
| 747 | |||
| 726 | return ret; | 748 | return ret; |
| 727 | } | 749 | } |
| 728 | 750 | ||
