bcachefs: Switch to .get_inode_acl()
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 7 Aug 2024 19:42:23 +0000 (15:42 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 8 Aug 2024 19:14:02 +0000 (15:14 -0400)
.set_acl() requires a dentry, and if one isn't passed it marks the VFS
inode as not having an ACL.

This has been causing inodes with ACLs to have them "disappear" on
bcachefs filesystem, depending on which path those inodes get pulled
into the cache from.

Switching to .get_inode_acl(), like other local filesystems, fixes this.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/acl.c
fs/bcachefs/acl.h
fs/bcachefs/fs.c

index a7b425d..331a17f 100644 (file)
@@ -272,16 +272,19 @@ bch2_acl_to_xattr(struct btree_trans *trans,
        return xattr;
 }
 
-struct posix_acl *bch2_get_acl(struct mnt_idmap *idmap,
-                              struct dentry *dentry, int type)
+struct posix_acl *bch2_get_acl(struct inode *vinode, int type, bool rcu)
 {
-       struct bch_inode_info *inode = to_bch_ei(dentry->d_inode);
+       struct bch_inode_info *inode = to_bch_ei(vinode);
        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 xattr_search_key search = X_SEARCH(acl_to_xattr_type(type), "", 0);
-       struct btree_trans *trans = bch2_trans_get(c);
        struct btree_iter iter = { NULL };
        struct posix_acl *acl = NULL;
+
+       if (rcu)
+               return ERR_PTR(-ECHILD);
+
+       struct btree_trans *trans = bch2_trans_get(c);
 retry:
        bch2_trans_begin(trans);
 
index 27e7eec..fe730a6 100644 (file)
@@ -28,7 +28,7 @@ void bch2_acl_to_text(struct printbuf *, const void *, size_t);
 
 #ifdef CONFIG_BCACHEFS_POSIX_ACL
 
-struct posix_acl *bch2_get_acl(struct mnt_idmap *, struct dentry *, int);
+struct posix_acl *bch2_get_acl(struct inode *, int, bool);
 
 int bch2_set_acl_trans(struct btree_trans *, subvol_inum,
                       struct bch_inode_unpacked *,
index 3a5f49a..15fc41e 100644 (file)
@@ -1199,7 +1199,7 @@ static const struct inode_operations bch_file_inode_operations = {
        .fiemap         = bch2_fiemap,
        .listxattr      = bch2_xattr_list,
 #ifdef CONFIG_BCACHEFS_POSIX_ACL
-       .get_acl        = bch2_get_acl,
+       .get_inode_acl  = bch2_get_acl,
        .set_acl        = bch2_set_acl,
 #endif
 };
@@ -1219,7 +1219,7 @@ static const struct inode_operations bch_dir_inode_operations = {
        .tmpfile        = bch2_tmpfile,
        .listxattr      = bch2_xattr_list,
 #ifdef CONFIG_BCACHEFS_POSIX_ACL
-       .get_acl        = bch2_get_acl,
+       .get_inode_acl  = bch2_get_acl,
        .set_acl        = bch2_set_acl,
 #endif
 };
@@ -1241,7 +1241,7 @@ static const struct inode_operations bch_symlink_inode_operations = {
        .setattr        = bch2_setattr,
        .listxattr      = bch2_xattr_list,
 #ifdef CONFIG_BCACHEFS_POSIX_ACL
-       .get_acl        = bch2_get_acl,
+       .get_inode_acl  = bch2_get_acl,
        .set_acl        = bch2_set_acl,
 #endif
 };
@@ -1251,7 +1251,7 @@ static const struct inode_operations bch_special_inode_operations = {
        .setattr        = bch2_setattr,
        .listxattr      = bch2_xattr_list,
 #ifdef CONFIG_BCACHEFS_POSIX_ACL
-       .get_acl        = bch2_get_acl,
+       .get_inode_acl  = bch2_get_acl,
        .set_acl        = bch2_set_acl,
 #endif
 };