From 22adbc519bf0f2790136c76d7840a1e86a9d5012 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Fri, 21 Nov 2025 10:45:11 -0500 Subject: [PATCH] Update bcachefs sources to 81f1897f3d8d debug patch for gregor --- .bcachefs_revision | 2 +- libbcachefs/bcachefs.h | 1 + libbcachefs/debug/sysfs.c | 9 ++++++--- libbcachefs/fs/inode.c | 4 +++- libbcachefs/opts.c | 4 ++++ libbcachefs/opts.h | 19 ++++++++++++------- libbcachefs/vfs/fs.c | 10 ++++++++++ 7 files changed, 37 insertions(+), 12 deletions(-) diff --git a/.bcachefs_revision b/.bcachefs_revision index 6e4c3e6e..af3af9be 100644 --- a/.bcachefs_revision +++ b/.bcachefs_revision @@ -1 +1 @@ -2f55ab5899a1e409e30d24303d77a67ba0a2efd0 +81f1897f3d8ddf1cce41646b93ec612690bca8ad diff --git a/libbcachefs/bcachefs.h b/libbcachefs/bcachefs.h index 9667ca88..2e15a6da 100644 --- a/libbcachefs/bcachefs.h +++ b/libbcachefs/bcachefs.h @@ -821,6 +821,7 @@ struct bch_fs { struct bch_opts opts; atomic_t opt_change_cookie; + struct bch_opts_mask mount_opts; unsigned loglevel; unsigned prev_loglevel; diff --git a/libbcachefs/debug/sysfs.c b/libbcachefs/debug/sysfs.c index d79d8d05..2c8cb647 100644 --- a/libbcachefs/debug/sysfs.c +++ b/libbcachefs/debug/sysfs.c @@ -706,11 +706,14 @@ static ssize_t sysfs_opt_store(struct bch_fs *c, BUG(); } - if (!ca) - bch2_opt_set_by_id(&c->opts, id, v); + if (changed) { + if (!ca) { + bch2_opt_set_by_id(&c->opts, id, v); + clear_bit(id, c->mount_opts.d); + } - if (changed) bch2_opt_hook_post_set(c, ca, 0, id, v); + } ret = size; err: diff --git a/libbcachefs/fs/inode.c b/libbcachefs/fs/inode.c index 727ff6b5..c23f707a 100644 --- a/libbcachefs/fs/inode.c +++ b/libbcachefs/fs/inode.c @@ -366,8 +366,10 @@ int __bch2_inode_peek(struct btree_trans *trans, return 0; err: - if (warn) + if (warn && should_print_err(ret)) { bch_err_msg(trans->c, ret, "looking up inum %llu:%llu:", inum.subvol, inum.inum); + dump_stack(); + } return ret; } diff --git a/libbcachefs/opts.c b/libbcachefs/opts.c index 9c15fad7..2ed1361d 100644 --- a/libbcachefs/opts.c +++ b/libbcachefs/opts.c @@ -508,6 +508,7 @@ void bch2_opt_to_text(struct printbuf *out, void bch2_opts_to_text(struct printbuf *out, struct bch_opts opts, struct bch_fs *c, struct bch_sb *sb, + struct bch_opts_mask *mask, unsigned show_mask, unsigned hide_mask, unsigned flags) { @@ -519,6 +520,9 @@ void bch2_opts_to_text(struct printbuf *out, if ((opt->flags & hide_mask) || !(opt->flags & show_mask)) continue; + if (mask && !test_bit(i, mask->d)) + continue; + u64 v = bch2_opt_get_by_id(&opts, i); if (v == bch2_opt_get_by_id(&bch2_opts_default, i)) continue; diff --git a/libbcachefs/opts.h b/libbcachefs/opts.h index 637cbf7d..b5a97664 100644 --- a/libbcachefs/opts.h +++ b/libbcachefs/opts.h @@ -563,6 +563,17 @@ enum fsck_err_opts { NULL, "BTREE_ITER_prefetch causes btree nodes to be\n"\ " prefetched sequentially") +enum bch_opt_id { +#define x(_name, ...) Opt_##_name, + BCH_OPTS() +#undef x + bch2_opts_nr +}; + +struct bch_opts_mask { + unsigned long d[BITS_TO_LONGS(bch2_opts_nr)]; +}; + struct bch_opts { #define x(_name, _bits, ...) unsigned _name##_defined:1; BCH_OPTS() @@ -607,13 +618,6 @@ static inline struct bch_opts bch2_opts_empty(void) void bch2_opts_apply(struct bch_opts *, struct bch_opts); -enum bch_opt_id { -#define x(_name, ...) Opt_##_name, - BCH_OPTS() -#undef x - bch2_opts_nr -}; - struct bch_fs; struct printbuf; @@ -664,6 +668,7 @@ void bch2_opt_to_text(struct printbuf *, struct bch_fs *, struct bch_sb *, void bch2_opts_to_text(struct printbuf *, struct bch_opts, struct bch_fs *, struct bch_sb *, + struct bch_opts_mask *, unsigned, unsigned, unsigned); int bch2_opt_hook_pre_set(struct bch_fs *, struct bch_dev *, u64, enum bch_opt_id, u64, bool); diff --git a/libbcachefs/vfs/fs.c b/libbcachefs/vfs/fs.c index a4f0f311..7cce3f37 100644 --- a/libbcachefs/vfs/fs.c +++ b/libbcachefs/vfs/fs.c @@ -2015,6 +2015,7 @@ static int bch2_show_options(struct seq_file *seq, struct dentry *root) CLASS(printbuf, buf)(); bch2_opts_to_text(&buf, c->opts, c, c->disk_sb.sb, + &c->mount_opts, OPT_MOUNT, OPT_HIDDEN, OPT_SHOW_MOUNT_STYLE); printbuf_nul_terminate(&buf); seq_printf(seq, ",%s", buf.buf); @@ -2098,6 +2099,13 @@ static int bch2_test_super(struct super_block *s, void *data) return true; } +static void set_mount_opts(struct bch_fs *c, struct bch_opts *opts) +{ + for (enum bch_opt_id id = 0; id < bch2_opts_nr; id++) + if (bch2_opt_defined_by_id(opts, id)) + set_bit(id, c->mount_opts.d); +} + static int bch2_fs_get_tree(struct fs_context *fc) { struct bch_fs *c; @@ -2134,6 +2142,7 @@ static int bch2_fs_get_tree(struct fs_context *fc) if (opt_defined(opts, discard)) set_bit(BCH_FS_discard_mount_opt_set, &c->flags); + set_mount_opts(c, &opts); /* Some options can't be parsed until after the fs is started: */ opts = bch2_opts_empty(); @@ -2142,6 +2151,7 @@ static int bch2_fs_get_tree(struct fs_context *fc) goto err_stop_fs; bch2_opts_apply(&c->opts, opts); + set_mount_opts(c, &opts); ret = bch2_fs_start(c); if (ret)