1 // SPDX-License-Identifier: GPL-2.0
3 * bcache sysfs interfaces
5 * Copyright 2010, 2011 Kent Overstreet <kent.overstreet@gmail.com>
6 * Copyright 2012 Google, Inc.
9 #ifndef NO_BCACHEFS_SYSFS
12 #include "alloc_background.h"
13 #include "alloc_foreground.h"
15 #include "btree_cache.h"
17 #include "btree_iter.h"
18 #include "btree_key_cache.h"
19 #include "btree_update.h"
20 #include "btree_update_interior.h"
24 #include "disk_groups.h"
31 #include "nocow_locking.h"
33 #include "rebalance.h"
38 #include <linux/blkdev.h>
39 #include <linux/sort.h>
40 #include <linux/sched/clock.h>
44 #define SYSFS_OPS(type) \
45 const struct sysfs_ops type ## _sysfs_ops = { \
46 .show = type ## _show, \
47 .store = type ## _store \
51 static ssize_t fn ## _to_text(struct printbuf *, \
52 struct kobject *, struct attribute *); \
54 static ssize_t fn ## _show(struct kobject *kobj, struct attribute *attr,\
57 struct printbuf out = PRINTBUF; \
58 ssize_t ret = fn ## _to_text(&out, kobj, attr); \
60 if (out.pos && out.buf[out.pos - 1] != '\n') \
63 if (!ret && out.allocation_failure) \
67 ret = min_t(size_t, out.pos, PAGE_SIZE - 1); \
68 memcpy(buf, out.buf, ret); \
70 printbuf_exit(&out); \
71 return bch2_err_class(ret); \
74 static ssize_t fn ## _to_text(struct printbuf *out, struct kobject *kobj,\
75 struct attribute *attr)
78 static ssize_t fn ## _store_inner(struct kobject *, struct attribute *,\
79 const char *, size_t); \
81 static ssize_t fn ## _store(struct kobject *kobj, struct attribute *attr,\
82 const char *buf, size_t size) \
84 return bch2_err_class(fn##_store_inner(kobj, attr, buf, size)); \
87 static ssize_t fn ## _store_inner(struct kobject *kobj, struct attribute *attr,\
88 const char *buf, size_t size)
90 #define __sysfs_attribute(_name, _mode) \
91 static struct attribute sysfs_##_name = \
92 { .name = #_name, .mode = _mode }
94 #define write_attribute(n) __sysfs_attribute(n, 0200)
95 #define read_attribute(n) __sysfs_attribute(n, 0444)
96 #define rw_attribute(n) __sysfs_attribute(n, 0644)
98 #define sysfs_printf(file, fmt, ...) \
100 if (attr == &sysfs_ ## file) \
101 prt_printf(out, fmt "\n", __VA_ARGS__); \
104 #define sysfs_print(file, var) \
106 if (attr == &sysfs_ ## file) \
110 #define sysfs_hprint(file, val) \
112 if (attr == &sysfs_ ## file) \
113 prt_human_readable_s64(out, val); \
116 #define sysfs_strtoul(file, var) \
118 if (attr == &sysfs_ ## file) \
119 return strtoul_safe(buf, var) ?: (ssize_t) size; \
122 #define sysfs_strtoul_clamp(file, var, min, max) \
124 if (attr == &sysfs_ ## file) \
125 return strtoul_safe_clamp(buf, var, min, max) \
129 #define strtoul_or_return(cp) \
132 int _r = kstrtoul(cp, 10, &_v); \
138 write_attribute(trigger_gc);
139 write_attribute(trigger_discards);
140 write_attribute(trigger_invalidates);
141 write_attribute(prune_cache);
142 write_attribute(btree_wakeup);
143 rw_attribute(btree_gc_periodic);
144 rw_attribute(gc_gens_pos);
146 read_attribute(uuid);
147 read_attribute(minor);
148 read_attribute(bucket_size);
149 read_attribute(first_bucket);
150 read_attribute(nbuckets);
151 rw_attribute(durability);
152 read_attribute(io_done);
153 read_attribute(io_errors);
154 write_attribute(io_errors_reset);
156 read_attribute(io_latency_read);
157 read_attribute(io_latency_write);
158 read_attribute(io_latency_stats_read);
159 read_attribute(io_latency_stats_write);
160 read_attribute(congested);
162 read_attribute(btree_write_stats);
164 read_attribute(btree_cache_size);
165 read_attribute(compression_stats);
166 read_attribute(journal_debug);
167 read_attribute(btree_updates);
168 read_attribute(btree_cache);
169 read_attribute(btree_key_cache);
170 read_attribute(stripes_heap);
171 read_attribute(open_buckets);
172 read_attribute(open_buckets_partial);
173 read_attribute(write_points);
174 read_attribute(nocow_lock_table);
176 #ifdef BCH_WRITE_REF_DEBUG
177 read_attribute(write_refs);
179 static const char * const bch2_write_refs[] = {
186 static void bch2_write_refs_to_text(struct printbuf *out, struct bch_fs *c)
188 bch2_printbuf_tabstop_push(out, 24);
190 for (unsigned i = 0; i < ARRAY_SIZE(c->writes); i++) {
191 prt_str(out, bch2_write_refs[i]);
193 prt_printf(out, "%li", atomic_long_read(&c->writes[i]));
199 read_attribute(internal_uuid);
200 read_attribute(disk_groups);
202 read_attribute(has_data);
203 read_attribute(alloc_debug);
205 #define x(t, n, ...) read_attribute(t);
206 BCH_PERSISTENT_COUNTERS()
209 rw_attribute(discard);
212 rw_attribute(copy_gc_enabled);
213 read_attribute(copy_gc_wait);
215 rw_attribute(rebalance_enabled);
216 sysfs_pd_controller_attribute(rebalance);
217 read_attribute(rebalance_status);
218 rw_attribute(promote_whole_extents);
220 read_attribute(new_stripes);
222 read_attribute(io_timers_read);
223 read_attribute(io_timers_write);
225 read_attribute(moving_ctxts);
227 #ifdef CONFIG_BCACHEFS_TESTS
228 write_attribute(perf_test);
229 #endif /* CONFIG_BCACHEFS_TESTS */
232 static struct attribute sysfs_time_stat_##_name = \
233 { .name = #_name, .mode = 0444 };
237 static struct attribute sysfs_state_rw = {
242 static size_t bch2_btree_cache_size(struct bch_fs *c)
247 mutex_lock(&c->btree_cache.lock);
248 list_for_each_entry(b, &c->btree_cache.live, list)
249 ret += btree_bytes(c);
251 mutex_unlock(&c->btree_cache.lock);
255 static int bch2_compression_stats_to_text(struct printbuf *out, struct bch_fs *c)
257 struct btree_trans *trans;
258 struct btree_iter iter;
261 struct compression_type_stats {
263 u64 sectors_compressed;
264 u64 sectors_uncompressed;
265 } s[BCH_COMPRESSION_TYPE_NR];
266 u64 compressed_incompressible = 0;
269 memset(s, 0, sizeof(s));
271 if (!test_bit(BCH_FS_STARTED, &c->flags))
274 trans = bch2_trans_get(c);
276 for (id = 0; id < BTREE_ID_NR; id++) {
277 if (!btree_type_has_ptrs(id))
280 for_each_btree_key(trans, iter, id, POS_MIN,
281 BTREE_ITER_ALL_SNAPSHOTS, k, ret) {
282 struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
283 struct bch_extent_crc_unpacked crc;
284 const union bch_extent_entry *entry;
285 bool compressed = false, incompressible = false;
287 bkey_for_each_crc(k.k, ptrs, crc, entry) {
288 incompressible |= crc.compression_type == BCH_COMPRESSION_TYPE_incompressible;
289 compressed |= crc_is_compressed(crc);
291 if (crc_is_compressed(crc)) {
292 s[crc.compression_type].nr_extents++;
293 s[crc.compression_type].sectors_compressed += crc.compressed_size;
294 s[crc.compression_type].sectors_uncompressed += crc.uncompressed_size;
298 compressed_incompressible += compressed && incompressible;
301 unsigned t = incompressible ? BCH_COMPRESSION_TYPE_incompressible : 0;
304 s[t].sectors_compressed += k.k->size;
305 s[t].sectors_uncompressed += k.k->size;
308 bch2_trans_iter_exit(trans, &iter);
311 bch2_trans_put(trans);
316 prt_str(out, "type");
317 printbuf_tabstop_push(out, 12);
320 prt_str(out, "compressed");
321 printbuf_tabstop_push(out, 16);
324 prt_str(out, "uncompressed");
325 printbuf_tabstop_push(out, 16);
328 prt_str(out, "average extent size");
329 printbuf_tabstop_push(out, 24);
333 for (unsigned i = 0; i < ARRAY_SIZE(s); i++) {
334 prt_str(out, bch2_compression_types[i]);
337 prt_human_readable_u64(out, s[i].sectors_compressed << 9);
340 prt_human_readable_u64(out, s[i].sectors_uncompressed << 9);
343 prt_human_readable_u64(out, s[i].nr_extents
344 ? div_u64(s[i].sectors_uncompressed << 9, s[i].nr_extents)
350 if (compressed_incompressible) {
351 prt_printf(out, "%llu compressed & incompressible extents", compressed_incompressible);
358 static void bch2_gc_gens_pos_to_text(struct printbuf *out, struct bch_fs *c)
360 prt_printf(out, "%s: ", bch2_btree_id_str(c->gc_gens_btree));
361 bch2_bpos_to_text(out, c->gc_gens_pos);
362 prt_printf(out, "\n");
365 static void bch2_btree_wakeup_all(struct bch_fs *c)
367 struct btree_trans *trans;
369 seqmutex_lock(&c->btree_trans_lock);
370 list_for_each_entry(trans, &c->btree_trans_list, list) {
371 struct btree_bkey_cached_common *b = READ_ONCE(trans->locking);
374 six_lock_wakeup_all(&b->lock);
377 seqmutex_unlock(&c->btree_trans_lock);
382 struct bch_fs *c = container_of(kobj, struct bch_fs, kobj);
384 sysfs_print(minor, c->minor);
385 sysfs_printf(internal_uuid, "%pU", c->sb.uuid.b);
387 sysfs_hprint(btree_cache_size, bch2_btree_cache_size(c));
389 if (attr == &sysfs_btree_write_stats)
390 bch2_btree_write_stats_to_text(out, c);
392 sysfs_printf(btree_gc_periodic, "%u", (int) c->btree_gc_periodic);
394 if (attr == &sysfs_gc_gens_pos)
395 bch2_gc_gens_pos_to_text(out, c);
397 sysfs_printf(copy_gc_enabled, "%i", c->copy_gc_enabled);
399 sysfs_printf(rebalance_enabled, "%i", c->rebalance.enabled);
400 sysfs_pd_controller_show(rebalance, &c->rebalance.pd); /* XXX */
402 if (attr == &sysfs_copy_gc_wait)
403 bch2_copygc_wait_to_text(out, c);
405 if (attr == &sysfs_rebalance_status)
406 bch2_rebalance_status_to_text(out, c);
408 sysfs_print(promote_whole_extents, c->promote_whole_extents);
412 if (attr == &sysfs_journal_debug)
413 bch2_journal_debug_to_text(out, &c->journal);
415 if (attr == &sysfs_btree_updates)
416 bch2_btree_updates_to_text(out, c);
418 if (attr == &sysfs_btree_cache)
419 bch2_btree_cache_to_text(out, &c->btree_cache);
421 if (attr == &sysfs_btree_key_cache)
422 bch2_btree_key_cache_to_text(out, &c->btree_key_cache);
424 if (attr == &sysfs_stripes_heap)
425 bch2_stripes_heap_to_text(out, c);
427 if (attr == &sysfs_open_buckets)
428 bch2_open_buckets_to_text(out, c);
430 if (attr == &sysfs_open_buckets_partial)
431 bch2_open_buckets_partial_to_text(out, c);
433 if (attr == &sysfs_write_points)
434 bch2_write_points_to_text(out, c);
436 if (attr == &sysfs_compression_stats)
437 bch2_compression_stats_to_text(out, c);
439 if (attr == &sysfs_new_stripes)
440 bch2_new_stripes_to_text(out, c);
442 if (attr == &sysfs_io_timers_read)
443 bch2_io_timers_to_text(out, &c->io_clock[READ]);
445 if (attr == &sysfs_io_timers_write)
446 bch2_io_timers_to_text(out, &c->io_clock[WRITE]);
448 if (attr == &sysfs_moving_ctxts)
449 bch2_fs_moving_ctxts_to_text(out, c);
451 #ifdef BCH_WRITE_REF_DEBUG
452 if (attr == &sysfs_write_refs)
453 bch2_write_refs_to_text(out, c);
456 if (attr == &sysfs_nocow_lock_table)
457 bch2_nocow_locks_to_text(out, &c->nocow_locks);
459 if (attr == &sysfs_disk_groups)
460 bch2_disk_groups_to_text(out, c);
467 struct bch_fs *c = container_of(kobj, struct bch_fs, kobj);
469 if (attr == &sysfs_btree_gc_periodic) {
470 ssize_t ret = strtoul_safe(buf, c->btree_gc_periodic)
473 wake_up_process(c->gc_thread);
477 if (attr == &sysfs_copy_gc_enabled) {
478 ssize_t ret = strtoul_safe(buf, c->copy_gc_enabled)
481 if (c->copygc_thread)
482 wake_up_process(c->copygc_thread);
486 if (attr == &sysfs_rebalance_enabled) {
487 ssize_t ret = strtoul_safe(buf, c->rebalance.enabled)
494 sysfs_pd_controller_store(rebalance, &c->rebalance.pd);
496 sysfs_strtoul(promote_whole_extents, c->promote_whole_extents);
500 if (!test_bit(BCH_FS_STARTED, &c->flags))
505 if (!test_bit(BCH_FS_RW, &c->flags))
508 if (attr == &sysfs_prune_cache) {
509 struct shrink_control sc;
511 sc.gfp_mask = GFP_KERNEL;
512 sc.nr_to_scan = strtoul_or_return(buf);
513 c->btree_cache.shrink->scan_objects(c->btree_cache.shrink, &sc);
516 if (attr == &sysfs_btree_wakeup)
517 bch2_btree_wakeup_all(c);
519 if (attr == &sysfs_trigger_gc) {
521 * Full gc is currently incompatible with btree key cache:
524 down_read(&c->state_lock);
525 bch2_gc(c, false, false);
526 up_read(&c->state_lock);
532 if (attr == &sysfs_trigger_discards)
535 if (attr == &sysfs_trigger_invalidates)
536 bch2_do_invalidates(c);
538 #ifdef CONFIG_BCACHEFS_TESTS
539 if (attr == &sysfs_perf_test) {
540 char *tmp = kstrdup(buf, GFP_KERNEL), *p = tmp;
541 char *test = strsep(&p, " \t\n");
542 char *nr_str = strsep(&p, " \t\n");
543 char *threads_str = strsep(&p, " \t\n");
549 !(ret = kstrtouint(threads_str, 10, &threads)) &&
550 !(ret = bch2_strtoull_h(nr_str, &nr)))
551 ret = bch2_btree_perf_test(c, test, nr, threads);
562 struct attribute *bch2_fs_files[] = {
564 &sysfs_btree_cache_size,
565 &sysfs_btree_write_stats,
567 &sysfs_promote_whole_extents,
569 &sysfs_compression_stats,
571 #ifdef CONFIG_BCACHEFS_TESTS
579 SHOW(bch2_fs_counters)
581 struct bch_fs *c = container_of(kobj, struct bch_fs, counters_kobj);
583 u64 counter_since_mount = 0;
585 printbuf_tabstop_push(out, 32);
588 if (attr == &sysfs_##t) { \
589 counter = percpu_u64_get(&c->counters[BCH_COUNTER_##t]);\
590 counter_since_mount = counter - c->counters_on_mount[BCH_COUNTER_##t];\
591 prt_printf(out, "since mount:"); \
593 prt_human_readable_u64(out, counter_since_mount); \
596 prt_printf(out, "since filesystem creation:"); \
598 prt_human_readable_u64(out, counter); \
601 BCH_PERSISTENT_COUNTERS()
606 STORE(bch2_fs_counters) {
610 SYSFS_OPS(bch2_fs_counters);
612 struct attribute *bch2_fs_counters_files[] = {
615 BCH_PERSISTENT_COUNTERS()
619 /* internal dir - just a wrapper */
621 SHOW(bch2_fs_internal)
623 struct bch_fs *c = container_of(kobj, struct bch_fs, internal);
625 return bch2_fs_to_text(out, &c->kobj, attr);
628 STORE(bch2_fs_internal)
630 struct bch_fs *c = container_of(kobj, struct bch_fs, internal);
632 return bch2_fs_store(&c->kobj, attr, buf, size);
634 SYSFS_OPS(bch2_fs_internal);
636 struct attribute *bch2_fs_internal_files[] = {
637 &sysfs_journal_debug,
638 &sysfs_btree_updates,
640 &sysfs_btree_key_cache,
644 &sysfs_open_buckets_partial,
646 #ifdef BCH_WRITE_REF_DEBUG
649 &sysfs_nocow_lock_table,
650 &sysfs_io_timers_read,
651 &sysfs_io_timers_write,
654 &sysfs_trigger_discards,
655 &sysfs_trigger_invalidates,
661 &sysfs_copy_gc_enabled,
664 &sysfs_rebalance_enabled,
665 &sysfs_rebalance_status,
666 sysfs_pd_controller_files(rebalance),
670 &sysfs_internal_uuid,
678 SHOW(bch2_fs_opts_dir)
680 struct bch_fs *c = container_of(kobj, struct bch_fs, opts_dir);
681 const struct bch_option *opt = container_of(attr, struct bch_option, attr);
682 int id = opt - bch2_opt_table;
683 u64 v = bch2_opt_get_by_id(&c->opts, id);
685 bch2_opt_to_text(out, c, c->disk_sb.sb, opt, v, OPT_SHOW_FULL_LIST);
691 STORE(bch2_fs_opts_dir)
693 struct bch_fs *c = container_of(kobj, struct bch_fs, opts_dir);
694 const struct bch_option *opt = container_of(attr, struct bch_option, attr);
695 int ret, id = opt - bch2_opt_table;
700 * We don't need to take c->writes for correctness, but it eliminates an
701 * unsightly error message in the dmesg log when we're RO:
703 if (unlikely(!bch2_write_ref_tryget(c, BCH_WRITE_REF_sysfs)))
706 tmp = kstrdup(buf, GFP_KERNEL);
712 ret = bch2_opt_parse(c, opt, strim(tmp), &v, NULL);
718 ret = bch2_opt_check_may_set(c, id, v);
722 bch2_opt_set_sb(c, opt, v);
723 bch2_opt_set_by_id(&c->opts, id, v);
725 if ((id == Opt_background_target ||
726 id == Opt_background_compression) && v)
727 bch2_set_rebalance_needs_scan(c, 0);
731 bch2_write_ref_put(c, BCH_WRITE_REF_sysfs);
734 SYSFS_OPS(bch2_fs_opts_dir);
736 struct attribute *bch2_fs_opts_dir_files[] = { NULL };
738 int bch2_opts_create_sysfs_files(struct kobject *kobj)
740 const struct bch_option *i;
743 for (i = bch2_opt_table;
744 i < bch2_opt_table + bch2_opts_nr;
746 if (!(i->flags & OPT_FS))
749 ret = sysfs_create_file(kobj, &i->attr);
759 SHOW(bch2_fs_time_stats)
761 struct bch_fs *c = container_of(kobj, struct bch_fs, time_stats);
764 if (attr == &sysfs_time_stat_##name) \
765 bch2_time_stats_to_text(out, &c->times[BCH_TIME_##name]);
772 STORE(bch2_fs_time_stats)
776 SYSFS_OPS(bch2_fs_time_stats);
778 struct attribute *bch2_fs_time_stats_files[] = {
780 &sysfs_time_stat_##name,
786 static void dev_alloc_debug_to_text(struct printbuf *out, struct bch_dev *ca)
788 struct bch_fs *c = ca->fs;
789 struct bch_dev_usage stats = bch2_dev_usage_read(ca);
790 unsigned i, nr[BCH_DATA_NR];
792 memset(nr, 0, sizeof(nr));
794 for (i = 0; i < ARRAY_SIZE(c->open_buckets); i++)
795 nr[c->open_buckets[i].data_type]++;
797 printbuf_tabstop_push(out, 8);
798 printbuf_tabstop_push(out, 16);
799 printbuf_tabstop_push(out, 16);
800 printbuf_tabstop_push(out, 16);
801 printbuf_tabstop_push(out, 16);
803 bch2_dev_usage_to_text(out, &stats);
807 prt_printf(out, "reserves:");
809 for (i = 0; i < BCH_WATERMARK_NR; i++) {
810 prt_str(out, bch2_watermarks[i]);
812 prt_u64(out, bch2_dev_buckets_reserved(ca, i));
819 printbuf_tabstops_reset(out);
820 printbuf_tabstop_push(out, 24);
822 prt_str(out, "freelist_wait");
824 prt_str(out, c->freelist_wait.list.first ? "waiting" : "empty");
827 prt_str(out, "open buckets allocated");
829 prt_u64(out, OPEN_BUCKETS_COUNT - c->open_buckets_nr_free);
832 prt_str(out, "open buckets this dev");
834 prt_u64(out, ca->nr_open_buckets);
837 prt_str(out, "open buckets total");
839 prt_u64(out, OPEN_BUCKETS_COUNT);
842 prt_str(out, "open_buckets_wait");
844 prt_str(out, c->open_buckets_wait.list.first ? "waiting" : "empty");
847 prt_str(out, "open_buckets_btree");
849 prt_u64(out, nr[BCH_DATA_btree]);
852 prt_str(out, "open_buckets_user");
854 prt_u64(out, nr[BCH_DATA_user]);
857 prt_str(out, "buckets_to_invalidate");
859 prt_u64(out, should_invalidate_buckets(ca, stats));
862 prt_str(out, "btree reserve cache");
864 prt_u64(out, c->btree_reserve_cache_nr);
868 static const char * const bch2_rw[] = {
874 static void dev_io_done_to_text(struct printbuf *out, struct bch_dev *ca)
878 for (rw = 0; rw < 2; rw++) {
879 prt_printf(out, "%s:\n", bch2_rw[rw]);
881 for (i = 1; i < BCH_DATA_NR; i++)
882 prt_printf(out, "%-12s:%12llu\n",
884 percpu_u64_get(&ca->io_done->sectors[rw][i]) << 9);
890 struct bch_dev *ca = container_of(kobj, struct bch_dev, kobj);
891 struct bch_fs *c = ca->fs;
893 sysfs_printf(uuid, "%pU\n", ca->uuid.b);
895 sysfs_print(bucket_size, bucket_bytes(ca));
896 sysfs_print(first_bucket, ca->mi.first_bucket);
897 sysfs_print(nbuckets, ca->mi.nbuckets);
898 sysfs_print(durability, ca->mi.durability);
899 sysfs_print(discard, ca->mi.discard);
901 if (attr == &sysfs_label) {
903 bch2_disk_path_to_text(out, c, ca->mi.group - 1);
907 if (attr == &sysfs_has_data) {
908 prt_bitflags(out, bch2_data_types, bch2_dev_has_data(c, ca));
912 if (attr == &sysfs_state_rw) {
913 prt_string_option(out, bch2_member_states, ca->mi.state);
917 if (attr == &sysfs_io_done)
918 dev_io_done_to_text(out, ca);
920 if (attr == &sysfs_io_errors)
921 bch2_dev_io_errors_to_text(out, ca);
923 sysfs_print(io_latency_read, atomic64_read(&ca->cur_latency[READ]));
924 sysfs_print(io_latency_write, atomic64_read(&ca->cur_latency[WRITE]));
926 if (attr == &sysfs_io_latency_stats_read)
927 bch2_time_stats_to_text(out, &ca->io_latency[READ]);
929 if (attr == &sysfs_io_latency_stats_write)
930 bch2_time_stats_to_text(out, &ca->io_latency[WRITE]);
932 sysfs_printf(congested, "%u%%",
933 clamp(atomic_read(&ca->congested), 0, CONGESTED_MAX)
934 * 100 / CONGESTED_MAX);
936 if (attr == &sysfs_alloc_debug)
937 dev_alloc_debug_to_text(out, ca);
944 struct bch_dev *ca = container_of(kobj, struct bch_dev, kobj);
945 struct bch_fs *c = ca->fs;
946 struct bch_member *mi;
948 if (attr == &sysfs_discard) {
949 bool v = strtoul_or_return(buf);
951 mutex_lock(&c->sb_lock);
952 mi = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx);
954 if (v != BCH_MEMBER_DISCARD(mi)) {
955 SET_BCH_MEMBER_DISCARD(mi, v);
958 mutex_unlock(&c->sb_lock);
961 if (attr == &sysfs_durability) {
962 u64 v = strtoul_or_return(buf);
964 mutex_lock(&c->sb_lock);
965 mi = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx);
967 if (v + 1 != BCH_MEMBER_DURABILITY(mi)) {
968 SET_BCH_MEMBER_DURABILITY(mi, v + 1);
971 mutex_unlock(&c->sb_lock);
974 if (attr == &sysfs_label) {
978 tmp = kstrdup(buf, GFP_KERNEL);
982 ret = bch2_dev_group_set(c, ca, strim(tmp));
988 if (attr == &sysfs_io_errors_reset)
989 bch2_dev_errors_reset(ca);
995 struct attribute *bch2_dev_files[] = {
1010 &sysfs_io_errors_reset,
1012 &sysfs_io_latency_read,
1013 &sysfs_io_latency_write,
1014 &sysfs_io_latency_stats_read,
1015 &sysfs_io_latency_stats_write,
1023 #endif /* _BCACHEFS_SYSFS_H_ */