diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-27 20:14:05 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-27 20:14:05 -0400 |
commit | d102a56edba7a3f236454716fa09920e66772044 (patch) | |
tree | bfed5508d09028bbf180507b21b8ab25c6980eac | |
parent | 0121a32201dcc72933fb6019c41661e2f8a02fc5 (diff) | |
parent | 3767e255b390d72f9a33c08d9e86c5f21f25860f (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs fixes from Al Viro:
"Followups to the parallel lookup work:
- update docs
- restore killability of the places that used to take ->i_mutex
killably now that we have down_write_killable() merged
- Additionally, it turns out that I missed a prerequisite for
security_d_instantiate() stuff - ->getxattr() wasn't the only thing
that could be called before dentry is attached to inode; with smack
we needed the same treatment applied to ->setxattr() as well"
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
switch ->setxattr() to passing dentry and inode separately
switch xattr_handler->set() to passing dentry and inode separately
restore killability of old mutex_lock_killable(&inode->i_mutex) users
add down_write_killable_nested()
update D/f/directory-locking
58 files changed, 265 insertions, 209 deletions
diff --git a/Documentation/filesystems/directory-locking b/Documentation/filesystems/directory-locking index 09bbf9a54f80..c314badbcfc6 100644 --- a/Documentation/filesystems/directory-locking +++ b/Documentation/filesystems/directory-locking | |||
@@ -1,30 +1,37 @@ | |||
1 | Locking scheme used for directory operations is based on two | 1 | Locking scheme used for directory operations is based on two |
2 | kinds of locks - per-inode (->i_mutex) and per-filesystem | 2 | kinds of locks - per-inode (->i_rwsem) and per-filesystem |
3 | (->s_vfs_rename_mutex). | 3 | (->s_vfs_rename_mutex). |
4 | 4 | ||
5 | When taking the i_mutex on multiple non-directory objects, we | 5 | When taking the i_rwsem on multiple non-directory objects, we |
6 | always acquire the locks in order by increasing address. We'll call | 6 | always acquire the locks in order by increasing address. We'll call |
7 | that "inode pointer" order in the following. | 7 | that "inode pointer" order in the following. |
8 | 8 | ||
9 | For our purposes all operations fall in 5 classes: | 9 | For our purposes all operations fall in 5 classes: |
10 | 10 | ||
11 | 1) read access. Locking rules: caller locks directory we are accessing. | 11 | 1) read access. Locking rules: caller locks directory we are accessing. |
12 | The lock is taken shared. | ||
12 | 13 | ||
13 | 2) object creation. Locking rules: same as above. | 14 | 2) object creation. Locking rules: same as above, but the lock is taken |
15 | exclusive. | ||
14 | 16 | ||
15 | 3) object removal. Locking rules: caller locks parent, finds victim, | 17 | 3) object removal. Locking rules: caller locks parent, finds victim, |
16 | locks victim and calls the method. | 18 | locks victim and calls the method. Locks are exclusive. |
17 | 19 | ||
18 | 4) rename() that is _not_ cross-directory. Locking rules: caller locks | 20 | 4) rename() that is _not_ cross-directory. Locking rules: caller locks |
19 | the parent and finds source and target. If target already exists, lock | 21 | the parent and finds source and target. In case of exchange (with |
20 | it. If source is a non-directory, lock it. If that means we need to | 22 | RENAME_EXCHANGE in rename2() flags argument) lock both. In any case, |
21 | lock both, lock them in inode pointer order. | 23 | if the target already exists, lock it. If the source is a non-directory, |
24 | lock it. If we need to lock both, lock them in inode pointer order. | ||
25 | Then call the method. All locks are exclusive. | ||
26 | NB: we might get away with locking the the source (and target in exchange | ||
27 | case) shared. | ||
22 | 28 | ||
23 | 5) link creation. Locking rules: | 29 | 5) link creation. Locking rules: |
24 | * lock parent | 30 | * lock parent |
25 | * check that source is not a directory | 31 | * check that source is not a directory |
26 | * lock source | 32 | * lock source |
27 | * call the method. | 33 | * call the method. |
34 | All locks are exclusive. | ||
28 | 35 | ||
29 | 6) cross-directory rename. The trickiest in the whole bunch. Locking | 36 | 6) cross-directory rename. The trickiest in the whole bunch. Locking |
30 | rules: | 37 | rules: |
@@ -35,11 +42,12 @@ rules: | |||
35 | fail with -ENOTEMPTY | 42 | fail with -ENOTEMPTY |
36 | * if new parent is equal to or is a descendent of source | 43 | * if new parent is equal to or is a descendent of source |
37 | fail with -ELOOP | 44 | fail with -ELOOP |
38 | * If target exists, lock it. If source is a non-directory, lock | 45 | * If it's an exchange, lock both the source and the target. |
39 | it. In case that means we need to lock both source and target, | 46 | * If the target exists, lock it. If the source is a non-directory, |
40 | do so in inode pointer order. | 47 | lock it. If we need to lock both, do so in inode pointer order. |
41 | * call the method. | 48 | * call the method. |
42 | 49 | All ->i_rwsem are taken exclusive. Again, we might get away with locking | |
50 | the the source (and target in exchange case) shared. | ||
43 | 51 | ||
44 | The rules above obviously guarantee that all directories that are going to be | 52 | The rules above obviously guarantee that all directories that are going to be |
45 | read, modified or removed by method will be locked by caller. | 53 | read, modified or removed by method will be locked by caller. |
@@ -73,7 +81,7 @@ objects - A < B iff A is an ancestor of B. | |||
73 | attempt to acquire some lock and already holds at least one lock. Let's | 81 | attempt to acquire some lock and already holds at least one lock. Let's |
74 | consider the set of contended locks. First of all, filesystem lock is | 82 | consider the set of contended locks. First of all, filesystem lock is |
75 | not contended, since any process blocked on it is not holding any locks. | 83 | not contended, since any process blocked on it is not holding any locks. |
76 | Thus all processes are blocked on ->i_mutex. | 84 | Thus all processes are blocked on ->i_rwsem. |
77 | 85 | ||
78 | By (3), any process holding a non-directory lock can only be | 86 | By (3), any process holding a non-directory lock can only be |
79 | waiting on another non-directory lock with a larger address. Therefore | 87 | waiting on another non-directory lock with a larger address. Therefore |
diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting index 46f3bb7a02f5..a5fb89cac615 100644 --- a/Documentation/filesystems/porting +++ b/Documentation/filesystems/porting | |||
@@ -578,3 +578,10 @@ in your dentry operations instead. | |||
578 | -- | 578 | -- |
579 | [mandatory] | 579 | [mandatory] |
580 | ->atomic_open() calls without O_CREAT may happen in parallel. | 580 | ->atomic_open() calls without O_CREAT may happen in parallel. |
581 | -- | ||
582 | [mandatory] | ||
583 | ->setxattr() and xattr_handler.set() get dentry and inode passed separately. | ||
584 | dentry might be yet to be attached to inode, so do _not_ use its ->d_inode | ||
585 | in the instances. Rationale: !@#!@# security_d_instantiate() needs to be | ||
586 | called before we attach dentry to inode and !@#!@##!@$!$#!@#$!@$!@$ smack | ||
587 | ->d_instantiate() uses not just ->getxattr() but ->setxattr() as well. | ||
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index ce1f949430f1..3f2f30b6542c 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h | |||
@@ -976,8 +976,8 @@ static inline __u64 ll_file_maxbytes(struct inode *inode) | |||
976 | } | 976 | } |
977 | 977 | ||
978 | /* llite/xattr.c */ | 978 | /* llite/xattr.c */ |
979 | int ll_setxattr(struct dentry *dentry, const char *name, | 979 | int ll_setxattr(struct dentry *dentry, struct inode *inode, |
980 | const void *value, size_t size, int flags); | 980 | const char *name, const void *value, size_t size, int flags); |
981 | ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode, | 981 | ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode, |
982 | const char *name, void *buffer, size_t size); | 982 | const char *name, void *buffer, size_t size); |
983 | ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size); | 983 | ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size); |
diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index ed4de04381c3..608014b0dbcd 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c | |||
@@ -211,11 +211,9 @@ int ll_setxattr_common(struct inode *inode, const char *name, | |||
211 | return 0; | 211 | return 0; |
212 | } | 212 | } |
213 | 213 | ||
214 | int ll_setxattr(struct dentry *dentry, const char *name, | 214 | int ll_setxattr(struct dentry *dentry, struct inode *inode, |
215 | const void *value, size_t size, int flags) | 215 | const char *name, const void *value, size_t size, int flags) |
216 | { | 216 | { |
217 | struct inode *inode = d_inode(dentry); | ||
218 | |||
219 | LASSERT(inode); | 217 | LASSERT(inode); |
220 | LASSERT(name); | 218 | LASSERT(name); |
221 | 219 | ||
diff --git a/fs/9p/acl.c b/fs/9p/acl.c index eb3589edf485..0576eaeb60b9 100644 --- a/fs/9p/acl.c +++ b/fs/9p/acl.c | |||
@@ -239,13 +239,13 @@ static int v9fs_xattr_get_acl(const struct xattr_handler *handler, | |||
239 | } | 239 | } |
240 | 240 | ||
241 | static int v9fs_xattr_set_acl(const struct xattr_handler *handler, | 241 | static int v9fs_xattr_set_acl(const struct xattr_handler *handler, |
242 | struct dentry *dentry, const char *name, | 242 | struct dentry *dentry, struct inode *inode, |
243 | const void *value, size_t size, int flags) | 243 | const char *name, const void *value, |
244 | size_t size, int flags) | ||
244 | { | 245 | { |
245 | int retval; | 246 | int retval; |
246 | struct posix_acl *acl; | 247 | struct posix_acl *acl; |
247 | struct v9fs_session_info *v9ses; | 248 | struct v9fs_session_info *v9ses; |
248 | struct inode *inode = d_inode(dentry); | ||
249 | 249 | ||
250 | v9ses = v9fs_dentry2v9ses(dentry); | 250 | v9ses = v9fs_dentry2v9ses(dentry); |
251 | /* | 251 | /* |
diff --git a/fs/9p/xattr.c b/fs/9p/xattr.c index 18c62bae9591..a6bd349bab23 100644 --- a/fs/9p/xattr.c +++ b/fs/9p/xattr.c | |||
@@ -147,8 +147,9 @@ static int v9fs_xattr_handler_get(const struct xattr_handler *handler, | |||
147 | } | 147 | } |
148 | 148 | ||
149 | static int v9fs_xattr_handler_set(const struct xattr_handler *handler, | 149 | static int v9fs_xattr_handler_set(const struct xattr_handler *handler, |
150 | struct dentry *dentry, const char *name, | 150 | struct dentry *dentry, struct inode *inode, |
151 | const void *value, size_t size, int flags) | 151 | const char *name, const void *value, |
152 | size_t size, int flags) | ||
152 | { | 153 | { |
153 | const char *full_name = xattr_full_name(handler, name); | 154 | const char *full_name = xattr_full_name(handler, name); |
154 | 155 | ||
diff --git a/fs/bad_inode.c b/fs/bad_inode.c index 72e35b721608..3ba385eaa26e 100644 --- a/fs/bad_inode.c +++ b/fs/bad_inode.c | |||
@@ -100,8 +100,8 @@ static int bad_inode_setattr(struct dentry *direntry, struct iattr *attrs) | |||
100 | return -EIO; | 100 | return -EIO; |
101 | } | 101 | } |
102 | 102 | ||
103 | static int bad_inode_setxattr(struct dentry *dentry, const char *name, | 103 | static int bad_inode_setxattr(struct dentry *dentry, struct inode *inode, |
104 | const void *value, size_t size, int flags) | 104 | const char *name, const void *value, size_t size, int flags) |
105 | { | 105 | { |
106 | return -EIO; | 106 | return -EIO; |
107 | } | 107 | } |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 001c111e5627..05173563e4a6 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -846,11 +846,9 @@ static noinline int btrfs_mksubvol(struct path *parent, | |||
846 | struct dentry *dentry; | 846 | struct dentry *dentry; |
847 | int error; | 847 | int error; |
848 | 848 | ||
849 | inode_lock_nested(dir, I_MUTEX_PARENT); | 849 | error = down_write_killable_nested(&dir->i_rwsem, I_MUTEX_PARENT); |
850 | // XXX: should've been | 850 | if (error == -EINTR) |
851 | // mutex_lock_killable_nested(&dir->i_mutex, I_MUTEX_PARENT); | 851 | return error; |
852 | // if (error == -EINTR) | ||
853 | // return error; | ||
854 | 852 | ||
855 | dentry = lookup_one_len(name, parent->dentry, namelen); | 853 | dentry = lookup_one_len(name, parent->dentry, namelen); |
856 | error = PTR_ERR(dentry); | 854 | error = PTR_ERR(dentry); |
@@ -2377,11 +2375,9 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, | |||
2377 | goto out; | 2375 | goto out; |
2378 | 2376 | ||
2379 | 2377 | ||
2380 | inode_lock_nested(dir, I_MUTEX_PARENT); | 2378 | err = down_write_killable_nested(&dir->i_rwsem, I_MUTEX_PARENT); |
2381 | // XXX: should've been | 2379 | if (err == -EINTR) |
2382 | // err = mutex_lock_killable_nested(&dir->i_mutex, I_MUTEX_PARENT); | 2380 | goto out_drop_write; |
2383 | // if (err == -EINTR) | ||
2384 | // goto out_drop_write; | ||
2385 | dentry = lookup_one_len(vol_args->name, parent, namelen); | 2381 | dentry = lookup_one_len(vol_args->name, parent, namelen); |
2386 | if (IS_ERR(dentry)) { | 2382 | if (IS_ERR(dentry)) { |
2387 | err = PTR_ERR(dentry); | 2383 | err = PTR_ERR(dentry); |
@@ -2571,7 +2567,7 @@ out_dput: | |||
2571 | dput(dentry); | 2567 | dput(dentry); |
2572 | out_unlock_dir: | 2568 | out_unlock_dir: |
2573 | inode_unlock(dir); | 2569 | inode_unlock(dir); |
2574 | //out_drop_write: | 2570 | out_drop_write: |
2575 | mnt_drop_write_file(file); | 2571 | mnt_drop_write_file(file); |
2576 | out: | 2572 | out: |
2577 | kfree(vol_args); | 2573 | kfree(vol_args); |
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index 3bfb252206c7..d1a177a3dbe8 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c | |||
@@ -380,23 +380,21 @@ static int btrfs_xattr_handler_get(const struct xattr_handler *handler, | |||
380 | } | 380 | } |
381 | 381 | ||
382 | static int btrfs_xattr_handler_set(const struct xattr_handler *handler, | 382 | static int btrfs_xattr_handler_set(const struct xattr_handler *handler, |
383 | struct dentry *dentry, const char *name, | 383 | struct dentry *unused, struct inode *inode, |
384 | const void *buffer, size_t size, | 384 | const char *name, const void *buffer, |
385 | int flags) | 385 | size_t size, int flags) |
386 | { | 386 | { |
387 | struct inode *inode = d_inode(dentry); | ||
388 | |||
389 | name = xattr_full_name(handler, name); | 387 | name = xattr_full_name(handler, name); |
390 | return __btrfs_setxattr(NULL, inode, name, buffer, size, flags); | 388 | return __btrfs_setxattr(NULL, inode, name, buffer, size, flags); |
391 | } | 389 | } |
392 | 390 | ||
393 | static int btrfs_xattr_handler_set_prop(const struct xattr_handler *handler, | 391 | static int btrfs_xattr_handler_set_prop(const struct xattr_handler *handler, |
394 | struct dentry *dentry, | 392 | struct dentry *unused, struct inode *inode, |
395 | const char *name, const void *value, | 393 | const char *name, const void *value, |
396 | size_t size, int flags) | 394 | size_t size, int flags) |
397 | { | 395 | { |
398 | name = xattr_full_name(handler, name); | 396 | name = xattr_full_name(handler, name); |
399 | return btrfs_set_prop(d_inode(dentry), name, value, size, flags); | 397 | return btrfs_set_prop(inode, name, value, size, flags); |
400 | } | 398 | } |
401 | 399 | ||
402 | static const struct xattr_handler btrfs_security_xattr_handler = { | 400 | static const struct xattr_handler btrfs_security_xattr_handler = { |
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index dacc1bd85629..4870b29df224 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c | |||
@@ -1056,12 +1056,13 @@ static int ceph_get_xattr_handler(const struct xattr_handler *handler, | |||
1056 | } | 1056 | } |
1057 | 1057 | ||
1058 | static int ceph_set_xattr_handler(const struct xattr_handler *handler, | 1058 | static int ceph_set_xattr_handler(const struct xattr_handler *handler, |
1059 | struct dentry *dentry, const char *name, | 1059 | struct dentry *unused, struct inode *inode, |
1060 | const void *value, size_t size, int flags) | 1060 | const char *name, const void *value, |
1061 | size_t size, int flags) | ||
1061 | { | 1062 | { |
1062 | if (!ceph_is_valid_xattr(name)) | 1063 | if (!ceph_is_valid_xattr(name)) |
1063 | return -EOPNOTSUPP; | 1064 | return -EOPNOTSUPP; |
1064 | return __ceph_setxattr(d_inode(dentry), name, value, size, flags); | 1065 | return __ceph_setxattr(inode, name, value, size, flags); |
1065 | } | 1066 | } |
1066 | 1067 | ||
1067 | const struct xattr_handler ceph_other_xattr_handler = { | 1068 | const struct xattr_handler ceph_other_xattr_handler = { |
diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c index c8b77aa24a1d..5e23f64c0804 100644 --- a/fs/cifs/xattr.c +++ b/fs/cifs/xattr.c | |||
@@ -39,8 +39,9 @@ | |||
39 | enum { XATTR_USER, XATTR_CIFS_ACL, XATTR_ACL_ACCESS, XATTR_ACL_DEFAULT }; | 39 | enum { XATTR_USER, XATTR_CIFS_ACL, XATTR_ACL_ACCESS, XATTR_ACL_DEFAULT }; |
40 | 40 | ||
41 | static int cifs_xattr_set(const struct xattr_handler *handler, | 41 | static int cifs_xattr_set(const struct xattr_handler *handler, |
42 | struct dentry *dentry, const char *name, | 42 | struct dentry *dentry, struct inode *inode, |
43 | const void *value, size_t size, int flags) | 43 | const char *name, const void *value, |
44 | size_t size, int flags) | ||
44 | { | 45 | { |
45 | int rc = -EOPNOTSUPP; | 46 | int rc = -EOPNOTSUPP; |
46 | unsigned int xid; | 47 | unsigned int xid; |
@@ -99,12 +100,12 @@ static int cifs_xattr_set(const struct xattr_handler *handler, | |||
99 | if (value && | 100 | if (value && |
100 | pTcon->ses->server->ops->set_acl) | 101 | pTcon->ses->server->ops->set_acl) |
101 | rc = pTcon->ses->server->ops->set_acl(pacl, | 102 | rc = pTcon->ses->server->ops->set_acl(pacl, |
102 | size, d_inode(dentry), | 103 | size, inode, |
103 | full_path, CIFS_ACL_DACL); | 104 | full_path, CIFS_ACL_DACL); |
104 | else | 105 | else |
105 | rc = -EOPNOTSUPP; | 106 | rc = -EOPNOTSUPP; |
106 | if (rc == 0) /* force revalidate of the inode */ | 107 | if (rc == 0) /* force revalidate of the inode */ |
107 | CIFS_I(d_inode(dentry))->time = 0; | 108 | CIFS_I(inode)->time = 0; |
108 | kfree(pacl); | 109 | kfree(pacl); |
109 | } | 110 | } |
110 | #endif /* CONFIG_CIFS_ACL */ | 111 | #endif /* CONFIG_CIFS_ACL */ |
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index ebd40f46ed4c..0d8eb3455b34 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c | |||
@@ -1141,12 +1141,13 @@ ecryptfs_write_metadata_to_contents(struct inode *ecryptfs_inode, | |||
1141 | 1141 | ||
1142 | static int | 1142 | static int |
1143 | ecryptfs_write_metadata_to_xattr(struct dentry *ecryptfs_dentry, | 1143 | ecryptfs_write_metadata_to_xattr(struct dentry *ecryptfs_dentry, |
1144 | struct inode *ecryptfs_inode, | ||
1144 | char *page_virt, size_t size) | 1145 | char *page_virt, size_t size) |
1145 | { | 1146 | { |
1146 | int rc; | 1147 | int rc; |
1147 | 1148 | ||
1148 | rc = ecryptfs_setxattr(ecryptfs_dentry, ECRYPTFS_XATTR_NAME, page_virt, | 1149 | rc = ecryptfs_setxattr(ecryptfs_dentry, ecryptfs_inode, |
1149 | size, 0); | 1150 | ECRYPTFS_XATTR_NAME, page_virt, size, 0); |
1150 | return rc; | 1151 | return rc; |
1151 | } | 1152 | } |
1152 | 1153 | ||
@@ -1215,8 +1216,8 @@ int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry, | |||
1215 | goto out_free; | 1216 | goto out_free; |
1216 | } | 1217 | } |
1217 | if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) | 1218 | if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) |
1218 | rc = ecryptfs_write_metadata_to_xattr(ecryptfs_dentry, virt, | 1219 | rc = ecryptfs_write_metadata_to_xattr(ecryptfs_dentry, ecryptfs_inode, |
1219 | size); | 1220 | virt, size); |
1220 | else | 1221 | else |
1221 | rc = ecryptfs_write_metadata_to_contents(ecryptfs_inode, virt, | 1222 | rc = ecryptfs_write_metadata_to_contents(ecryptfs_inode, virt, |
1222 | virt_len); | 1223 | virt_len); |
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h index 3ec495db7e82..4ba1547bb9ad 100644 --- a/fs/ecryptfs/ecryptfs_kernel.h +++ b/fs/ecryptfs/ecryptfs_kernel.h | |||
@@ -609,8 +609,8 @@ ssize_t | |||
609 | ecryptfs_getxattr_lower(struct dentry *lower_dentry, struct inode *lower_inode, | 609 | ecryptfs_getxattr_lower(struct dentry *lower_dentry, struct inode *lower_inode, |
610 | const char *name, void *value, size_t size); | 610 | const char *name, void *value, size_t size); |
611 | int | 611 | int |
612 | ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, | 612 | ecryptfs_setxattr(struct dentry *dentry, struct inode *inode, const char *name, |
613 | size_t size, int flags); | 613 | const void *value, size_t size, int flags); |
614 | int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode); | 614 | int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode); |
615 | #ifdef CONFIG_ECRYPT_FS_MESSAGING | 615 | #ifdef CONFIG_ECRYPT_FS_MESSAGING |
616 | int ecryptfs_process_response(struct ecryptfs_daemon *daemon, | 616 | int ecryptfs_process_response(struct ecryptfs_daemon *daemon, |
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 318b04689d76..9d153b6a1d72 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -1001,7 +1001,8 @@ static int ecryptfs_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | int | 1003 | int |
1004 | ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, | 1004 | ecryptfs_setxattr(struct dentry *dentry, struct inode *inode, |
1005 | const char *name, const void *value, | ||
1005 | size_t size, int flags) | 1006 | size_t size, int flags) |
1006 | { | 1007 | { |
1007 | int rc = 0; | 1008 | int rc = 0; |
@@ -1014,8 +1015,8 @@ ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, | |||
1014 | } | 1015 | } |
1015 | 1016 | ||
1016 | rc = vfs_setxattr(lower_dentry, name, value, size, flags); | 1017 | rc = vfs_setxattr(lower_dentry, name, value, size, flags); |
1017 | if (!rc && d_really_is_positive(dentry)) | 1018 | if (!rc && inode) |
1018 | fsstack_copy_attr_all(d_inode(dentry), d_inode(lower_dentry)); | 1019 | fsstack_copy_attr_all(inode, d_inode(lower_dentry)); |
1019 | out: | 1020 | out: |
1020 | return rc; | 1021 | return rc; |
1021 | } | 1022 | } |
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c index 148d11b514fb..9c3437c8a5b1 100644 --- a/fs/ecryptfs/mmap.c +++ b/fs/ecryptfs/mmap.c | |||
@@ -442,7 +442,8 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode) | |||
442 | if (size < 0) | 442 | if (size < 0) |
443 | size = 8; | 443 | size = 8; |
444 | put_unaligned_be64(i_size_read(ecryptfs_inode), xattr_virt); | 444 | put_unaligned_be64(i_size_read(ecryptfs_inode), xattr_virt); |
445 | rc = lower_inode->i_op->setxattr(lower_dentry, ECRYPTFS_XATTR_NAME, | 445 | rc = lower_inode->i_op->setxattr(lower_dentry, lower_inode, |
446 | ECRYPTFS_XATTR_NAME, | ||
446 | xattr_virt, size, 0); | 447 | xattr_virt, size, 0); |
447 | inode_unlock(lower_inode); | 448 | inode_unlock(lower_inode); |
448 | if (rc) | 449 | if (rc) |
diff --git a/fs/ext2/xattr_security.c b/fs/ext2/xattr_security.c index 7fd3b867ce65..7b9e9c1842d5 100644 --- a/fs/ext2/xattr_security.c +++ b/fs/ext2/xattr_security.c | |||
@@ -18,10 +18,11 @@ ext2_xattr_security_get(const struct xattr_handler *handler, | |||
18 | 18 | ||
19 | static int | 19 | static int |
20 | ext2_xattr_security_set(const struct xattr_handler *handler, | 20 | ext2_xattr_security_set(const struct xattr_handler *handler, |
21 | struct dentry *dentry, const char *name, | 21 | struct dentry *unused, struct inode *inode, |
22 | const void *value, size_t size, int flags) | 22 | const char *name, const void *value, |
23 | size_t size, int flags) | ||
23 | { | 24 | { |
24 | return ext2_xattr_set(d_inode(dentry), EXT2_XATTR_INDEX_SECURITY, name, | 25 | return ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY, name, |
25 | value, size, flags); | 26 | value, size, flags); |
26 | } | 27 | } |
27 | 28 | ||
diff --git a/fs/ext2/xattr_trusted.c b/fs/ext2/xattr_trusted.c index 0f85705ff519..65049b71af13 100644 --- a/fs/ext2/xattr_trusted.c +++ b/fs/ext2/xattr_trusted.c | |||
@@ -25,10 +25,11 @@ ext2_xattr_trusted_get(const struct xattr_handler *handler, | |||
25 | 25 | ||
26 | static int | 26 | static int |
27 | ext2_xattr_trusted_set(const struct xattr_handler *handler, | 27 | ext2_xattr_trusted_set(const struct xattr_handler *handler, |
28 | struct dentry *dentry, const char *name, | 28 | struct dentry *unused, struct inode *inode, |
29 | const void *value, size_t size, int flags) | 29 | const char *name, const void *value, |
30 | size_t size, int flags) | ||
30 | { | 31 | { |
31 | return ext2_xattr_set(d_inode(dentry), EXT2_XATTR_INDEX_TRUSTED, name, | 32 | return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name, |
32 | value, size, flags); | 33 | value, size, flags); |
33 | } | 34 | } |
34 | 35 | ||
diff --git a/fs/ext2/xattr_user.c b/fs/ext2/xattr_user.c index 1fafd27037cc..fb2f992ae763 100644 --- a/fs/ext2/xattr_user.c +++ b/fs/ext2/xattr_user.c | |||
@@ -29,13 +29,14 @@ ext2_xattr_user_get(const struct xattr_handler *handler, | |||
29 | 29 | ||
30 | static int | 30 | static int |
31 | ext2_xattr_user_set(const struct xattr_handler *handler, | 31 | ext2_xattr_user_set(const struct xattr_handler *handler, |
32 | struct dentry *dentry, const char *name, | 32 | struct dentry *unused, struct inode *inode, |
33 | const void *value, size_t size, int flags) | 33 | const char *name, const void *value, |
34 | size_t size, int flags) | ||
34 | { | 35 | { |
35 | if (!test_opt(dentry->d_sb, XATTR_USER)) | 36 | if (!test_opt(inode->i_sb, XATTR_USER)) |
36 | return -EOPNOTSUPP; | 37 | return -EOPNOTSUPP; |
37 | 38 | ||
38 | return ext2_xattr_set(d_inode(dentry), EXT2_XATTR_INDEX_USER, | 39 | return ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER, |
39 | name, value, size, flags); | 40 | name, value, size, flags); |
40 | } | 41 | } |
41 | 42 | ||
diff --git a/fs/ext4/xattr_security.c b/fs/ext4/xattr_security.c index 123a7d010efe..a8921112030d 100644 --- a/fs/ext4/xattr_security.c +++ b/fs/ext4/xattr_security.c | |||
@@ -22,10 +22,11 @@ ext4_xattr_security_get(const struct xattr_handler *handler, | |||
22 | 22 | ||
23 | static int | 23 | static int |
24 | ext4_xattr_security_set(const struct xattr_handler *handler, | 24 | ext4_xattr_security_set(const struct xattr_handler *handler, |
25 | struct dentry *dentry, const char *name, | 25 | struct dentry *unused, struct inode *inode, |
26 | const void *value, size_t size, int flags) | 26 | const char *name, const void *value, |
27 | size_t size, int flags) | ||
27 | { | 28 | { |
28 | return ext4_xattr_set(d_inode(dentry), EXT4_XATTR_INDEX_SECURITY, | 29 | return ext4_xattr_set(inode, EXT4_XATTR_INDEX_SECURITY, |
29 | name, value, size, flags); | 30 | name, value, size, flags); |
30 | } | 31 | } |
31 | 32 | ||
diff --git a/fs/ext4/xattr_trusted.c b/fs/ext4/xattr_trusted.c index 60652fa24cbc..c7765c735714 100644 --- a/fs/ext4/xattr_trusted.c +++ b/fs/ext4/xattr_trusted.c | |||
@@ -29,10 +29,11 @@ ext4_xattr_trusted_get(const struct xattr_handler *handler, | |||
29 | 29 | ||
30 | static int | 30 | static int |
31 | ext4_xattr_trusted_set(const struct xattr_handler *handler, | 31 | ext4_xattr_trusted_set(const struct xattr_handler *handler, |
32 | struct dentry *dentry, const char *name, | 32 | struct dentry *unused, struct inode *inode, |
33 | const void *value, size_t size, int flags) | 33 | const char *name, const void *value, |
34 | size_t size, int flags) | ||
34 | { | 35 | { |
35 | return ext4_xattr_set(d_inode(dentry), EXT4_XATTR_INDEX_TRUSTED, | 36 | return ext4_xattr_set(inode, EXT4_XATTR_INDEX_TRUSTED, |
36 | name, value, size, flags); | 37 | name, value, size, flags); |
37 | } | 38 | } |
38 | 39 | ||
diff --git a/fs/ext4/xattr_user.c b/fs/ext4/xattr_user.c index 17a446ffecd3..ca20e423034b 100644 --- a/fs/ext4/xattr_user.c +++ b/fs/ext4/xattr_user.c | |||
@@ -30,12 +30,13 @@ ext4_xattr_user_get(const struct xattr_handler *handler, | |||
30 | 30 | ||
31 | static int | 31 | static int |
32 | ext4_xattr_user_set(const struct xattr_handler *handler, | 32 | ext4_xattr_user_set(const struct xattr_handler *handler, |
33 | struct dentry *dentry, const char *name, | 33 | struct dentry *unused, struct inode *inode, |
34 | const void *value, size_t size, int flags) | 34 | const char *name, const void *value, |
35 | size_t size, int flags) | ||
35 | { | 36 | { |
36 | if (!test_opt(dentry->d_sb, XATTR_USER)) | 37 | if (!test_opt(inode->i_sb, XATTR_USER)) |
37 | return -EOPNOTSUPP; | 38 | return -EOPNOTSUPP; |
38 | return ext4_xattr_set(d_inode(dentry), EXT4_XATTR_INDEX_USER, | 39 | return ext4_xattr_set(inode, EXT4_XATTR_INDEX_USER, |
39 | name, value, size, flags); | 40 | name, value, size, flags); |
40 | } | 41 | } |
41 | 42 | ||
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c index 00ea56797258..e3decae3acfb 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c | |||
@@ -50,10 +50,11 @@ static int f2fs_xattr_generic_get(const struct xattr_handler *handler, | |||
50 | } | 50 | } |
51 | 51 | ||
52 | static int f2fs_xattr_generic_set(const struct xattr_handler *handler, | 52 | static int f2fs_xattr_generic_set(const struct xattr_handler *handler, |
53 | struct dentry *dentry, const char *name, const void *value, | 53 | struct dentry *unused, struct inode *inode, |
54 | const char *name, const void *value, | ||
54 | size_t size, int flags) | 55 | size_t size, int flags) |
55 | { | 56 | { |
56 | struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb); | 57 | struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); |
57 | 58 | ||
58 | switch (handler->flags) { | 59 | switch (handler->flags) { |
59 | case F2FS_XATTR_INDEX_USER: | 60 | case F2FS_XATTR_INDEX_USER: |
@@ -69,7 +70,7 @@ static int f2fs_xattr_generic_set(const struct xattr_handler *handler, | |||
69 | default: | 70 | default: |
70 | return -EINVAL; | 71 | return -EINVAL; |
71 | } | 72 | } |
72 | return f2fs_setxattr(d_inode(dentry), handler->flags, name, | 73 | return f2fs_setxattr(inode, handler->flags, name, |
73 | value, size, NULL, flags); | 74 | value, size, NULL, flags); |
74 | } | 75 | } |
75 | 76 | ||
@@ -95,11 +96,10 @@ static int f2fs_xattr_advise_get(const struct xattr_handler *handler, | |||
95 | } | 96 | } |
96 | 97 | ||
97 | static int f2fs_xattr_advise_set(const struct xattr_handler *handler, | 98 | static int f2fs_xattr_advise_set(const struct xattr_handler *handler, |
98 | struct dentry *dentry, const char *name, const void *value, | 99 | struct dentry *unused, struct inode *inode, |
100 | const char *name, const void *value, | ||
99 | size_t size, int flags) | 101 | size_t size, int flags) |
100 | { | 102 | { |
101 | struct inode *inode = d_inode(dentry); | ||
102 | |||
103 | if (!inode_owner_or_capable(inode)) | 103 | if (!inode_owner_or_capable(inode)) |
104 | return -EPERM; | 104 | return -EPERM; |
105 | if (value == NULL) | 105 | if (value == NULL) |
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index b9419058108f..ccd4971cc6c1 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -1719,10 +1719,10 @@ static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry, | |||
1719 | return fuse_update_attributes(inode, stat, NULL, NULL); | 1719 | return fuse_update_attributes(inode, stat, NULL, NULL); |
1720 | } | 1720 | } |
1721 | 1721 | ||
1722 | static int fuse_setxattr(struct dentry *entry, const char *name, | 1722 | static int fuse_setxattr(struct dentry *unused, struct inode *inode, |
1723 | const void *value, size_t size, int flags) | 1723 | const char *name, const void *value, |
1724 | size_t size, int flags) | ||
1724 | { | 1725 | { |
1725 | struct inode *inode = d_inode(entry); | ||
1726 | struct fuse_conn *fc = get_fuse_conn(inode); | 1726 | struct fuse_conn *fc = get_fuse_conn(inode); |
1727 | FUSE_ARGS(args); | 1727 | FUSE_ARGS(args); |
1728 | struct fuse_setxattr_in inarg; | 1728 | struct fuse_setxattr_in inarg; |
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c index f42ab53bd30d..3a2853504084 100644 --- a/fs/gfs2/xattr.c +++ b/fs/gfs2/xattr.c | |||
@@ -1251,10 +1251,10 @@ int __gfs2_xattr_set(struct inode *inode, const char *name, | |||
1251 | } | 1251 | } |
1252 | 1252 | ||
1253 | static int gfs2_xattr_set(const struct xattr_handler *handler, | 1253 | static int gfs2_xattr_set(const struct xattr_handler *handler, |
1254 | struct dentry *dentry, const char *name, | 1254 | struct dentry *unused, struct inode *inode, |
1255 | const void *value, size_t size, int flags) | 1255 | const char *name, const void *value, |
1256 | size_t size, int flags) | ||
1256 | { | 1257 | { |
1257 | struct inode *inode = d_inode(dentry); | ||
1258 | struct gfs2_inode *ip = GFS2_I(inode); | 1258 | struct gfs2_inode *ip = GFS2_I(inode); |
1259 | struct gfs2_holder gh; | 1259 | struct gfs2_holder gh; |
1260 | int ret; | 1260 | int ret; |
diff --git a/fs/hfs/attr.c b/fs/hfs/attr.c index 064f92f17efc..d9a86919fdf6 100644 --- a/fs/hfs/attr.c +++ b/fs/hfs/attr.c | |||
@@ -13,10 +13,10 @@ | |||
13 | #include "hfs_fs.h" | 13 | #include "hfs_fs.h" |
14 | #include "btree.h" | 14 | #include "btree.h" |
15 | 15 | ||
16 | int hfs_setxattr(struct dentry *dentry, const char *name, | 16 | int hfs_setxattr(struct dentry *unused, struct inode *inode, |
17 | const void *value, size_t size, int flags) | 17 | const char *name, const void *value, |
18 | size_t size, int flags) | ||
18 | { | 19 | { |
19 | struct inode *inode = d_inode(dentry); | ||
20 | struct hfs_find_data fd; | 20 | struct hfs_find_data fd; |
21 | hfs_cat_rec rec; | 21 | hfs_cat_rec rec; |
22 | struct hfs_cat_file *file; | 22 | struct hfs_cat_file *file; |
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h index fa3eed86837c..ee2f385811c8 100644 --- a/fs/hfs/hfs_fs.h +++ b/fs/hfs/hfs_fs.h | |||
@@ -212,7 +212,7 @@ extern void hfs_evict_inode(struct inode *); | |||
212 | extern void hfs_delete_inode(struct inode *); | 212 | extern void hfs_delete_inode(struct inode *); |
213 | 213 | ||
214 | /* attr.c */ | 214 | /* attr.c */ |
215 | extern int hfs_setxattr(struct dentry *dentry, const char *name, | 215 | extern int hfs_setxattr(struct dentry *dentry, struct inode *inode, const char *name, |
216 | const void *value, size_t size, int flags); | 216 | const void *value, size_t size, int flags); |
217 | extern ssize_t hfs_getxattr(struct dentry *dentry, struct inode *inode, | 217 | extern ssize_t hfs_getxattr(struct dentry *dentry, struct inode *inode, |
218 | const char *name, void *value, size_t size); | 218 | const char *name, void *value, size_t size); |
diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c index 4f118d282a7a..d37bb88dc746 100644 --- a/fs/hfsplus/xattr.c +++ b/fs/hfsplus/xattr.c | |||
@@ -424,7 +424,7 @@ static int copy_name(char *buffer, const char *xattr_name, int name_len) | |||
424 | return len; | 424 | return len; |
425 | } | 425 | } |
426 | 426 | ||
427 | int hfsplus_setxattr(struct dentry *dentry, const char *name, | 427 | int hfsplus_setxattr(struct inode *inode, const char *name, |
428 | const void *value, size_t size, int flags, | 428 | const void *value, size_t size, int flags, |
429 | const char *prefix, size_t prefixlen) | 429 | const char *prefix, size_t prefixlen) |
430 | { | 430 | { |
@@ -437,8 +437,7 @@ int hfsplus_setxattr(struct dentry *dentry, const char *name, | |||
437 | return -ENOMEM; | 437 | return -ENOMEM; |
438 | strcpy(xattr_name, prefix); | 438 | strcpy(xattr_name, prefix); |
439 | strcpy(xattr_name + prefixlen, name); | 439 | strcpy(xattr_name + prefixlen, name); |
440 | res = __hfsplus_setxattr(d_inode(dentry), xattr_name, value, size, | 440 | res = __hfsplus_setxattr(inode, xattr_name, value, size, flags); |
441 | flags); | ||
442 | kfree(xattr_name); | 441 | kfree(xattr_name); |
443 | return res; | 442 | return res; |
444 | } | 443 | } |
@@ -864,8 +863,9 @@ static int hfsplus_osx_getxattr(const struct xattr_handler *handler, | |||
864 | } | 863 | } |
865 | 864 | ||
866 | static int hfsplus_osx_setxattr(const struct xattr_handler *handler, | 865 | static int hfsplus_osx_setxattr(const struct xattr_handler *handler, |
867 | struct dentry *dentry, const char *name, | 866 | struct dentry *unused, struct inode *inode, |
868 | const void *buffer, size_t size, int flags) | 867 | const char *name, const void *buffer, |
868 | size_t size, int flags) | ||
869 | { | 869 | { |
870 | /* | 870 | /* |
871 | * Don't allow setting properly prefixed attributes | 871 | * Don't allow setting properly prefixed attributes |
@@ -880,7 +880,7 @@ static int hfsplus_osx_setxattr(const struct xattr_handler *handler, | |||
880 | * creates), so we pass the name through unmodified (after | 880 | * creates), so we pass the name through unmodified (after |
881 | * ensuring it doesn't conflict with another namespace). | 881 | * ensuring it doesn't conflict with another namespace). |
882 | */ | 882 | */ |
883 | return __hfsplus_setxattr(d_inode(dentry), name, buffer, size, flags); | 883 | return __hfsplus_setxattr(inode, name, buffer, size, flags); |
884 | } | 884 | } |
885 | 885 | ||
886 | const struct xattr_handler hfsplus_xattr_osx_handler = { | 886 | const struct xattr_handler hfsplus_xattr_osx_handler = { |
diff --git a/fs/hfsplus/xattr.h b/fs/hfsplus/xattr.h index d04ba6f58df2..68f6b539371f 100644 --- a/fs/hfsplus/xattr.h +++ b/fs/hfsplus/xattr.h | |||
@@ -21,7 +21,7 @@ extern const struct xattr_handler *hfsplus_xattr_handlers[]; | |||
21 | int __hfsplus_setxattr(struct inode *inode, const char *name, | 21 | int __hfsplus_setxattr(struct inode *inode, const char *name, |
22 | const void *value, size_t size, int flags); | 22 | const void *value, size_t size, int flags); |
23 | 23 | ||
24 | int hfsplus_setxattr(struct dentry *dentry, const char *name, | 24 | int hfsplus_setxattr(struct inode *inode, const char *name, |
25 | const void *value, size_t size, int flags, | 25 | const void *value, size_t size, int flags, |
26 | const char *prefix, size_t prefixlen); | 26 | const char *prefix, size_t prefixlen); |
27 | 27 | ||
diff --git a/fs/hfsplus/xattr_security.c b/fs/hfsplus/xattr_security.c index ae2ca8c2e335..37b3efa733ef 100644 --- a/fs/hfsplus/xattr_security.c +++ b/fs/hfsplus/xattr_security.c | |||
@@ -23,10 +23,11 @@ static int hfsplus_security_getxattr(const struct xattr_handler *handler, | |||
23 | } | 23 | } |
24 | 24 | ||
25 | static int hfsplus_security_setxattr(const struct xattr_handler *handler, | 25 | static int hfsplus_security_setxattr(const struct xattr_handler *handler, |
26 | struct dentry *dentry, const char *name, | 26 | struct dentry *unused, struct inode *inode, |
27 | const void *buffer, size_t size, int flags) | 27 | const char *name, const void *buffer, |
28 | size_t size, int flags) | ||
28 | { | 29 | { |
29 | return hfsplus_setxattr(dentry, name, buffer, size, flags, | 30 | return hfsplus_setxattr(inode, name, buffer, size, flags, |
30 | XATTR_SECURITY_PREFIX, | 31 | XATTR_SECURITY_PREFIX, |
31 | XATTR_SECURITY_PREFIX_LEN); | 32 | XATTR_SECURITY_PREFIX_LEN); |
32 | } | 33 | } |
diff --git a/fs/hfsplus/xattr_trusted.c b/fs/hfsplus/xattr_trusted.c index eae2947060aa..94519d6c627d 100644 --- a/fs/hfsplus/xattr_trusted.c +++ b/fs/hfsplus/xattr_trusted.c | |||
@@ -21,10 +21,11 @@ static int hfsplus_trusted_getxattr(const struct xattr_handler *handler, | |||
21 | } | 21 | } |
22 | 22 | ||
23 | static int hfsplus_trusted_setxattr(const struct xattr_handler *handler, | 23 | static int hfsplus_trusted_setxattr(const struct xattr_handler *handler, |
24 | struct dentry *dentry, const char *name, | 24 | struct dentry *unused, struct inode *inode, |
25 | const void *buffer, size_t size, int flags) | 25 | const char *name, const void *buffer, |
26 | size_t size, int flags) | ||
26 | { | 27 | { |
27 | return hfsplus_setxattr(dentry, name, buffer, size, flags, | 28 | return hfsplus_setxattr(inode, name, buffer, size, flags, |
28 | XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN); | 29 | XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN); |
29 | } | 30 | } |
30 | 31 | ||
diff --git a/fs/hfsplus/xattr_user.c b/fs/hfsplus/xattr_user.c index 3c9eec3e4c7b..fae6c0ea0030 100644 --- a/fs/hfsplus/xattr_user.c +++ b/fs/hfsplus/xattr_user.c | |||
@@ -21,10 +21,11 @@ static int hfsplus_user_getxattr(const struct xattr_handler *handler, | |||
21 | } | 21 | } |
22 | 22 | ||
23 | static int hfsplus_user_setxattr(const struct xattr_handler *handler, | 23 | static int hfsplus_user_setxattr(const struct xattr_handler *handler, |
24 | struct dentry *dentry, const char *name, | 24 | struct dentry *unused, struct inode *inode, |
25 | const void *buffer, size_t size, int flags) | 25 | const char *name, const void *buffer, |
26 | size_t size, int flags) | ||
26 | { | 27 | { |
27 | return hfsplus_setxattr(dentry, name, buffer, size, flags, | 28 | return hfsplus_setxattr(inode, name, buffer, size, flags, |
28 | XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN); | 29 | XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN); |
29 | } | 30 | } |
30 | 31 | ||
diff --git a/fs/jffs2/security.c b/fs/jffs2/security.c index 3ed9a4b49778..c2332e30f218 100644 --- a/fs/jffs2/security.c +++ b/fs/jffs2/security.c | |||
@@ -57,10 +57,11 @@ static int jffs2_security_getxattr(const struct xattr_handler *handler, | |||
57 | } | 57 | } |
58 | 58 | ||
59 | static int jffs2_security_setxattr(const struct xattr_handler *handler, | 59 | static int jffs2_security_setxattr(const struct xattr_handler *handler, |
60 | struct dentry *dentry, const char *name, | 60 | struct dentry *unused, struct inode *inode, |
61 | const void *buffer, size_t size, int flags) | 61 | const char *name, const void *buffer, |
62 | size_t size, int flags) | ||
62 | { | 63 | { |
63 | return do_jffs2_setxattr(d_inode(dentry), JFFS2_XPREFIX_SECURITY, | 64 | return do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY, |
64 | name, buffer, size, flags); | 65 | name, buffer, size, flags); |
65 | } | 66 | } |
66 | 67 | ||
diff --git a/fs/jffs2/xattr_trusted.c b/fs/jffs2/xattr_trusted.c index 4ebecff1d922..5d6030826c52 100644 --- a/fs/jffs2/xattr_trusted.c +++ b/fs/jffs2/xattr_trusted.c | |||
@@ -25,10 +25,11 @@ static int jffs2_trusted_getxattr(const struct xattr_handler *handler, | |||
25 | } | 25 | } |
26 | 26 | ||
27 | static int jffs2_trusted_setxattr(const struct xattr_handler *handler, | 27 | static int jffs2_trusted_setxattr(const struct xattr_handler *handler, |
28 | struct dentry *dentry, const char *name, | 28 | struct dentry *unused, struct inode *inode, |
29 | const void *buffer, size_t size, int flags) | 29 | const char *name, const void *buffer, |
30 | size_t size, int flags) | ||
30 | { | 31 | { |
31 | return do_jffs2_setxattr(d_inode(dentry), JFFS2_XPREFIX_TRUSTED, | 32 | return do_jffs2_setxattr(inode, JFFS2_XPREFIX_TRUSTED, |
32 | name, buffer, size, flags); | 33 | name, buffer, size, flags); |
33 | } | 34 | } |
34 | 35 | ||
diff --git a/fs/jffs2/xattr_user.c b/fs/jffs2/xattr_user.c index bce249e1b277..9d027b4abcf9 100644 --- a/fs/jffs2/xattr_user.c +++ b/fs/jffs2/xattr_user.c | |||
@@ -25,10 +25,11 @@ static int jffs2_user_getxattr(const struct xattr_handler *handler, | |||
25 | } | 25 | } |
26 | 26 | ||
27 | static int jffs2_user_setxattr(const struct xattr_handler *handler, | 27 | static int jffs2_user_setxattr(const struct xattr_handler *handler, |
28 | struct dentry *dentry, const char *name, | 28 | struct dentry *unused, struct inode *inode, |
29 | const void *buffer, size_t size, int flags) | 29 | const char *name, const void *buffer, |
30 | size_t size, int flags) | ||
30 | { | 31 | { |
31 | return do_jffs2_setxattr(d_inode(dentry), JFFS2_XPREFIX_USER, | 32 | return do_jffs2_setxattr(inode, JFFS2_XPREFIX_USER, |
32 | name, buffer, size, flags); | 33 | name, buffer, size, flags); |
33 | } | 34 | } |
34 | 35 | ||
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c index beb182b503b3..0bf3c33aedff 100644 --- a/fs/jfs/xattr.c +++ b/fs/jfs/xattr.c | |||
@@ -943,11 +943,10 @@ static int jfs_xattr_get(const struct xattr_handler *handler, | |||
943 | } | 943 | } |
944 | 944 | ||
945 | static int jfs_xattr_set(const struct xattr_handler *handler, | 945 | static int jfs_xattr_set(const struct xattr_handler *handler, |
946 | struct dentry *dentry, const char *name, | 946 | struct dentry *unused, struct inode *inode, |
947 | const void *value, size_t size, int flags) | 947 | const char *name, const void *value, |
948 | size_t size, int flags) | ||
948 | { | 949 | { |
949 | struct inode *inode = d_inode(dentry); | ||
950 | |||
951 | name = xattr_full_name(handler, name); | 950 | name = xattr_full_name(handler, name); |
952 | return __jfs_xattr_set(inode, name, value, size, flags); | 951 | return __jfs_xattr_set(inode, name, value, size, flags); |
953 | } | 952 | } |
@@ -962,11 +961,10 @@ static int jfs_xattr_get_os2(const struct xattr_handler *handler, | |||
962 | } | 961 | } |
963 | 962 | ||
964 | static int jfs_xattr_set_os2(const struct xattr_handler *handler, | 963 | static int jfs_xattr_set_os2(const struct xattr_handler *handler, |
965 | struct dentry *dentry, const char *name, | 964 | struct dentry *unused, struct inode *inode, |
966 | const void *value, size_t size, int flags) | 965 | const char *name, const void *value, |
966 | size_t size, int flags) | ||
967 | { | 967 | { |
968 | struct inode *inode = d_inode(dentry); | ||
969 | |||
970 | if (is_known_namespace(name)) | 968 | if (is_known_namespace(name)) |
971 | return -EOPNOTSUPP; | 969 | return -EOPNOTSUPP; |
972 | return __jfs_xattr_set(inode, name, value, size, flags); | 970 | return __jfs_xattr_set(inode, name, value, size, flags); |
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c index 1719649d7ad7..63b925d5ba1e 100644 --- a/fs/kernfs/inode.c +++ b/fs/kernfs/inode.c | |||
@@ -160,10 +160,11 @@ static int kernfs_node_setsecdata(struct kernfs_node *kn, void **secdata, | |||
160 | return 0; | 160 | return 0; |
161 | } | 161 | } |
162 | 162 | ||
163 | int kernfs_iop_setxattr(struct dentry *dentry, const char *name, | 163 | int kernfs_iop_setxattr(struct dentry *unused, struct inode *inode, |
164 | const void *value, size_t size, int flags) | 164 | const char *name, const void *value, |
165 | size_t size, int flags) | ||
165 | { | 166 | { |
166 | struct kernfs_node *kn = dentry->d_fsdata; | 167 | struct kernfs_node *kn = inode->i_private; |
167 | struct kernfs_iattrs *attrs; | 168 | struct kernfs_iattrs *attrs; |
168 | void *secdata; | 169 | void *secdata; |
169 | int error; | 170 | int error; |
@@ -175,11 +176,11 @@ int kernfs_iop_setxattr(struct dentry *dentry, const char *name, | |||
175 | 176 | ||
176 | if (!strncmp(name, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN)) { | 177 | if (!strncmp(name, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN)) { |
177 | const char *suffix = name + XATTR_SECURITY_PREFIX_LEN; | 178 | const char *suffix = name + XATTR_SECURITY_PREFIX_LEN; |
178 | error = security_inode_setsecurity(d_inode(dentry), suffix, | 179 | error = security_inode_setsecurity(inode, suffix, |
179 | value, size, flags); | 180 | value, size, flags); |
180 | if (error) | 181 | if (error) |
181 | return error; | 182 | return error; |
182 | error = security_inode_getsecctx(d_inode(dentry), | 183 | error = security_inode_getsecctx(inode, |
183 | &secdata, &secdata_len); | 184 | &secdata, &secdata_len); |
184 | if (error) | 185 | if (error) |
185 | return error; | 186 | return error; |
diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h index 45c9192c276e..37159235ac10 100644 --- a/fs/kernfs/kernfs-internal.h +++ b/fs/kernfs/kernfs-internal.h | |||
@@ -81,7 +81,8 @@ int kernfs_iop_permission(struct inode *inode, int mask); | |||
81 | int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr); | 81 | int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr); |
82 | int kernfs_iop_getattr(struct vfsmount *mnt, struct dentry *dentry, | 82 | int kernfs_iop_getattr(struct vfsmount *mnt, struct dentry *dentry, |
83 | struct kstat *stat); | 83 | struct kstat *stat); |
84 | int kernfs_iop_setxattr(struct dentry *dentry, const char *name, const void *value, | 84 | int kernfs_iop_setxattr(struct dentry *dentry, struct inode *inode, |
85 | const char *name, const void *value, | ||
85 | size_t size, int flags); | 86 | size_t size, int flags); |
86 | int kernfs_iop_removexattr(struct dentry *dentry, const char *name); | 87 | int kernfs_iop_removexattr(struct dentry *dentry, const char *name); |
87 | ssize_t kernfs_iop_getxattr(struct dentry *dentry, struct inode *inode, | 88 | ssize_t kernfs_iop_getxattr(struct dentry *dentry, struct inode *inode, |
diff --git a/fs/libfs.c b/fs/libfs.c index 8765ff1adc07..3db2721144c2 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
@@ -1118,8 +1118,9 @@ static int empty_dir_setattr(struct dentry *dentry, struct iattr *attr) | |||
1118 | return -EPERM; | 1118 | return -EPERM; |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | static int empty_dir_setxattr(struct dentry *dentry, const char *name, | 1121 | static int empty_dir_setxattr(struct dentry *dentry, struct inode *inode, |
1122 | const void *value, size_t size, int flags) | 1122 | const char *name, const void *value, |
1123 | size_t size, int flags) | ||
1123 | { | 1124 | { |
1124 | return -EOPNOTSUPP; | 1125 | return -EOPNOTSUPP; |
1125 | } | 1126 | } |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 223982eb38c9..de97567795a5 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -5015,12 +5015,11 @@ static int nfs4_do_set_security_label(struct inode *inode, | |||
5015 | } | 5015 | } |
5016 | 5016 | ||
5017 | static int | 5017 | static int |
5018 | nfs4_set_security_label(struct dentry *dentry, const void *buf, size_t buflen) | 5018 | nfs4_set_security_label(struct inode *inode, const void *buf, size_t buflen) |
5019 | { | 5019 | { |
5020 | struct nfs4_label ilabel, *olabel = NULL; | 5020 | struct nfs4_label ilabel, *olabel = NULL; |
5021 | struct nfs_fattr fattr; | 5021 | struct nfs_fattr fattr; |
5022 | struct rpc_cred *cred; | 5022 | struct rpc_cred *cred; |
5023 | struct inode *inode = d_inode(dentry); | ||
5024 | int status; | 5023 | int status; |
5025 | 5024 | ||
5026 | if (!nfs_server_capable(inode, NFS_CAP_SECURITY_LABEL)) | 5025 | if (!nfs_server_capable(inode, NFS_CAP_SECURITY_LABEL)) |
@@ -6281,11 +6280,11 @@ nfs4_release_lockowner(struct nfs_server *server, struct nfs4_lock_state *lsp) | |||
6281 | #define XATTR_NAME_NFSV4_ACL "system.nfs4_acl" | 6280 | #define XATTR_NAME_NFSV4_ACL "system.nfs4_acl" |
6282 | 6281 | ||
6283 | static int nfs4_xattr_set_nfs4_acl(const struct xattr_handler *handler, | 6282 | static int nfs4_xattr_set_nfs4_acl(const struct xattr_handler *handler, |
6284 | struct dentry *dentry, const char *key, | 6283 | struct dentry *unused, struct inode *inode, |
6285 | const void *buf, size_t buflen, | 6284 | const char *key, const void *buf, |
6286 | int flags) | 6285 | size_t buflen, int flags) |
6287 | { | 6286 | { |
6288 | return nfs4_proc_set_acl(d_inode(dentry), buf, buflen); | 6287 | return nfs4_proc_set_acl(inode, buf, buflen); |
6289 | } | 6288 | } |
6290 | 6289 | ||
6291 | static int nfs4_xattr_get_nfs4_acl(const struct xattr_handler *handler, | 6290 | static int nfs4_xattr_get_nfs4_acl(const struct xattr_handler *handler, |
@@ -6303,12 +6302,12 @@ static bool nfs4_xattr_list_nfs4_acl(struct dentry *dentry) | |||
6303 | #ifdef CONFIG_NFS_V4_SECURITY_LABEL | 6302 | #ifdef CONFIG_NFS_V4_SECURITY_LABEL |
6304 | 6303 | ||
6305 | static int nfs4_xattr_set_nfs4_label(const struct xattr_handler *handler, | 6304 | static int nfs4_xattr_set_nfs4_label(const struct xattr_handler *handler, |
6306 | struct dentry *dentry, const char *key, | 6305 | struct dentry *unused, struct inode *inode, |
6307 | const void *buf, size_t buflen, | 6306 | const char *key, const void *buf, |
6308 | int flags) | 6307 | size_t buflen, int flags) |
6309 | { | 6308 | { |
6310 | if (security_ismaclabel(key)) | 6309 | if (security_ismaclabel(key)) |
6311 | return nfs4_set_security_label(dentry, buf, buflen); | 6310 | return nfs4_set_security_label(inode, buf, buflen); |
6312 | 6311 | ||
6313 | return -EOPNOTSUPP; | 6312 | return -EOPNOTSUPP; |
6314 | } | 6313 | } |
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index ad16995c9e7a..d2053853951e 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -7254,10 +7254,11 @@ static int ocfs2_xattr_security_get(const struct xattr_handler *handler, | |||
7254 | } | 7254 | } |
7255 | 7255 | ||
7256 | static int ocfs2_xattr_security_set(const struct xattr_handler *handler, | 7256 | static int ocfs2_xattr_security_set(const struct xattr_handler *handler, |
7257 | struct dentry *dentry, const char *name, | 7257 | struct dentry *unused, struct inode *inode, |
7258 | const void *value, size_t size, int flags) | 7258 | const char *name, const void *value, |
7259 | size_t size, int flags) | ||
7259 | { | 7260 | { |
7260 | return ocfs2_xattr_set(d_inode(dentry), OCFS2_XATTR_INDEX_SECURITY, | 7261 | return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, |
7261 | name, value, size, flags); | 7262 | name, value, size, flags); |
7262 | } | 7263 | } |
7263 | 7264 | ||
@@ -7325,10 +7326,11 @@ static int ocfs2_xattr_trusted_get(const struct xattr_handler *handler, | |||
7325 | } | 7326 | } |
7326 | 7327 | ||
7327 | static int ocfs2_xattr_trusted_set(const struct xattr_handler *handler, | 7328 | static int ocfs2_xattr_trusted_set(const struct xattr_handler *handler, |
7328 | struct dentry *dentry, const char *name, | 7329 | struct dentry *unused, struct inode *inode, |
7329 | const void *value, size_t size, int flags) | 7330 | const char *name, const void *value, |
7331 | size_t size, int flags) | ||
7330 | { | 7332 | { |
7331 | return ocfs2_xattr_set(d_inode(dentry), OCFS2_XATTR_INDEX_TRUSTED, | 7333 | return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_TRUSTED, |
7332 | name, value, size, flags); | 7334 | name, value, size, flags); |
7333 | } | 7335 | } |
7334 | 7336 | ||
@@ -7354,15 +7356,16 @@ static int ocfs2_xattr_user_get(const struct xattr_handler *handler, | |||
7354 | } | 7356 | } |
7355 | 7357 | ||
7356 | static int ocfs2_xattr_user_set(const struct xattr_handler *handler, | 7358 | static int ocfs2_xattr_user_set(const struct xattr_handler *handler, |
7357 | struct dentry *dentry, const char *name, | 7359 | struct dentry *unused, struct inode *inode, |
7358 | const void *value, size_t size, int flags) | 7360 | const char *name, const void *value, |
7361 | size_t size, int flags) | ||
7359 | { | 7362 | { |
7360 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); | 7363 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
7361 | 7364 | ||
7362 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | 7365 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) |
7363 | return -EOPNOTSUPP; | 7366 | return -EOPNOTSUPP; |
7364 | 7367 | ||
7365 | return ocfs2_xattr_set(d_inode(dentry), OCFS2_XATTR_INDEX_USER, | 7368 | return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER, |
7366 | name, value, size, flags); | 7369 | name, value, size, flags); |
7367 | } | 7370 | } |
7368 | 7371 | ||
diff --git a/fs/orangefs/xattr.c b/fs/orangefs/xattr.c index 99c19545752c..5893ddde0e4b 100644 --- a/fs/orangefs/xattr.c +++ b/fs/orangefs/xattr.c | |||
@@ -448,13 +448,14 @@ out_unlock: | |||
448 | } | 448 | } |
449 | 449 | ||
450 | static int orangefs_xattr_set_default(const struct xattr_handler *handler, | 450 | static int orangefs_xattr_set_default(const struct xattr_handler *handler, |
451 | struct dentry *dentry, | 451 | struct dentry *unused, |
452 | struct inode *inode, | ||
452 | const char *name, | 453 | const char *name, |
453 | const void *buffer, | 454 | const void *buffer, |
454 | size_t size, | 455 | size_t size, |
455 | int flags) | 456 | int flags) |
456 | { | 457 | { |
457 | return orangefs_inode_setxattr(dentry->d_inode, | 458 | return orangefs_inode_setxattr(inode, |
458 | ORANGEFS_XATTR_NAME_DEFAULT_PREFIX, | 459 | ORANGEFS_XATTR_NAME_DEFAULT_PREFIX, |
459 | name, | 460 | name, |
460 | buffer, | 461 | buffer, |
@@ -478,13 +479,14 @@ static int orangefs_xattr_get_default(const struct xattr_handler *handler, | |||
478 | } | 479 | } |
479 | 480 | ||
480 | static int orangefs_xattr_set_trusted(const struct xattr_handler *handler, | 481 | static int orangefs_xattr_set_trusted(const struct xattr_handler *handler, |
481 | struct dentry *dentry, | 482 | struct dentry *unused, |
483 | struct inode *inode, | ||
482 | const char *name, | 484 | const char *name, |
483 | const void *buffer, | 485 | const void *buffer, |
484 | size_t size, | 486 | size_t size, |
485 | int flags) | 487 | int flags) |
486 | { | 488 | { |
487 | return orangefs_inode_setxattr(dentry->d_inode, | 489 | return orangefs_inode_setxattr(inode, |
488 | ORANGEFS_XATTR_NAME_TRUSTED_PREFIX, | 490 | ORANGEFS_XATTR_NAME_TRUSTED_PREFIX, |
489 | name, | 491 | name, |
490 | buffer, | 492 | buffer, |
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index c7b31a03dc9c..0ed7c4012437 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c | |||
@@ -210,8 +210,9 @@ static bool ovl_is_private_xattr(const char *name) | |||
210 | return strncmp(name, OVL_XATTR_PRE_NAME, OVL_XATTR_PRE_LEN) == 0; | 210 | return strncmp(name, OVL_XATTR_PRE_NAME, OVL_XATTR_PRE_LEN) == 0; |
211 | } | 211 | } |
212 | 212 | ||
213 | int ovl_setxattr(struct dentry *dentry, const char *name, | 213 | int ovl_setxattr(struct dentry *dentry, struct inode *inode, |
214 | const void *value, size_t size, int flags) | 214 | const char *name, const void *value, |
215 | size_t size, int flags) | ||
215 | { | 216 | { |
216 | int err; | 217 | int err; |
217 | struct dentry *upperdentry; | 218 | struct dentry *upperdentry; |
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 724f5fcb4e24..4bd9b5ba8f42 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h | |||
@@ -172,8 +172,9 @@ int ovl_check_d_type_supported(struct path *realpath); | |||
172 | /* inode.c */ | 172 | /* inode.c */ |
173 | int ovl_setattr(struct dentry *dentry, struct iattr *attr); | 173 | int ovl_setattr(struct dentry *dentry, struct iattr *attr); |
174 | int ovl_permission(struct inode *inode, int mask); | 174 | int ovl_permission(struct inode *inode, int mask); |
175 | int ovl_setxattr(struct dentry *dentry, const char *name, | 175 | int ovl_setxattr(struct dentry *dentry, struct inode *inode, |
176 | const void *value, size_t size, int flags); | 176 | const char *name, const void *value, |
177 | size_t size, int flags); | ||
177 | ssize_t ovl_getxattr(struct dentry *dentry, struct inode *inode, | 178 | ssize_t ovl_getxattr(struct dentry *dentry, struct inode *inode, |
178 | const char *name, void *value, size_t size); | 179 | const char *name, void *value, size_t size); |
179 | ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size); | 180 | ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size); |
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c index d11ae826bcbc..cf37fc76fc9f 100644 --- a/fs/overlayfs/readdir.c +++ b/fs/overlayfs/readdir.c | |||
@@ -210,9 +210,7 @@ static int ovl_check_whiteouts(struct dentry *dir, struct ovl_readdir_data *rdd) | |||
210 | 210 | ||
211 | old_cred = ovl_override_creds(rdd->dentry->d_sb); | 211 | old_cred = ovl_override_creds(rdd->dentry->d_sb); |
212 | 212 | ||
213 | inode_lock(dir->d_inode); | 213 | err = down_write_killable(&dir->d_inode->i_rwsem); |
214 | err = 0; | ||
215 | // XXX: err = mutex_lock_killable(&dir->d_inode->i_mutex); | ||
216 | if (!err) { | 214 | if (!err) { |
217 | while (rdd->first_maybe_whiteout) { | 215 | while (rdd->first_maybe_whiteout) { |
218 | p = rdd->first_maybe_whiteout; | 216 | p = rdd->first_maybe_whiteout; |
diff --git a/fs/posix_acl.c b/fs/posix_acl.c index 2c60f17e7d92..8a4a266beff3 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c | |||
@@ -822,10 +822,10 @@ posix_acl_xattr_get(const struct xattr_handler *handler, | |||
822 | 822 | ||
823 | static int | 823 | static int |
824 | posix_acl_xattr_set(const struct xattr_handler *handler, | 824 | posix_acl_xattr_set(const struct xattr_handler *handler, |
825 | struct dentry *dentry, const char *name, | 825 | struct dentry *unused, struct inode *inode, |
826 | const void *value, size_t size, int flags) | 826 | const char *name, const void *value, |
827 | size_t size, int flags) | ||
827 | { | 828 | { |
828 | struct inode *inode = d_backing_inode(dentry); | ||
829 | struct posix_acl *acl = NULL; | 829 | struct posix_acl *acl = NULL; |
830 | int ret; | 830 | int ret; |
831 | 831 | ||
diff --git a/fs/readdir.c b/fs/readdir.c index 68ef06efe6bc..9d0212c374d6 100644 --- a/fs/readdir.c +++ b/fs/readdir.c | |||
@@ -35,13 +35,13 @@ int iterate_dir(struct file *file, struct dir_context *ctx) | |||
35 | if (res) | 35 | if (res) |
36 | goto out; | 36 | goto out; |
37 | 37 | ||
38 | if (shared) | 38 | if (shared) { |
39 | inode_lock_shared(inode); | 39 | inode_lock_shared(inode); |
40 | else | 40 | } else { |
41 | inode_lock(inode); | 41 | res = down_write_killable(&inode->i_rwsem); |
42 | // res = mutex_lock_killable(&inode->i_mutex); | 42 | if (res) |
43 | // if (res) | 43 | goto out; |
44 | // goto out; | 44 | } |
45 | 45 | ||
46 | res = -ENOENT; | 46 | res = -ENOENT; |
47 | if (!IS_DEADDIR(inode)) { | 47 | if (!IS_DEADDIR(inode)) { |
diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c index 86aeb9dd805a..e4cbb7719906 100644 --- a/fs/reiserfs/xattr_security.c +++ b/fs/reiserfs/xattr_security.c | |||
@@ -20,13 +20,14 @@ security_get(const struct xattr_handler *handler, struct dentry *unused, | |||
20 | } | 20 | } |
21 | 21 | ||
22 | static int | 22 | static int |
23 | security_set(const struct xattr_handler *handler, struct dentry *dentry, | 23 | security_set(const struct xattr_handler *handler, struct dentry *unused, |
24 | const char *name, const void *buffer, size_t size, int flags) | 24 | struct inode *inode, const char *name, const void *buffer, |
25 | size_t size, int flags) | ||
25 | { | 26 | { |
26 | if (IS_PRIVATE(d_inode(dentry))) | 27 | if (IS_PRIVATE(inode)) |
27 | return -EPERM; | 28 | return -EPERM; |
28 | 29 | ||
29 | return reiserfs_xattr_set(d_inode(dentry), | 30 | return reiserfs_xattr_set(inode, |
30 | xattr_full_name(handler, name), | 31 | xattr_full_name(handler, name), |
31 | buffer, size, flags); | 32 | buffer, size, flags); |
32 | } | 33 | } |
diff --git a/fs/reiserfs/xattr_trusted.c b/fs/reiserfs/xattr_trusted.c index 31837f031f59..f15a5f9e84ce 100644 --- a/fs/reiserfs/xattr_trusted.c +++ b/fs/reiserfs/xattr_trusted.c | |||
@@ -19,13 +19,14 @@ trusted_get(const struct xattr_handler *handler, struct dentry *unused, | |||
19 | } | 19 | } |
20 | 20 | ||
21 | static int | 21 | static int |
22 | trusted_set(const struct xattr_handler *handler, struct dentry *dentry, | 22 | trusted_set(const struct xattr_handler *handler, struct dentry *unused, |
23 | const char *name, const void *buffer, size_t size, int flags) | 23 | struct inode *inode, const char *name, const void *buffer, |
24 | size_t size, int flags) | ||
24 | { | 25 | { |
25 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry))) | 26 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) |
26 | return -EPERM; | 27 | return -EPERM; |
27 | 28 | ||
28 | return reiserfs_xattr_set(d_inode(dentry), | 29 | return reiserfs_xattr_set(inode, |
29 | xattr_full_name(handler, name), | 30 | xattr_full_name(handler, name), |
30 | buffer, size, flags); | 31 | buffer, size, flags); |
31 | } | 32 | } |
diff --git a/fs/reiserfs/xattr_user.c b/fs/reiserfs/xattr_user.c index f7c39731684b..dc59df43b2db 100644 --- a/fs/reiserfs/xattr_user.c +++ b/fs/reiserfs/xattr_user.c | |||
@@ -17,12 +17,13 @@ user_get(const struct xattr_handler *handler, struct dentry *unused, | |||
17 | } | 17 | } |
18 | 18 | ||
19 | static int | 19 | static int |
20 | user_set(const struct xattr_handler *handler, struct dentry *dentry, | 20 | user_set(const struct xattr_handler *handler, struct dentry *unused, |
21 | const char *name, const void *buffer, size_t size, int flags) | 21 | struct inode *inode, const char *name, const void *buffer, |
22 | size_t size, int flags) | ||
22 | { | 23 | { |
23 | if (!reiserfs_xattrs_user(dentry->d_sb)) | 24 | if (!reiserfs_xattrs_user(inode->i_sb)) |
24 | return -EOPNOTSUPP; | 25 | return -EOPNOTSUPP; |
25 | return reiserfs_xattr_set(d_inode(dentry), | 26 | return reiserfs_xattr_set(inode, |
26 | xattr_full_name(handler, name), | 27 | xattr_full_name(handler, name), |
27 | buffer, size, flags); | 28 | buffer, size, flags); |
28 | } | 29 | } |
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c index 6c277eb6aef9..b5fc27969e9d 100644 --- a/fs/ubifs/xattr.c +++ b/fs/ubifs/xattr.c | |||
@@ -579,11 +579,10 @@ static int ubifs_xattr_get(const struct xattr_handler *handler, | |||
579 | } | 579 | } |
580 | 580 | ||
581 | static int ubifs_xattr_set(const struct xattr_handler *handler, | 581 | static int ubifs_xattr_set(const struct xattr_handler *handler, |
582 | struct dentry *dentry, const char *name, | 582 | struct dentry *dentry, struct inode *inode, |
583 | const void *value, size_t size, int flags) | 583 | const char *name, const void *value, |
584 | size_t size, int flags) | ||
584 | { | 585 | { |
585 | struct inode *inode = d_inode(dentry); | ||
586 | |||
587 | dbg_gen("xattr '%s', host ino %lu ('%pd'), size %zd", | 586 | dbg_gen("xattr '%s', host ino %lu ('%pd'), size %zd", |
588 | name, inode->i_ino, dentry, size); | 587 | name, inode->i_ino, dentry, size); |
589 | 588 | ||
diff --git a/fs/xattr.c b/fs/xattr.c index fc81e771488a..4beafc43daa5 100644 --- a/fs/xattr.c +++ b/fs/xattr.c | |||
@@ -100,7 +100,7 @@ int __vfs_setxattr_noperm(struct dentry *dentry, const char *name, | |||
100 | if (issec) | 100 | if (issec) |
101 | inode->i_flags &= ~S_NOSEC; | 101 | inode->i_flags &= ~S_NOSEC; |
102 | if (inode->i_op->setxattr) { | 102 | if (inode->i_op->setxattr) { |
103 | error = inode->i_op->setxattr(dentry, name, value, size, flags); | 103 | error = inode->i_op->setxattr(dentry, inode, name, value, size, flags); |
104 | if (!error) { | 104 | if (!error) { |
105 | fsnotify_xattr(dentry); | 105 | fsnotify_xattr(dentry); |
106 | security_inode_post_setxattr(dentry, name, value, | 106 | security_inode_post_setxattr(dentry, name, value, |
@@ -745,7 +745,8 @@ generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) | |||
745 | * Find the handler for the prefix and dispatch its set() operation. | 745 | * Find the handler for the prefix and dispatch its set() operation. |
746 | */ | 746 | */ |
747 | int | 747 | int |
748 | generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) | 748 | generic_setxattr(struct dentry *dentry, struct inode *inode, const char *name, |
749 | const void *value, size_t size, int flags) | ||
749 | { | 750 | { |
750 | const struct xattr_handler *handler; | 751 | const struct xattr_handler *handler; |
751 | 752 | ||
@@ -754,7 +755,7 @@ generic_setxattr(struct dentry *dentry, const char *name, const void *value, siz | |||
754 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); | 755 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); |
755 | if (IS_ERR(handler)) | 756 | if (IS_ERR(handler)) |
756 | return PTR_ERR(handler); | 757 | return PTR_ERR(handler); |
757 | return handler->set(handler, dentry, name, value, size, flags); | 758 | return handler->set(handler, dentry, inode, name, value, size, flags); |
758 | } | 759 | } |
759 | 760 | ||
760 | /* | 761 | /* |
@@ -769,7 +770,8 @@ generic_removexattr(struct dentry *dentry, const char *name) | |||
769 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); | 770 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); |
770 | if (IS_ERR(handler)) | 771 | if (IS_ERR(handler)) |
771 | return PTR_ERR(handler); | 772 | return PTR_ERR(handler); |
772 | return handler->set(handler, dentry, name, NULL, 0, XATTR_REPLACE); | 773 | return handler->set(handler, dentry, d_inode(dentry), name, NULL, |
774 | 0, XATTR_REPLACE); | ||
773 | } | 775 | } |
774 | 776 | ||
775 | EXPORT_SYMBOL(generic_getxattr); | 777 | EXPORT_SYMBOL(generic_getxattr); |
diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index ec58ff094b1d..ea62245fee26 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c | |||
@@ -74,11 +74,12 @@ xfs_forget_acl( | |||
74 | } | 74 | } |
75 | 75 | ||
76 | static int | 76 | static int |
77 | xfs_xattr_set(const struct xattr_handler *handler, struct dentry *dentry, | 77 | xfs_xattr_set(const struct xattr_handler *handler, struct dentry *unused, |
78 | const char *name, const void *value, size_t size, int flags) | 78 | struct inode *inode, const char *name, const void *value, |
79 | size_t size, int flags) | ||
79 | { | 80 | { |
80 | int xflags = handler->flags; | 81 | int xflags = handler->flags; |
81 | struct xfs_inode *ip = XFS_I(d_inode(dentry)); | 82 | struct xfs_inode *ip = XFS_I(inode); |
82 | int error; | 83 | int error; |
83 | 84 | ||
84 | /* Convert Linux syscall to XFS internal ATTR flags */ | 85 | /* Convert Linux syscall to XFS internal ATTR flags */ |
@@ -92,7 +93,7 @@ xfs_xattr_set(const struct xattr_handler *handler, struct dentry *dentry, | |||
92 | error = xfs_attr_set(ip, (unsigned char *)name, | 93 | error = xfs_attr_set(ip, (unsigned char *)name, |
93 | (void *)value, size, xflags); | 94 | (void *)value, size, xflags); |
94 | if (!error) | 95 | if (!error) |
95 | xfs_forget_acl(d_inode(dentry), name, xflags); | 96 | xfs_forget_acl(inode, name, xflags); |
96 | 97 | ||
97 | return error; | 98 | return error; |
98 | } | 99 | } |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 9ace7f745bcd..dd288148a6b1 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1729,7 +1729,8 @@ struct inode_operations { | |||
1729 | struct inode *, struct dentry *, unsigned int); | 1729 | struct inode *, struct dentry *, unsigned int); |
1730 | int (*setattr) (struct dentry *, struct iattr *); | 1730 | int (*setattr) (struct dentry *, struct iattr *); |
1731 | int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); | 1731 | int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); |
1732 | int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); | 1732 | int (*setxattr) (struct dentry *, struct inode *, |
1733 | const char *, const void *, size_t, int); | ||
1733 | ssize_t (*getxattr) (struct dentry *, struct inode *, | 1734 | ssize_t (*getxattr) (struct dentry *, struct inode *, |
1734 | const char *, void *, size_t); | 1735 | const char *, void *, size_t); |
1735 | ssize_t (*listxattr) (struct dentry *, char *, size_t); | 1736 | ssize_t (*listxattr) (struct dentry *, char *, size_t); |
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index d1c12d160ace..d37fbb34d06f 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h | |||
@@ -156,6 +156,7 @@ extern void downgrade_write(struct rw_semaphore *sem); | |||
156 | */ | 156 | */ |
157 | extern void down_read_nested(struct rw_semaphore *sem, int subclass); | 157 | extern void down_read_nested(struct rw_semaphore *sem, int subclass); |
158 | extern void down_write_nested(struct rw_semaphore *sem, int subclass); | 158 | extern void down_write_nested(struct rw_semaphore *sem, int subclass); |
159 | extern int down_write_killable_nested(struct rw_semaphore *sem, int subclass); | ||
159 | extern void _down_write_nest_lock(struct rw_semaphore *sem, struct lockdep_map *nest_lock); | 160 | extern void _down_write_nest_lock(struct rw_semaphore *sem, struct lockdep_map *nest_lock); |
160 | 161 | ||
161 | # define down_write_nest_lock(sem, nest_lock) \ | 162 | # define down_write_nest_lock(sem, nest_lock) \ |
@@ -176,6 +177,7 @@ extern void up_read_non_owner(struct rw_semaphore *sem); | |||
176 | # define down_read_nested(sem, subclass) down_read(sem) | 177 | # define down_read_nested(sem, subclass) down_read(sem) |
177 | # define down_write_nest_lock(sem, nest_lock) down_write(sem) | 178 | # define down_write_nest_lock(sem, nest_lock) down_write(sem) |
178 | # define down_write_nested(sem, subclass) down_write(sem) | 179 | # define down_write_nested(sem, subclass) down_write(sem) |
180 | # define down_write_killable_nested(sem, subclass) down_write_killable(sem) | ||
179 | # define down_read_non_owner(sem) down_read(sem) | 181 | # define down_read_non_owner(sem) down_read(sem) |
180 | # define up_read_non_owner(sem) up_read(sem) | 182 | # define up_read_non_owner(sem) up_read(sem) |
181 | #endif | 183 | #endif |
diff --git a/include/linux/xattr.h b/include/linux/xattr.h index 1cc4c578deb9..94079bab9243 100644 --- a/include/linux/xattr.h +++ b/include/linux/xattr.h | |||
@@ -33,8 +33,8 @@ struct xattr_handler { | |||
33 | struct inode *inode, const char *name, void *buffer, | 33 | struct inode *inode, const char *name, void *buffer, |
34 | size_t size); | 34 | size_t size); |
35 | int (*set)(const struct xattr_handler *, struct dentry *dentry, | 35 | int (*set)(const struct xattr_handler *, struct dentry *dentry, |
36 | const char *name, const void *buffer, size_t size, | 36 | struct inode *inode, const char *name, const void *buffer, |
37 | int flags); | 37 | size_t size, int flags); |
38 | }; | 38 | }; |
39 | 39 | ||
40 | const char *xattr_full_name(const struct xattr_handler *, const char *); | 40 | const char *xattr_full_name(const struct xattr_handler *, const char *); |
@@ -54,7 +54,8 @@ int vfs_removexattr(struct dentry *, const char *); | |||
54 | 54 | ||
55 | ssize_t generic_getxattr(struct dentry *dentry, struct inode *inode, const char *name, void *buffer, size_t size); | 55 | ssize_t generic_getxattr(struct dentry *dentry, struct inode *inode, const char *name, void *buffer, size_t size); |
56 | ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size); | 56 | ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size); |
57 | int generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags); | 57 | int generic_setxattr(struct dentry *dentry, struct inode *inode, |
58 | const char *name, const void *value, size_t size, int flags); | ||
58 | int generic_removexattr(struct dentry *dentry, const char *name); | 59 | int generic_removexattr(struct dentry *dentry, const char *name); |
59 | ssize_t vfs_getxattr_alloc(struct dentry *dentry, const char *name, | 60 | ssize_t vfs_getxattr_alloc(struct dentry *dentry, const char *name, |
60 | char **xattr_value, size_t size, gfp_t flags); | 61 | char **xattr_value, size_t size, gfp_t flags); |
diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c index c817216c1615..2e853ad93a3a 100644 --- a/kernel/locking/rwsem.c +++ b/kernel/locking/rwsem.c | |||
@@ -173,6 +173,22 @@ void down_write_nested(struct rw_semaphore *sem, int subclass) | |||
173 | 173 | ||
174 | EXPORT_SYMBOL(down_write_nested); | 174 | EXPORT_SYMBOL(down_write_nested); |
175 | 175 | ||
176 | int __sched down_write_killable_nested(struct rw_semaphore *sem, int subclass) | ||
177 | { | ||
178 | might_sleep(); | ||
179 | rwsem_acquire(&sem->dep_map, subclass, 0, _RET_IP_); | ||
180 | |||
181 | if (LOCK_CONTENDED_RETURN(sem, __down_write_trylock, __down_write_killable)) { | ||
182 | rwsem_release(&sem->dep_map, 1, _RET_IP_); | ||
183 | return -EINTR; | ||
184 | } | ||
185 | |||
186 | rwsem_set_owner(sem); | ||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | EXPORT_SYMBOL(down_write_killable_nested); | ||
191 | |||
176 | void up_read_non_owner(struct rw_semaphore *sem) | 192 | void up_read_non_owner(struct rw_semaphore *sem) |
177 | { | 193 | { |
178 | __up_read(sem); | 194 | __up_read(sem); |
diff --git a/mm/shmem.c b/mm/shmem.c index e418a995427d..a36144909b28 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -2645,10 +2645,11 @@ static int shmem_xattr_handler_get(const struct xattr_handler *handler, | |||
2645 | } | 2645 | } |
2646 | 2646 | ||
2647 | static int shmem_xattr_handler_set(const struct xattr_handler *handler, | 2647 | static int shmem_xattr_handler_set(const struct xattr_handler *handler, |
2648 | struct dentry *dentry, const char *name, | 2648 | struct dentry *unused, struct inode *inode, |
2649 | const void *value, size_t size, int flags) | 2649 | const char *name, const void *value, |
2650 | size_t size, int flags) | ||
2650 | { | 2651 | { |
2651 | struct shmem_inode_info *info = SHMEM_I(d_inode(dentry)); | 2652 | struct shmem_inode_info *info = SHMEM_I(inode); |
2652 | 2653 | ||
2653 | name = xattr_full_name(handler, name); | 2654 | name = xattr_full_name(handler, name); |
2654 | return simple_xattr_set(&info->xattrs, name, value, size, flags); | 2655 | return simple_xattr_set(&info->xattrs, name, value, size, flags); |
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index ff2b8c3cf7a9..6777295f4b2b 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c | |||
@@ -3514,7 +3514,7 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode) | |||
3514 | */ | 3514 | */ |
3515 | if (isp->smk_flags & SMK_INODE_CHANGED) { | 3515 | if (isp->smk_flags & SMK_INODE_CHANGED) { |
3516 | isp->smk_flags &= ~SMK_INODE_CHANGED; | 3516 | isp->smk_flags &= ~SMK_INODE_CHANGED; |
3517 | rc = inode->i_op->setxattr(dp, | 3517 | rc = inode->i_op->setxattr(dp, inode, |
3518 | XATTR_NAME_SMACKTRANSMUTE, | 3518 | XATTR_NAME_SMACKTRANSMUTE, |
3519 | TRANS_TRUE, TRANS_TRUE_SIZE, | 3519 | TRANS_TRUE, TRANS_TRUE_SIZE, |
3520 | 0); | 3520 | 0); |