Skip to content

Commit 0cad624

Browse files
author
Miklos Szeredi
committed
vfs: add rcu argument to ->get_acl() callback
Add a rcu argument to the ->get_acl() callback to allow get_cached_acl_rcu() to call the ->get_acl() method in the next patch. Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 52d5a0c commit 0cad624

File tree

39 files changed

+91
-40
lines changed

39 files changed

+91
-40
lines changed

Documentation/filesystems/locking.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ prototypes::
7070
const char *(*get_link) (struct dentry *, struct inode *, struct delayed_call *);
7171
void (*truncate) (struct inode *);
7272
int (*permission) (struct inode *, int, unsigned int);
73-
int (*get_acl)(struct inode *, int);
73+
struct posix_acl * (*get_acl)(struct inode *, int, bool);
7474
int (*setattr) (struct dentry *, struct iattr *);
7575
int (*getattr) (const struct path *, struct kstat *, u32, unsigned int);
7676
ssize_t (*listxattr) (struct dentry *, char *, size_t);

Documentation/filesystems/vfs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ As of kernel 2.6.22, the following members are defined:
432432
const char *(*get_link) (struct dentry *, struct inode *,
433433
struct delayed_call *);
434434
int (*permission) (struct user_namespace *, struct inode *, int);
435-
int (*get_acl)(struct inode *, int);
435+
struct posix_acl * (*get_acl)(struct inode *, int, bool);
436436
int (*setattr) (struct user_namespace *, struct dentry *, struct iattr *);
437437
int (*getattr) (struct user_namespace *, const struct path *, struct kstat *, u32, unsigned int);
438438
ssize_t (*listxattr) (struct dentry *, char *, size_t);

fs/9p/acl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,13 @@ static struct posix_acl *v9fs_get_cached_acl(struct inode *inode, int type)
9797
return acl;
9898
}
9999

100-
struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type)
100+
struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type, bool rcu)
101101
{
102102
struct v9fs_session_info *v9ses;
103103

104+
if (rcu)
105+
return ERR_PTR(-ECHILD);
106+
104107
v9ses = v9fs_inode2v9ses(inode);
105108
if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) ||
106109
((v9ses->flags & V9FS_ACL_MASK) != V9FS_POSIX_ACL)) {

fs/9p/acl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#ifdef CONFIG_9P_FS_POSIX_ACL
1818
extern int v9fs_get_acl(struct inode *, struct p9_fid *);
19-
extern struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type);
19+
extern struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type, bool rcu);
2020
extern int v9fs_acl_chmod(struct inode *, struct p9_fid *);
2121
extern int v9fs_set_create_acl(struct inode *, struct p9_fid *,
2222
struct posix_acl *, struct posix_acl *);

fs/bad_inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static const char *bad_inode_get_link(struct dentry *dentry,
121121
return ERR_PTR(-EIO);
122122
}
123123

124-
static struct posix_acl *bad_inode_get_acl(struct inode *inode, int type)
124+
static struct posix_acl *bad_inode_get_acl(struct inode *inode, int type, bool rcu)
125125
{
126126
return ERR_PTR(-EIO);
127127
}

fs/btrfs/acl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616
#include "btrfs_inode.h"
1717
#include "xattr.h"
1818

