Message ID | 9519d52d87d0cd2d65ba651a8a1282106d988d76.1602273837.git.josef@toxicpanda.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | New rescue mount options | expand |
On 09/10/2020 22:10, Josef Bacik wrote: > +#define print_rescue_option(opt, name) \ > + if (btrfs_test_opt(info, opt)) { \ > + seq_printf(seq, "%s%s", printed ? ":" : ",rescue=", name); \ > + printed = true; \ > + } \ > + > static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) > { > struct btrfs_fs_info *info = btrfs_sb(dentry->d_sb); > const char *compress_type; > const char *subvol_name; > + bool printed = false; > > if (btrfs_test_opt(info, DEGRADED)) > seq_puts(seq, ",degraded"); Hmm I don't quite like that print_rescue_options() is relying on the local variable printed from btrfs_show_options(). I personally would prefer if you'd either pass in 'printed' or define the macro inside the function's body.
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index f99e89ec46b2..be56fe15cd74 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1392,11 +1392,18 @@ int btrfs_sync_fs(struct super_block *sb, int wait) return btrfs_commit_transaction(trans); } +#define print_rescue_option(opt, name) \ + if (btrfs_test_opt(info, opt)) { \ + seq_printf(seq, "%s%s", printed ? ":" : ",rescue=", name); \ + printed = true; \ + } \ + static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) { struct btrfs_fs_info *info = btrfs_sb(dentry->d_sb); const char *compress_type; const char *subvol_name; + bool printed = false; if (btrfs_test_opt(info, DEGRADED)) seq_puts(seq, ",degraded"); @@ -1428,8 +1435,7 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) seq_puts(seq, ",ssd"); if (btrfs_test_opt(info, NOTREELOG)) seq_puts(seq, ",notreelog"); - if (btrfs_test_opt(info, NOLOGREPLAY)) - seq_puts(seq, ",rescue=nologreplay"); + print_rescue_option(NOLOGREPLAY, "nologreplay"); if (btrfs_test_opt(info, FLUSHONCOMMIT)) seq_puts(seq, ",flushoncommit"); if (btrfs_test_opt(info, DISCARD_SYNC))
We're going to have a lot of rescue options, add a helper to collapse the /proc/mounts output to rescue=option1:option2:option3 format. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/super.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)