]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/sysfs.c
Update bcachefs sources to 4837f82ee1 bcachefs: Use cached iterators for alloc btree
[bcachefs-tools-debian] / libbcachefs / sysfs.c
index a8bcba74758274cc23f9da4fed8caf22abe96dc4..15c5dc1dd46b35e8283da56c80492a74d86f1169 100644 (file)
@@ -134,7 +134,6 @@ do {                                                                        \
 write_attribute(trigger_journal_flush);
 write_attribute(trigger_btree_coalesce);
 write_attribute(trigger_gc);
-write_attribute(trigger_alloc_write);
 write_attribute(prune_cache);
 rw_attribute(btree_gc_periodic);
 
@@ -166,6 +165,7 @@ read_attribute(journal_debug);
 read_attribute(journal_pins);
 read_attribute(btree_updates);
 read_attribute(dirty_btree_nodes);
+read_attribute(btree_transactions);
 
 read_attribute(internal_uuid);
 
@@ -276,7 +276,7 @@ static ssize_t bch2_compression_stats(struct bch_fs *c, char *buf)
                        struct extent_ptr_decoded p;
 
                        extent_for_each_ptr_decode(e, p, entry) {
-                               if (p.crc.compression_type == BCH_COMPRESSION_TYPE_none) {
+                               if (!crc_is_compressed(p.crc)) {
                                        nr_uncompressed_extents++;
                                        uncompressed_sectors += e.k->size;
                                } else {
@@ -401,6 +401,12 @@ SHOW(bch2_fs)
 
        if (attr == &sysfs_dirty_btree_nodes)
                return bch2_dirty_btree_nodes_print(c, buf);
+       if (attr == &sysfs_btree_transactions) {
+               struct printbuf out = _PBUF(buf, PAGE_SIZE);
+
+               bch2_btree_trans_to_text(&out, c);
+               return out.pos - buf;
+       }
 
        if (attr == &sysfs_compression_stats)
                return bch2_compression_stats(c, buf);
@@ -420,7 +426,7 @@ SHOW(bch2_fs)
        return 0;
 }
 
-STORE(__bch2_fs)
+STORE(bch2_fs)
 {
        struct bch_fs *c = container_of(kobj, struct bch_fs, kobj);
 
@@ -478,13 +484,17 @@ STORE(__bch2_fs)
        if (attr == &sysfs_trigger_btree_coalesce)
                bch2_coalesce(c);
 
-       if (attr == &sysfs_trigger_gc)
+       if (attr == &sysfs_trigger_gc) {
+               /*
+                * Full gc is currently incompatible with btree key cache:
+                */
+#if 0
+               down_read(&c->state_lock);
                bch2_gc(c, NULL, false, false);
-
-       if (attr == &sysfs_trigger_alloc_write) {
-               bool wrote;
-
-               bch2_alloc_write(c, 0, &wrote);
+               up_read(&c->state_lock);
+#else
+               bch2_gc_gens(c);
+#endif
        }
 
        if (attr == &sysfs_prune_cache) {
@@ -494,6 +504,7 @@ STORE(__bch2_fs)
                sc.nr_to_scan = strtoul_or_return(buf);
                c->btree_cache.shrink.scan_objects(&c->btree_cache.shrink, &sc);
        }
+
 #ifdef CONFIG_BCACHEFS_TESTS
        if (attr == &sysfs_perf_test) {
                char *tmp = kstrdup(buf, GFP_KERNEL), *p = tmp;
@@ -515,17 +526,6 @@ STORE(__bch2_fs)
 #endif
        return size;
 }
-
-STORE(bch2_fs)
-{
-       struct bch_fs *c = container_of(kobj, struct bch_fs, kobj);
-
-       mutex_lock(&c->state_lock);
-       size = __bch2_fs_store(kobj, attr, buf, size);
-       mutex_unlock(&c->state_lock);
-
-       return size;
-}
 SYSFS_OPS(bch2_fs);
 
 struct attribute *bch2_fs_files[] = {
@@ -571,6 +571,7 @@ struct attribute *bch2_fs_internal_files[] = {
        &sysfs_journal_pins,
        &sysfs_btree_updates,
        &sysfs_dirty_btree_nodes,
+       &sysfs_btree_transactions,
 
        &sysfs_read_realloc_races,
        &sysfs_extent_migrate_done,
@@ -579,7 +580,6 @@ struct attribute *bch2_fs_internal_files[] = {
        &sysfs_trigger_journal_flush,
        &sysfs_trigger_btree_coalesce,
        &sysfs_trigger_gc,
-       &sysfs_trigger_alloc_write,
        &sysfs_prune_cache,
 
        &sysfs_copy_gc_enabled,
@@ -916,8 +916,6 @@ SHOW(bch2_dev)
                        bch2_disk_path_to_text(&out, &c->disk_sb,
                                               ca->mi.group - 1);
                        mutex_unlock(&c->sb_lock);
-               } else {
-                       pr_buf(&out, "none");
                }
 
                pr_buf(&out, "\n");