aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2016-05-26 10:55:18 -0400
committerJan Kara <jack@suse.cz>2016-09-22 04:56:19 -0400
commit31051c85b5e2aaaf6315f74c72a732673632a905 (patch)
treea3bdc58adf95cd02276f44188f6b33c9f06f5e1a
parent62490330769c1ce5dcba3f1f3e8f4005e9b797e6 (diff)
fs: Give dentry to inode_change_ok() instead of inode
inode_change_ok() will be resposible for clearing capabilities and IMA extended attributes and as such will need dentry. Give it as an argument to inode_change_ok() instead of an inode. Also rename inode_change_ok() to setattr_prepare() to better relect that it does also some modifications in addition to checks. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--Documentation/filesystems/porting4
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_lib.c2
-rw-r--r--fs/9p/vfs_inode.c2
-rw-r--r--fs/9p/vfs_inode_dotl.c2
-rw-r--r--fs/adfs/inode.c2
-rw-r--r--fs/affs/inode.c2
-rw-r--r--fs/attr.c15
-rw-r--r--fs/btrfs/inode.c2
-rw-r--r--fs/ceph/inode.c2
-rw-r--r--fs/cifs/inode.c4
-rw-r--r--fs/ecryptfs/inode.c2
-rw-r--r--fs/exofs/inode.c2
-rw-r--r--fs/ext2/inode.c2
-rw-r--r--fs/ext4/inode.c2
-rw-r--r--fs/f2fs/file.c2
-rw-r--r--fs/fat/file.c2
-rw-r--r--fs/fuse/dir.c2
-rw-r--r--fs/gfs2/inode.c2
-rw-r--r--fs/hfs/inode.c2
-rw-r--r--fs/hfsplus/inode.c2
-rw-r--r--fs/hostfs/hostfs_kern.c2
-rw-r--r--fs/hpfs/inode.c2
-rw-r--r--fs/hugetlbfs/inode.c2
-rw-r--r--fs/jffs2/fs.c2
-rw-r--r--fs/jfs/file.c2
-rw-r--r--fs/kernfs/inode.c2
-rw-r--r--fs/libfs.c2
-rw-r--r--fs/logfs/file.c2
-rw-r--r--fs/minix/file.c2
-rw-r--r--fs/ncpfs/inode.c2
-rw-r--r--fs/nfsd/nfsproc.c8
-rw-r--r--fs/nilfs2/inode.c2
-rw-r--r--fs/ntfs/inode.c2
-rw-r--r--fs/ocfs2/dlmfs/dlmfs.c2
-rw-r--r--fs/ocfs2/file.c2
-rw-r--r--fs/omfs/file.c2
-rw-r--r--fs/orangefs/inode.c2
-rw-r--r--fs/overlayfs/inode.c2
-rw-r--r--fs/proc/base.c2
-rw-r--r--fs/proc/generic.c2
-rw-r--r--fs/proc/proc_sysctl.c2
-rw-r--r--fs/ramfs/file-nommu.c2
-rw-r--r--fs/reiserfs/inode.c2
-rw-r--r--fs/sysv/file.c2
-rw-r--r--fs/ubifs/file.c2
-rw-r--r--fs/udf/file.c2
-rw-r--r--fs/ufs/inode.c2
-rw-r--r--fs/utimes.c4
-rw-r--r--fs/xfs/xfs_iops.c10
-rw-r--r--include/linux/fs.h2
-rw-r--r--mm/shmem.c2
51 files changed, 67 insertions, 68 deletions
diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting
index b1bd05ea66b2..ab320c77147a 100644
--- a/Documentation/filesystems/porting
+++ b/Documentation/filesystems/porting
@@ -287,8 +287,8 @@ implementing on-disk size changes. Start with a copy of the old inode_setattr
287and vmtruncate, and the reorder the vmtruncate + foofs_vmtruncate sequence to 287and vmtruncate, and the reorder the vmtruncate + foofs_vmtruncate sequence to
288be in order of zeroing blocks using block_truncate_page or similar helpers, 288be in order of zeroing blocks using block_truncate_page or similar helpers,
289size update and on finally on-disk truncation which should not fail. 289size update and on finally on-disk truncation which should not fail.
290inode_change_ok now includes the size checks for ATTR_SIZE and must be called 290setattr_prepare (which used to be inode_change_ok) now includes the size checks
291in the beginning of ->setattr unconditionally. 291for ATTR_SIZE and must be called in the beginning of ->setattr unconditionally.
292 292
293[mandatory] 293[mandatory]
294 294
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 546063e728db..fb7b54eff027 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1192,7 +1192,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
1192 attr->ia_valid |= ATTR_MTIME | ATTR_CTIME; 1192 attr->ia_valid |= ATTR_MTIME | ATTR_CTIME;
1193 } 1193 }
1194 1194
1195 /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */ 1195 /* POSIX: check before ATTR_*TIME_SET set (from setattr_prepare) */
1196 if (attr->ia_valid & TIMES_SET_FLAGS) { 1196 if (attr->ia_valid & TIMES_SET_FLAGS) {
1197 if ((!uid_eq(current_fsuid(), inode->i_uid)) && 1197 if ((!uid_eq(current_fsuid(), inode->i_uid)) &&
1198 !capable(CFS_CAP_FOWNER)) 1198 !capable(CFS_CAP_FOWNER))
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 8b1999b528e9..aa639bb1f289 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -1094,7 +1094,7 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
1094 struct p9_wstat wstat; 1094 struct p9_wstat wstat;
1095 1095
1096 p9_debug(P9_DEBUG_VFS, "\n"); 1096 p9_debug(P9_DEBUG_VFS, "\n");
1097 retval = inode_change_ok(d_inode(dentry), iattr); 1097 retval = setattr_prepare(dentry, iattr);
1098 if (retval) 1098 if (retval)
1099 return retval; 1099 return retval;
1100 1100
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index eeabcb0bad12..0e6ad3019711 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -558,7 +558,7 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
558 558
559 p9_debug(P9_DEBUG_VFS, "\n"); 559 p9_debug(P9_DEBUG_VFS, "\n");
560 560
561 retval = inode_change_ok(inode, iattr); 561 retval = setattr_prepare(dentry, iattr);
562 if (retval) 562 if (retval)
563 return retval; 563 return retval;
564 564
diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c
index 335055d828e4..f57baaa511aa 100644
--- a/fs/adfs/inode.c
+++ b/fs/adfs/inode.c
@@ -303,7 +303,7 @@ adfs_notify_change(struct dentry *dentry, struct iattr *attr)
303 unsigned int ia_valid = attr->ia_valid; 303 unsigned int ia_valid = attr->ia_valid;
304 int error; 304 int error;
305 305
306 error = inode_change_ok(inode, attr); 306 error = setattr_prepare(dentry, attr);
307 307
308 /* 308 /*
309 * we can't change the UID or GID of any file - 309 * we can't change the UID or GID of any file -
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 0fdb0f5b2239..1aa243502c7f 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -219,7 +219,7 @@ affs_notify_change(struct dentry *dentry, struct iattr *attr)
219 219
220 pr_debug("notify_change(%lu,0x%x)\n", inode->i_ino, attr->ia_valid); 220 pr_debug("notify_change(%lu,0x%x)\n", inode->i_ino, attr->ia_valid);
221 221
222 error = inode_change_ok(inode,attr); 222 error = setattr_prepare(dentry, attr);
223 if (error) 223 if (error)
224 goto out; 224 goto out;
225 225
diff --git a/fs/attr.c b/fs/attr.c
index 42bb42bb3c72..5c45909ea204 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -17,19 +17,22 @@
17#include <linux/ima.h> 17#include <linux/ima.h>
18 18
19/** 19/**
20 * inode_change_ok - check if attribute changes to an inode are allowed 20 * setattr_prepare - check if attribute changes to a dentry are allowed
21 * @inode: inode to check 21 * @dentry: dentry to check
22 * @attr: attributes to change 22 * @attr: attributes to change
23 * 23 *
24 * Check if we are allowed to change the attributes contained in @attr 24 * Check if we are allowed to change the attributes contained in @attr
25 * in the given inode. This includes the normal unix access permission 25 * in the given dentry. This includes the normal unix access permission
26 * checks, as well as checks for rlimits and others. 26 * checks, as well as checks for rlimits and others. The function also clears
27 * SGID bit from mode if user is not allowed to set it. Also file capabilities
28 * and IMA extended attributes are cleared if ATTR_KILL_PRIV is set.
27 * 29 *
28 * Should be called as the first thing in ->setattr implementations, 30 * Should be called as the first thing in ->setattr implementations,
29 * possibly after taking additional locks. 31 * possibly after taking additional locks.
30 */ 32 */
31int inode_change_ok(const struct inode *inode, struct iattr *attr) 33int setattr_prepare(struct dentry *dentry, struct iattr *attr)
32{ 34{
35 struct inode *inode = d_inode(dentry);
33 unsigned int ia_valid = attr->ia_valid; 36 unsigned int ia_valid = attr->ia_valid;
34 37
35 /* 38 /*
@@ -79,7 +82,7 @@ int inode_change_ok(const struct inode *inode, struct iattr *attr)
79 82
80 return 0; 83 return 0;
81} 84}
82EXPORT_SYMBOL(inode_change_ok); 85EXPORT_SYMBOL(setattr_prepare);
83 86
84/** 87/**
85 * inode_newsize_ok - may this inode be truncated to a given size 88 * inode_newsize_ok - may this inode be truncated to a given size
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 2f5975954ccf..bfa0b07160d5 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5042,7 +5042,7 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr)
5042 if (btrfs_root_readonly(root)) 5042 if (btrfs_root_readonly(root))
5043 return -EROFS; 5043 return -EROFS;
5044 5044
5045 err = inode_change_ok(inode, attr); 5045 err = setattr_prepare(dentry, attr);
5046 if (err) 5046 if (err)
5047 return err; 5047 return err;
5048 5048
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 2aa3c0bcf3a5..082e82dcbaa4 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -2123,7 +2123,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
2123 if (ceph_snap(inode) != CEPH_NOSNAP) 2123 if (ceph_snap(inode) != CEPH_NOSNAP)
2124 return -EROFS; 2124 return -EROFS;
2125 2125
2126 err = inode_change_ok(inode, attr); 2126 err = setattr_prepare(dentry, attr);
2127 if (err != 0) 2127 if (err != 0)
2128 return err; 2128 return err;
2129 2129
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index b87efd0c92d6..13cf507d1423 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -2154,7 +2154,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
2154 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) 2154 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
2155 attrs->ia_valid |= ATTR_FORCE; 2155 attrs->ia_valid |= ATTR_FORCE;
2156 2156
2157 rc = inode_change_ok(inode, attrs); 2157 rc = setattr_prepare(direntry, attrs);
2158 if (rc < 0) 2158 if (rc < 0)
2159 goto out; 2159 goto out;
2160 2160
@@ -2294,7 +2294,7 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
2294 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) 2294 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
2295 attrs->ia_valid |= ATTR_FORCE; 2295 attrs->ia_valid |= ATTR_FORCE;
2296 2296
2297 rc = inode_change_ok(inode, attrs); 2297 rc = setattr_prepare(direntry, attrs);
2298 if (rc < 0) { 2298 if (rc < 0) {
2299 free_xid(xid); 2299 free_xid(xid);
2300 return rc; 2300 return rc;
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 9d153b6a1d72..5ffba186f352 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -927,7 +927,7 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
927 } 927 }
928 mutex_unlock(&crypt_stat->cs_mutex); 928 mutex_unlock(&crypt_stat->cs_mutex);
929 929
930 rc = inode_change_ok(inode, ia); 930 rc = setattr_prepare(dentry, ia);
931 if (rc) 931 if (rc)
932 goto out; 932 goto out;
933 if (ia->ia_valid & ATTR_SIZE) { 933 if (ia->ia_valid & ATTR_SIZE) {
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index 9dc4c6dbf3c9..5e68daee5fe4 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -1034,7 +1034,7 @@ int exofs_setattr(struct dentry *dentry, struct iattr *iattr)
1034 if (unlikely(error)) 1034 if (unlikely(error))
1035 return error; 1035 return error;
1036 1036
1037 error = inode_change_ok(inode, iattr); 1037 error = setattr_prepare(dentry, iattr);
1038 if (unlikely(error)) 1038 if (unlikely(error))
1039 return error; 1039 return error;
1040 1040
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index d5c7d09919f3..65c077d9a5e9 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -1580,7 +1580,7 @@ int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
1580 struct inode *inode = d_inode(dentry); 1580 struct inode *inode = d_inode(dentry);
1581 int error; 1581 int error;
1582 1582
1583 error = inode_change_ok(inode, iattr); 1583 error = setattr_prepare(dentry, iattr);
1584 if (error) 1584 if (error)
1585 return error; 1585 return error;
1586 1586
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 3131747199e1..fdf9bee67a12 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5073,7 +5073,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
5073 int orphan = 0; 5073 int orphan = 0;
5074 const unsigned int ia_valid = attr->ia_valid; 5074 const unsigned int ia_valid = attr->ia_valid;
5075 5075
5076 error = inode_change_ok(inode, attr); 5076 error = setattr_prepare(dentry, attr);
5077 if (error) 5077 if (error)
5078 return error; 5078 return error;
5079 5079
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 0e493f63ea41..26ebda971d53 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -680,7 +680,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
680 struct inode *inode = d_inode(dentry); 680 struct inode *inode = d_inode(dentry);
681 int err; 681 int err;
682 682
683 err = inode_change_ok(inode, attr); 683 err = setattr_prepare(dentry, attr);
684 if (err) 684 if (err)
685 return err; 685 return err;
686 686
diff --git a/fs/fat/file.c b/fs/fat/file.c
index f70185668832..c09ab4e108e5 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -450,7 +450,7 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr)
450 attr->ia_valid &= ~TIMES_SET_FLAGS; 450 attr->ia_valid &= ~TIMES_SET_FLAGS;
451 } 451 }
452 452
453 error = inode_change_ok(inode, attr); 453 error = setattr_prepare(dentry, attr);
454 attr->ia_valid = ia_valid; 454 attr->ia_valid = ia_valid;
455 if (error) { 455 if (error) {
456 if (sbi->options.quiet) 456 if (sbi->options.quiet)
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 6911bfad7834..b23502174682 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1609,7 +1609,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
1609 if (!(fc->flags & FUSE_DEFAULT_PERMISSIONS)) 1609 if (!(fc->flags & FUSE_DEFAULT_PERMISSIONS))
1610 attr->ia_valid |= ATTR_FORCE; 1610 attr->ia_valid |= ATTR_FORCE;
1611 1611
1612 err = inode_change_ok(inode, attr); 1612 err = setattr_prepare(dentry, attr);
1613 if (err) 1613 if (err)
1614 return err; 1614 return err;
1615 1615
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index e4da0ecd3285..d693af5ca5bc 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1932,7 +1932,7 @@ static int gfs2_setattr(struct dentry *dentry, struct iattr *attr)
1932 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 1932 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1933 goto out; 1933 goto out;
1934 1934
1935 error = inode_change_ok(inode, attr); 1935 error = setattr_prepare(dentry, attr);
1936 if (error) 1936 if (error)
1937 goto out; 1937 goto out;
1938 1938
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index c6a32415735b..09cce23864da 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -605,7 +605,7 @@ int hfs_inode_setattr(struct dentry *dentry, struct iattr * attr)
605 struct hfs_sb_info *hsb = HFS_SB(inode->i_sb); 605 struct hfs_sb_info *hsb = HFS_SB(inode->i_sb);
606 int error; 606 int error;
607 607
608 error = inode_change_ok(inode, attr); /* basic permission checks */ 608 error = setattr_prepare(dentry, attr); /* basic permission checks */
609 if (error) 609 if (error)
610 return error; 610 return error;
611 611
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 19462d773fe2..c43ef397a3aa 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -245,7 +245,7 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr)
245 struct inode *inode = d_inode(dentry); 245 struct inode *inode = d_inode(dentry);
246 int error; 246 int error;
247 247
248 error = inode_change_ok(inode, attr); 248 error = setattr_prepare(dentry, attr);
249 if (error) 249 if (error)
250 return error; 250 return error;
251 251
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 90e46cd752fe..44aa96ba1df8 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -812,7 +812,7 @@ static int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
812 812
813 int fd = HOSTFS_I(inode)->fd; 813 int fd = HOSTFS_I(inode)->fd;
814 814
815 err = inode_change_ok(inode, attr); 815 err = setattr_prepare(dentry, attr);
816 if (err) 816 if (err)
817 return err; 817 return err;
818 818
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index 1f3c6d76200b..b9c724ed1e7e 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -273,7 +273,7 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
273 if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size) 273 if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size)
274 goto out_unlock; 274 goto out_unlock;
275 275
276 error = inode_change_ok(inode, attr); 276 error = setattr_prepare(dentry, attr);
277 if (error) 277 if (error)
278 goto out_unlock; 278 goto out_unlock;
279 279
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 4ea71eba40a5..fb3312f2c861 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -672,7 +672,7 @@ static int hugetlbfs_setattr(struct dentry *dentry, struct iattr *attr)
672 672
673 BUG_ON(!inode); 673 BUG_ON(!inode);
674 674
675 error = inode_change_ok(inode, attr); 675 error = setattr_prepare(dentry, attr);
676 if (error) 676 if (error)
677 return error; 677 return error;
678 678
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index ae2ebb26b446..3773b24b4db0 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -193,7 +193,7 @@ int jffs2_setattr(struct dentry *dentry, struct iattr *iattr)
193 struct inode *inode = d_inode(dentry); 193 struct inode *inode = d_inode(dentry);
194 int rc; 194 int rc;
195 195
196 rc = inode_change_ok(inode, iattr); 196 rc = setattr_prepare(dentry, iattr);
197 if (rc) 197 if (rc)
198 return rc; 198 return rc;
199 199
diff --git a/fs/jfs/file.c b/fs/jfs/file.c
index 7f1a585a0a94..cf62037b8a04 100644
--- a/fs/jfs/file.c
+++ b/fs/jfs/file.c
@@ -103,7 +103,7 @@ int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
103 struct inode *inode = d_inode(dentry); 103 struct inode *inode = d_inode(dentry);
104 int rc; 104 int rc;
105 105
106 rc = inode_change_ok(inode, iattr); 106 rc = setattr_prepare(dentry, iattr);
107 if (rc) 107 if (rc)
108 return rc; 108 return rc;
109 109
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index 63b925d5ba1e..df21f5b75549 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -122,7 +122,7 @@ int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr)
122 return -EINVAL; 122 return -EINVAL;
123 123
124 mutex_lock(&kernfs_mutex); 124 mutex_lock(&kernfs_mutex);
125 error = inode_change_ok(inode, iattr); 125 error = setattr_prepare(dentry, iattr);
126 if (error) 126 if (error)
127 goto out; 127 goto out;
128 128
diff --git a/fs/libfs.c b/fs/libfs.c
index 74dc8b9e7f53..2b3c3ae70153 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -394,7 +394,7 @@ int simple_setattr(struct dentry *dentry, struct iattr *iattr)
394 struct inode *inode = d_inode(dentry); 394 struct inode *inode = d_inode(dentry);
395 int error; 395 int error;
396 396
397 error = inode_change_ok(inode, iattr); 397 error = setattr_prepare(dentry, iattr);
398 if (error) 398 if (error)
399 return error; 399 return error;
400 400
diff --git a/fs/logfs/file.c b/fs/logfs/file.c
index f01ddfb1a03b..5d9fe466bbc9 100644
--- a/fs/logfs/file.c
+++ b/fs/logfs/file.c
@@ -244,7 +244,7 @@ static int logfs_setattr(struct dentry *dentry, struct iattr *attr)
244 struct inode *inode = d_inode(dentry); 244 struct inode *inode = d_inode(dentry);
245 int err = 0; 245 int err = 0;
246 246
247 err = inode_change_ok(inode, attr); 247 err = setattr_prepare(dentry, attr);
248 if (err) 248 if (err)
249 return err; 249 return err;
250 250
diff --git a/fs/minix/file.c b/fs/minix/file.c
index 94f0eb9a6e2c..a6a4797aa0d4 100644
--- a/fs/minix/file.c
+++ b/fs/minix/file.c
@@ -26,7 +26,7 @@ static int minix_setattr(struct dentry *dentry, struct iattr *attr)
26 struct inode *inode = d_inode(dentry); 26 struct inode *inode = d_inode(dentry);
27 int error; 27 int error;
28 28
29 error = inode_change_ok(inode, attr); 29 error = setattr_prepare(dentry, attr);
30 if (error) 30 if (error)
31 return error; 31 return error;
32 32
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 1af15fcbe57b..f6cf4c7e92b1 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -884,7 +884,7 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
884 /* ageing the dentry to force validation */ 884 /* ageing the dentry to force validation */
885 ncp_age_dentry(server, dentry); 885 ncp_age_dentry(server, dentry);
886 886
887 result = inode_change_ok(inode, attr); 887 result = setattr_prepare(dentry, attr);
888 if (result < 0) 888 if (result < 0)
889 goto out; 889 goto out;
890 890
diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c
index e9214768cde9..08188743db53 100644
--- a/fs/nfsd/nfsproc.c
+++ b/fs/nfsd/nfsproc.c
@@ -74,10 +74,10 @@ nfsd_proc_setattr(struct svc_rqst *rqstp, struct nfsd_sattrargs *argp,
74 * which only requires access, and "set-[ac]time-to-X" which 74 * which only requires access, and "set-[ac]time-to-X" which
75 * requires ownership. 75 * requires ownership.
76 * So if it looks like it might be "set both to the same time which 76 * So if it looks like it might be "set both to the same time which
77 * is close to now", and if inode_change_ok fails, then we 77 * is close to now", and if setattr_prepare fails, then we
78 * convert to "set to now" instead of "set to explicit time" 78 * convert to "set to now" instead of "set to explicit time"
79 * 79 *
80 * We only call inode_change_ok as the last test as technically 80 * We only call setattr_prepare as the last test as technically
81 * it is not an interface that we should be using. 81 * it is not an interface that we should be using.
82 */ 82 */
83#define BOTH_TIME_SET (ATTR_ATIME_SET | ATTR_MTIME_SET) 83#define BOTH_TIME_SET (ATTR_ATIME_SET | ATTR_MTIME_SET)
@@ -92,17 +92,15 @@ nfsd_proc_setattr(struct svc_rqst *rqstp, struct nfsd_sattrargs *argp,
92 * request is. We require it be within 30 minutes of now. 92 * request is. We require it be within 30 minutes of now.
93 */ 93 */
94 time_t delta = iap->ia_atime.tv_sec - get_seconds(); 94 time_t delta = iap->ia_atime.tv_sec - get_seconds();
95 struct inode *inode;
96 95
97 nfserr = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP); 96 nfserr = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP);
98 if (nfserr) 97 if (nfserr)
99 goto done; 98 goto done;
100 inode = d_inode(fhp->fh_dentry);
101 99
102 if (delta < 0) 100 if (delta < 0)
103 delta = -delta; 101 delta = -delta;
104 if (delta < MAX_TOUCH_TIME_ERROR && 102 if (delta < MAX_TOUCH_TIME_ERROR &&
105 inode_change_ok(inode, iap) != 0) { 103 setattr_prepare(fhp->fh_dentry, iap) != 0) {
106 /* 104 /*
107 * Turn off ATTR_[AM]TIME_SET but leave ATTR_[AM]TIME. 105 * Turn off ATTR_[AM]TIME_SET but leave ATTR_[AM]TIME.
108 * This will cause notify_change to set these times 106 * This will cause notify_change to set these times
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index af04f553d7c9..402c325e0467 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -829,7 +829,7 @@ int nilfs_setattr(struct dentry *dentry, struct iattr *iattr)
829 struct super_block *sb = inode->i_sb; 829 struct super_block *sb = inode->i_sb;
830 int err; 830 int err;
831 831
832 err = inode_change_ok(inode, iattr); 832 err = setattr_prepare(dentry, iattr);
833 if (err) 833 if (err)
834 return err; 834 return err;
835 835
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index e01287c964a8..9d7a44872df5 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -2893,7 +2893,7 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr)
2893 int err; 2893 int err;
2894 unsigned int ia_valid = attr->ia_valid; 2894 unsigned int ia_valid = attr->ia_valid;
2895 2895
2896 err = inode_change_ok(vi, attr); 2896 err = setattr_prepare(dentry, attr);
2897 if (err) 2897 if (err)
2898 goto out; 2898 goto out;
2899 /* We do not support NTFS ACLs yet. */ 2899 /* We do not support NTFS ACLs yet. */
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index ef474cdd6404..6a4b21654037 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -211,7 +211,7 @@ static int dlmfs_file_setattr(struct dentry *dentry, struct iattr *attr)
211 struct inode *inode = d_inode(dentry); 211 struct inode *inode = d_inode(dentry);
212 212
213 attr->ia_valid &= ~ATTR_SIZE; 213 attr->ia_valid &= ~ATTR_SIZE;
214 error = inode_change_ok(inode, attr); 214 error = setattr_prepare(dentry, attr);
215 if (error) 215 if (error)
216 return error; 216 return error;
217 217
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 4e7b0dc22450..1ab3657242e8 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1155,7 +1155,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
1155 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) 1155 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
1156 return 0; 1156 return 0;
1157 1157
1158 status = inode_change_ok(inode, attr); 1158 status = setattr_prepare(dentry, attr);
1159 if (status) 1159 if (status)
1160 return status; 1160 return status;
1161 1161
diff --git a/fs/omfs/file.c b/fs/omfs/file.c
index d9e26cfbb793..bf83e6644333 100644
--- a/fs/omfs/file.c
+++ b/fs/omfs/file.c
@@ -349,7 +349,7 @@ static int omfs_setattr(struct dentry *dentry, struct iattr *attr)
349 struct inode *inode = d_inode(dentry); 349 struct inode *inode = d_inode(dentry);
350 int error; 350 int error;
351 351
352 error = inode_change_ok(inode, attr); 352 error = setattr_prepare(dentry, attr);
353 if (error) 353 if (error)
354 return error; 354 return error;
355 355
diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index 28a0557a69be..cff00ebac03a 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -219,7 +219,7 @@ int orangefs_setattr(struct dentry *dentry, struct iattr *iattr)
219 "orangefs_setattr: called on %s\n", 219 "orangefs_setattr: called on %s\n",
220 dentry->d_name.name); 220 dentry->d_name.name);
221 221
222 ret = inode_change_ok(inode, iattr); 222 ret = setattr_prepare(dentry, iattr);
223 if (ret) 223 if (ret)
224 goto out; 224 goto out;
225 225
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 1b885c156028..990388dba9b8 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -52,7 +52,7 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
52 * inode_newsize_ok() will always check against MAX_LFS_FILESIZE and not 52 * inode_newsize_ok() will always check against MAX_LFS_FILESIZE and not
53 * check for a swapfile (which this won't be anyway). 53 * check for a swapfile (which this won't be anyway).
54 */ 54 */
55 err = inode_change_ok(dentry->d_inode, attr); 55 err = setattr_prepare(dentry, attr);
56 if (err) 56 if (err)
57 return err; 57 return err;
58 58
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 54e270262979..207f36039f63 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -709,7 +709,7 @@ int proc_setattr(struct dentry *dentry, struct iattr *attr)
709 if (attr->ia_valid & ATTR_MODE) 709 if (attr->ia_valid & ATTR_MODE)
710 return -EPERM; 710 return -EPERM;
711 711
712 error = inode_change_ok(inode, attr); 712 error = setattr_prepare(dentry, attr);
713 if (error) 713 if (error)
714 return error; 714 return error;
715 715
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index c633476616e0..23ff30e3c1e7 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -105,7 +105,7 @@ static int proc_notify_change(struct dentry *dentry, struct iattr *iattr)
105 struct proc_dir_entry *de = PDE(inode); 105 struct proc_dir_entry *de = PDE(inode);
106 int error; 106 int error;
107 107
108 error = inode_change_ok(inode, iattr); 108 error = setattr_prepare(dentry, iattr);
109 if (error) 109 if (error)
110 return error; 110 return error;
111 111
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 1b93650dda2f..268fcf592b0e 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -754,7 +754,7 @@ static int proc_sys_setattr(struct dentry *dentry, struct iattr *attr)
754 if (attr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID)) 754 if (attr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID))
755 return -EPERM; 755 return -EPERM;
756 756
757 error = inode_change_ok(inode, attr); 757 error = setattr_prepare(dentry, attr);
758 if (error) 758 if (error)
759 return error; 759 return error;
760 760
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index be3ddd189cd4..2bcbf4e77982 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -169,7 +169,7 @@ static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia)
169 int ret = 0; 169 int ret = 0;
170 170
171 /* POSIX UID/GID verification for setting inode attributes */ 171 /* POSIX UID/GID verification for setting inode attributes */
172 ret = inode_change_ok(inode, ia); 172 ret = setattr_prepare(dentry, ia);
173 if (ret) 173 if (ret)
174 return ret; 174 return ret;
175 175
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index c2c59f9ff04b..cb7f518d37ae 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -3312,7 +3312,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
3312 unsigned int ia_valid; 3312 unsigned int ia_valid;
3313 int error; 3313 int error;
3314 3314
3315 error = inode_change_ok(inode, attr); 3315 error = setattr_prepare(dentry, attr);
3316 if (error) 3316 if (error)
3317 return error; 3317 return error;
3318 3318
diff --git a/fs/sysv/file.c b/fs/sysv/file.c
index 82ddc09061e2..7ba997e31aeb 100644
--- a/fs/sysv/file.c
+++ b/fs/sysv/file.c
@@ -33,7 +33,7 @@ static int sysv_setattr(struct dentry *dentry, struct iattr *attr)
33 struct inode *inode = d_inode(dentry); 33 struct inode *inode = d_inode(dentry);
34 int error; 34 int error;
35 35
36 error = inode_change_ok(inode, attr); 36 error = setattr_prepare(dentry, attr);
37 if (error) 37 if (error)
38 return error; 38 return error;
39 39
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 7bbf420d1289..b0a6a53263f3 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1262,7 +1262,7 @@ int ubifs_setattr(struct dentry *dentry, struct iattr *attr)
1262 1262
1263 dbg_gen("ino %lu, mode %#x, ia_valid %#x", 1263 dbg_gen("ino %lu, mode %#x, ia_valid %#x",
1264 inode->i_ino, inode->i_mode, attr->ia_valid); 1264 inode->i_ino, inode->i_mode, attr->ia_valid);
1265 err = inode_change_ok(inode, attr); 1265 err = setattr_prepare(dentry, attr);
1266 if (err) 1266 if (err)
1267 return err; 1267 return err;
1268 1268
diff --git a/fs/udf/file.c b/fs/udf/file.c
index e855bf8d74b4..dbcb3a4a0cb9 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -261,7 +261,7 @@ static int udf_setattr(struct dentry *dentry, struct iattr *attr)
261 struct inode *inode = d_inode(dentry); 261 struct inode *inode = d_inode(dentry);
262 int error; 262 int error;
263 263
264 error = inode_change_ok(inode, attr); 264 error = setattr_prepare(dentry, attr);
265 if (error) 265 if (error)
266 return error; 266 return error;
267 267
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 9f49431e798d..e4a4d248a0f5 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -1208,7 +1208,7 @@ int ufs_setattr(struct dentry *dentry, struct iattr *attr)
1208 unsigned int ia_valid = attr->ia_valid; 1208 unsigned int ia_valid = attr->ia_valid;
1209 int error; 1209 int error;
1210 1210
1211 error = inode_change_ok(inode, attr); 1211 error = setattr_prepare(dentry, attr);
1212 if (error) 1212 if (error)
1213 return error; 1213 return error;
1214 1214
diff --git a/fs/utimes.c b/fs/utimes.c
index 794f5f5b1fb5..c84b26e46bc5 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -81,7 +81,7 @@ static int utimes_common(struct path *path, struct timespec *times)
81 newattrs.ia_valid |= ATTR_MTIME_SET; 81 newattrs.ia_valid |= ATTR_MTIME_SET;
82 } 82 }
83 /* 83 /*
84 * Tell inode_change_ok(), that this is an explicit time 84 * Tell setattr_prepare(), that this is an explicit time
85 * update, even if neither ATTR_ATIME_SET nor ATTR_MTIME_SET 85 * update, even if neither ATTR_ATIME_SET nor ATTR_MTIME_SET
86 * were used. 86 * were used.
87 */ 87 */
@@ -90,7 +90,7 @@ static int utimes_common(struct path *path, struct timespec *times)
90 /* 90 /*
91 * If times is NULL (or both times are UTIME_NOW), 91 * If times is NULL (or both times are UTIME_NOW),
92 * then we need to check permissions, because 92 * then we need to check permissions, because
93 * inode_change_ok() won't do it. 93 * setattr_prepare() won't do it.
94 */ 94 */
95 error = -EPERM; 95 error = -EPERM;
96 if (IS_IMMUTABLE(inode)) 96 if (IS_IMMUTABLE(inode))
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index f5db392e7d1e..6d0d5d413fad 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -547,9 +547,7 @@ xfs_vn_change_ok(
547 struct dentry *dentry, 547 struct dentry *dentry,
548 struct iattr *iattr) 548 struct iattr *iattr)
549{ 549{
550 struct inode *inode = d_inode(dentry); 550 struct xfs_mount *mp = XFS_I(d_inode(dentry))->i_mount;
551 struct xfs_inode *ip = XFS_I(inode);
552 struct xfs_mount *mp = ip->i_mount;
553 551
554 if (mp->m_flags & XFS_MOUNT_RDONLY) 552 if (mp->m_flags & XFS_MOUNT_RDONLY)
555 return -EROFS; 553 return -EROFS;
@@ -557,14 +555,14 @@ xfs_vn_change_ok(
557 if (XFS_FORCED_SHUTDOWN(mp)) 555 if (XFS_FORCED_SHUTDOWN(mp))
558 return -EIO; 556 return -EIO;
559 557
560 return inode_change_ok(inode, iattr); 558 return setattr_prepare(dentry, iattr);
561} 559}
562 560
563/* 561/*
564 * Set non-size attributes of an inode. 562 * Set non-size attributes of an inode.
565 * 563 *
566 * Caution: The caller of this function is responsible for calling 564 * Caution: The caller of this function is responsible for calling
567 * inode_change_ok() or otherwise verifying the change is fine. 565 * setattr_prepare() or otherwise verifying the change is fine.
568 */ 566 */
569int 567int
570xfs_setattr_nonsize( 568xfs_setattr_nonsize(
@@ -772,7 +770,7 @@ xfs_vn_setattr_nonsize(
772 * Truncate file. Must have write permission and not be a directory. 770 * Truncate file. Must have write permission and not be a directory.
773 * 771 *
774 * Caution: The caller of this function is responsible for calling 772 * Caution: The caller of this function is responsible for calling
775 * inode_change_ok() or otherwise verifying the change is fine. 773 * setattr_prepare() or otherwise verifying the change is fine.
776 */ 774 */
777int 775int
778xfs_setattr_size( 776xfs_setattr_size(
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 3523bf62f328..943a21cbb469 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2994,7 +2994,7 @@ extern int buffer_migrate_page(struct address_space *,
2994#define buffer_migrate_page NULL 2994#define buffer_migrate_page NULL
2995#endif 2995#endif
2996 2996
2997extern int inode_change_ok(const struct inode *, struct iattr *); 2997extern int setattr_prepare(struct dentry *, struct iattr *);
2998extern int inode_newsize_ok(const struct inode *, loff_t offset); 2998extern int inode_newsize_ok(const struct inode *, loff_t offset);
2999extern void setattr_copy(struct inode *inode, const struct iattr *attr); 2999extern void setattr_copy(struct inode *inode, const struct iattr *attr);
3000 3000
diff --git a/mm/shmem.c b/mm/shmem.c
index 7f7748a0f9e1..886b1236e68a 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -959,7 +959,7 @@ static int shmem_setattr(struct dentry *dentry, struct iattr *attr)
959 struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); 959 struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
960 int error; 960 int error;
961 961
962 error = inode_change_ok(inode, attr); 962 error = setattr_prepare(dentry, attr);
963 if (error) 963 if (error)
964 return error; 964 return error;
965 965