Lines Matching +full:out +full:-

1 // SPDX-License-Identifier: GPL-2.0
38 #include "super-io.h"
60 struct printbuf out = PRINTBUF; \
61 ssize_t ret = fn ## _to_text(&out, kobj, attr); \
63 if (out.pos && out.buf[out.pos - 1] != '\n') \
64 prt_newline(&out); \
66 if (!ret && out.allocation_failure) \
67 ret = -ENOMEM; \
70 ret = min_t(size_t, out.pos, PAGE_SIZE - 1); \
71 memcpy(buf, out.buf, ret); \
73 printbuf_exit(&out); \
77 static ssize_t fn ## _to_text(struct printbuf *out, struct kobject *kobj,\
104 prt_printf(out, fmt "\n", __VA_ARGS__); \
110 snprint(out, var); \
116 prt_human_readable_s64(out, val); \
192 static void bch2_write_refs_to_text(struct printbuf *out, struct bch_fs *c) in bch2_write_refs_to_text() argument
194 bch2_printbuf_tabstop_push(out, 24); in bch2_write_refs_to_text()
196 for (unsigned i = 0; i < ARRAY_SIZE(c->writes); i++) in bch2_write_refs_to_text()
197 prt_printf(out, "%s\t%li\n", bch2_write_refs[i], atomic_long_read(&c->writes[i])); in bch2_write_refs_to_text()
247 struct btree_cache *bc = &c->btree_cache; in bch2_btree_cache_size()
251 mutex_lock(&bc->lock); in bch2_btree_cache_size()
252 list_for_each_entry(b, &bc->live[0].list, list) in bch2_btree_cache_size()
254 list_for_each_entry(b, &bc->live[1].list, list) in bch2_btree_cache_size()
256 list_for_each_entry(b, &bc->freeable, list) in bch2_btree_cache_size()
258 mutex_unlock(&bc->lock); in bch2_btree_cache_size()
262 static int bch2_compression_stats_to_text(struct printbuf *out, struct bch_fs *c) in bch2_compression_stats_to_text() argument
264 prt_str(out, "type"); in bch2_compression_stats_to_text()
265 printbuf_tabstop_push(out, 12); in bch2_compression_stats_to_text()
266 printbuf_tabstop_push(out, 16); in bch2_compression_stats_to_text()
267 printbuf_tabstop_push(out, 16); in bch2_compression_stats_to_text()
268 printbuf_tabstop_push(out, 24); in bch2_compression_stats_to_text()
269 prt_printf(out, "type\tcompressed\runcompressed\raverage extent size\r\n"); in bch2_compression_stats_to_text()
284 bch2_prt_compression_type(out, i); in bch2_compression_stats_to_text()
285 prt_tab(out); in bch2_compression_stats_to_text()
287 prt_human_readable_u64(out, sectors_compressed << 9); in bch2_compression_stats_to_text()
288 prt_tab_rjust(out); in bch2_compression_stats_to_text()
290 prt_human_readable_u64(out, sectors_uncompressed << 9); in bch2_compression_stats_to_text()
291 prt_tab_rjust(out); in bch2_compression_stats_to_text()
293 prt_human_readable_u64(out, nr_extents in bch2_compression_stats_to_text()
296 prt_tab_rjust(out); in bch2_compression_stats_to_text()
297 prt_newline(out); in bch2_compression_stats_to_text()
303 static void bch2_gc_gens_pos_to_text(struct printbuf *out, struct bch_fs *c) in bch2_gc_gens_pos_to_text() argument
305 prt_printf(out, "%s: ", bch2_btree_id_str(c->gc_gens_btree)); in bch2_gc_gens_pos_to_text()
306 bch2_bpos_to_text(out, c->gc_gens_pos); in bch2_gc_gens_pos_to_text()
307 prt_printf(out, "\n"); in bch2_gc_gens_pos_to_text()
310 static void bch2_fs_usage_base_to_text(struct printbuf *out, struct bch_fs *c) in bch2_fs_usage_base_to_text() argument
314 acc_u64s_percpu(&b.hidden, &c->usage->hidden, sizeof(b) / sizeof(u64)); in bch2_fs_usage_base_to_text()
316 prt_printf(out, "hidden:\t\t%llu\n", b.hidden); in bch2_fs_usage_base_to_text()
317 prt_printf(out, "btree:\t\t%llu\n", b.btree); in bch2_fs_usage_base_to_text()
318 prt_printf(out, "data:\t\t%llu\n", b.data); in bch2_fs_usage_base_to_text()
319 prt_printf(out, "cached:\t%llu\n", b.cached); in bch2_fs_usage_base_to_text()
320 prt_printf(out, "reserved:\t\t%llu\n", b.reserved); in bch2_fs_usage_base_to_text()
321 prt_printf(out, "nr_inodes:\t%llu\n", b.nr_inodes); in bch2_fs_usage_base_to_text()
328 sysfs_print(minor, c->minor); in SHOW()
329 sysfs_printf(internal_uuid, "%pU", c->sb.uuid.b); in SHOW()
332 prt_bitflags(out, bch2_fs_flag_strs, c->flags); in SHOW()
337 bch2_btree_write_stats_to_text(out, c); in SHOW()
340 bch2_gc_gens_pos_to_text(out, c); in SHOW()
342 sysfs_printf(copy_gc_enabled, "%i", c->copy_gc_enabled); in SHOW()
344 sysfs_printf(rebalance_enabled, "%i", c->rebalance.enabled); in SHOW()
345 sysfs_pd_controller_show(rebalance, &c->rebalance.pd); /* XXX */ in SHOW()
348 bch2_copygc_wait_to_text(out, c); in SHOW()
351 bch2_rebalance_status_to_text(out, c); in SHOW()
356 bch2_journal_debug_to_text(out, &c->journal); in SHOW()
359 bch2_btree_cache_to_text(out, &c->btree_cache); in SHOW()
362 bch2_btree_key_cache_to_text(out, &c->btree_key_cache); in SHOW()
365 bch2_btree_reserve_cache_to_text(out, c); in SHOW()
368 bch2_stripes_heap_to_text(out, c); in SHOW()
371 bch2_open_buckets_to_text(out, c, NULL); in SHOW()
374 bch2_open_buckets_partial_to_text(out, c); in SHOW()
377 bch2_write_points_to_text(out, c); in SHOW()
380 bch2_compression_stats_to_text(out, c); in SHOW()
383 bch2_new_stripes_to_text(out, c); in SHOW()
386 bch2_io_timers_to_text(out, &c->io_clock[READ]); in SHOW()
389 bch2_io_timers_to_text(out, &c->io_clock[WRITE]); in SHOW()
392 bch2_fs_moving_ctxts_to_text(out, c); in SHOW()
396 bch2_write_refs_to_text(out, c); in SHOW()
400 bch2_nocow_locks_to_text(out, &c->nocow_locks); in SHOW()
403 bch2_disk_groups_to_text(out, c); in SHOW()
406 bch2_fs_alloc_debug_to_text(out, c); in SHOW()
409 bch2_fs_accounting_to_text(out, c); in SHOW()
412 bch2_fs_usage_base_to_text(out, c); in SHOW()
422 ssize_t ret = strtoul_safe(buf, c->copy_gc_enabled) in STORE()
425 if (c->copygc_thread) in STORE()
426 wake_up_process(c->copygc_thread); in STORE()
431 ssize_t ret = strtoul_safe(buf, c->rebalance.enabled) in STORE()
438 sysfs_pd_controller_store(rebalance, &c->rebalance.pd); in STORE()
442 if (!test_bit(BCH_FS_started, &c->flags)) in STORE()
443 return -EPERM; in STORE()
448 return -EROFS; in STORE()
451 struct btree_cache *bc = &c->btree_cache; in STORE()
456 bc->live[0].shrink->scan_objects(bc->live[0].shrink, &sc); in STORE()
464 c->btree_key_cache.shrink->scan_objects(c->btree_key_cache.shrink, &sc); in STORE()
477 bch2_journal_flush_all_pins(&c->journal); in STORE()
478 bch2_journal_meta(&c->journal); in STORE()
482 bch2_journal_do_writes(&c->journal); in STORE()
485 closure_wake_up(&c->freelist_wait); in STORE()
495 int ret = -EINVAL; in STORE()
535 printbuf_tabstop_push(out, 32); in SHOW()
539 counter = percpu_u64_get(&c->counters[BCH_COUNTER_##t]);\ in SHOW()
540 counter_since_mount = counter - c->counters_on_mount[BCH_COUNTER_##t];\ in SHOW()
541 prt_printf(out, "since mount:\t"); \ in SHOW()
542 prt_human_readable_u64(out, counter_since_mount); \ in SHOW()
543 prt_newline(out); \ in SHOW()
545 prt_printf(out, "since filesystem creation:\t"); \ in SHOW()
546 prt_human_readable_u64(out, counter); \ in SHOW()
547 prt_newline(out); \ in SHOW()
567 /* internal dir - just a wrapper */
573 return bch2_fs_to_text(out, &c->kobj, attr); in SHOW()
580 return bch2_fs_store(&c->kobj, attr, buf, size); in STORE()
636 int id = opt - bch2_opt_table; in SHOW()
637 u64 v = bch2_opt_get_by_id(&c->opts, id); in SHOW()
639 bch2_opt_to_text(out, c, c->disk_sb.sb, opt, v, OPT_SHOW_FULL_LIST); in SHOW()
640 prt_char(out, '\n'); in SHOW()
649 int ret, id = opt - bch2_opt_table; in STORE()
654 * We don't need to take c->writes for correctness, but it eliminates an in STORE()
658 return -EROFS; in STORE()
662 ret = -ENOMEM; in STORE()
677 bch2_opt_set_by_id(&c->opts, id, v); in STORE()
682 (id == Opt_compression && !c->opts.background_compression))) in STORE()
702 if (!(i->flags & OPT_FS)) in bch2_opts_create_sysfs_files()
705 ret = sysfs_create_file(kobj, &i->attr); in bch2_opts_create_sysfs_files()
721 bch2_time_stats_to_text(out, &c->times[BCH_TIME_##name]); in SHOW()
734 bch2_time_stats_reset(&c->times[BCH_TIME_##name]); in STORE()
755 static void dev_io_done_to_text(struct printbuf *out, struct bch_dev *ca) in dev_io_done_to_text() argument
760 prt_printf(out, "%s:\n", bch2_rw[rw]); in dev_io_done_to_text()
763 prt_printf(out, "%-12s:%12llu\n", in dev_io_done_to_text()
765 percpu_u64_get(&ca->io_done->sectors[rw][i]) << 9); in dev_io_done_to_text()
772 struct bch_fs *c = ca->fs; in SHOW()
774 sysfs_printf(uuid, "%pU\n", ca->uuid.b); in SHOW()
777 sysfs_print(first_bucket, ca->mi.first_bucket); in SHOW()
778 sysfs_print(nbuckets, ca->mi.nbuckets); in SHOW()
779 sysfs_print(durability, ca->mi.durability); in SHOW()
780 sysfs_print(discard, ca->mi.discard); in SHOW()
783 if (ca->mi.group) in SHOW()
784 bch2_disk_path_to_text(out, c, ca->mi.group - 1); in SHOW()
785 prt_char(out, '\n'); in SHOW()
789 prt_bitflags(out, __bch2_data_types, bch2_dev_has_data(c, ca)); in SHOW()
790 prt_char(out, '\n'); in SHOW()
794 prt_string_option(out, bch2_member_states, ca->mi.state); in SHOW()
795 prt_char(out, '\n'); in SHOW()
799 dev_io_done_to_text(out, ca); in SHOW()
802 bch2_dev_io_errors_to_text(out, ca); in SHOW()
804 sysfs_print(io_latency_read, atomic64_read(&ca->cur_latency[READ])); in SHOW()
805 sysfs_print(io_latency_write, atomic64_read(&ca->cur_latency[WRITE])); in SHOW()
808 bch2_time_stats_to_text(out, &ca->io_latency[READ].stats); in SHOW()
811 bch2_time_stats_to_text(out, &ca->io_latency[WRITE].stats); in SHOW()
814 clamp(atomic_read(&ca->congested), 0, CONGESTED_MAX) in SHOW()
818 bch2_dev_alloc_debug_to_text(out, ca); in SHOW()
821 bch2_open_buckets_to_text(out, c, ca); in SHOW()
829 struct bch_fs *c = ca->fs; in STORE()
849 return -ENOMEM; in STORE()