diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-01-22 15:40:57 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-01-22 18:04:28 -0500 |
commit | 5955102c9984fa081b2d570cfac75c97eecf8f3b (patch) | |
tree | a4744386eac4b916e847eb4eedfada158f6527b4 /fs/ecryptfs | |
parent | 57b8f112cfe6622ddddb8c2641206bb5fa8a112d (diff) |
wrappers for ->i_mutex access
parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
inode_foo(inode) being mutex_foo(&inode->i_mutex).
Please, use those for access to ->i_mutex; over the coming cycle
->i_mutex will become rwsem, with ->lookup() done with it held
only shared.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r-- | fs/ecryptfs/inode.c | 32 | ||||
-rw-r--r-- | fs/ecryptfs/mmap.c | 4 |
2 files changed, 18 insertions, 18 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 040aa879d634..4e685ac1024d 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -41,13 +41,13 @@ static struct dentry *lock_parent(struct dentry *dentry) | |||
41 | struct dentry *dir; | 41 | struct dentry *dir; |
42 | 42 | ||
43 | dir = dget_parent(dentry); | 43 | dir = dget_parent(dentry); |
44 | mutex_lock_nested(&(d_inode(dir)->i_mutex), I_MUTEX_PARENT); | 44 | inode_lock_nested(d_inode(dir), I_MUTEX_PARENT); |
45 | return dir; | 45 | return dir; |
46 | } | 46 | } |
47 | 47 | ||
48 | static void unlock_dir(struct dentry *dir) | 48 | static void unlock_dir(struct dentry *dir) |
49 | { | 49 | { |
50 | mutex_unlock(&d_inode(dir)->i_mutex); | 50 | inode_unlock(d_inode(dir)); |
51 | dput(dir); | 51 | dput(dir); |
52 | } | 52 | } |
53 | 53 | ||
@@ -397,11 +397,11 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode, | |||
397 | int rc = 0; | 397 | int rc = 0; |
398 | 398 | ||
399 | lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent); | 399 | lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent); |
400 | mutex_lock(&d_inode(lower_dir_dentry)->i_mutex); | 400 | inode_lock(d_inode(lower_dir_dentry)); |
401 | lower_dentry = lookup_one_len(ecryptfs_dentry->d_name.name, | 401 | lower_dentry = lookup_one_len(ecryptfs_dentry->d_name.name, |
402 | lower_dir_dentry, | 402 | lower_dir_dentry, |
403 | ecryptfs_dentry->d_name.len); | 403 | ecryptfs_dentry->d_name.len); |
404 | mutex_unlock(&d_inode(lower_dir_dentry)->i_mutex); | 404 | inode_unlock(d_inode(lower_dir_dentry)); |
405 | if (IS_ERR(lower_dentry)) { | 405 | if (IS_ERR(lower_dentry)) { |
406 | rc = PTR_ERR(lower_dentry); | 406 | rc = PTR_ERR(lower_dentry); |
407 | ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " | 407 | ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " |
@@ -426,11 +426,11 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode, | |||
426 | "filename; rc = [%d]\n", __func__, rc); | 426 | "filename; rc = [%d]\n", __func__, rc); |
427 | goto out; | 427 | goto out; |
428 | } | 428 | } |
429 | mutex_lock(&d_inode(lower_dir_dentry)->i_mutex); | 429 | inode_lock(d_inode(lower_dir_dentry)); |
430 | lower_dentry = lookup_one_len(encrypted_and_encoded_name, | 430 | lower_dentry = lookup_one_len(encrypted_and_encoded_name, |
431 | lower_dir_dentry, | 431 | lower_dir_dentry, |
432 | encrypted_and_encoded_name_size); | 432 | encrypted_and_encoded_name_size); |
433 | mutex_unlock(&d_inode(lower_dir_dentry)->i_mutex); | 433 | inode_unlock(d_inode(lower_dir_dentry)); |
434 | if (IS_ERR(lower_dentry)) { | 434 | if (IS_ERR(lower_dentry)) { |
435 | rc = PTR_ERR(lower_dentry); | 435 | rc = PTR_ERR(lower_dentry); |
436 | ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " | 436 | ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " |
@@ -869,9 +869,9 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length) | |||
869 | if (!rc && lower_ia.ia_valid & ATTR_SIZE) { | 869 | if (!rc && lower_ia.ia_valid & ATTR_SIZE) { |
870 | struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); | 870 | struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); |
871 | 871 | ||
872 | mutex_lock(&d_inode(lower_dentry)->i_mutex); | 872 | inode_lock(d_inode(lower_dentry)); |
873 | rc = notify_change(lower_dentry, &lower_ia, NULL); | 873 | rc = notify_change(lower_dentry, &lower_ia, NULL); |
874 | mutex_unlock(&d_inode(lower_dentry)->i_mutex); | 874 | inode_unlock(d_inode(lower_dentry)); |
875 | } | 875 | } |
876 | return rc; | 876 | return rc; |
877 | } | 877 | } |
@@ -970,9 +970,9 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia) | |||
970 | if (lower_ia.ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID)) | 970 | if (lower_ia.ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID)) |
971 | lower_ia.ia_valid &= ~ATTR_MODE; | 971 | lower_ia.ia_valid &= ~ATTR_MODE; |
972 | 972 | ||
973 | mutex_lock(&d_inode(lower_dentry)->i_mutex); | 973 | inode_lock(d_inode(lower_dentry)); |
974 | rc = notify_change(lower_dentry, &lower_ia, NULL); | 974 | rc = notify_change(lower_dentry, &lower_ia, NULL); |
975 | mutex_unlock(&d_inode(lower_dentry)->i_mutex); | 975 | inode_unlock(d_inode(lower_dentry)); |
976 | out: | 976 | out: |
977 | fsstack_copy_attr_all(inode, lower_inode); | 977 | fsstack_copy_attr_all(inode, lower_inode); |
978 | return rc; | 978 | return rc; |
@@ -1048,10 +1048,10 @@ ecryptfs_getxattr_lower(struct dentry *lower_dentry, const char *name, | |||
1048 | rc = -EOPNOTSUPP; | 1048 | rc = -EOPNOTSUPP; |
1049 | goto out; | 1049 | goto out; |
1050 | } | 1050 | } |
1051 | mutex_lock(&d_inode(lower_dentry)->i_mutex); | 1051 | inode_lock(d_inode(lower_dentry)); |
1052 | rc = d_inode(lower_dentry)->i_op->getxattr(lower_dentry, name, value, | 1052 | rc = d_inode(lower_dentry)->i_op->getxattr(lower_dentry, name, value, |
1053 | size); | 1053 | size); |
1054 | mutex_unlock(&d_inode(lower_dentry)->i_mutex); | 1054 | inode_unlock(d_inode(lower_dentry)); |
1055 | out: | 1055 | out: |
1056 | return rc; | 1056 | return rc; |
1057 | } | 1057 | } |
@@ -1075,9 +1075,9 @@ ecryptfs_listxattr(struct dentry *dentry, char *list, size_t size) | |||
1075 | rc = -EOPNOTSUPP; | 1075 | rc = -EOPNOTSUPP; |
1076 | goto out; | 1076 | goto out; |
1077 | } | 1077 | } |
1078 | mutex_lock(&d_inode(lower_dentry)->i_mutex); | 1078 | inode_lock(d_inode(lower_dentry)); |
1079 | rc = d_inode(lower_dentry)->i_op->listxattr(lower_dentry, list, size); | 1079 | rc = d_inode(lower_dentry)->i_op->listxattr(lower_dentry, list, size); |
1080 | mutex_unlock(&d_inode(lower_dentry)->i_mutex); | 1080 | inode_unlock(d_inode(lower_dentry)); |
1081 | out: | 1081 | out: |
1082 | return rc; | 1082 | return rc; |
1083 | } | 1083 | } |
@@ -1092,9 +1092,9 @@ static int ecryptfs_removexattr(struct dentry *dentry, const char *name) | |||
1092 | rc = -EOPNOTSUPP; | 1092 | rc = -EOPNOTSUPP; |
1093 | goto out; | 1093 | goto out; |
1094 | } | 1094 | } |
1095 | mutex_lock(&d_inode(lower_dentry)->i_mutex); | 1095 | inode_lock(d_inode(lower_dentry)); |
1096 | rc = d_inode(lower_dentry)->i_op->removexattr(lower_dentry, name); | 1096 | rc = d_inode(lower_dentry)->i_op->removexattr(lower_dentry, name); |
1097 | mutex_unlock(&d_inode(lower_dentry)->i_mutex); | 1097 | inode_unlock(d_inode(lower_dentry)); |
1098 | out: | 1098 | out: |
1099 | return rc; | 1099 | return rc; |
1100 | } | 1100 | } |
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c index caba848ac763..c6ced4cbf0cf 100644 --- a/fs/ecryptfs/mmap.c +++ b/fs/ecryptfs/mmap.c | |||
@@ -436,7 +436,7 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode) | |||
436 | rc = -ENOMEM; | 436 | rc = -ENOMEM; |
437 | goto out; | 437 | goto out; |
438 | } | 438 | } |
439 | mutex_lock(&lower_inode->i_mutex); | 439 | inode_lock(lower_inode); |
440 | size = lower_inode->i_op->getxattr(lower_dentry, ECRYPTFS_XATTR_NAME, | 440 | size = lower_inode->i_op->getxattr(lower_dentry, ECRYPTFS_XATTR_NAME, |
441 | xattr_virt, PAGE_CACHE_SIZE); | 441 | xattr_virt, PAGE_CACHE_SIZE); |
442 | if (size < 0) | 442 | if (size < 0) |
@@ -444,7 +444,7 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode) | |||
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, ECRYPTFS_XATTR_NAME, |
446 | xattr_virt, size, 0); | 446 | xattr_virt, size, 0); |
447 | mutex_unlock(&lower_inode->i_mutex); | 447 | inode_unlock(lower_inode); |
448 | if (rc) | 448 | if (rc) |
449 | printk(KERN_ERR "Error whilst attempting to write inode size " | 449 | printk(KERN_ERR "Error whilst attempting to write inode size " |
450 | "to lower file xattr; rc = [%d]\n", rc); | 450 | "to lower file xattr; rc = [%d]\n", rc); |