2 * bcache sysfs interfaces
4 * Copyright 2010, 2011 Kent Overstreet <kent.overstreet@gmail.com>
5 * Copyright 2012 Google, Inc.
12 #include "writeback.h"
14 #include <linux/blkdev.h>
15 #include <linux/sort.h>
17 static const char * const cache_replacement_policies[] = {
24 static const char * const error_actions[] = {
30 write_attribute(attach);
31 write_attribute(detach);
32 write_attribute(unregister);
33 write_attribute(stop);
34 write_attribute(clear_stats);
35 write_attribute(trigger_gc);
36 write_attribute(prune_cache);
37 write_attribute(flash_vol_create);
39 read_attribute(bucket_size);
40 read_attribute(block_size);
41 read_attribute(nbuckets);
42 read_attribute(tree_depth);
43 read_attribute(root_usage_percent);
44 read_attribute(priority_stats);
45 read_attribute(btree_cache_size);
46 read_attribute(btree_cache_max_chain);
47 read_attribute(cache_available_percent);
48 read_attribute(written);
49 read_attribute(btree_written);
50 read_attribute(metadata_written);
51 read_attribute(active_journal_entries);
53 sysfs_time_stats_attribute(btree_gc, sec, ms);
54 sysfs_time_stats_attribute(btree_split, sec, us);
55 sysfs_time_stats_attribute(btree_sort, ms, us);
56 sysfs_time_stats_attribute(btree_read, ms, us);
57 sysfs_time_stats_attribute(try_harder, ms, us);
59 read_attribute(btree_nodes);
60 read_attribute(btree_used_percent);
61 read_attribute(average_key_size);
62 read_attribute(dirty_data);
63 read_attribute(bset_tree_stats);
65 read_attribute(state);
66 read_attribute(cache_read_races);
67 read_attribute(writeback_keys_done);
68 read_attribute(writeback_keys_failed);
69 read_attribute(io_errors);
70 read_attribute(congested);
71 rw_attribute(congested_read_threshold_us);
72 rw_attribute(congested_write_threshold_us);
74 rw_attribute(sequential_cutoff);
75 rw_attribute(data_csum);
76 rw_attribute(cache_mode);
77 rw_attribute(writeback_metadata);
78 rw_attribute(writeback_running);
79 rw_attribute(writeback_percent);
80 rw_attribute(writeback_delay);
81 rw_attribute(writeback_rate);
83 rw_attribute(writeback_rate_update_seconds);
84 rw_attribute(writeback_rate_d_term);
85 rw_attribute(writeback_rate_p_term_inverse);
86 read_attribute(writeback_rate_debug);
88 read_attribute(stripe_size);
89 read_attribute(partial_stripes_expensive);
91 rw_attribute(synchronous);
92 rw_attribute(journal_delay_ms);
93 rw_attribute(discard);
94 rw_attribute(running);
96 rw_attribute(readahead);
98 rw_attribute(io_error_limit);
99 rw_attribute(io_error_halflife);
100 rw_attribute(verify);
101 rw_attribute(bypass_torture_test);
102 rw_attribute(key_merging_disabled);
103 rw_attribute(gc_always_rewrite);
104 rw_attribute(expensive_debug_checks);
105 rw_attribute(cache_replacement_policy);
106 rw_attribute(btree_shrinker_disabled);
107 rw_attribute(copy_gc_enabled);
110 SHOW(__bch_cached_dev)
112 struct cached_dev *dc = container_of(kobj, struct cached_dev,
114 const char *states[] = { "no cache", "clean", "dirty", "inconsistent" };
116 #define var(stat) (dc->stat)
118 if (attr == &sysfs_cache_mode)
119 return bch_snprint_string_list(buf, PAGE_SIZE,
121 BDEV_CACHE_MODE(&dc->sb));
123 sysfs_printf(data_csum, "%i", dc->disk.data_csum);
124 var_printf(verify, "%i");
125 var_printf(bypass_torture_test, "%i");
126 var_printf(writeback_metadata, "%i");
127 var_printf(writeback_running, "%i");
128 var_print(writeback_delay);
129 var_print(writeback_percent);
130 sysfs_hprint(writeback_rate, dc->writeback_rate.rate << 9);
132 var_print(writeback_rate_update_seconds);
133 var_print(writeback_rate_d_term);
134 var_print(writeback_rate_p_term_inverse);
136 if (attr == &sysfs_writeback_rate_debug) {
140 char proportional[20];
145 bch_hprint(rate, dc->writeback_rate.rate << 9);
146 bch_hprint(dirty, bcache_dev_sectors_dirty(&dc->disk) << 9);
147 bch_hprint(target, dc->writeback_rate_target << 9);
148 bch_hprint(proportional,dc->writeback_rate_proportional << 9);
149 bch_hprint(derivative, dc->writeback_rate_derivative << 9);
150 bch_hprint(change, dc->writeback_rate_change << 9);
152 next_io = div64_s64(dc->writeback_rate.next - local_clock(),
159 "proportional:\t%s\n"
161 "change:\t\t%s/sec\n"
162 "next io:\t%llims\n",
163 rate, dirty, target, proportional,
164 derivative, change, next_io);
167 sysfs_hprint(dirty_data,
168 bcache_dev_sectors_dirty(&dc->disk) << 9);
170 sysfs_hprint(stripe_size, dc->disk.stripe_size << 9);
171 var_printf(partial_stripes_expensive, "%u");
173 var_hprint(sequential_cutoff);
174 var_hprint(readahead);
176 sysfs_print(running, atomic_read(&dc->running));
177 sysfs_print(state, states[BDEV_STATE(&dc->sb)]);
179 if (attr == &sysfs_label) {
180 memcpy(buf, dc->sb.label, SB_LABEL_SIZE);
181 buf[SB_LABEL_SIZE + 1] = '\0';
189 SHOW_LOCKED(bch_cached_dev)
193 struct cached_dev *dc = container_of(kobj, struct cached_dev,
197 struct kobj_uevent_env *env;
199 #define d_strtoul(var) sysfs_strtoul(var, dc->var)
200 #define d_strtoul_nonzero(var) sysfs_strtoul_clamp(var, dc->var, 1, INT_MAX)
201 #define d_strtoi_h(var) sysfs_hatoi(var, dc->var)
203 sysfs_strtoul(data_csum, dc->disk.data_csum);
205 d_strtoul(bypass_torture_test);
206 d_strtoul(writeback_metadata);
207 d_strtoul(writeback_running);
208 d_strtoul(writeback_delay);
210 sysfs_strtoul_clamp(writeback_percent, dc->writeback_percent, 0, 40);
212 sysfs_strtoul_clamp(writeback_rate,
213 dc->writeback_rate.rate, 1, INT_MAX);
215 d_strtoul_nonzero(writeback_rate_update_seconds);
216 d_strtoul(writeback_rate_d_term);
217 d_strtoul_nonzero(writeback_rate_p_term_inverse);
219 d_strtoi_h(sequential_cutoff);
220 d_strtoi_h(readahead);
222 if (attr == &sysfs_clear_stats)
223 bch_cache_accounting_clear(&dc->accounting);
225 if (attr == &sysfs_running &&
226 strtoul_or_return(buf))
227 bch_cached_dev_run(dc);
229 if (attr == &sysfs_cache_mode) {
230 ssize_t v = bch_read_string_list(buf, bch_cache_modes + 1);
235 if ((unsigned) v != BDEV_CACHE_MODE(&dc->sb)) {
236 SET_BDEV_CACHE_MODE(&dc->sb, v);
237 bch_write_bdev_super(dc, NULL);
241 if (attr == &sysfs_label) {
242 if (size > SB_LABEL_SIZE)
244 memcpy(dc->sb.label, buf, size);
245 if (size < SB_LABEL_SIZE)
246 dc->sb.label[size] = '\0';
247 if (size && dc->sb.label[size - 1] == '\n')
248 dc->sb.label[size - 1] = '\0';
249 bch_write_bdev_super(dc, NULL);
251 memcpy(dc->disk.c->uuids[dc->disk.id].label,
253 bch_uuid_write(dc->disk.c);
255 env = kzalloc(sizeof(struct kobj_uevent_env), GFP_KERNEL);
258 add_uevent_var(env, "DRIVER=bcache");
259 add_uevent_var(env, "CACHED_UUID=%pU", dc->sb.uuid),
260 add_uevent_var(env, "CACHED_LABEL=%s", buf);
262 &disk_to_dev(dc->disk.disk)->kobj, KOBJ_CHANGE, env->envp);
266 if (attr == &sysfs_attach) {
267 if (bch_parse_uuid(buf, dc->sb.set_uuid) < 16)
270 list_for_each_entry(c, &bch_cache_sets, list) {
271 v = bch_cached_dev_attach(dc, c);
276 pr_err("Can't attach %s: cache set not found", buf);
280 if (attr == &sysfs_detach && dc->disk.c)
281 bch_cached_dev_detach(dc);
283 if (attr == &sysfs_stop)
284 bcache_device_stop(&dc->disk);
289 STORE(bch_cached_dev)
291 struct cached_dev *dc = container_of(kobj, struct cached_dev,
294 mutex_lock(&bch_register_lock);
295 size = __cached_dev_store(kobj, attr, buf, size);
297 if (attr == &sysfs_writeback_running)
298 bch_writeback_queue(dc);
300 if (attr == &sysfs_writeback_percent)
301 schedule_delayed_work(&dc->writeback_rate_update,
302 dc->writeback_rate_update_seconds * HZ);
304 mutex_unlock(&bch_register_lock);
308 static struct attribute *bch_cached_dev_files[] = {
316 &sysfs_writeback_metadata,
317 &sysfs_writeback_running,
318 &sysfs_writeback_delay,
319 &sysfs_writeback_percent,
320 &sysfs_writeback_rate,
321 &sysfs_writeback_rate_update_seconds,
322 &sysfs_writeback_rate_d_term,
323 &sysfs_writeback_rate_p_term_inverse,
324 &sysfs_writeback_rate_debug,
327 &sysfs_partial_stripes_expensive,
328 &sysfs_sequential_cutoff,
334 #ifdef CONFIG_BCACHE_DEBUG
336 &sysfs_bypass_torture_test,
340 KTYPE(bch_cached_dev);
344 struct bcache_device *d = container_of(kobj, struct bcache_device,
346 struct uuid_entry *u = &d->c->uuids[d->id];
348 sysfs_printf(data_csum, "%i", d->data_csum);
349 sysfs_hprint(size, u->sectors << 9);
351 if (attr == &sysfs_label) {
352 memcpy(buf, u->label, SB_LABEL_SIZE);
353 buf[SB_LABEL_SIZE + 1] = '\0';
361 STORE(__bch_flash_dev)
363 struct bcache_device *d = container_of(kobj, struct bcache_device,
365 struct uuid_entry *u = &d->c->uuids[d->id];
367 sysfs_strtoul(data_csum, d->data_csum);
369 if (attr == &sysfs_size) {
371 strtoi_h_or_return(buf, v);
374 bch_uuid_write(d->c);
375 set_capacity(d->disk, u->sectors);
378 if (attr == &sysfs_label) {
379 memcpy(u->label, buf, SB_LABEL_SIZE);
380 bch_uuid_write(d->c);
383 if (attr == &sysfs_unregister) {
384 set_bit(BCACHE_DEV_DETACHING, &d->flags);
385 bcache_device_stop(d);
390 STORE_LOCKED(bch_flash_dev)
392 static struct attribute *bch_flash_dev_files[] = {
401 KTYPE(bch_flash_dev);
403 struct bset_stats_op {
406 struct bset_stats stats;
409 static int btree_bset_stats(struct btree_op *b_op, struct btree *b)
411 struct bset_stats_op *op = container_of(b_op, struct bset_stats_op, op);
414 bch_btree_keys_stats(&b->keys, &op->stats);
419 int bch_bset_print_stats(struct cache_set *c, char *buf)
421 struct bset_stats_op op;
424 memset(&op, 0, sizeof(op));
425 bch_btree_op_init(&op.op, -1);
427 ret = bch_btree_map_nodes(&op.op, c, &ZERO_KEY, btree_bset_stats);
431 return snprintf(buf, PAGE_SIZE,
433 "written sets: %zu\n"
434 "unwritten sets: %zu\n"
435 "written key bytes: %zu\n"
436 "unwritten key bytes: %zu\n"
440 op.stats.sets_written, op.stats.sets_unwritten,
441 op.stats.bytes_written, op.stats.bytes_unwritten,
442 op.stats.floats, op.stats.failed);
445 SHOW(__bch_cache_set)
447 unsigned root_usage(struct cache_set *c)
452 struct btree_iter iter;
460 rw_lock(false, b, b->level);
461 } while (b != c->root);
463 for_each_key_filter(&b->keys, k, &iter, bch_ptr_bad)
464 bytes += bkey_bytes(k);
468 return (bytes * 100) / btree_bytes(c);
471 size_t cache_size(struct cache_set *c)
476 mutex_lock(&c->bucket_lock);
477 list_for_each_entry(b, &c->btree_cache, list)
478 ret += 1 << (b->keys.page_order + PAGE_SHIFT);
480 mutex_unlock(&c->bucket_lock);
484 unsigned cache_max_chain(struct cache_set *c)
487 struct hlist_head *h;
489 mutex_lock(&c->bucket_lock);
491 for (h = c->bucket_hash;
492 h < c->bucket_hash + (1 << BUCKET_HASH_BITS);
495 struct hlist_node *p;
503 mutex_unlock(&c->bucket_lock);
507 unsigned btree_used(struct cache_set *c)
509 return div64_u64(c->gc_stats.key_bytes * 100,
510 (c->gc_stats.nodes ?: 1) * btree_bytes(c));
513 unsigned average_key_size(struct cache_set *c)
515 return c->gc_stats.nkeys
516 ? div64_u64(c->gc_stats.data, c->gc_stats.nkeys)
520 struct cache_set *c = container_of(kobj, struct cache_set, kobj);
522 sysfs_print(synchronous, CACHE_SYNC(&c->sb));
523 sysfs_print(journal_delay_ms, c->journal_delay_ms);
524 sysfs_hprint(bucket_size, bucket_bytes(c));
525 sysfs_hprint(block_size, block_bytes(c));
526 sysfs_print(tree_depth, c->root->level);
527 sysfs_print(root_usage_percent, root_usage(c));
529 sysfs_hprint(btree_cache_size, cache_size(c));
530 sysfs_print(btree_cache_max_chain, cache_max_chain(c));
531 sysfs_print(cache_available_percent, 100 - c->gc_stats.in_use);
533 sysfs_print_time_stats(&c->btree_gc_time, btree_gc, sec, ms);
534 sysfs_print_time_stats(&c->btree_split_time, btree_split, sec, us);
535 sysfs_print_time_stats(&c->sort.time, btree_sort, ms, us);
536 sysfs_print_time_stats(&c->btree_read_time, btree_read, ms, us);
537 sysfs_print_time_stats(&c->try_harder_time, try_harder, ms, us);
539 sysfs_print(btree_used_percent, btree_used(c));
540 sysfs_print(btree_nodes, c->gc_stats.nodes);
541 sysfs_hprint(average_key_size, average_key_size(c));
543 sysfs_print(cache_read_races,
544 atomic_long_read(&c->cache_read_races));
546 sysfs_print(writeback_keys_done,
547 atomic_long_read(&c->writeback_keys_done));
548 sysfs_print(writeback_keys_failed,
549 atomic_long_read(&c->writeback_keys_failed));
551 if (attr == &sysfs_errors)
552 return bch_snprint_string_list(buf, PAGE_SIZE, error_actions,
555 /* See count_io_errors for why 88 */
556 sysfs_print(io_error_halflife, c->error_decay * 88);
557 sysfs_print(io_error_limit, c->error_limit >> IO_ERROR_SHIFT);
559 sysfs_hprint(congested,
560 ((uint64_t) bch_get_congested(c)) << 9);
561 sysfs_print(congested_read_threshold_us,
562 c->congested_read_threshold_us);
563 sysfs_print(congested_write_threshold_us,
564 c->congested_write_threshold_us);
566 sysfs_print(active_journal_entries, fifo_used(&c->journal.pin));
567 sysfs_printf(verify, "%i", c->verify);
568 sysfs_printf(key_merging_disabled, "%i", c->key_merging_disabled);
569 sysfs_printf(expensive_debug_checks,
570 "%i", c->expensive_debug_checks);
571 sysfs_printf(gc_always_rewrite, "%i", c->gc_always_rewrite);
572 sysfs_printf(btree_shrinker_disabled, "%i", c->shrinker_disabled);
573 sysfs_printf(copy_gc_enabled, "%i", c->copy_gc_enabled);
575 if (attr == &sysfs_bset_tree_stats)
576 return bch_bset_print_stats(c, buf);
580 SHOW_LOCKED(bch_cache_set)
582 STORE(__bch_cache_set)
584 struct cache_set *c = container_of(kobj, struct cache_set, kobj);
586 if (attr == &sysfs_unregister)
587 bch_cache_set_unregister(c);
589 if (attr == &sysfs_stop)
590 bch_cache_set_stop(c);
592 if (attr == &sysfs_synchronous) {
593 bool sync = strtoul_or_return(buf);
595 if (sync != CACHE_SYNC(&c->sb)) {
596 SET_CACHE_SYNC(&c->sb, sync);
597 bcache_write_super(c);
601 if (attr == &sysfs_flash_vol_create) {
604 strtoi_h_or_return(buf, v);
606 r = bch_flash_dev_create(c, v);
611 if (attr == &sysfs_clear_stats) {
612 atomic_long_set(&c->writeback_keys_done, 0);
613 atomic_long_set(&c->writeback_keys_failed, 0);
615 memset(&c->gc_stats, 0, sizeof(struct gc_stat));
616 bch_cache_accounting_clear(&c->accounting);
619 if (attr == &sysfs_trigger_gc)
622 if (attr == &sysfs_prune_cache) {
623 struct shrink_control sc;
624 sc.gfp_mask = GFP_KERNEL;
625 sc.nr_to_scan = strtoul_or_return(buf);
626 c->shrink.scan_objects(&c->shrink, &sc);
629 sysfs_strtoul(congested_read_threshold_us,
630 c->congested_read_threshold_us);
631 sysfs_strtoul(congested_write_threshold_us,
632 c->congested_write_threshold_us);
634 if (attr == &sysfs_errors) {
635 ssize_t v = bch_read_string_list(buf, error_actions);
643 if (attr == &sysfs_io_error_limit)
644 c->error_limit = strtoul_or_return(buf) << IO_ERROR_SHIFT;
646 /* See count_io_errors() for why 88 */
647 if (attr == &sysfs_io_error_halflife)
648 c->error_decay = strtoul_or_return(buf) / 88;
650 sysfs_strtoul(journal_delay_ms, c->journal_delay_ms);
651 sysfs_strtoul(verify, c->verify);
652 sysfs_strtoul(key_merging_disabled, c->key_merging_disabled);
653 sysfs_strtoul(expensive_debug_checks, c->expensive_debug_checks);
654 sysfs_strtoul(gc_always_rewrite, c->gc_always_rewrite);
655 sysfs_strtoul(btree_shrinker_disabled, c->shrinker_disabled);
656 sysfs_strtoul(copy_gc_enabled, c->copy_gc_enabled);
660 STORE_LOCKED(bch_cache_set)
662 SHOW(bch_cache_set_internal)
664 struct cache_set *c = container_of(kobj, struct cache_set, internal);
665 return bch_cache_set_show(&c->kobj, attr, buf);
668 STORE(bch_cache_set_internal)
670 struct cache_set *c = container_of(kobj, struct cache_set, internal);
671 return bch_cache_set_store(&c->kobj, attr, buf, size);
674 static void bch_cache_set_internal_release(struct kobject *k)
678 static struct attribute *bch_cache_set_files[] = {
682 &sysfs_journal_delay_ms,
683 &sysfs_flash_vol_create,
688 &sysfs_root_usage_percent,
689 &sysfs_btree_cache_size,
690 &sysfs_cache_available_percent,
692 &sysfs_average_key_size,
695 &sysfs_io_error_limit,
696 &sysfs_io_error_halflife,
698 &sysfs_congested_read_threshold_us,
699 &sysfs_congested_write_threshold_us,
703 KTYPE(bch_cache_set);
705 static struct attribute *bch_cache_set_internal_files[] = {
706 &sysfs_active_journal_entries,
708 sysfs_time_stats_attribute_list(btree_gc, sec, ms)
709 sysfs_time_stats_attribute_list(btree_split, sec, us)
710 sysfs_time_stats_attribute_list(btree_sort, ms, us)
711 sysfs_time_stats_attribute_list(btree_read, ms, us)
712 sysfs_time_stats_attribute_list(try_harder, ms, us)
715 &sysfs_btree_used_percent,
716 &sysfs_btree_cache_max_chain,
718 &sysfs_bset_tree_stats,
719 &sysfs_cache_read_races,
720 &sysfs_writeback_keys_done,
721 &sysfs_writeback_keys_failed,
725 #ifdef CONFIG_BCACHE_DEBUG
727 &sysfs_key_merging_disabled,
728 &sysfs_expensive_debug_checks,
730 &sysfs_gc_always_rewrite,
731 &sysfs_btree_shrinker_disabled,
732 &sysfs_copy_gc_enabled,
735 KTYPE(bch_cache_set_internal);
739 struct cache *ca = container_of(kobj, struct cache, kobj);
741 sysfs_hprint(bucket_size, bucket_bytes(ca));
742 sysfs_hprint(block_size, block_bytes(ca));
743 sysfs_print(nbuckets, ca->sb.nbuckets);
744 sysfs_print(discard, ca->discard);
745 sysfs_hprint(written, atomic_long_read(&ca->sectors_written) << 9);
746 sysfs_hprint(btree_written,
747 atomic_long_read(&ca->btree_sectors_written) << 9);
748 sysfs_hprint(metadata_written,
749 (atomic_long_read(&ca->meta_sectors_written) +
750 atomic_long_read(&ca->btree_sectors_written)) << 9);
752 sysfs_print(io_errors,
753 atomic_read(&ca->io_errors) >> IO_ERROR_SHIFT);
755 if (attr == &sysfs_cache_replacement_policy)
756 return bch_snprint_string_list(buf, PAGE_SIZE,
757 cache_replacement_policies,
758 CACHE_REPLACEMENT(&ca->sb));
760 if (attr == &sysfs_priority_stats) {
761 int cmp(const void *l, const void *r)
762 { return *((uint16_t *) r) - *((uint16_t *) l); }
764 size_t n = ca->sb.nbuckets, i, unused, btree;
766 /* Compute 31 quantiles */
767 uint16_t q[31], *p, *cached;
770 cached = p = vmalloc(ca->sb.nbuckets * sizeof(uint16_t));
774 mutex_lock(&ca->set->bucket_lock);
775 for (i = ca->sb.first_bucket; i < n; i++)
776 p[i] = ca->buckets[i].prio;
777 mutex_unlock(&ca->set->bucket_lock);
779 sort(p, n, sizeof(uint16_t), cmp, NULL);
785 unused = ca->sb.nbuckets - n;
787 while (cached < p + n &&
788 *cached == BTREE_PRIO)
794 for (i = 0; i < n; i++)
795 sum += INITIAL_PRIO - cached[i];
800 for (i = 0; i < ARRAY_SIZE(q); i++)
801 q[i] = INITIAL_PRIO - cached[n * (i + 1) /
802 (ARRAY_SIZE(q) + 1)];
806 ret = scnprintf(buf, PAGE_SIZE,
810 "Sectors per Q: %zu\n"
812 unused * 100 / (size_t) ca->sb.nbuckets,
813 btree * 100 / (size_t) ca->sb.nbuckets, sum,
814 n * ca->sb.bucket_size / (ARRAY_SIZE(q) + 1));
816 for (i = 0; i < ARRAY_SIZE(q); i++)
817 ret += scnprintf(buf + ret, PAGE_SIZE - ret,
821 ret += scnprintf(buf + ret, PAGE_SIZE - ret, "]\n");
828 SHOW_LOCKED(bch_cache)
832 struct cache *ca = container_of(kobj, struct cache, kobj);
834 if (attr == &sysfs_discard) {
835 bool v = strtoul_or_return(buf);
837 if (blk_queue_discard(bdev_get_queue(ca->bdev)))
840 if (v != CACHE_DISCARD(&ca->sb)) {
841 SET_CACHE_DISCARD(&ca->sb, v);
842 bcache_write_super(ca->set);
846 if (attr == &sysfs_cache_replacement_policy) {
847 ssize_t v = bch_read_string_list(buf, cache_replacement_policies);
852 if ((unsigned) v != CACHE_REPLACEMENT(&ca->sb)) {
853 mutex_lock(&ca->set->bucket_lock);
854 SET_CACHE_REPLACEMENT(&ca->sb, v);
855 mutex_unlock(&ca->set->bucket_lock);
857 bcache_write_super(ca->set);
861 if (attr == &sysfs_clear_stats) {
862 atomic_long_set(&ca->sectors_written, 0);
863 atomic_long_set(&ca->btree_sectors_written, 0);
864 atomic_long_set(&ca->meta_sectors_written, 0);
865 atomic_set(&ca->io_count, 0);
866 atomic_set(&ca->io_errors, 0);
871 STORE_LOCKED(bch_cache)
873 static struct attribute *bch_cache_files[] = {
877 &sysfs_priority_stats,
880 &sysfs_btree_written,
881 &sysfs_metadata_written,
884 &sysfs_cache_replacement_policy,