diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-11-23 20:28:15 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2022-11-30 12:30:49 -0500 |
commit | 676c6fc28673a9d054890b462e196de314e7b161 (patch) | |
tree | d95aaff40ba3014b164b227d763fb2f587bb9998 | |
parent | 951cb3ce09de1e33b45c1fd7193822d18106ea44 (diff) |
bcachefs: Improve bch2_inode_opts_to_opts()
It turns out the *_defined entries of bch_io_opts are only used in one
place - in the xattr get path - and there we immediately convert to a
bch_opts struct, which also has the *_defined entries.
This patch changes bch2_inode_opts_to_opts() to go directly from
bch_inode_unpacked to bch_opts, which is a minor simplification and will
also let us slim down struct bch_io_opts in another patch.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/inode.c | 11 | ||||
-rw-r--r-- | fs/bcachefs/inode.h | 2 | ||||
-rw-r--r-- | fs/bcachefs/opts.c | 11 | ||||
-rw-r--r-- | fs/bcachefs/opts.h | 1 | ||||
-rw-r--r-- | fs/bcachefs/xattr.c | 2 |
5 files changed, 14 insertions, 13 deletions
diff --git a/fs/bcachefs/inode.c b/fs/bcachefs/inode.c index b902da0fc11e..848efbfbc65d 100644 --- a/fs/bcachefs/inode.c +++ b/fs/bcachefs/inode.c @@ -897,3 +897,14 @@ void bch2_inode_nlink_dec(struct btree_trans *trans, struct bch_inode_unpacked * else bi->bi_flags |= BCH_INODE_UNLINKED; } + +struct bch_opts bch2_inode_opts_to_opts(struct bch_inode_unpacked *inode) +{ + struct bch_opts ret = { 0 }; +#define x(_name, _bits) \ + if (inode->bi_##_name) \ + opt_set(ret, _name, inode->bi_##_name - 1); + BCH_INODE_OPTS() +#undef x + return ret; +} diff --git a/fs/bcachefs/inode.h b/fs/bcachefs/inode.h index be016043aa82..fb47eda68fa1 100644 --- a/fs/bcachefs/inode.h +++ b/fs/bcachefs/inode.h @@ -201,4 +201,6 @@ static inline void bch2_inode_nlink_set(struct bch_inode_unpacked *bi, int bch2_inode_nlink_inc(struct bch_inode_unpacked *); void bch2_inode_nlink_dec(struct btree_trans *, struct bch_inode_unpacked *); +struct bch_opts bch2_inode_opts_to_opts(struct bch_inode_unpacked *); + #endif /* _BCACHEFS_INODE_H */ diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c index c7b8a69a7145..7e59ec31a7a2 100644 --- a/fs/bcachefs/opts.c +++ b/fs/bcachefs/opts.c @@ -542,17 +542,6 @@ struct bch_io_opts bch2_opts_to_inode_opts(struct bch_opts src) return ret; } -struct bch_opts bch2_inode_opts_to_opts(struct bch_io_opts src) -{ - struct bch_opts ret = { 0 }; -#define x(_name, _bits) \ - if (opt_defined(src, _name)) \ - opt_set(ret, _name, src._name); - BCH_INODE_OPTS() -#undef x - return ret; -} - void bch2_io_opts_apply(struct bch_io_opts *dst, struct bch_io_opts src) { #define x(_name, _bits) \ diff --git a/fs/bcachefs/opts.h b/fs/bcachefs/opts.h index ad0b13ebc1f9..14a5ac003c10 100644 --- a/fs/bcachefs/opts.h +++ b/fs/bcachefs/opts.h @@ -509,7 +509,6 @@ struct bch_io_opts { }; struct bch_io_opts bch2_opts_to_inode_opts(struct bch_opts); -struct bch_opts bch2_inode_opts_to_opts(struct bch_io_opts); void bch2_io_opts_apply(struct bch_io_opts *, struct bch_io_opts); bool bch2_opt_is_inode_opt(enum bch_opt_id); diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c index 28fa435f1d2b..b5022a8b38c7 100644 --- a/fs/bcachefs/xattr.c +++ b/fs/bcachefs/xattr.c @@ -444,7 +444,7 @@ static int __bch2_xattr_bcachefs_get(const struct xattr_handler *handler, struct bch_inode_info *inode = to_bch_ei(vinode); struct bch_fs *c = inode->v.i_sb->s_fs_info; struct bch_opts opts = - bch2_inode_opts_to_opts(bch2_inode_opts_get(&inode->ei_inode)); + bch2_inode_opts_to_opts(&inode->ei_inode); const struct bch_option *opt; int id, inode_opt_id; struct printbuf out = PRINTBUF; |