Commit 07bca3bd authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Kill ei_str_hash

Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 5f0e4ae1
...@@ -217,6 +217,7 @@ struct posix_acl *bch2_get_acl(struct mnt_idmap *idmap, ...@@ -217,6 +217,7 @@ struct posix_acl *bch2_get_acl(struct mnt_idmap *idmap,
{ {
struct bch_inode_info *inode = to_bch_ei(dentry->d_inode); struct bch_inode_info *inode = to_bch_ei(dentry->d_inode);
struct bch_fs *c = inode->v.i_sb->s_fs_info; struct bch_fs *c = inode->v.i_sb->s_fs_info;
struct bch_hash_info hash = bch2_hash_info_init(c, &inode->ei_inode);
struct btree_trans trans; struct btree_trans trans;
struct btree_iter *iter; struct btree_iter *iter;
struct bkey_s_c_xattr xattr; struct bkey_s_c_xattr xattr;
...@@ -227,7 +228,7 @@ struct posix_acl *bch2_get_acl(struct mnt_idmap *idmap, ...@@ -227,7 +228,7 @@ struct posix_acl *bch2_get_acl(struct mnt_idmap *idmap,
bch2_trans_begin(&trans); bch2_trans_begin(&trans);
iter = bch2_hash_lookup(&trans, bch2_xattr_hash_desc, iter = bch2_hash_lookup(&trans, bch2_xattr_hash_desc,
&inode->ei_str_hash, inode->v.i_ino, &hash, inode->v.i_ino,
&X_SEARCH(acl_to_xattr_type(type), "", 0), &X_SEARCH(acl_to_xattr_type(type), "", 0),
0); 0);
if (IS_ERR(iter)) { if (IS_ERR(iter)) {
...@@ -290,6 +291,7 @@ int bch2_set_acl(struct mnt_idmap *idmap, ...@@ -290,6 +291,7 @@ int bch2_set_acl(struct mnt_idmap *idmap,
struct btree_trans trans; struct btree_trans trans;
struct btree_iter *inode_iter; struct btree_iter *inode_iter;
struct bch_inode_unpacked inode_u; struct bch_inode_unpacked inode_u;
struct bch_hash_info hash_info;
struct posix_acl *acl; struct posix_acl *acl;
umode_t mode; umode_t mode;
int ret; int ret;
...@@ -314,9 +316,9 @@ int bch2_set_acl(struct mnt_idmap *idmap, ...@@ -314,9 +316,9 @@ int bch2_set_acl(struct mnt_idmap *idmap,
goto err; goto err;
} }
ret = bch2_set_acl_trans(&trans, &inode_u, hash_info = bch2_hash_info_init(c, &inode_u);
&inode->ei_str_hash,
acl, type); ret = bch2_set_acl_trans(&trans, &inode_u, &hash_info, acl, type);
if (ret) if (ret)
goto btree_err; goto btree_err;
...@@ -345,10 +347,11 @@ int bch2_set_acl(struct mnt_idmap *idmap, ...@@ -345,10 +347,11 @@ int bch2_set_acl(struct mnt_idmap *idmap,
} }
int bch2_acl_chmod(struct btree_trans *trans, int bch2_acl_chmod(struct btree_trans *trans,
struct bch_inode_info *inode, struct bch_inode_unpacked *inode,
umode_t mode, umode_t mode,
struct posix_acl **new_acl) struct posix_acl **new_acl)
{ {
struct bch_hash_info hash_info = bch2_hash_info_init(trans->c, inode);
struct btree_iter *iter; struct btree_iter *iter;
struct bkey_s_c_xattr xattr; struct bkey_s_c_xattr xattr;
struct bkey_i_xattr *new; struct bkey_i_xattr *new;
...@@ -356,7 +359,7 @@ int bch2_acl_chmod(struct btree_trans *trans, ...@@ -356,7 +359,7 @@ int bch2_acl_chmod(struct btree_trans *trans,
int ret = 0; int ret = 0;
iter = bch2_hash_lookup(trans, bch2_xattr_hash_desc, iter = bch2_hash_lookup(trans, bch2_xattr_hash_desc,
&inode->ei_str_hash, inode->v.i_ino, &hash_info, inode->bi_inum,
&X_SEARCH(KEY_TYPE_XATTR_INDEX_POSIX_ACL_ACCESS, "", 0), &X_SEARCH(KEY_TYPE_XATTR_INDEX_POSIX_ACL_ACCESS, "", 0),
BTREE_ITER_INTENT); BTREE_ITER_INTENT);
if (IS_ERR(iter)) if (IS_ERR(iter))
......
...@@ -33,7 +33,7 @@ int bch2_set_acl_trans(struct btree_trans *, ...@@ -33,7 +33,7 @@ int bch2_set_acl_trans(struct btree_trans *,
const struct bch_hash_info *, const struct bch_hash_info *,
struct posix_acl *, int); struct posix_acl *, int);
int bch2_set_acl(struct mnt_idmap *, struct dentry *, struct posix_acl *, int); int bch2_set_acl(struct mnt_idmap *, struct dentry *, struct posix_acl *, int);
int bch2_acl_chmod(struct btree_trans *, struct bch_inode_info *, int bch2_acl_chmod(struct btree_trans *, struct bch_inode_unpacked *,
umode_t, struct posix_acl **); umode_t, struct posix_acl **);
#else #else
...@@ -47,7 +47,7 @@ static inline int bch2_set_acl_trans(struct btree_trans *trans, ...@@ -47,7 +47,7 @@ static inline int bch2_set_acl_trans(struct btree_trans *trans,
} }
static inline int bch2_acl_chmod(struct btree_trans *trans, static inline int bch2_acl_chmod(struct btree_trans *trans,
struct bch_inode_info *inode, struct bch_inode_unpacked *inode,
umode_t mode, umode_t mode,
struct posix_acl **new_acl) struct posix_acl **new_acl)
{ {
......
...@@ -183,6 +183,7 @@ static int bch2_ioc_reinherit_attrs(struct bch_fs *c, ...@@ -183,6 +183,7 @@ static int bch2_ioc_reinherit_attrs(struct bch_fs *c,
struct bch_inode_info *src, struct bch_inode_info *src,
const char __user *name) const char __user *name)
{ {
struct bch_hash_info hash = bch2_hash_info_init(c, &src->ei_inode);
struct bch_inode_info *dst; struct bch_inode_info *dst;
struct inode *vinode = NULL; struct inode *vinode = NULL;
char *kname = NULL; char *kname = NULL;
...@@ -202,8 +203,7 @@ static int bch2_ioc_reinherit_attrs(struct bch_fs *c, ...@@ -202,8 +203,7 @@ static int bch2_ioc_reinherit_attrs(struct bch_fs *c,
qstr.name = kname; qstr.name = kname;
ret = -ENOENT; ret = -ENOENT;
inum = bch2_dirent_lookup(c, src->v.i_ino, inum = bch2_dirent_lookup(c, src->v.i_ino, &hash,
&src->ei_str_hash,
&qstr); &qstr);
if (!inum) if (!inum)
goto err1; goto err1;
......
...@@ -370,11 +370,11 @@ static struct dentry *bch2_lookup(struct inode *vdir, struct dentry *dentry, ...@@ -370,11 +370,11 @@ static struct dentry *bch2_lookup(struct inode *vdir, struct dentry *dentry,
{ {
struct bch_fs *c = vdir->i_sb->s_fs_info; struct bch_fs *c = vdir->i_sb->s_fs_info;
struct bch_inode_info *dir = to_bch_ei(vdir); struct bch_inode_info *dir = to_bch_ei(vdir);
struct bch_hash_info hash = bch2_hash_info_init(c, &dir->ei_inode);
struct inode *vinode = NULL; struct inode *vinode = NULL;
u64 inum; u64 inum;
inum = bch2_dirent_lookup(c, dir->v.i_ino, inum = bch2_dirent_lookup(c, dir->v.i_ino, &hash,
&dir->ei_str_hash,
&dentry->d_name); &dentry->d_name);
if (inum) if (inum)
...@@ -723,7 +723,7 @@ static int bch2_setattr_nonsize(struct mnt_idmap *idmap, ...@@ -723,7 +723,7 @@ static int bch2_setattr_nonsize(struct mnt_idmap *idmap,
bch2_setattr_copy(idmap, inode, &inode_u, attr); bch2_setattr_copy(idmap, inode, &inode_u, attr);
if (attr->ia_valid & ATTR_MODE) { if (attr->ia_valid & ATTR_MODE) {
ret = bch2_acl_chmod(&trans, inode, inode_u.bi_mode, &acl); ret = bch2_acl_chmod(&trans, &inode_u, inode_u.bi_mode, &acl);
if (ret) if (ret)
goto btree_err; goto btree_err;
} }
...@@ -1150,7 +1150,6 @@ static void bch2_vfs_inode_init(struct bch_fs *c, ...@@ -1150,7 +1150,6 @@ static void bch2_vfs_inode_init(struct bch_fs *c,
inode->ei_flags = 0; inode->ei_flags = 0;
inode->ei_journal_seq = 0; inode->ei_journal_seq = 0;
inode->ei_quota_reserved = 0; inode->ei_quota_reserved = 0;
inode->ei_str_hash = bch2_hash_info_init(c, bi);
inode->ei_qid = bch_qid(bi); inode->ei_qid = bch_qid(bi);
inode->v.i_mapping->a_ops = &bch_address_space_operations; inode->v.i_mapping->a_ops = &bch_address_space_operations;
......
...@@ -44,8 +44,6 @@ struct bch_inode_info { ...@@ -44,8 +44,6 @@ struct bch_inode_info {
struct mutex ei_quota_lock; struct mutex ei_quota_lock;
struct bch_qid ei_qid; struct bch_qid ei_qid;
struct bch_hash_info ei_str_hash;
/* copy of inode in btree: */ /* copy of inode in btree: */
struct bch_inode_unpacked ei_inode; struct bch_inode_unpacked ei_inode;
}; };
......
...@@ -121,6 +121,7 @@ void bch2_xattr_to_text(struct printbuf *out, struct bch_fs *c, ...@@ -121,6 +121,7 @@ void bch2_xattr_to_text(struct printbuf *out, struct bch_fs *c,
int bch2_xattr_get(struct bch_fs *c, struct bch_inode_info *inode, int bch2_xattr_get(struct bch_fs *c, struct bch_inode_info *inode,
const char *name, void *buffer, size_t size, int type) const char *name, void *buffer, size_t size, int type)
{ {
struct bch_hash_info hash = bch2_hash_info_init(c, &inode->ei_inode);
struct btree_trans trans; struct btree_trans trans;
struct btree_iter *iter; struct btree_iter *iter;
struct bkey_s_c_xattr xattr; struct bkey_s_c_xattr xattr;
...@@ -128,8 +129,8 @@ int bch2_xattr_get(struct bch_fs *c, struct bch_inode_info *inode, ...@@ -128,8 +129,8 @@ int bch2_xattr_get(struct bch_fs *c, struct bch_inode_info *inode,
bch2_trans_init(&trans, c, 0, 0); bch2_trans_init(&trans, c, 0, 0);
iter = bch2_hash_lookup(&trans, bch2_xattr_hash_desc, iter = bch2_hash_lookup(&trans, bch2_xattr_hash_desc, &hash,
&inode->ei_str_hash, inode->v.i_ino, inode->v.i_ino,
&X_SEARCH(type, name, strlen(name)), &X_SEARCH(type, name, strlen(name)),
0); 0);
if (IS_ERR(iter)) { if (IS_ERR(iter)) {
...@@ -239,7 +240,7 @@ static int bch2_xattr_emit(struct dentry *dentry, ...@@ -239,7 +240,7 @@ static int bch2_xattr_emit(struct dentry *dentry,
} }
static int bch2_xattr_list_bcachefs(struct bch_fs *c, static int bch2_xattr_list_bcachefs(struct bch_fs *c,
struct bch_inode_info *inode, struct bch_inode_unpacked *inode,
struct xattr_buf *buf, struct xattr_buf *buf,
bool all) bool all)
{ {
...@@ -249,12 +250,12 @@ static int bch2_xattr_list_bcachefs(struct bch_fs *c, ...@@ -249,12 +250,12 @@ static int bch2_xattr_list_bcachefs(struct bch_fs *c,
u64 v; u64 v;
for (id = 0; id < Inode_opt_nr; id++) { for (id = 0; id < Inode_opt_nr; id++) {
v = bch2_inode_opt_get(&inode->ei_inode, id); v = bch2_inode_opt_get(inode, id);
if (!v) if (!v)
continue; continue;
if (!all && if (!all &&
!(inode->ei_inode.bi_fields_set & (1 << id))) !(inode->bi_fields_set & (1 << id)))
continue; continue;
ret = __bch2_xattr_emit(prefix, bch2_inode_opts[id], ret = __bch2_xattr_emit(prefix, bch2_inode_opts[id],
...@@ -298,11 +299,11 @@ ssize_t bch2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) ...@@ -298,11 +299,11 @@ ssize_t bch2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
if (ret) if (ret)
return ret; return ret;
ret = bch2_xattr_list_bcachefs(c, inode, &buf, false); ret = bch2_xattr_list_bcachefs(c, &inode->ei_inode, &buf, false);
if (ret) if (ret)
return ret; return ret;
ret = bch2_xattr_list_bcachefs(c, inode, &buf, true); ret = bch2_xattr_list_bcachefs(c, &inode->ei_inode, &buf, true);
if (ret) if (ret)
return ret; return ret;
...@@ -327,10 +328,10 @@ static int bch2_xattr_set_handler(const struct xattr_handler *handler, ...@@ -327,10 +328,10 @@ static int bch2_xattr_set_handler(const struct xattr_handler *handler,
{ {
struct bch_inode_info *inode = to_bch_ei(vinode); struct bch_inode_info *inode = to_bch_ei(vinode);
struct bch_fs *c = inode->v.i_sb->s_fs_info; struct bch_fs *c = inode->v.i_sb->s_fs_info;
struct bch_hash_info hash = bch2_hash_info_init(c, &inode->ei_inode);
return bch2_trans_do(c, NULL, &inode->ei_journal_seq, 0, return bch2_trans_do(c, NULL, &inode->ei_journal_seq, 0,
bch2_xattr_set(&trans, inode->v.i_ino, bch2_xattr_set(&trans, inode->v.i_ino, &hash,
&inode->ei_str_hash,
name, value, size, name, value, size,
handler->flags, flags)); handler->flags, flags));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment