[PATCH] bcache: trivial: show active_journal_entries in real time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



active_journal_entries is used to show the value of
    fifo_used(&c->journal.pin)

fifo_used(&c->journal.pin) may count none-0-valued pins and 0-valued
pins both. While none-0 valued pins stands for active journal entries,
0-valued pins do not.

journal_reclaim() is used to pop out the 0-valued pins in the front
part of FIFO, and is called for each bch_journal() call.

There are 2 small cases which journal_reclaim() may not cover:
* The pin used in bch_journal_meta(): if no more IOs, then no reclaim.
  If the pin is decreased to 0 in bch_journal_meta(), 0-valued pin is
  kept and counted by fifo_used().
* When the system reboot up or the bcache module reload,
  bch_journal_mark() will take up some pins, e.g N pins, for entries
  to be replayed, and bch_journal_replay() will decrease the pins to 0.
  If no new IOs after bcache up, active_journal_entries will keep N+1
  (the 1 is set by bch_journal_next(), which is called() after
  bch_journal_mark() in run_cache_set())

In both cases, active_journal_entries do not reflect the real active
entries. This does not impact the work of bcache subsystem, but may
introduce some confusion.

This patch will try to pop out the 0-valued pins in the front part of
journal.pin FIFO before show the realtime active journal entries.

Signed-off-by: Shenghui Wang <shhuiw@xxxxxxxxxxx>
---
 drivers/md/bcache/sysfs.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index 557a8a3270a1..a9b851bc5c98 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -692,7 +692,6 @@ SHOW(__bch_cache_set)
 	sysfs_print(cutoff_writeback, bch_cutoff_writeback);
 	sysfs_print(cutoff_writeback_sync, bch_cutoff_writeback_sync);
 
-	sysfs_print(active_journal_entries,	fifo_used(&c->journal.pin));
 	sysfs_printf(verify,			"%i", c->verify);
 	sysfs_printf(key_merging_disabled,	"%i", c->key_merging_disabled);
 	sysfs_printf(expensive_debug_checks,
@@ -704,6 +703,16 @@ SHOW(__bch_cache_set)
 	sysfs_printf(io_disable,		"%i",
 		     test_bit(CACHE_SET_IO_DISABLE, &c->flags));
 
+	if (attr == &sysfs_active_journal_entries) {
+		atomic_t p;
+
+		spin_lock(&c->journal.lock);
+		while (!atomic_read(&fifo_front(&c->journal.pin)))
+			fifo_pop(&c->journal.pin, p);
+		spin_unlock(&c->journal.lock);
+		return snprint(buf, PAGE_SIZE, fifo_used(&c->journal.pin));
+	}
+
 	if (attr == &sysfs_bset_tree_stats)
 		return bch_bset_print_stats(c, buf);
 
-- 
2.20.1





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux ARM Kernel]     [Linux Filesystem Development]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux