From: Kent Overstreet Date: Mon, 13 Jun 2022 23:34:17 +0000 (-0400) Subject: bcachefs: Call bch2_do_invalidates() when going read write X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=0e96f5dcd7ff678c5448f64cb957117399754d2e;p=linux.git bcachefs: Call bch2_do_invalidates() when going read write 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 --- diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index cc887a1b8c8f0..b926fb1b14a9a 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -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); diff --git a/fs/bcachefs/sysfs.c b/fs/bcachefs/sysfs.c index 4a85fffdfa4c5..b2d6a5c49a4d5 100644 --- a/fs/bcachefs/sysfs.c +++ b/fs/bcachefs/sysfs.c @@ -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); }