* [PATCH] bcachefs: fix incorrect show_options results
@ 2024-09-23 9:50 Hongbo Li
2024-09-23 14:39 ` David Disseldorp
0 siblings, 1 reply; 5+ messages in thread
From: Hongbo Li @ 2024-09-23 9:50 UTC (permalink / raw)
To: kent.overstreet; +Cc: linux-bcachefs, lihongbo22, liaochang1
When call show_options in bcachefs, the options buffer is appeneded
to the seq variable. In fact, it requires an additional comma to be
appended first. This will affect the remount process when reading
existing mount options.
Fixes: 9305cf91d05e ("bcachefs: bch2_opts_to_text()")
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
fs/bcachefs/fs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index e774cb3e6b1a..79c3a650b714 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -1927,7 +1927,7 @@ static int bch2_show_options(struct seq_file *seq, struct dentry *root)
bch2_opts_to_text(&buf, c->opts, c, c->disk_sb.sb,
OPT_MOUNT, OPT_HIDDEN, OPT_SHOW_MOUNT_STYLE);
printbuf_nul_terminate(&buf);
- seq_puts(seq, buf.buf);
+ seq_printf(seq, ",%s", buf.buf);
int ret = buf.allocation_failure ? -ENOMEM : 0;
printbuf_exit(&buf);
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] bcachefs: fix incorrect show_options results
2024-09-23 9:50 [PATCH] bcachefs: fix incorrect show_options results Hongbo Li
@ 2024-09-23 14:39 ` David Disseldorp
2024-09-23 21:40 ` Kent Overstreet
2024-09-24 1:29 ` Hongbo Li
0 siblings, 2 replies; 5+ messages in thread
From: David Disseldorp @ 2024-09-23 14:39 UTC (permalink / raw)
To: Hongbo Li; +Cc: kent.overstreet, linux-bcachefs, liaochang1
On Mon, 23 Sep 2024 17:50:03 +0800, Hongbo Li wrote:
> When call show_options in bcachefs, the options buffer is appeneded
> to the seq variable. In fact, it requires an additional comma to be
> appended first. This will affect the remount process when reading
> existing mount options.
>
> Fixes: 9305cf91d05e ("bcachefs: bch2_opts_to_text()")
Ah, that'd explain why I wasn't seeing this alongside the
fail-on-unknown-opt fix. FWIW, this first appears in
bcachefs-2024-09-21 as 3621ecc10f831f4fd27784083dfaf5b8481098b5 .
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> ---
> fs/bcachefs/fs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
> index e774cb3e6b1a..79c3a650b714 100644
> --- a/fs/bcachefs/fs.c
> +++ b/fs/bcachefs/fs.c
> @@ -1927,7 +1927,7 @@ static int bch2_show_options(struct seq_file *seq, struct dentry *root)
> bch2_opts_to_text(&buf, c->opts, c, c->disk_sb.sb,
> OPT_MOUNT, OPT_HIDDEN, OPT_SHOW_MOUNT_STYLE);
> printbuf_nul_terminate(&buf);
> - seq_puts(seq, buf.buf);
> + seq_printf(seq, ",%s", buf.buf);
Looks okay, although it might be simpler to just drop the !first
conditionals from bch2_opts_to_text() as things were prior to the
regression.
> int ret = buf.allocation_failure ? -ENOMEM : 0;
Should the copy from buf into seq occur if allocation_failure
is already flagged? I'd expect seq_puts() to have oopsed.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] bcachefs: fix incorrect show_options results
2024-09-23 14:39 ` David Disseldorp
@ 2024-09-23 21:40 ` Kent Overstreet
2024-09-24 2:52 ` David Disseldorp
2024-09-24 1:29 ` Hongbo Li
1 sibling, 1 reply; 5+ messages in thread
From: Kent Overstreet @ 2024-09-23 21:40 UTC (permalink / raw)
To: David Disseldorp; +Cc: Hongbo Li, linux-bcachefs, liaochang1
On Mon, Sep 23, 2024 at 02:39:31PM GMT, David Disseldorp wrote:
> On Mon, 23 Sep 2024 17:50:03 +0800, Hongbo Li wrote:
>
> > When call show_options in bcachefs, the options buffer is appeneded
> > to the seq variable. In fact, it requires an additional comma to be
> > appended first. This will affect the remount process when reading
> > existing mount options.
> >
> > Fixes: 9305cf91d05e ("bcachefs: bch2_opts_to_text()")
>
> Ah, that'd explain why I wasn't seeing this alongside the
> fail-on-unknown-opt fix. FWIW, this first appears in
> bcachefs-2024-09-21 as 3621ecc10f831f4fd27784083dfaf5b8481098b5 .
>
> > Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> > ---
> > fs/bcachefs/fs.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
> > index e774cb3e6b1a..79c3a650b714 100644
> > --- a/fs/bcachefs/fs.c
> > +++ b/fs/bcachefs/fs.c
> > @@ -1927,7 +1927,7 @@ static int bch2_show_options(struct seq_file *seq, struct dentry *root)
> > bch2_opts_to_text(&buf, c->opts, c, c->disk_sb.sb,
> > OPT_MOUNT, OPT_HIDDEN, OPT_SHOW_MOUNT_STYLE);
> > printbuf_nul_terminate(&buf);
> > - seq_puts(seq, buf.buf);
> > + seq_printf(seq, ",%s", buf.buf);
>
> Looks okay, although it might be simpler to just drop the !first
> conditionals from bch2_opts_to_text() as things were prior to the
> regression.
>
> > int ret = buf.allocation_failure ? -ENOMEM : 0;
>
> Should the copy from buf into seq occur if allocation_failure
> is already flagged? I'd expect seq_puts() to have oopsed.
That's a good point; it might be the first allocation that fails, not a
realloc. It won't be in practice, buuuut....
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] bcachefs: fix incorrect show_options results
2024-09-23 21:40 ` Kent Overstreet
@ 2024-09-24 2:52 ` David Disseldorp
0 siblings, 0 replies; 5+ messages in thread
From: David Disseldorp @ 2024-09-24 2:52 UTC (permalink / raw)
To: Kent Overstreet; +Cc: Hongbo Li, linux-bcachefs, liaochang1
On Mon, 23 Sep 2024 17:40:05 -0400, Kent Overstreet wrote:
> On Mon, Sep 23, 2024 at 02:39:31PM GMT, David Disseldorp wrote:
...
> > > int ret = buf.allocation_failure ? -ENOMEM : 0;
> >
> > Should the copy from buf into seq occur if allocation_failure
> > is already flagged? I'd expect seq_puts() to have oopsed.
>
> That's a good point; it might be the first allocation that fails, not a
> realloc. It won't be in practice, buuuut....
I've sent a follow-up patch to avoid the seq_puts(seq, NULL). Feel free
to squash it in with this if you like.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bcachefs: fix incorrect show_options results
2024-09-23 14:39 ` David Disseldorp
2024-09-23 21:40 ` Kent Overstreet
@ 2024-09-24 1:29 ` Hongbo Li
1 sibling, 0 replies; 5+ messages in thread
From: Hongbo Li @ 2024-09-24 1:29 UTC (permalink / raw)
To: David Disseldorp, Kent Overstreet; +Cc: linux-bcachefs, liaochang1
On 2024/9/23 22:39, David Disseldorp wrote:
> On Mon, 23 Sep 2024 17:50:03 +0800, Hongbo Li wrote:
>
>> When call show_options in bcachefs, the options buffer is appeneded
>> to the seq variable. In fact, it requires an additional comma to be
>> appended first. This will affect the remount process when reading
>> existing mount options.
>>
>> Fixes: 9305cf91d05e ("bcachefs: bch2_opts_to_text()")
>
> Ah, that'd explain why I wasn't seeing this alongside the
> fail-on-unknown-opt fix. FWIW, this first appears in
> bcachefs-2024-09-21 as 3621ecc10f831f4fd27784083dfaf5b8481098b5 .
>
>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
>> ---
>> fs/bcachefs/fs.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
>> index e774cb3e6b1a..79c3a650b714 100644
>> --- a/fs/bcachefs/fs.c
>> +++ b/fs/bcachefs/fs.c
>> @@ -1927,7 +1927,7 @@ static int bch2_show_options(struct seq_file *seq, struct dentry *root)
>> bch2_opts_to_text(&buf, c->opts, c, c->disk_sb.sb,
>> OPT_MOUNT, OPT_HIDDEN, OPT_SHOW_MOUNT_STYLE);
>> printbuf_nul_terminate(&buf);
>> - seq_puts(seq, buf.buf);
>> + seq_printf(seq, ",%s", buf.buf);
>
> Looks okay, although it might be simpler to just drop the !first
> conditionals from bch2_opts_to_text() as things were prior to the
> regression.
>
The bch2_opts_to_text may be intended to provide a unified format(by
joining options into a string with commas), although currently ther is
only one call to it.
>> int ret = buf.allocation_failure ? -ENOMEM : 0;
>
> Should the copy from buf into seq occur if allocation_failure
> is already flagged? I'd expect seq_puts() to have oopsed.
Or to be more rigorous, copy buf only when allocation_failure is false?
Thanks,
Hongbo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-09-24 2:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-23 9:50 [PATCH] bcachefs: fix incorrect show_options results Hongbo Li
2024-09-23 14:39 ` David Disseldorp
2024-09-23 21:40 ` Kent Overstreet
2024-09-24 2:52 ` David Disseldorp
2024-09-24 1:29 ` Hongbo Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox