]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/sysfs.c
Disable pristine-tar option in gbp.conf, since there is no pristine-tar branch.
[bcachefs-tools-debian] / libbcachefs / sysfs.c
index 7223418d3bb427d36921e957d59a584d7a9691e9..c86a93a8d8fc81bbe373efcbec74f3e2563e6da5 100644 (file)
@@ -21,6 +21,7 @@
 #include "btree_gc.h"
 #include "buckets.h"
 #include "clock.h"
+#include "compress.h"
 #include "disk_groups.h"
 #include "ec.h"
 #include "inode.h"
@@ -145,6 +146,7 @@ rw_attribute(gc_gens_pos);
 
 read_attribute(uuid);
 read_attribute(minor);
+read_attribute(flags);
 read_attribute(bucket_size);
 read_attribute(first_bucket);
 read_attribute(nbuckets);
@@ -246,7 +248,7 @@ static size_t bch2_btree_cache_size(struct bch_fs *c)
 
        mutex_lock(&c->btree_cache.lock);
        list_for_each_entry(b, &c->btree_cache.live, list)
-               ret += btree_bytes(c);
+               ret += btree_buf_bytes(b);
 
        mutex_unlock(&c->btree_cache.lock);
        return ret;
@@ -255,8 +257,6 @@ static size_t bch2_btree_cache_size(struct bch_fs *c)
 static int bch2_compression_stats_to_text(struct printbuf *out, struct bch_fs *c)
 {
        struct btree_trans *trans;
-       struct btree_iter iter;
-       struct bkey_s_c k;
        enum btree_id id;
        struct compression_type_stats {
                u64             nr_extents;
@@ -268,7 +268,7 @@ static int bch2_compression_stats_to_text(struct printbuf *out, struct bch_fs *c
 
        memset(s, 0, sizeof(s));
 
-       if (!test_bit(BCH_FS_STARTED, &c->flags))
+       if (!test_bit(BCH_FS_started, &c->flags))
                return -EPERM;
 
        trans = bch2_trans_get(c);
@@ -277,8 +277,8 @@ static int bch2_compression_stats_to_text(struct printbuf *out, struct bch_fs *c
                if (!btree_type_has_ptrs(id))
                        continue;
 
-               for_each_btree_key(trans, iter, id, POS_MIN,
-                                  BTREE_ITER_ALL_SNAPSHOTS, k, ret) {
+               ret = for_each_btree_key(trans, iter, id, POS_MIN,
+                                        BTREE_ITER_ALL_SNAPSHOTS, k, ({
                        struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
                        struct bch_extent_crc_unpacked crc;
                        const union bch_extent_entry *entry;
@@ -304,8 +304,8 @@ static int bch2_compression_stats_to_text(struct printbuf *out, struct bch_fs *c
                                s[t].sectors_compressed += k.k->size;
                                s[t].sectors_uncompressed += k.k->size;
                        }
-               }
-               bch2_trans_iter_exit(trans, &iter);
+                       0;
+               }));
        }
 
        bch2_trans_put(trans);
@@ -331,7 +331,7 @@ static int bch2_compression_stats_to_text(struct printbuf *out, struct bch_fs *c
        prt_newline(out);
 
        for (unsigned i = 0; i < ARRAY_SIZE(s); i++) {
-               prt_str(out, bch2_compression_types[i]);
+               bch2_prt_compression_type(out, i);
                prt_tab(out);
 
                prt_human_readable_u64(out, s[i].sectors_compressed << 9);
@@ -384,6 +384,9 @@ SHOW(bch2_fs)
        sysfs_print(minor,                      c->minor);
        sysfs_printf(internal_uuid, "%pU",      c->sb.uuid.b);
 
+       if (attr == &sysfs_flags)
+               prt_bitflags(out, bch2_fs_flag_strs, c->flags);
+
        sysfs_hprint(btree_cache_size,          bch2_btree_cache_size(c));
 
        if (attr == &sysfs_btree_write_stats)
@@ -416,7 +419,7 @@ SHOW(bch2_fs)
                bch2_btree_updates_to_text(out, c);
 
        if (attr == &sysfs_btree_cache)
-               bch2_btree_cache_to_text(out, &c->btree_cache);
+               bch2_btree_cache_to_text(out, c);
 
        if (attr == &sysfs_btree_key_cache)
                bch2_btree_key_cache_to_text(out, &c->btree_key_cache);
@@ -497,12 +500,12 @@ STORE(bch2_fs)
 
        /* Debugging: */
 
-       if (!test_bit(BCH_FS_STARTED, &c->flags))
+       if (!test_bit(BCH_FS_started, &c->flags))
                return -EPERM;
 
        /* Debugging: */
 
-       if (!test_bit(BCH_FS_RW, &c->flags))
+       if (!test_bit(BCH_FS_rw, &c->flags))
                return -EROFS;
 
        if (attr == &sysfs_prune_cache) {
@@ -634,6 +637,7 @@ STORE(bch2_fs_internal)
 SYSFS_OPS(bch2_fs_internal);
 
 struct attribute *bch2_fs_internal_files[] = {
+       &sysfs_flags,
        &sysfs_journal_debug,
        &sysfs_btree_updates,
        &sysfs_btree_cache,
@@ -722,8 +726,10 @@ STORE(bch2_fs_opts_dir)
        bch2_opt_set_sb(c, opt, v);
        bch2_opt_set_by_id(&c->opts, id, v);
 
-       if ((id == Opt_background_target ||
-            id == Opt_background_compression) && v)
+       if (v &&
+           (id == Opt_background_target ||
+            id == Opt_background_compression ||
+            (id == Opt_compression && !c->opts.background_compression)))
                bch2_set_rebalance_needs_scan(c, 0);
 
        ret = size;
@@ -880,7 +886,7 @@ static void dev_io_done_to_text(struct printbuf *out, struct bch_dev *ca)
 
                for (i = 1; i < BCH_DATA_NR; i++)
                        prt_printf(out, "%-12s:%12llu\n",
-                              bch2_data_types[i],
+                              bch2_data_type_str(i),
                               percpu_u64_get(&ca->io_done->sectors[rw][i]) << 9);
        }
 }
@@ -905,7 +911,7 @@ SHOW(bch2_dev)
        }
 
        if (attr == &sysfs_has_data) {
-               prt_bitflags(out, bch2_data_types, bch2_dev_has_data(c, ca));
+               prt_bitflags(out, __bch2_data_types, bch2_dev_has_data(c, ca));
                prt_char(out, '\n');
        }
 
@@ -924,10 +930,10 @@ SHOW(bch2_dev)
        sysfs_print(io_latency_write,           atomic64_read(&ca->cur_latency[WRITE]));
 
        if (attr == &sysfs_io_latency_stats_read)
-               bch2_time_stats_to_text(out, &ca->io_latency[READ]);
+               bch2_time_stats_to_text(out, &ca->io_latency[READ].stats);
 
        if (attr == &sysfs_io_latency_stats_write)
-               bch2_time_stats_to_text(out, &ca->io_latency[WRITE]);
+               bch2_time_stats_to_text(out, &ca->io_latency[WRITE].stats);
 
        sysfs_printf(congested,                 "%u%%",
                     clamp(atomic_read(&ca->congested), 0, CONGESTED_MAX)