* [PATCH] bcachefs: Change opts param to const pointer in bch2_opts_to_text
@ 2024-09-12 18:35 Riyan Dhiman
2024-09-13 10:49 ` Hongbo Li
0 siblings, 1 reply; 2+ messages in thread
From: Riyan Dhiman @ 2024-09-12 18:35 UTC (permalink / raw)
To: kent.overstreet; +Cc: linux-bcachefs, linux-kernel, Riyan Dhiman
Convert struct bch_opts opts to const struct bch_opts *opts in
bch2_opts_to_text() function paramter. This improves efficiency by
avoiding structure copying and reflects the function's read-only
access to opts.
Fixes: 283ba1b92b1c (bcachefs: bch2_opts_to_text())
Signed-off-by: Riyan Dhiman <riyandhiman14@gmail.com>
---
Compile tested only.
fs/bcachefs/fs.c | 2 +-
fs/bcachefs/opts.c | 4 ++--
fs/bcachefs/opts.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index e44794f7c6a0..1a2ba8472cb1 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -1924,7 +1924,7 @@ static int bch2_show_options(struct seq_file *seq, struct dentry *root)
struct bch_fs *c = root->d_sb->s_fs_info;
struct printbuf buf = PRINTBUF;
- bch2_opts_to_text(&buf, c->opts, c, c->disk_sb.sb,
+ 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);
diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c
index 232be8a44051..6216ab5d5c81 100644
--- a/fs/bcachefs/opts.c
+++ b/fs/bcachefs/opts.c
@@ -444,7 +444,7 @@ void bch2_opt_to_text(struct printbuf *out,
}
void bch2_opts_to_text(struct printbuf *out,
- struct bch_opts opts,
+ const struct bch_opts *opts,
struct bch_fs *c, struct bch_sb *sb,
unsigned show_mask, unsigned hide_mask,
unsigned flags)
@@ -457,7 +457,7 @@ void bch2_opts_to_text(struct printbuf *out,
if ((opt->flags & hide_mask) || !(opt->flags & show_mask))
continue;
- u64 v = bch2_opt_get_by_id(&opts, i);
+ u64 v = bch2_opt_get_by_id(opts, i);
if (v == bch2_opt_get_by_id(&bch2_opts_default, i))
continue;
diff --git a/fs/bcachefs/opts.h b/fs/bcachefs/opts.h
index cb2e244a2429..78e1991dc4be 100644
--- a/fs/bcachefs/opts.h
+++ b/fs/bcachefs/opts.h
@@ -606,7 +606,7 @@ int bch2_opt_parse(struct bch_fs *, const struct bch_option *,
void bch2_opt_to_text(struct printbuf *, struct bch_fs *, struct bch_sb *,
const struct bch_option *, u64, unsigned);
void bch2_opts_to_text(struct printbuf *,
- struct bch_opts,
+ const struct bch_opts *,
struct bch_fs *, struct bch_sb *,
unsigned, unsigned, unsigned);
--
2.46.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] bcachefs: Change opts param to const pointer in bch2_opts_to_text
2024-09-12 18:35 [PATCH] bcachefs: Change opts param to const pointer in bch2_opts_to_text Riyan Dhiman
@ 2024-09-13 10:49 ` Hongbo Li
0 siblings, 0 replies; 2+ messages in thread
From: Hongbo Li @ 2024-09-13 10:49 UTC (permalink / raw)
To: Riyan Dhiman, kent.overstreet; +Cc: linux-bcachefs, linux-kernel
On 2024/9/13 2:35, Riyan Dhiman wrote:
> Convert struct bch_opts opts to const struct bch_opts *opts in
> bch2_opts_to_text() function paramter. This improves efficiency by
> avoiding structure copying and reflects the function's read-only
> access to opts.
>
> Fixes: 283ba1b92b1c (bcachefs: bch2_opts_to_text())
> Signed-off-by: Riyan Dhiman <riyandhiman14@gmail.com>
> ---
> Compile tested only.
>
> fs/bcachefs/fs.c | 2 +-
> fs/bcachefs/opts.c | 4 ++--
> fs/bcachefs/opts.h | 2 +-
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
Reviewed-by: Hongbo Li <lihongbo22@huawei.com>
> diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
> index e44794f7c6a0..1a2ba8472cb1 100644
> --- a/fs/bcachefs/fs.c
> +++ b/fs/bcachefs/fs.c
> @@ -1924,7 +1924,7 @@ static int bch2_show_options(struct seq_file *seq, struct dentry *root)
> struct bch_fs *c = root->d_sb->s_fs_info;
> struct printbuf buf = PRINTBUF;
>
> - bch2_opts_to_text(&buf, c->opts, c, c->disk_sb.sb,
> + 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);
> diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c
> index 232be8a44051..6216ab5d5c81 100644
> --- a/fs/bcachefs/opts.c
> +++ b/fs/bcachefs/opts.c
> @@ -444,7 +444,7 @@ void bch2_opt_to_text(struct printbuf *out,
> }
>
> void bch2_opts_to_text(struct printbuf *out,
> - struct bch_opts opts,
> + const struct bch_opts *opts,
> struct bch_fs *c, struct bch_sb *sb,
> unsigned show_mask, unsigned hide_mask,
> unsigned flags)
> @@ -457,7 +457,7 @@ void bch2_opts_to_text(struct printbuf *out,
> if ((opt->flags & hide_mask) || !(opt->flags & show_mask))
> continue;
>
> - u64 v = bch2_opt_get_by_id(&opts, i);
> + u64 v = bch2_opt_get_by_id(opts, i);
> if (v == bch2_opt_get_by_id(&bch2_opts_default, i))
> continue;
>
> diff --git a/fs/bcachefs/opts.h b/fs/bcachefs/opts.h
> index cb2e244a2429..78e1991dc4be 100644
> --- a/fs/bcachefs/opts.h
> +++ b/fs/bcachefs/opts.h
> @@ -606,7 +606,7 @@ int bch2_opt_parse(struct bch_fs *, const struct bch_option *,
> void bch2_opt_to_text(struct printbuf *, struct bch_fs *, struct bch_sb *,
> const struct bch_option *, u64, unsigned);
> void bch2_opts_to_text(struct printbuf *,
> - struct bch_opts,
> + const struct bch_opts *,
> struct bch_fs *, struct bch_sb *,
> unsigned, unsigned, unsigned);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-13 10:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-12 18:35 [PATCH] bcachefs: Change opts param to const pointer in bch2_opts_to_text Riyan Dhiman
2024-09-13 10:49 ` Hongbo Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox