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"
25 #include "disk_groups.h"
32 #include "nocow_locking.h"
34 #include "rebalance.h"
39 #include <linux/blkdev.h>
40 #include <linux/sort.h>
41 #include <linux/sched/clock.h>
45 #define SYSFS_OPS(type) \
46 const struct sysfs_ops type ## _sysfs_ops = { \
47 .show = type ## _show, \
48 .store = type ## _store \
52 static ssize_t fn ## _to_text(struct printbuf *, \
53 struct kobject *, struct attribute *); \
55 static ssize_t fn ## _show(struct kobject *kobj, struct attribute *attr,\
58 struct printbuf out = PRINTBUF; \
59 ssize_t ret = fn ## _to_text(&out, kobj, attr); \
61 if (out.pos && out.buf[out.pos - 1] != '\n') \
64 if (!ret && out.allocation_failure) \
68 ret = min_t(size_t, out.pos, PAGE_SIZE - 1); \
69 memcpy(buf, out.buf, ret); \
71 printbuf_exit(&out); \
72 return bch2_err_class(ret); \
75 static ssize_t fn ## _to_text(struct printbuf *out, struct kobject *kobj,\
76 struct attribute *attr)
79 static ssize_t fn ## _store_inner(struct kobject *, struct attribute *,\
80 const char *, size_t); \
82 static ssize_t fn ## _store(struct kobject *kobj, struct attribute *attr,\
83 const char *buf, size_t size) \
85 return bch2_err_class(fn##_store_inner(kobj, attr, buf, size)); \
88 static ssize_t fn ## _store_inner(struct kobject *kobj, struct attribute *attr,\
89 const char *buf, size_t size)
91 #define __sysfs_attribute(_name, _mode) \
92 static struct attribute sysfs_##_name = \
93 { .name = #_name, .mode = _mode }
95 #define write_attribute(n) __sysfs_attribute(n, 0200)
96 #define read_attribute(n) __sysfs_attribute(n, 0444)
97 #define rw_attribute(n) __sysfs_attribute(n, 0644)
99 #define sysfs_printf(file, fmt, ...) \
101 if (attr == &sysfs_ ## file) \
102 prt_printf(out, fmt "\n", __VA_ARGS__); \
105 #define sysfs_print(file, var) \
107 if (attr == &sysfs_ ## file) \
111 #define sysfs_hprint(file, val) \
113 if (attr == &sysfs_ ## file) \
114 prt_human_readable_s64(out, val); \
117 #define sysfs_strtoul(file, var) \
119 if (attr == &sysfs_ ## file) \
120 return strtoul_safe(buf, var) ?: (ssize_t) size; \
123 #define sysfs_strtoul_clamp(file, var, min, max) \
125 if (attr == &sysfs_ ## file) \
126 return strtoul_safe_clamp(buf, var, min, max) \
130 #define strtoul_or_return(cp) \
133 int _r = kstrtoul(cp, 10, &_v); \
139 write_attribute(trigger_gc);
140 write_attribute(trigger_discards);
141 write_attribute(trigger_invalidates);
142 write_attribute(prune_cache);
143 write_attribute(btree_wakeup);
144 rw_attribute(btree_gc_periodic);
145 rw_attribute(gc_gens_pos);
147 read_attribute(uuid);
148 read_attribute(minor);
149 read_attribute(flags);
150 read_attribute(bucket_size);
151 read_attribute(first_bucket);
152 read_attribute(nbuckets);
153 rw_attribute(durability);
154 read_attribute(io_done);
155 read_attribute(io_errors);
156 write_attribute(io_errors_reset);
158 read_attribute(io_latency_read);
159 read_attribute(io_latency_write);
160 read_attribute(io_latency_stats_read);
161 read_attribute(io_latency_stats_write);
162 read_attribute(congested);
164 read_attribute(btree_write_stats);
166 read_attribute(btree_cache_size);
167 read_attribute(compression_stats);
168 read_attribute(journal_debug);
169 read_attribute(btree_updates);
170 read_attribute(btree_cache);
171 read_attribute(btree_key_cache);
172 read_attribute(stripes_heap);
173 read_attribute(open_buckets);
174 read_attribute(open_buckets_partial);
175 read_attribute(write_points);
176 read_attribute(nocow_lock_table);
178 #ifdef BCH_WRITE_REF_DEBUG
179 read_attribute(write_refs);
181 static const char * const bch2_write_refs[] = {
188 static void bch2_write_refs_to_text(struct printbuf *out, struct bch_fs *c)
190 bch2_printbuf_tabstop_push(out, 24);
192 for (unsigned i = 0; i < ARRAY_SIZE(c->writes); i++) {
193 prt_str(out, bch2_write_refs[i]);
195 prt_printf(out, "%li", atomic_long_read(&c->writes[i]));
201 read_attribute(internal_uuid);
202 read_attribute(disk_groups);
204 read_attribute(has_data);
205 read_attribute(alloc_debug);
207 #define x(t, n, ...) read_attribute(t);
208 BCH_PERSISTENT_COUNTERS()
211 rw_attribute(discard);
214 rw_attribute(copy_gc_enabled);
215 read_attribute(copy_gc_wait);
217 rw_attribute(rebalance_enabled);
218 sysfs_pd_controller_attribute(rebalance);
219 read_attribute(rebalance_status);
220 rw_attribute(promote_whole_extents);
222 read_attribute(new_stripes);
224 read_attribute(io_timers_read);
225 read_attribute(io_timers_write);
227 read_attribute(moving_ctxts);
229 #ifdef CONFIG_BCACHEFS_TESTS
230 write_attribute(perf_test);
231 #endif /* CONFIG_BCACHEFS_TESTS */
234 static struct attribute sysfs_time_stat_##_name = \
235 { .name = #_name, .mode = 0444 };
239 static struct attribute sysfs_state_rw = {
244 static size_t bch2_btree_cache_size(struct bch_fs *c)
249 mutex_lock(&c->btree_cache.lock);
250 list_for_each_entry(b, &c->btree_cache.live, list)
251 ret += btree_buf_bytes(b);
253 mutex_unlock(&c->btree_cache.lock);
257 static int bch2_compression_stats_to_text(struct printbuf *out, struct bch_fs *c)
259 struct btree_trans *trans;
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 ret = for_each_btree_key(trans, iter, id, POS_MIN,
281 BTREE_ITER_ALL_SNAPSHOTS, k, ({
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;
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 bch2_prt_compression_type(out, 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 if (attr == &sysfs_flags)
388 prt_bitflags(out, bch2_fs_flag_strs, c->flags);
390 sysfs_hprint(btree_cache_size, bch2_btree_cache_size(c));
392 if (attr == &sysfs_btree_write_stats)
393 bch2_btree_write_stats_to_text(out, c);
395 sysfs_printf(btree_gc_periodic, "%u", (int) c->btree_gc_periodic);
397 if (attr == &sysfs_gc_gens_pos)
398 bch2_gc_gens_pos_to_text(out, c);
400 sysfs_printf(copy_gc_enabled, "%i", c->copy_gc_enabled);
402 sysfs_printf(rebalance_enabled, "%i", c->rebalance.enabled);
403 sysfs_pd_controller_show(rebalance, &c->rebalance.pd); /* XXX */
405 if (attr == &sysfs_copy_gc_wait)
406 bch2_copygc_wait_to_text(out, c);
408 if (attr == &sysfs_rebalance_status)
409 bch2_rebalance_status_to_text(out, c);
411 sysfs_print(promote_whole_extents, c->promote_whole_extents);
415 if (attr == &sysfs_journal_debug)
416 bch2_journal_debug_to_text(out, &c->journal);
418 if (attr == &sysfs_btree_updates)
419 bch2_btree_updates_to_text(out, c);
421 if (attr == &sysfs_btree_cache)
422 bch2_btree_cache_to_text(out, c);
424 if (attr == &sysfs_btree_key_cache)
425 bch2_btree_key_cache_to_text(out, &c->btree_key_cache);
427 if (attr == &sysfs_stripes_heap)
428 bch2_stripes_heap_to_text(out, c);
430 if (attr == &sysfs_open_buckets)
431 bch2_open_buckets_to_text(out, c);
433 if (attr == &sysfs_open_buckets_partial)
434 bch2_open_buckets_partial_to_text(out, c);
436 if (attr == &sysfs_write_points)
437 bch2_write_points_to_text(out, c);
439 if (attr == &sysfs_compression_stats)
440 bch2_compression_stats_to_text(out, c);
442 if (attr == &sysfs_new_stripes)
443 bch2_new_stripes_to_text(out, c);
445 if (attr == &sysfs_io_timers_read)
446 bch2_io_timers_to_text(out, &c->io_clock[READ]);
448 if (attr == &sysfs_io_timers_write)
449 bch2_io_timers_to_text(out, &c->io_clock[WRITE]);
451 if (attr == &sysfs_moving_ctxts)
452 bch2_fs_moving_ctxts_to_text(out, c);
454 #ifdef BCH_WRITE_REF_DEBUG
455 if (attr == &sysfs_write_refs)
456 bch2_write_refs_to_text(out, c);
459 if (attr == &sysfs_nocow_lock_table)
460 bch2_nocow_locks_to_text(out, &c->nocow_locks);
462 if (attr == &sysfs_disk_groups)
463 bch2_disk_groups_to_text(out, c);
470 struct bch_fs *c = container_of(kobj, struct bch_fs, kobj);
472 if (attr == &sysfs_btree_gc_periodic) {
473 ssize_t ret = strtoul_safe(buf, c->btree_gc_periodic)
476 wake_up_process(c->gc_thread);
480 if (attr == &sysfs_copy_gc_enabled) {
481 ssize_t ret = strtoul_safe(buf, c->copy_gc_enabled)
484 if (c->copygc_thread)
485 wake_up_process(c->copygc_thread);
489 if (attr == &sysfs_rebalance_enabled) {
490 ssize_t ret = strtoul_safe(buf, c->rebalance.enabled)
497 sysfs_pd_controller_store(rebalance, &c->rebalance.pd);
499 sysfs_strtoul(promote_whole_extents, c->promote_whole_extents);
503 if (!test_bit(BCH_FS_started, &c->flags))
508 if (!test_bit(BCH_FS_rw, &c->flags))
511 if (attr == &sysfs_prune_cache) {
512 struct shrink_control sc;
514 sc.gfp_mask = GFP_KERNEL;
515 sc.nr_to_scan = strtoul_or_return(buf);
516 c->btree_cache.shrink->scan_objects(c->btree_cache.shrink, &sc);
519 if (attr == &sysfs_btree_wakeup)
520 bch2_btree_wakeup_all(c);
522 if (attr == &sysfs_trigger_gc) {
524 * Full gc is currently incompatible with btree key cache:
527 down_read(&c->state_lock);
528 bch2_gc(c, false, false);
529 up_read(&c->state_lock);
535 if (attr == &sysfs_trigger_discards)
538 if (attr == &sysfs_trigger_invalidates)
539 bch2_do_invalidates(c);
541 #ifdef CONFIG_BCACHEFS_TESTS
542 if (attr == &sysfs_perf_test) {
543 char *tmp = kstrdup(buf, GFP_KERNEL), *p = tmp;
544 char *test = strsep(&p, " \t\n");
545 char *nr_str = strsep(&p, " \t\n");
546 char *threads_str = strsep(&p, " \t\n");
552 !(ret = kstrtouint(threads_str, 10, &threads)) &&
553 !(ret = bch2_strtoull_h(nr_str, &nr)))
554 ret = bch2_btree_perf_test(c, test, nr, threads);
565 struct attribute *bch2_fs_files[] = {
567 &sysfs_btree_cache_size,
568 &sysfs_btree_write_stats,
570 &sysfs_promote_whole_extents,
572 &sysfs_compression_stats,
574 #ifdef CONFIG_BCACHEFS_TESTS
582 SHOW(bch2_fs_counters)
584 struct bch_fs *c = container_of(kobj, struct bch_fs, counters_kobj);
586 u64 counter_since_mount = 0;
588 printbuf_tabstop_push(out, 32);
591 if (attr == &sysfs_##t) { \
592 counter = percpu_u64_get(&c->counters[BCH_COUNTER_##t]);\
593 counter_since_mount = counter - c->counters_on_mount[BCH_COUNTER_##t];\
594 prt_printf(out, "since mount:"); \
596 prt_human_readable_u64(out, counter_since_mount); \
599 prt_printf(out, "since filesystem creation:"); \
601 prt_human_readable_u64(out, counter); \
604 BCH_PERSISTENT_COUNTERS()
609 STORE(bch2_fs_counters) {
613 SYSFS_OPS(bch2_fs_counters);
615 struct attribute *bch2_fs_counters_files[] = {
618 BCH_PERSISTENT_COUNTERS()
622 /* internal dir - just a wrapper */
624 SHOW(bch2_fs_internal)
626 struct bch_fs *c = container_of(kobj, struct bch_fs, internal);
628 return bch2_fs_to_text(out, &c->kobj, attr);
631 STORE(bch2_fs_internal)
633 struct bch_fs *c = container_of(kobj, struct bch_fs, internal);
635 return bch2_fs_store(&c->kobj, attr, buf, size);
637 SYSFS_OPS(bch2_fs_internal);
639 struct attribute *bch2_fs_internal_files[] = {
641 &sysfs_journal_debug,
642 &sysfs_btree_updates,
644 &sysfs_btree_key_cache,
648 &sysfs_open_buckets_partial,
650 #ifdef BCH_WRITE_REF_DEBUG
653 &sysfs_nocow_lock_table,
654 &sysfs_io_timers_read,
655 &sysfs_io_timers_write,
658 &sysfs_trigger_discards,
659 &sysfs_trigger_invalidates,
665 &sysfs_copy_gc_enabled,
668 &sysfs_rebalance_enabled,
669 &sysfs_rebalance_status,
670 sysfs_pd_controller_files(rebalance),
674 &sysfs_internal_uuid,
682 SHOW(bch2_fs_opts_dir)
684 struct bch_fs *c = container_of(kobj, struct bch_fs, opts_dir);
685 const struct bch_option *opt = container_of(attr, struct bch_option, attr);
686 int id = opt - bch2_opt_table;
687 u64 v = bch2_opt_get_by_id(&c->opts, id);
689 bch2_opt_to_text(out, c, c->disk_sb.sb, opt, v, OPT_SHOW_FULL_LIST);
695 STORE(bch2_fs_opts_dir)
697 struct bch_fs *c = container_of(kobj, struct bch_fs, opts_dir);
698 const struct bch_option *opt = container_of(attr, struct bch_option, attr);
699 int ret, id = opt - bch2_opt_table;
704 * We don't need to take c->writes for correctness, but it eliminates an
705 * unsightly error message in the dmesg log when we're RO:
707 if (unlikely(!bch2_write_ref_tryget(c, BCH_WRITE_REF_sysfs)))
710 tmp = kstrdup(buf, GFP_KERNEL);
716 ret = bch2_opt_parse(c, opt, strim(tmp), &v, NULL);
722 ret = bch2_opt_check_may_set(c, id, v);
726 bch2_opt_set_sb(c, opt, v);
727 bch2_opt_set_by_id(&c->opts, id, v);
730 (id == Opt_background_target ||
731 id == Opt_background_compression ||
732 (id == Opt_compression && !c->opts.background_compression)))
733 bch2_set_rebalance_needs_scan(c, 0);
737 bch2_write_ref_put(c, BCH_WRITE_REF_sysfs);
740 SYSFS_OPS(bch2_fs_opts_dir);
742 struct attribute *bch2_fs_opts_dir_files[] = { NULL };
744 int bch2_opts_create_sysfs_files(struct kobject *kobj)
746 const struct bch_option *i;
749 for (i = bch2_opt_table;
750 i < bch2_opt_table + bch2_opts_nr;
752 if (!(i->flags & OPT_FS))
755 ret = sysfs_create_file(kobj, &i->attr);
765 SHOW(bch2_fs_time_stats)
767 struct bch_fs *c = container_of(kobj, struct bch_fs, time_stats);
770 if (attr == &sysfs_time_stat_##name) \
771 bch2_time_stats_to_text(out, &c->times[BCH_TIME_##name]);
778 STORE(bch2_fs_time_stats)
782 SYSFS_OPS(bch2_fs_time_stats);
784 struct attribute *bch2_fs_time_stats_files[] = {
786 &sysfs_time_stat_##name,
792 static void dev_alloc_debug_to_text(struct printbuf *out, struct bch_dev *ca)
794 struct bch_fs *c = ca->fs;
795 struct bch_dev_usage stats = bch2_dev_usage_read(ca);
796 unsigned i, nr[BCH_DATA_NR];
798 memset(nr, 0, sizeof(nr));
800 for (i = 0; i < ARRAY_SIZE(c->open_buckets); i++)
801 nr[c->open_buckets[i].data_type]++;
803 printbuf_tabstop_push(out, 8);
804 printbuf_tabstop_push(out, 16);
805 printbuf_tabstop_push(out, 16);
806 printbuf_tabstop_push(out, 16);
807 printbuf_tabstop_push(out, 16);
809 bch2_dev_usage_to_text(out, &stats);
813 prt_printf(out, "reserves:");
815 for (i = 0; i < BCH_WATERMARK_NR; i++) {
816 prt_str(out, bch2_watermarks[i]);
818 prt_u64(out, bch2_dev_buckets_reserved(ca, i));
825 printbuf_tabstops_reset(out);
826 printbuf_tabstop_push(out, 24);
828 prt_str(out, "freelist_wait");
830 prt_str(out, c->freelist_wait.list.first ? "waiting" : "empty");
833 prt_str(out, "open buckets allocated");
835 prt_u64(out, OPEN_BUCKETS_COUNT - c->open_buckets_nr_free);
838 prt_str(out, "open buckets this dev");
840 prt_u64(out, ca->nr_open_buckets);
843 prt_str(out, "open buckets total");
845 prt_u64(out, OPEN_BUCKETS_COUNT);
848 prt_str(out, "open_buckets_wait");
850 prt_str(out, c->open_buckets_wait.list.first ? "waiting" : "empty");
853 prt_str(out, "open_buckets_btree");
855 prt_u64(out, nr[BCH_DATA_btree]);
858 prt_str(out, "open_buckets_user");
860 prt_u64(out, nr[BCH_DATA_user]);
863 prt_str(out, "buckets_to_invalidate");
865 prt_u64(out, should_invalidate_buckets(ca, stats));
868 prt_str(out, "btree reserve cache");
870 prt_u64(out, c->btree_reserve_cache_nr);
874 static const char * const bch2_rw[] = {
880 static void dev_io_done_to_text(struct printbuf *out, struct bch_dev *ca)
884 for (rw = 0; rw < 2; rw++) {
885 prt_printf(out, "%s:\n", bch2_rw[rw]);
887 for (i = 1; i < BCH_DATA_NR; i++)
888 prt_printf(out, "%-12s:%12llu\n",
889 bch2_data_type_str(i),
890 percpu_u64_get(&ca->io_done->sectors[rw][i]) << 9);
896 struct bch_dev *ca = container_of(kobj, struct bch_dev, kobj);
897 struct bch_fs *c = ca->fs;
899 sysfs_printf(uuid, "%pU\n", ca->uuid.b);
901 sysfs_print(bucket_size, bucket_bytes(ca));
902 sysfs_print(first_bucket, ca->mi.first_bucket);
903 sysfs_print(nbuckets, ca->mi.nbuckets);
904 sysfs_print(durability, ca->mi.durability);
905 sysfs_print(discard, ca->mi.discard);
907 if (attr == &sysfs_label) {
909 bch2_disk_path_to_text(out, c, ca->mi.group - 1);
913 if (attr == &sysfs_has_data) {
914 prt_bitflags(out, __bch2_data_types, bch2_dev_has_data(c, ca));
918 if (attr == &sysfs_state_rw) {
919 prt_string_option(out, bch2_member_states, ca->mi.state);
923 if (attr == &sysfs_io_done)
924 dev_io_done_to_text(out, ca);
926 if (attr == &sysfs_io_errors)
927 bch2_dev_io_errors_to_text(out, ca);
929 sysfs_print(io_latency_read, atomic64_read(&ca->cur_latency[READ]));
930 sysfs_print(io_latency_write, atomic64_read(&ca->cur_latency[WRITE]));
932 if (attr == &sysfs_io_latency_stats_read)
933 bch2_time_stats_to_text(out, &ca->io_latency[READ]);
935 if (attr == &sysfs_io_latency_stats_write)
936 bch2_time_stats_to_text(out, &ca->io_latency[WRITE]);
938 sysfs_printf(congested, "%u%%",
939 clamp(atomic_read(&ca->congested), 0, CONGESTED_MAX)
940 * 100 / CONGESTED_MAX);
942 if (attr == &sysfs_alloc_debug)
943 dev_alloc_debug_to_text(out, ca);
950 struct bch_dev *ca = container_of(kobj, struct bch_dev, kobj);
951 struct bch_fs *c = ca->fs;
952 struct bch_member *mi;
954 if (attr == &sysfs_discard) {
955 bool v = strtoul_or_return(buf);
957 mutex_lock(&c->sb_lock);
958 mi = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx);
960 if (v != BCH_MEMBER_DISCARD(mi)) {
961 SET_BCH_MEMBER_DISCARD(mi, v);
964 mutex_unlock(&c->sb_lock);
967 if (attr == &sysfs_durability) {
968 u64 v = strtoul_or_return(buf);
970 mutex_lock(&c->sb_lock);
971 mi = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx);
973 if (v + 1 != BCH_MEMBER_DURABILITY(mi)) {
974 SET_BCH_MEMBER_DURABILITY(mi, v + 1);
977 mutex_unlock(&c->sb_lock);
980 if (attr == &sysfs_label) {
984 tmp = kstrdup(buf, GFP_KERNEL);
988 ret = bch2_dev_group_set(c, ca, strim(tmp));
994 if (attr == &sysfs_io_errors_reset)
995 bch2_dev_errors_reset(ca);
1001 struct attribute *bch2_dev_files[] = {
1004 &sysfs_first_bucket,
1016 &sysfs_io_errors_reset,
1018 &sysfs_io_latency_read,
1019 &sysfs_io_latency_write,
1020 &sysfs_io_latency_stats_read,
1021 &sysfs_io_latency_stats_write,
1029 #endif /* _BCACHEFS_SYSFS_H_ */