bcachefs: Change opts param to const pointer in bch2_opts_to_text
PATCH 1/1 bcachefs: Change opts param to const pointer in bch2_opts_to_text
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 <[email protected]>
---
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(-)
fs/bcachefs/fs.c +1 -1
@@ -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);
fs/bcachefs/opts.c +2 -2
@@ -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 ;
fs/bcachefs/opts.h +1 -1
@@ -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 );
Signature · 1 line
2.46.0
Quoted 7 lines · Riyan Dhiman
Convert struct
bch_optsopts to const structbch_opts*opts inbch2_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 <[email protected]>
Quoted 8 lines
---
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 <[email protected]>
Quoted 48 lines
fs/bcachefs/fs.c +1
-1@@ -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);fs/bcachefs/opts.c +2
-2@@ -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 ;fs/bcachefs/opts.h +1
-1@@ -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 );