19-
struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
19+
struct posix_acl *btrfs_get_acl(struct inode *inode, int type, bool rcu)
2020
{
2121
int size;
2222
const char *name;
2323
char *value = NULL;
2424
struct posix_acl *acl;
2525

26+
if (rcu)
27+
return ERR_PTR(-ECHILD);
28+
2629
switch (type) {
2730
case ACL_TYPE_ACCESS:
2831
name = XATTR_NAME_POSIX_ACL_ACCESS;

fs/btrfs/ctree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3686,7 +3686,7 @@ static inline int __btrfs_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag)
36863686

36873687
/* acl.c */
36883688
#ifdef CONFIG_BTRFS_FS_POSIX_ACL
3689-
struct posix_acl *btrfs_get_acl(struct inode *inode, int type);
3689+
struct posix_acl *btrfs_get_acl(struct inode *inode, int type, bool rcu);
36903690
int btrfs_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
36913691
struct posix_acl *acl, int type);
36923692
int btrfs_init_acl(struct btrfs_trans_handle *trans,

fs/ceph/acl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@ static inline void ceph_set_cached_acl(struct inode *inode,
2929
spin_unlock(&ci->i_ceph_lock);
3030
}
3131

32-
struct posix_acl *ceph_get_acl(struct inode *inode, int type)
32+
struct posix_acl *ceph_get_acl(struct inode *inode, int type, bool rcu)
3333
{
3434
int size;
3535
unsigned int retry_cnt = 0;
3636
const char *name;
3737
char *value = NULL;
3838
struct posix_acl *acl;
3939

40+
if (rcu)
41+
return ERR_PTR(-ECHILD);
42+
4043
switch (type) {
4144
case ACL_TYPE_ACCESS:
4245
name = XATTR_NAME_POSIX_ACL_ACCESS;

fs/ceph/super.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ void ceph_release_acl_sec_ctx(struct ceph_acl_sec_ctx *as_ctx);
10871087
/* acl.c */
10881088
#ifdef CONFIG_CEPH_FS_POSIX_ACL
10891089

1090-
struct posix_acl *ceph_get_acl(struct inode *, int);
1090+
struct posix_acl *ceph_get_acl(struct inode *, int, bool);
10911091
int ceph_set_acl(struct user_namespace *mnt_userns,
10921092
struct inode *inode, struct posix_acl *acl, int type);
10931093
int ceph_pre_init_acls(struct inode *dir, umode_t *mode,

fs/erofs/xattr.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,12 +673,15 @@ ssize_t erofs_listxattr(struct dentry *dentry,
673673
}
674674

675675
#ifdef CONFIG_EROFS_FS_POSIX_ACL
676-
struct posix_acl *erofs_get_acl(struct inode *inode, int type)
676+
struct posix_acl *erofs_get_acl(struct inode *inode, int type, bool rcu)
677677
{
678678
struct posix_acl *acl;
679679
int prefix, rc;
680680
char *value = NULL;
681681

682+
if (rcu)
683+
return ERR_PTR(-ECHILD);
684+
682685
switch (type) {
683686
case ACL_TYPE_ACCESS:
684687
prefix = EROFS_XATTR_INDEX_POSIX_ACL_ACCESS;

fs/erofs/xattr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static inline int erofs_getxattr(struct inode *inode, int index,
8080
#endif /* !CONFIG_EROFS_FS_XATTR */
8181

8282
#ifdef CONFIG_EROFS_FS_POSIX_ACL
83-
struct posix_acl *erofs_get_acl(struct inode *inode, int type);
83+
struct posix_acl *erofs_get_acl(struct inode *inode, int type, bool rcu);
8484
#else
8585
#define erofs_get_acl (NULL)
8686
#endif

fs/ext2/acl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,16 @@ ext2_acl_to_disk(const struct posix_acl *acl, size_t *size)
141141
* inode->i_mutex: don't care
142142
*/
143143
struct posix_acl *
144-
ext2_get_acl(struct inode *inode, int type)
144+
ext2_get_acl(struct inode *inode, int type, bool rcu)
145145
{
146146
int name_index;
147147
char *value = NULL;
148148
struct posix_acl *acl;
149149
int retval;
150150

151+
if (rcu)
152+
return ERR_PTR(-ECHILD);
153+
151154
switch (type) {
152155
case ACL_TYPE_ACCESS:
153156
name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS;

fs/ext2/acl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static inline int ext2_acl_count(size_t size)
5555
#ifdef CONFIG_EXT2_FS_POSIX_ACL
5656

5757
/* acl.c */
58-
extern struct posix_acl *ext2_get_acl(struct inode *inode, int type);
58+
extern struct posix_acl *ext2_get_acl(struct inode *inode, int type, bool rcu);
5959
extern int ext2_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
6060
struct posix_acl *acl, int type);
6161
extern int ext2_init_acl (struct inode *, struct inode *);

fs/ext4/acl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,16 @@ ext4_acl_to_disk(const struct posix_acl *acl, size_t *size)
142142
* inode->i_mutex: don't care
143143
*/
144144
struct posix_acl *
145-
ext4_get_acl(struct inode *inode, int type)
145+
ext4_get_acl(struct inode *inode, int type, bool rcu)
146146
{
147147
int name_index;
148148
char *value = NULL;
149149
struct posix_acl *acl;
150150
int retval;
151151

152+
if (rcu)
153+
return ERR_PTR(-ECHILD);
154+
152155
switch (type) {
153156
case ACL_TYPE_ACCESS:
154157
name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;

fs/ext4/acl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static inline int ext4_acl_count(size_t size)
5555
#ifdef CONFIG_EXT4_FS_POSIX_ACL
5656

5757
/* acl.c */
58-
struct posix_acl *ext4_get_acl(struct inode *inode, int type);
58+
struct posix_acl *ext4_get_acl(struct inode *inode, int type, bool rcu);
5959
int ext4_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
6060
struct posix_acl *acl, int type);
6161
extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);

fs/f2fs/acl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,11 @@ static struct posix_acl *__f2fs_get_acl(struct inode *inode, int type,
196196
return acl;
197197
}
198198

199-
struct posix_acl *f2fs_get_acl(struct inode *inode, int type)
199+
struct posix_acl *f2fs_get_acl(struct inode *inode, int type, bool rcu)
200200
{
201+
if (rcu)
202+
return ERR_PTR(-ECHILD);
203+
201204
return __f2fs_get_acl(inode, type, NULL);
202205
}
203206

fs/f2fs/acl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct f2fs_acl_header {
3333

3434
#ifdef CONFIG_F2FS_FS_POSIX_ACL
3535

36-
extern struct posix_acl *f2fs_get_acl(struct inode *, int);
36+
extern struct posix_acl *f2fs_get_acl(struct inode *, int, bool);
3737
extern int f2fs_set_acl(struct user_namespace *, struct inode *,
3838
struct posix_acl *, int);
3939
extern int f2fs_init_acl(struct inode *, struct inode *, struct page *,

fs/fuse/acl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111
#include <linux/posix_acl.h>
1212
#include <linux/posix_acl_xattr.h>
1313

14-
struct posix_acl *fuse_get_acl(struct inode *inode, int type)
14+
struct posix_acl *fuse_get_acl(struct inode *inode, int type, bool rcu)
1515
{
1616
struct fuse_conn *fc = get_fuse_conn(inode);
1717
int size;
1818
const char *name;
1919
void *value = NULL;
2020
struct posix_acl *acl;
2121

22+
if (rcu)
23+
return ERR_PTR(-ECHILD);
24+
2225
if (fuse_is_bad(inode))
2326
return ERR_PTR(-EIO);
2427

fs/fuse/fuse_i.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ extern const struct xattr_handler *fuse_acl_xattr_handlers[];
12161216
extern const struct xattr_handler *fuse_no_acl_xattr_handlers[];
12171217

12181218
struct posix_acl;
1219-
struct posix_acl *fuse_get_acl(struct inode *inode, int type);
1219+
struct posix_acl *fuse_get_acl(struct inode *inode, int type, bool rcu);
12201220
int fuse_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
12211221
struct posix_acl *acl, int type);
12221222

fs/gfs2/acl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,16 @@ static struct posix_acl *__gfs2_get_acl(struct inode *inode, int type)
5757
return acl;
5858
}
5959

60-
struct posix_acl *gfs2_get_acl(struct inode *inode, int type)
60+
struct posix_acl *gfs2_get_acl(struct inode *inode, int type, bool rcu)
6161
{
6262
struct gfs2_inode *ip = GFS2_I(inode);
6363
struct gfs2_holder gh;
6464
bool need_unlock = false;
6565
struct posix_acl *acl;
6666

67+
if (rcu)
68+
return ERR_PTR(-ECHILD);
69+
6770
if (!gfs2_glock_is_locked_by_me(ip->i_gl)) {
6871
int ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED,
6972
LM_FLAG_ANY, &gh);

fs/gfs2/acl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#define GFS2_ACL_MAX_ENTRIES(sdp) ((300 << (sdp)->sd_sb.sb_bsize_shift) >> 12)
1313

14-
extern struct posix_acl *gfs2_get_acl(struct inode *inode, int type);
14+
extern struct posix_acl *gfs2_get_acl(struct inode *inode, int type, bool rcu);
1515
extern int __gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type);
1616
extern int gfs2_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
1717
struct posix_acl *acl, int type);

fs/jffs2/acl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,15 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size)
173173
return ERR_PTR(-EINVAL);
174174
}
175175

176-
struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
176+
struct posix_acl *jffs2_get_acl(struct inode *inode, int type, bool rcu)
177177
{
178178
struct posix_acl *acl;
179179
char *value = NULL;
180180
int rc, xprefix;
181181

182+
if (rcu)
183+
return ERR_PTR(-ECHILD);
184+
182185
switch (type) {
183186
case ACL_TYPE_ACCESS:
184187
xprefix = JFFS2_XPREFIX_ACL_ACCESS;

fs/jffs2/acl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct jffs2_acl_header {
2727

2828
#ifdef CONFIG_JFFS2_FS_POSIX_ACL
2929

30-
struct posix_acl *jffs2_get_acl(struct inode *inode, int type);
30+
struct posix_acl *jffs2_get_acl(struct inode *inode, int type, bool rcu);
3131
int jffs2_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
3232
struct posix_acl *acl, int type);
3333
extern int jffs2_init_acl_pre(struct inode *, struct inode *, umode_t *);

fs/jfs/acl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
#include "jfs_xattr.h"
1515
#include "jfs_acl.h"
1616

17-
struct posix_acl *jfs_get_acl(struct inode *inode, int type)
17+
struct posix_acl *jfs_get_acl(struct inode *inode, int type, bool rcu)
1818
{
1919
struct posix_acl *acl;
2020
char *ea_name;
2121
int size;
2222
char *value = NULL;
2323

24+
if (rcu)
25+
return ERR_PTR(-ECHILD);
26+
2427
switch(type) {
2528
case ACL_TYPE_ACCESS:
2629
ea_name = XATTR_NAME_POSIX_ACL_ACCESS;

fs/jfs/jfs_acl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#ifdef CONFIG_JFS_POSIX_ACL
99

10-
struct posix_acl *jfs_get_acl(struct inode *inode, int type);
10+
struct posix_acl *jfs_get_acl(struct inode *inode, int type, bool rcu);
1111
int jfs_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
1212
struct posix_acl *acl, int type);
1313
int jfs_init_acl(tid_t, struct inode *, struct inode *);

fs/nfs/nfs3_fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* nfs3acl.c
1212
*/
1313
#ifdef CONFIG_NFS_V3_ACL
14-
extern struct posix_acl *nfs3_get_acl(struct inode *inode, int type);
14+
extern struct posix_acl *nfs3_get_acl(struct inode *inode, int type, bool rcu);
1515
extern int nfs3_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
1616
struct posix_acl *acl, int type);
1717
extern int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,

fs/nfs/nfs3acl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static void nfs3_abort_get_acl(struct posix_acl **p)
4444
cmpxchg(p, sentinel, ACL_NOT_CACHED);
4545
}
4646

47-
struct posix_acl *nfs3_get_acl(struct inode *inode, int type)
47+
struct posix_acl *nfs3_get_acl(struct inode *inode, int type, bool rcu)
4848
{
4949
struct nfs_server *server = NFS_SERVER(inode);
5050
struct page *pages[NFSACL_MAXPAGES] = { };
@@ -62,6 +62,9 @@ struct posix_acl *nfs3_get_acl(struct inode *inode, int type)
6262
};
6363
int status, count;
6464

65+
if (rcu)
66+
return ERR_PTR(-ECHILD);
67+
6568
if (!nfs_server_capable(inode, NFS_CAP_ACLS))
6669
return ERR_PTR(-EOPNOTSUPP);
6770

fs/ocfs2/acl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,17 @@ int ocfs2_iop_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
289289
return status;
290290
}
291291

292-
struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type)
292+
struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type, bool rcu)
293293
{
294294
struct ocfs2_super *osb;
295295
struct buffer_head *di_bh = NULL;
296296
struct posix_acl *acl;
297297
int had_lock;
298298
struct ocfs2_lock_holder oh;
299299

300+
if (rcu)
301+
return ERR_PTR(-ECHILD);
302+
300303
osb = OCFS2_SB(inode->i_sb);
301304
if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
302305
return NULL;

fs/ocfs2/acl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct ocfs2_acl_entry {
1616
__le32 e_id;
1717
};
1818

19-
struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type);
19+
struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type, bool rcu);
2020
int ocfs2_iop_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
2121
struct posix_acl *acl, int type);
2222
extern int ocfs2_acl_chmod(struct inode *, struct buffer_head *);

fs/orangefs/acl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@
1010
#include "orangefs-bufmap.h"
1111
#include <linux/posix_acl_xattr.h>
1212

13-
struct posix_acl *orangefs_get_acl(struct inode *inode, int type)
13+
struct posix_acl *orangefs_get_acl(struct inode *inode, int type, bool rcu)
1414
{
1515
struct posix_acl *acl;
1616
int ret;
1717
char *key = NULL, *value = NULL;
1818

19+
if (rcu)
20+
return ERR_PTR(-ECHILD);
21+
1922
switch (type) {
2023
case ACL_TYPE_ACCESS:
2124
key = XATTR_NAME_POSIX_ACL_ACCESS;

fs/orangefs/orangefs-kernel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ enum orangefs_vfs_op_states {
106106
extern int orangefs_init_acl(struct inode *inode, struct inode *dir);
107107
extern const struct xattr_handler *orangefs_xattr_handlers[];
108108

109-
extern struct posix_acl *orangefs_get_acl(struct inode *inode, int type);
109+
extern struct posix_acl *orangefs_get_acl(struct inode *inode, int type, bool rcu);
110110
extern int orangefs_set_acl(struct user_namespace *mnt_userns,
111111
struct inode *inode, struct posix_acl *acl,
112112
int type);

0 commit comments

Comments
 (0)