bcache: add reclaimed_journal_buckets to struct cache_set
authorColy Li <colyli@suse.de>
Fri, 28 Jun 2019 12:00:00 +0000 (20:00 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 28 Jun 2019 13:39:18 +0000 (07:39 -0600)
Now we have counters for how many times jouranl is reclaimed, how many
times cached dirty btree nodes are flushed, but we don't know how many
jouranl buckets are really reclaimed.

This patch adds reclaimed_journal_buckets into struct cache_set, this
is an increasing only counter, to tell how many journal buckets are
reclaimed since cache set runs. From all these three counters (reclaim,
reclaimed_journal_buckets, flush_write), we can have idea how well
current journal space reclaim code works.

Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/bcache.h
drivers/md/bcache/journal.c
drivers/md/bcache/sysfs.c

index 35396248a7d536db46aa1efb350ae44b5c26c155..013e35a9e317a44c09426af9b26ff894c5a94692 100644 (file)
@@ -705,6 +705,7 @@ struct cache_set {
        atomic_long_t           writeback_keys_failed;
 
        atomic_long_t           reclaim;
+       atomic_long_t           reclaimed_journal_buckets;
        atomic_long_t           flush_write;
 
        enum                    {
index 8bcd8f1bf8cb2af07566168d1d63aa6dc63285b1..be2a2a2016032da538a5b4d30842d829334b4120 100644 (file)
@@ -614,6 +614,7 @@ static void journal_reclaim(struct cache_set *c)
                k->ptr[n++] = MAKE_PTR(0,
                                  bucket_to_sector(c, ca->sb.d[ja->cur_idx]),
                                  ca->sb.nr_this_dev);
+               atomic_long_inc(&c->reclaimed_journal_buckets);
        }
 
        if (n) {
index 701a386a954caee47b44b0acab56e58763cfd000..9f0826712845050ab6ee3d54abe69980eb8d9216 100644 (file)
@@ -82,6 +82,7 @@ read_attribute(bset_tree_stats);
 read_attribute(state);
 read_attribute(cache_read_races);
 read_attribute(reclaim);
+read_attribute(reclaimed_journal_buckets);
 read_attribute(flush_write);
 read_attribute(writeback_keys_done);
 read_attribute(writeback_keys_failed);
@@ -705,6 +706,9 @@ SHOW(__bch_cache_set)
        sysfs_print(reclaim,
                    atomic_long_read(&c->reclaim));
 
+       sysfs_print(reclaimed_journal_buckets,
+                   atomic_long_read(&c->reclaimed_journal_buckets));
+
        sysfs_print(flush_write,
                    atomic_long_read(&c->flush_write));
 
@@ -931,6 +935,7 @@ static struct attribute *bch_cache_set_internal_files[] = {
        &sysfs_bset_tree_stats,
        &sysfs_cache_read_races,
        &sysfs_reclaim,
+       &sysfs_reclaimed_journal_buckets,
        &sysfs_flush_write,
        &sysfs_writeback_keys_done,
        &sysfs_writeback_keys_failed,