]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/sysfs.c
Update bcachefs sources to 481b5f343248 bcachefs: Better error messages for missing...
[bcachefs-tools-debian] / libbcachefs / sysfs.c
index 4a7c93bcf2f4929ae2d172a46a4313f07a854a6e..cee80c47feea2b27fa7d18fc55a39228db7f0b96 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"
@@ -247,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;
@@ -256,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;
@@ -278,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;
@@ -305,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);
@@ -332,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);
@@ -727,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;
@@ -885,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);
        }
 }
@@ -910,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');
        }