]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Print last line in debugfs/btree_transaction_stats
authorKent Overstreet <kent.overstreet@gmail.com>
Fri, 12 Aug 2022 01:06:02 +0000 (21:06 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:38 +0000 (17:09 -0400)
We need to turn the flush_buf() thing into a proper API, to replace
seq_file.

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

index c982b0d80c916d8e99179b4b56a9ab1ca316f2d1..183e9f099ca9f7faf2f3b6cd7fdc60a230182464 100644 (file)
@@ -660,8 +660,7 @@ static ssize_t lock_held_stats_read(struct file *file, char __user *buf,
        i->size = size;
        i->ret  = 0;
 
-       while (i->iter < ARRAY_SIZE(c->btree_transaction_fns) &&
-              c->btree_transaction_fns[i->iter]) {
+       while (1) {
                struct btree_transaction_stats *s = &c->btree_transaction_stats[i->iter];
 
                err = flush_buf(i);
@@ -671,6 +670,10 @@ static ssize_t lock_held_stats_read(struct file *file, char __user *buf,
                if (!i->size)
                        break;
 
+               if (i->iter == ARRAY_SIZE(c->btree_transaction_fns) ||
+                   !c->btree_transaction_fns[i->iter])
+                       break;
+
                prt_printf(&i->buf, "%s: ", c->btree_transaction_fns[i->iter]);
                prt_newline(&i->buf);
                printbuf_indent_add(&i->buf, 2);