bcachefs: Call bch2_do_invalidates() when going read write
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 13 Jun 2022 23:34:17 +0000 (19:34 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:33 +0000 (17:09 -0400)
Like bch2_do_discards(), we should check if this needs to be done when
going rw.

Also, add some sysfs code for debugging bucket invalidation.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/super.c
fs/bcachefs/sysfs.c

index cc887a1b8c8f030164f36d941d067d9d30506fce..b926fb1b14a9a4cf6978042d9165ee8c9b7603af 100644 (file)
@@ -383,6 +383,7 @@ static int __bch2_fs_read_write(struct bch_fs *c, bool early)
        bch2_recalc_capacity(c);
 
        bch2_do_discards(c);
+       bch2_do_invalidates(c);
 
        if (!early) {
                ret = bch2_fs_read_write_late(c);
index 4a85fffdfa4c5051f3d47c71358b02b8332b3fff..b2d6a5c49a4d5f94e66794de9e11a0e071bd3ba7 100644 (file)
@@ -154,6 +154,7 @@ do {                                                                        \
 
 write_attribute(trigger_gc);
 write_attribute(trigger_discards);
+write_attribute(trigger_invalidates);
 write_attribute(prune_cache);
 rw_attribute(btree_gc_periodic);
 rw_attribute(gc_gens_pos);
@@ -516,6 +517,9 @@ STORE(bch2_fs)
        if (attr == &sysfs_trigger_discards)
                bch2_do_discards(c);
 
+       if (attr == &sysfs_trigger_invalidates)
+               bch2_do_invalidates(c);
+
 #ifdef CONFIG_BCACHEFS_TESTS
        if (attr == &sysfs_perf_test) {
                char *tmp = kstrdup(buf, GFP_KERNEL), *p = tmp;
@@ -627,6 +631,7 @@ struct attribute *bch2_fs_internal_files[] = {
 
        &sysfs_trigger_gc,
        &sysfs_trigger_discards,
+       &sysfs_trigger_invalidates,
        &sysfs_prune_cache,
 
        &sysfs_read_realloc_races,
@@ -792,6 +797,7 @@ static void dev_alloc_debug_to_text(struct printbuf *out, struct bch_dev *ca)
               "open_buckets_wait\t%s\n"
               "open_buckets_btree\t%u\n"
               "open_buckets_user\t%u\n"
+              "buckets_to_invalidate\t%llu\n"
               "btree reserve cache\t%u\n",
               stats.buckets_ec,
               c->freelist_wait.list.first              ? "waiting" : "empty",
@@ -801,6 +807,7 @@ static void dev_alloc_debug_to_text(struct printbuf *out, struct bch_dev *ca)
               c->open_buckets_wait.list.first          ? "waiting" : "empty",
               nr[BCH_DATA_btree],
               nr[BCH_DATA_user],
+              should_invalidate_buckets(ca, stats),
               c->btree_reserve_cache_nr);
 }