summaryrefslogtreecommitdiff
path: root/fs/bcachefs/super.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-07-11 23:23:40 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-07-12 01:46:59 -0400
commit1fec9ab170e57cb40b410d2d27cddd22a6fe08db (patch)
tree6c1190f204f92166c83f66e4a550f4270b6b6c6d /fs/bcachefs/super.c
parentef5b64f02690cd6f5cca6e854100b5a3abfd3541 (diff)
bcachefs: BCH_IOCTL_FSCKbcachefs-ioctl-fsck
This adds a new ioctl for running fsck on a list of devices. Normally, if we wish to use the kernel's implementation of fsck we'd run it at mount time with -o fsck. This ioctl lets us run fsck without mounting, so that userspace bcachefs-tools can transparently switch to the kernel's implementation of fsck when appropriate - primarily if the kernel version of bcachefs better matches the filesystem on disk. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/super.c')
-rw-r--r--fs/bcachefs/super.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index 9f1047a7666a..937a5f45a1ac 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -64,6 +64,23 @@
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Kent Overstreet <kent.overstreet@gmail.com>");
+void __bch2_print(struct bch_fs *c, const char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ if (likely(!c->output)) {
+ vprintk(fmt, args);
+ } else {
+ unsigned long flags;
+
+ spin_lock_irqsave(&c->output->lock, flags);
+ prt_vprintf(&c->output->buf, fmt, args);
+ spin_unlock_irqrestore(&c->output->lock, flags);
+ }
+ va_end(args);
+}
+
#define KTYPE(type) \
static const struct attribute_group type ## _group = { \
.attrs = type ## _files \
@@ -667,6 +684,8 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
goto out;
}
+ c->output = (void *)(unsigned long) opts.log_output;
+
__module_get(THIS_MODULE);
closure_init(&c->cl, NULL);