From: Kent Overstreet Date: Fri, 12 Aug 2022 01:06:02 +0000 (-0400) Subject: bcachefs: Print last line in debugfs/btree_transaction_stats X-Git-Tag: v6.7-rc1~201^2~837 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ff7dc3651d5bdcc9d9fe4ace3da21f0f5c2bd778;p=thirdparty%2Fkernel%2Flinux.git bcachefs: Print last line in debugfs/btree_transaction_stats We need to turn the flush_buf() thing into a proper API, to replace seq_file. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/debug.c b/fs/bcachefs/debug.c index c982b0d80c916..183e9f099ca9f 100644 --- a/fs/bcachefs/debug.c +++ b/fs/bcachefs/debug.c @@ -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);