Re: [PATCH 2/6] bcachefs: Add ability to redirect log output

Kent Overstreet
2023-12-08T20:35:54Z

On Fri, Dec 08, 2023 at 03:24:13PM -0500, Brian Foster wrote:
> On Wed, Dec 06, 2023 at 03:33:06PM -0500, Kent Overstreet wrote:
> > Upcoming patches are going to add two new ioctls for running fsck in the
> > kernel, but pretending that we're running our normal userspace fsck.
> >
> > This patch adds some plumbing for redirecting our normal log messages
> > away from the dmesg log to a thread_with_file file descriptor - via a
> > struct log_output, which will be consumed by the fsck f_op's read method.
> >
> > The new ioctls will allow for running fsck in the kernel against an
> > offline filesystem (without mounting it), and an online filesystem. For
> > an offline filesystem we need a way to pass in a pointer to the
> > log_output, which is done via a new hidden opts.h option.
> >
> > For online fsck, we can set c->output directly, but only want to
> > redirect log messages from the thread running fsck - hence the new
> > c->output_filter method.
> >
> > Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
> > ---
> > fs/bcachefs/bcachefs.h | 54 +++++++++++++++++++++++++++++++-----------
> > fs/bcachefs/opts.h | 5 ++++
> > fs/bcachefs/super.c | 28 ++++++++++++++++++++++
> > 3 files changed, 73 insertions(+), 14 deletions(-)
> >
> ...
> > diff --git a/fs/bcachefs/opts.h b/fs/bcachefs/opts.h
> > index 8526f177450a..91026dfb8c83 100644
> > --- a/fs/bcachefs/opts.h
> > +++ b/fs/bcachefs/opts.h
> > @@ -419,6 +419,11 @@ enum fsck_err_opts {
> > OPT_BOOL(), \
> > BCH2_NO_SB_OPT, false, \
> > NULL, "Allocate the buckets_nouse bitmap") \
> > + x(log_output, u64, \
> > + 0, \
> > + OPT_UINT(0, S64_MAX), \
> > + BCH2_NO_SB_OPT, false, \
> > + NULL, "Allocate the buckets_nouse bitmap") \
>
> I assume you want to update the string to something more related. :)

Whoops yes :) this is an internal, completely hidden option so nothing
should ever see that, fortunately :)