]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Include average write size in sysfs journal_debug
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 8 Nov 2023 21:51:06 +0000 (16:51 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 1 Jan 2024 16:47:36 +0000 (11:47 -0500)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/journal.c
fs/bcachefs/journal_io.c
fs/bcachefs/journal_types.h

index 8cf238be6213ece57815b6dce5e46a5c62c2853a..5df417cd674354fe8d793af173d38acbbeb5785b 100644 (file)
@@ -1262,6 +1262,7 @@ void __bch2_journal_debug_to_text(struct printbuf *out, struct journal *j)
        union journal_res_state s;
        struct bch_dev *ca;
        unsigned long now = jiffies;
+       u64 nr_writes = j->nr_flush_writes + j->nr_noflush_writes;
        u64 seq;
        unsigned i;
 
@@ -1275,20 +1276,23 @@ void __bch2_journal_debug_to_text(struct printbuf *out, struct journal *j)
        prt_printf(out, "dirty journal entries:\t%llu/%llu\n",  fifo_used(&j->pin), j->pin.size);
        prt_printf(out, "seq:\t\t\t%llu\n",                     journal_cur_seq(j));
        prt_printf(out, "seq_ondisk:\t\t%llu\n",                j->seq_ondisk);
-       prt_printf(out, "last_seq:\t\t%llu\n",          journal_last_seq(j));
+       prt_printf(out, "last_seq:\t\t%llu\n",                  journal_last_seq(j));
        prt_printf(out, "last_seq_ondisk:\t%llu\n",             j->last_seq_ondisk);
-       prt_printf(out, "flushed_seq_ondisk:\t%llu\n",  j->flushed_seq_ondisk);
-       prt_printf(out, "watermark:\t\t%s\n",           bch2_watermarks[j->watermark]);
-       prt_printf(out, "each entry reserved:\t%u\n",   j->entry_u64s_reserved);
+       prt_printf(out, "flushed_seq_ondisk:\t%llu\n",          j->flushed_seq_ondisk);
+       prt_printf(out, "watermark:\t\t%s\n",                   bch2_watermarks[j->watermark]);
+       prt_printf(out, "each entry reserved:\t%u\n",           j->entry_u64s_reserved);
        prt_printf(out, "nr flush writes:\t%llu\n",             j->nr_flush_writes);
-       prt_printf(out, "nr noflush writes:\t%llu\n",   j->nr_noflush_writes);
-       prt_printf(out, "nr direct reclaim:\t%llu\n",   j->nr_direct_reclaim);
+       prt_printf(out, "nr noflush writes:\t%llu\n",           j->nr_noflush_writes);
+       prt_printf(out, "average write size:\t");
+       prt_human_readable_u64(out, nr_writes ? div64_u64(j->entry_bytes_written, nr_writes) : 0);
+       prt_newline(out);
+       prt_printf(out, "nr direct reclaim:\t%llu\n",           j->nr_direct_reclaim);
        prt_printf(out, "nr background reclaim:\t%llu\n",       j->nr_background_reclaim);
        prt_printf(out, "reclaim kicked:\t\t%u\n",              j->reclaim_kicked);
-       prt_printf(out, "reclaim runs in:\t%u ms\n",    time_after(j->next_reclaim, now)
+       prt_printf(out, "reclaim runs in:\t%u ms\n",            time_after(j->next_reclaim, now)
               ? jiffies_to_msecs(j->next_reclaim - jiffies) : 0);
-       prt_printf(out, "current entry sectors:\t%u\n", j->cur_entry_sectors);
-       prt_printf(out, "current entry error:\t%s\n",   bch2_journal_errors[j->cur_entry_error]);
+       prt_printf(out, "current entry sectors:\t%u\n",         j->cur_entry_sectors);
+       prt_printf(out, "current entry error:\t%s\n",           bch2_journal_errors[j->cur_entry_error]);
        prt_printf(out, "current entry:\t\t");
 
        switch (s.cur_entry_offset) {
index 3eb6c3f62a811b6502ddacce19754d2cc4ffcd5c..62d409f793d39be5b4b2200056cb9b17ada688fa 100644 (file)
@@ -1890,6 +1890,8 @@ CLOSURE_CALLBACK(bch2_journal_write)
        if (ret)
                goto err;
 
+       j->entry_bytes_written += vstruct_bytes(w->data);
+
        while (1) {
                spin_lock(&j->lock);
                ret = journal_write_alloc(j, w);
index a756b69582e34955ecfe86fbaa688785aeca532f..1acce6ecfca01ad0f8805f590eea039b9817e8e2 100644 (file)
@@ -267,6 +267,7 @@ struct journal {
 
        u64                     nr_flush_writes;
        u64                     nr_noflush_writes;
+       u64                     entry_bytes_written;
 
        struct bch2_time_stats  *flush_write_time;
        struct bch2_time_stats  *noflush_write_time;