]> git.hungrycats.org Git - linux/commitdiff
fs: Give dentry to inode_change_ok() instead of inode
authorJan Kara <jack@suse.cz>
Thu, 26 May 2016 14:55:18 +0000 (16:55 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 20 Nov 2016 01:17:38 +0000 (01:17 +0000)
commit 31051c85b5e2aaaf6315f74c72a732673632a905 upstream.

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>
[bwh: Backported to 3.16:
 - Drop changes to orangefs, overlayfs
 - Adjust filenames, context
 - In fuse, pass dentry to fuse_do_setattr()
 - In nfsd, pass dentry to nfsd_sanitize_attrs()
 - In xfs, pass dentry to xfs_setattr_nonsize() and xfs_setattr_size()
 - Update ext3 as well]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
55 files changed:
Documentation/filesystems/porting
drivers/staging/lustre/lustre/llite/llite_lib.c
fs/9p/vfs_inode.c
fs/9p/vfs_inode_dotl.c
fs/adfs/inode.c
fs/affs/inode.c
fs/attr.c
fs/btrfs/inode.c
fs/ceph/inode.c
fs/cifs/inode.c
fs/ecryptfs/inode.c
fs/exofs/inode.c
fs/ext2/inode.c
fs/ext3/inode.c
fs/ext4/inode.c
fs/f2fs/file.c
fs/fat/file.c
fs/fuse/dir.c
fs/fuse/fuse_i.h
fs/gfs2/inode.c
fs/hfs/inode.c
fs/hfsplus/inode.c
fs/hostfs/hostfs_kern.c
fs/hpfs/inode.c
fs/hugetlbfs/inode.c
fs/jffs2/fs.c
fs/jfs/file.c
fs/kernfs/inode.c
fs/libfs.c
fs/logfs/file.c
fs/minix/file.c
fs/ncpfs/inode.c
fs/nfsd/vfs.c
fs/nilfs2/inode.c
fs/ntfs/inode.c
fs/ocfs2/dlmfs/dlmfs.c
fs/ocfs2/file.c
fs/omfs/file.c
fs/proc/base.c
fs/proc/generic.c
fs/proc/proc_sysctl.c
fs/ramfs/file-nommu.c
fs/reiserfs/inode.c
fs/sysv/file.c
fs/ubifs/file.c
fs/udf/file.c
fs/ufs/truncate.c
fs/utimes.c
fs/xfs/xfs_acl.c
fs/xfs/xfs_file.c
fs/xfs/xfs_ioctl.c
fs/xfs/xfs_iops.c
fs/xfs/xfs_iops.h
include/linux/fs.h
mm/shmem.c

index 0f3a1390bf0087a2509c39d6a317b25b78bd2988..4f65ae209a652f8b3ac1452f0e2769cec670b02b 100644 (file)
@@ -287,8 +287,8 @@ implementing on-disk size changes.  Start with a copy of the old inode_setattr
 and vmtruncate, and the reorder the vmtruncate + foofs_vmtruncate sequence to
 be in order of zeroing blocks using block_truncate_page or similar helpers,
 size update and on finally on-disk truncation which should not fail.
-inode_change_ok now includes the size checks for ATTR_SIZE and must be called
-in the beginning of ->setattr unconditionally.
+setattr_prepare (which used to be inode_change_ok) now includes the size checks
+for ATTR_SIZE and must be called in the beginning of ->setattr unconditionally.
 
 [mandatory]
 
index 0e507f53fd9b223157f4e2c7670f5c46c5592dc2..17cfa99b4fc094defee7ab7ee3209796566230f6 100644 (file)
@@ -1386,7 +1386,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
                attr->ia_valid |= ATTR_MTIME | ATTR_CTIME;
        }
 
-       /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */
+       /* POSIX: check before ATTR_*TIME_SET set (from setattr_prepare) */
        if (attr->ia_valid & TIMES_SET_FLAGS) {
                if ((!uid_eq(current_fsuid(), inode->i_uid)) &&
                    !capable(CFS_CAP_FOWNER))
index bdfcea010c9fe98346d6902ff4f6f8c62b285a93..d0b7320b17c4ca323439316c3ef70b872c462c7f 100644 (file)
@@ -1094,7 +1094,7 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
        struct p9_wstat wstat;
 
        p9_debug(P9_DEBUG_VFS, "\n");
-       retval = inode_change_ok(dentry->d_inode, iattr);
+       retval = setattr_prepare(dentry, iattr);
        if (retval)
                return retval;
 
index d3fb858719214a81c3c6475a3632eb6a7f8e6b8d..f03024e5bcbec765ae38e05d67fabe2bdef96c60 100644 (file)
@@ -560,7 +560,7 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
 
        p9_debug(P9_DEBUG_VFS, "\n");
 
-       retval = inode_change_ok(inode, iattr);
+       retval = setattr_prepare(dentry, iattr);
        if (retval)
                return retval;
 
index b9acadafa4a10780d92c6d520008406fce4d5ddc..247b351f300576f5a9354029b18358afb0719e1b 100644 (file)
@@ -303,7 +303,7 @@ adfs_notify_change(struct dentry *dentry, struct iattr *attr)
        unsigned int ia_valid = attr->ia_valid;
        int error;
        
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
 
        /*
         * we can't change the UID or GID of any file -
index bec2d1a0c91c3e8ac62eb40a706a3bb704fd404e..55a931da99176c0caa5a1246326f3863de7dd207 100644 (file)
@@ -222,7 +222,7 @@ affs_notify_change(struct dentry *dentry, struct iattr *attr)
 
        pr_debug("notify_change(%lu,0x%x)\n", inode->i_ino, attr->ia_valid);
 
-       error = inode_change_ok(inode,attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                goto out;
 
index 6530ced19697d49a9189fa289c9112187448fee3..85cae17db7846eb4e5534dbb31727a2d64b50437 100644 (file)
--- a/fs/attr.c
+++ b/fs/attr.c
 #include <linux/ima.h>
 
 /**
- * inode_change_ok - check if attribute changes to an inode are allowed
- * @inode:     inode to check
+ * setattr_prepare - check if attribute changes to a dentry are allowed
+ * @dentry:    dentry to check
  * @attr:      attributes to change
  *
  * Check if we are allowed to change the attributes contained in @attr
- * in the given inode.  This includes the normal unix access permission
- * checks, as well as checks for rlimits and others.
+ * in the given dentry.  This includes the normal unix access permission
+ * checks, as well as checks for rlimits and others. The function also clears
+ * SGID bit from mode if user is not allowed to set it. Also file capabilities
+ * and IMA extended attributes are cleared if ATTR_KILL_PRIV is set.
  *
  * Should be called as the first thing in ->setattr implementations,
  * possibly after taking additional locks.
  */
-int inode_change_ok(const struct inode *inode, struct iattr *attr)
+int setattr_prepare(struct dentry *dentry, struct iattr *attr)
 {
+       struct inode *inode = d_inode(dentry);
        unsigned int ia_valid = attr->ia_valid;
 
        /*
@@ -79,7 +82,7 @@ int inode_change_ok(const struct inode *inode, struct iattr *attr)
 
        return 0;
 }
-EXPORT_SYMBOL(inode_change_ok);
+EXPORT_SYMBOL(setattr_prepare);
 
 /**
  * inode_newsize_ok - may this inode be truncated to a given size
index a09ec5e7f3e2221b89b9170ab3ba555b3e2fcf81..4292500ef24113975edd66f48090e68fd7c4e50f 100644 (file)
@@ -4690,7 +4690,7 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr)
        if (btrfs_root_readonly(root))
                return -EROFS;
 
-       err = inode_change_ok(inode, attr);
+       err = setattr_prepare(dentry, attr);
        if (err)
                return err;
 
index c3e103ff18bd5e25e1a056253c6dfc57a1898ea1..122d60506ab9812e2912d9b6d70359e6d467d4bf 100644 (file)
@@ -1708,7 +1708,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
        if (ceph_snap(inode) != CEPH_NOSNAP)
                return -EROFS;
 
-       err = inode_change_ok(inode, attr);
+       err = setattr_prepare(dentry, attr);
        if (err != 0)
                return err;
 
index 8dc1cfcb534faa585f4e70cfad955e7296fc8ce2..6a5ca969c3014dccfa390918940f5b2854ef094d 100644 (file)
@@ -2074,7 +2074,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
                attrs->ia_valid |= ATTR_FORCE;
 
-       rc = inode_change_ok(inode, attrs);
+       rc = setattr_prepare(direntry, attrs);
        if (rc < 0)
                goto out;
 
@@ -2215,7 +2215,7 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
                attrs->ia_valid |= ATTR_FORCE;
 
-       rc = inode_change_ok(inode, attrs);
+       rc = setattr_prepare(direntry, attrs);
        if (rc < 0) {
                free_xid(xid);
                return rc;
index 57ee4c53b4f8416334d733a7599a01a7c961a452..8bc9ec714467e50996a2632f116ed6e9049776b5 100644 (file)
@@ -952,7 +952,7 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
        }
        mutex_unlock(&crypt_stat->cs_mutex);
 
-       rc = inode_change_ok(inode, ia);
+       rc = setattr_prepare(dentry, ia);
        if (rc)
                goto out;
        if (ia->ia_valid & ATTR_SIZE) {
index 3f9cafd739312bd1392b21bc6ed3dc6bb9b666a1..799e7d4562fec8c4b3a2efc84faf596cc43beac7 100644 (file)
@@ -1039,7 +1039,7 @@ int exofs_setattr(struct dentry *dentry, struct iattr *iattr)
        if (unlikely(error))
                return error;
 
-       error = inode_change_ok(inode, iattr);
+       error = setattr_prepare(dentry, iattr);
        if (unlikely(error))
                return error;
 
index 36d35c36311d69a025c5b804e8d8597cbd9cb2b2..b822e4a447d656253e0db7e2e7f2b06a249c17c9 100644 (file)
@@ -1547,7 +1547,7 @@ int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
        struct inode *inode = dentry->d_inode;
        int error;
 
-       error = inode_change_ok(inode, iattr);
+       error = setattr_prepare(dentry, iattr);
        if (error)
                return error;
 
index 2c6ccc49ba279cacf77fe6609fe44a50b970898c..215972e94e175fa766f6f6cace7cc878e0cd5e18 100644 (file)
@@ -3244,7 +3244,7 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr)
        int error, rc = 0;
        const unsigned int ia_valid = attr->ia_valid;
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                return error;
 
index 9ad4ccfef72e7313b867e7b388afc0bc685e96ea..ae4271d5c6ca0af713cdda20dcb0c00b3e62933d 100644 (file)
@@ -4672,7 +4672,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
        int orphan = 0;
        const unsigned int ia_valid = attr->ia_valid;
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                return error;
 
index 7d8b96275092a1109b1bfcb6f4bd07ef7d738f82..010c2af338588d6e593f29dfbf514d5dedfc3f2d 100644 (file)
@@ -500,7 +500,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
        struct f2fs_inode_info *fi = F2FS_I(inode);
        int err;
 
-       err = inode_change_ok(inode, attr);
+       err = setattr_prepare(dentry, attr);
        if (err)
                return err;
 
index 85f79a89e7474658c8c552cfe027e72ff048d542..17982aac0ef3cdced33a0992a9342f26b911536a 100644 (file)
@@ -394,7 +394,7 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr)
                        attr->ia_valid &= ~TIMES_SET_FLAGS;
        }
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        attr->ia_valid = ia_valid;
        if (error) {
                if (sbi->options.quiet)
index 0c6048247a34eb16a5146f7ea67479a21fec6173..31ad5fc879b8b6109bf0bcd1e4ebe11dac122827 100644 (file)
@@ -1704,9 +1704,10 @@ int fuse_flush_times(struct inode *inode, struct fuse_file *ff)
  * vmtruncate() doesn't allow for this case, so do the rlimit checking
  * and the actual truncation by hand.
  */
-int fuse_do_setattr(struct inode *inode, struct iattr *attr,
+int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
                    struct file *file)
 {
+       struct inode *inode = dentry->d_inode;
        struct fuse_conn *fc = get_fuse_conn(inode);
        struct fuse_inode *fi = get_fuse_inode(inode);
        struct fuse_req *req;
@@ -1721,7 +1722,7 @@ int fuse_do_setattr(struct inode *inode, struct iattr *attr,
        if (!(fc->flags & FUSE_DEFAULT_PERMISSIONS))
                attr->ia_valid |= ATTR_FORCE;
 
-       err = inode_change_ok(inode, attr);
+       err = setattr_prepare(dentry, attr);
        if (err)
                return err;
 
@@ -1826,9 +1827,9 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr)
                return -EACCES;
 
        if (attr->ia_valid & ATTR_FILE)
-               return fuse_do_setattr(inode, attr, attr->ia_file);
+               return fuse_do_setattr(entry, attr, attr->ia_file);
        else
-               return fuse_do_setattr(inode, attr, NULL);
+               return fuse_do_setattr(entry, attr, NULL);
 }
 
 static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry,
index e8e47a6ab5186be8df5889d65df28bc92bf8c97d..300619ba8591eb6a8a8e5214a9badd9433a2b7a9 100644 (file)
@@ -894,7 +894,7 @@ bool fuse_write_update_size(struct inode *inode, loff_t pos);
 int fuse_flush_times(struct inode *inode, struct fuse_file *ff);
 int fuse_write_inode(struct inode *inode, struct writeback_control *wbc);
 
-int fuse_do_setattr(struct inode *inode, struct iattr *attr,
+int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
                    struct file *file);
 
 #endif /* _FS_FUSE_I_H */
index ba4b2e5377db065cfc8d4524d643e5f42c66c7ca..b6657ddd1de502336f13ec03d7396466210388d5 100644 (file)
@@ -1774,7 +1774,7 @@ static int gfs2_setattr(struct dentry *dentry, struct iattr *attr)
        if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
                goto out;
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                goto out;
 
index d0929bc817826e012cc829bb0f021832eea24379..a4a3f8a674b9bfae16226133b7966b601a02e299 100644 (file)
@@ -604,7 +604,7 @@ int hfs_inode_setattr(struct dentry *dentry, struct iattr * attr)
        struct hfs_sb_info *hsb = HFS_SB(inode->i_sb);
        int error;
 
-       error = inode_change_ok(inode, attr); /* basic permission checks */
+       error = setattr_prepare(dentry, attr); /* basic permission checks */
        if (error)
                return error;
 
index 0cf786f2d046f9fbae9b110a2a2d212c008fb3aa..9cd897cc23846d99ec74a01e9778e34892ab3611 100644 (file)
@@ -247,7 +247,7 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr)
        struct inode *inode = dentry->d_inode;
        int error;
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                return error;
 
index 9206c4debf3bb1b53a265251832c9afd7ecc275d..50f0b4f0480ef3815c422db159dbbb63fdb74624 100644 (file)
@@ -792,7 +792,7 @@ static int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
 
        int fd = HOSTFS_I(inode)->fd;
 
-       err = inode_change_ok(inode, attr);
+       err = setattr_prepare(dentry, attr);
        if (err)
                return err;
 
index 7ce4b74234a12011140fb32594bde7bac6450173..5ada7b73b5d92fb3b975a5bf689dac9aadfb9ea8 100644 (file)
@@ -272,7 +272,7 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
        if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size)
                goto out_unlock;
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                goto out_unlock;
 
index 1e2872b25343f106df7a96d0b667e194dd070c54..e3ac491424fcb9d4f61b3236c505be4d70a4982e 100644 (file)
@@ -429,7 +429,7 @@ static int hugetlbfs_setattr(struct dentry *dentry, struct iattr *attr)
 
        BUG_ON(!inode);
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                return error;
 
index 601afd1afddf5bca94fb35f993e61919b6bbdcd4..bb9460ea36e8d415dd6584d98adbe91ce943e338 100644 (file)
@@ -193,7 +193,7 @@ int jffs2_setattr(struct dentry *dentry, struct iattr *iattr)
        struct inode *inode = dentry->d_inode;
        int rc;
 
-       rc = inode_change_ok(inode, iattr);
+       rc = setattr_prepare(dentry, iattr);
        if (rc)
                return rc;
 
index 33aa0cc1f8b863b7b101bec470af4238d0c6eeb1..b43cc9a6dba143db34ed4afc33dc08e25d773143 100644 (file)
@@ -103,7 +103,7 @@ int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
        struct inode *inode = dentry->d_inode;
        int rc;
 
-       rc = inode_change_ok(inode, iattr);
+       rc = setattr_prepare(dentry, iattr);
        if (rc)
                return rc;
 
index 5b8ab29494b782637ed276c9620feab5a688e40e..8b6cb8cbf8871dbe8289d2434f73e7f6b3ad530a 100644 (file)
@@ -131,7 +131,7 @@ int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr)
                return -EINVAL;
 
        mutex_lock(&kernfs_mutex);
-       error = inode_change_ok(inode, iattr);
+       error = setattr_prepare(dentry, iattr);
        if (error)
                goto out;
 
index 5ba7e10d6b23c50bfbc0af4884462caddcd85097..51994a562acac15f4ae1dcdd17f2b5866e0ad8aa 100644 (file)
@@ -371,7 +371,7 @@ int simple_setattr(struct dentry *dentry, struct iattr *iattr)
        struct inode *inode = dentry->d_inode;
        int error;
 
-       error = inode_change_ok(inode, iattr);
+       error = setattr_prepare(dentry, iattr);
        if (error)
                return error;
 
index 8538752df2f6a7dbb3dad0119e4e8bc47f4a25f4..34f4d33b6ee97beff0af3be8d4b0546df3aed803 100644 (file)
@@ -244,7 +244,7 @@ static int logfs_setattr(struct dentry *dentry, struct iattr *attr)
        struct inode *inode = dentry->d_inode;
        int err = 0;
 
-       err = inode_change_ok(inode, attr);
+       err = setattr_prepare(dentry, attr);
        if (err)
                return err;
 
index a967de085ac0f4cf7193101cd4e54a08bb4fff50..6b569161325eeed6d76f1708e02e54aa58e9208b 100644 (file)
@@ -28,7 +28,7 @@ static int minix_setattr(struct dentry *dentry, struct iattr *attr)
        struct inode *inode = dentry->d_inode;
        int error;
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                return error;
 
index e31e589369a49a930f45be2124114c7252c83723..f8d3f461a01f6f5a9f9f2ff87b4fa11a5117317e 100644 (file)
@@ -885,7 +885,7 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
        /* ageing the dentry to force validation */
        ncp_age_dentry(server, dentry);
 
-       result = inode_change_ok(inode, attr);
+       result = setattr_prepare(dentry, attr);
        if (result < 0)
                goto out;
 
index 140c496f612c4920c9a7819556f35841357e5aaa..521f717b4a99215393412a287494f2ae368962ac 100644 (file)
@@ -300,17 +300,19 @@ commit_metadata(struct svc_fh *fhp)
  * NFS semantics and what Linux expects.
  */
 static void
-nfsd_sanitize_attrs(struct inode *inode, struct iattr *iap)
+nfsd_sanitize_attrs(struct dentry *dentry, struct iattr *iap)
 {
+       struct inode *inode = dentry->d_inode;
+
        /*
         * NFSv2 does not differentiate between "set-[ac]time-to-now"
         * which only requires access, and "set-[ac]time-to-X" which
         * requires ownership.
         * So if it looks like it might be "set both to the same time which
-        * is close to now", and if inode_change_ok fails, then we
+        * is close to now", and if setattr_prepare fails, then we
         * convert to "set to now" instead of "set to explicit time"
         *
-        * We only call inode_change_ok as the last test as technically
+        * We only call setattr_prepare as the last test as technically
         * it is not an interface that we should be using.
         */
 #define BOTH_TIME_SET (ATTR_ATIME_SET | ATTR_MTIME_SET)
@@ -328,7 +330,7 @@ nfsd_sanitize_attrs(struct inode *inode, struct iattr *iap)
                if (delta < 0)
                        delta = -delta;
                if (delta < MAX_TOUCH_TIME_ERROR &&
-                   inode_change_ok(inode, iap) != 0) {
+                   setattr_prepare(dentry, iap) != 0) {
                        /*
                         * Turn off ATTR_[AM]TIME_SET but leave ATTR_[AM]TIME.
                         * This will cause notify_change to set these times
@@ -435,7 +437,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
        if (!iap->ia_valid)
                goto out;
 
-       nfsd_sanitize_attrs(inode, iap);
+       nfsd_sanitize_attrs(dentry, iap);
 
        /*
         * The size case is special, it changes the file in addition to the
index 31b6b2953c59ae53e5063c5d76a57b75be7b8c51..80e61bad215d29bcf6a35a65a526aa7e0436841e 100644 (file)
@@ -839,7 +839,7 @@ int nilfs_setattr(struct dentry *dentry, struct iattr *iattr)
        struct super_block *sb = inode->i_sb;
        int err;
 
-       err = inode_change_ok(inode, iattr);
+       err = setattr_prepare(dentry, iattr);
        if (err)
                return err;
 
index f47af5e6e23037ed0c82b17274b098d00a617517..a5589470373fe89b41410065e9b7eb33ae0d885c 100644 (file)
@@ -2891,7 +2891,7 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr)
        int err;
        unsigned int ia_valid = attr->ia_valid;
 
-       err = inode_change_ok(vi, attr);
+       err = setattr_prepare(dentry, attr);
        if (err)
                goto out;
        /* We do not support NTFS ACLs yet. */
index 09b7d9dac71d567d49d4f23d01511ba0a2c5adb1..4d129dfcc1c7db62c99993cbe5daceaa1c685e45 100644 (file)
@@ -211,7 +211,7 @@ static int dlmfs_file_setattr(struct dentry *dentry, struct iattr *attr)
        struct inode *inode = dentry->d_inode;
 
        attr->ia_valid &= ~ATTR_SIZE;
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                return error;
 
index 76e88cf082d01ce8df87b78c1ef44747baf6fd0f..cd3b06f600a2daaf4ee8c30935adbec0e24064fc 100644 (file)
@@ -1144,7 +1144,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
        if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
                return 0;
 
-       status = inode_change_ok(inode, attr);
+       status = setattr_prepare(dentry, attr);
        if (status)
                return status;
 
index 902e88527fcec443244bd12a9a25e1cf895ba763..b53f0602cc03a5a624684c386a1a776e629dc2ee 100644 (file)
@@ -351,7 +351,7 @@ static int omfs_setattr(struct dentry *dentry, struct iattr *attr)
        struct inode *inode = dentry->d_inode;
        int error;
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                return error;
 
index 0897f5cb4957aa40549f93e1e790a103de7bafa7..944c6be5819908f9c8a9a0eb3c33f4f58176419f 100644 (file)
@@ -536,7 +536,7 @@ int proc_setattr(struct dentry *dentry, struct iattr *attr)
        if (attr->ia_valid & ATTR_MODE)
                return -EPERM;
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                return error;
 
index c18d9b05cea9b467c30d96bc77f8d9b70c3e5f7c..d95c6868b5f52e14a021fbbfd86a00a8c8b07db3 100644 (file)
@@ -41,7 +41,7 @@ static int proc_notify_change(struct dentry *dentry, struct iattr *iattr)
        struct proc_dir_entry *de = PDE(inode);
        int error;
 
-       error = inode_change_ok(inode, iattr);
+       error = setattr_prepare(dentry, iattr);
        if (error)
                return error;
 
index b45db1ddb8e0fb4af033944ab0a84d3e6746bbe2..728c4657188f321314f804108e02f459c1583bae 100644 (file)
@@ -753,7 +753,7 @@ static int proc_sys_setattr(struct dentry *dentry, struct iattr *attr)
        if (attr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID))
                return -EPERM;
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                return error;
 
index dda012ad4208d3192521c80a082af5ff038f5b3b..a6b6083176d3ffc07b08e8181c11eb531b74511f 100644 (file)
@@ -163,7 +163,7 @@ static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia)
        int ret = 0;
 
        /* POSIX UID/GID verification for setting inode attributes */
-       ret = inode_change_ok(inode, ia);
+       ret = setattr_prepare(dentry, ia);
        if (ret)
                return ret;
 
index 63b2b0ec49e6afacd955abf9f172751768ee08ee..27b402e05aa24c2de8cb926d4d532ae02f6ed898 100644 (file)
@@ -3312,7 +3312,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
        unsigned int ia_valid;
        int error;
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                return error;
 
index b00811c75b24f63acb1651991f6972f4b0b6ff54..3bb4ccd697312aa5c8b6f00049e16828ecb3669a 100644 (file)
@@ -35,7 +35,7 @@ static int sysv_setattr(struct dentry *dentry, struct iattr *attr)
        struct inode *inode = dentry->d_inode;
        int error;
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                return error;
 
index d37140e5b722df63410a9fd22cc768f019e348f6..68d7fe857ba96550b03919f2c11f04170050b35d 100644 (file)
@@ -1262,7 +1262,7 @@ int ubifs_setattr(struct dentry *dentry, struct iattr *attr)
 
        dbg_gen("ino %lu, mode %#x, ia_valid %#x",
                inode->i_ino, inode->i_mode, attr->ia_valid);
-       err = inode_change_ok(inode, attr);
+       err = setattr_prepare(dentry, attr);
        if (err)
                return err;
 
index d80738fdf424cd61579a0544eab720bb8d7b0a64..1aaf63a5f32f56fad720835ae422a7fecb3a1577 100644 (file)
@@ -269,7 +269,7 @@ static int udf_setattr(struct dentry *dentry, struct iattr *attr)
        struct inode *inode = dentry->d_inode;
        int error;
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                return error;
 
index f04f89fbd4d9914b0a1a16f2cce8c8e0799e020e..92cde998aead77c6643fd616046085d86635319e 100644 (file)
@@ -496,7 +496,7 @@ int ufs_setattr(struct dentry *dentry, struct iattr *attr)
        unsigned int ia_valid = attr->ia_valid;
        int error;
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                return error;
 
index aa138d64560a6a3c2133bc70d57e367cc8c1476d..61abc3051377f092186376931ebd021caff52a7c 100644 (file)
@@ -81,7 +81,7 @@ static int utimes_common(struct path *path, struct timespec *times)
                        newattrs.ia_valid |= ATTR_MTIME_SET;
                }
                /*
-                * Tell inode_change_ok(), that this is an explicit time
+                * Tell setattr_prepare(), that this is an explicit time
                 * update, even if neither ATTR_ATIME_SET nor ATTR_MTIME_SET
                 * were used.
                 */
@@ -90,7 +90,7 @@ static int utimes_common(struct path *path, struct timespec *times)
                /*
                 * If times is NULL (or both times are UTIME_NOW),
                 * then we need to check permissions, because
-                * inode_change_ok() won't do it.
+                * setattr_prepare() won't do it.
                 */
                error = -EACCES;
                 if (IS_IMMUTABLE(inode))
index 6888ad886ff6205cc0baf0aa36352fa92f9d93ea..56ba5cf14dd3fc538f18c3b82d521157e227cfd2 100644 (file)
@@ -244,7 +244,8 @@ xfs_set_mode(struct inode *inode, umode_t mode)
                iattr.ia_mode = mode;
                iattr.ia_ctime = current_fs_time(inode->i_sb);
 
-               error = -xfs_setattr_nonsize(XFS_I(inode), &iattr, XFS_ATTR_NOACL);
+               error = -xfs_setattr_nonsize(NULL, XFS_I(inode), &iattr,
+                                            XFS_ATTR_NOACL);
        }
 
        return error;
index d2f4cb598b46b4a99758733a5b2d6cf753fc36dc..eb04981b03b4d3addd5e4686eb5bb5e1829d39d5 100644 (file)
@@ -862,7 +862,7 @@ xfs_file_fallocate(
 
                iattr.ia_valid = ATTR_SIZE;
                iattr.ia_size = new_size;
-               error = xfs_setattr_size(ip, &iattr);
+               error = xfs_setattr_size(file->f_dentry, &iattr);
        }
 
 out_unlock:
index afc859f44d013b83711f74859643b36fe8663bd0..cee62a5afbee53d3a20615541c129d41f98e1f40 100644 (file)
@@ -717,7 +717,7 @@ xfs_ioc_space(
                iattr.ia_valid = ATTR_SIZE;
                iattr.ia_size = bf->l_start;
 
-               error = xfs_setattr_size(ip, &iattr);
+               error = xfs_setattr_size(filp->f_dentry, &iattr);
                if (!error)
                        clrprealloc = true;
                break;
index 125da8969c72ca87492bf56f8a8ec1f4d01076fa..cfc5c260ecbe58db7addfeddb9b8270e3504ca6f 100644 (file)
@@ -527,6 +527,7 @@ xfs_setattr_time(
 
 int
 xfs_setattr_nonsize(
+       struct dentry           *dentry,
        struct xfs_inode        *ip,
        struct iattr            *iattr,
        int                     flags)
@@ -551,7 +552,7 @@ xfs_setattr_nonsize(
                if (XFS_FORCED_SHUTDOWN(mp))
                        return XFS_ERROR(EIO);
 
-               error = -inode_change_ok(inode, iattr);
+               error = -setattr_prepare(dentry, iattr);
                if (error)
                        return XFS_ERROR(error);
        }
@@ -734,11 +735,12 @@ out_dqrele:
  */
 int
 xfs_setattr_size(
-       struct xfs_inode        *ip,
+       struct dentry           *dentry,
        struct iattr            *iattr)
 {
+       struct inode            *inode = dentry->d_inode;
+       struct xfs_inode        *ip = XFS_I(inode);
        struct xfs_mount        *mp = ip->i_mount;
-       struct inode            *inode = VFS_I(ip);
        xfs_off_t               oldsize, newsize;
        struct xfs_trans        *tp;
        int                     error;
@@ -754,7 +756,7 @@ xfs_setattr_size(
        if (XFS_FORCED_SHUTDOWN(mp))
                return XFS_ERROR(EIO);
 
-       error = -inode_change_ok(inode, iattr);
+       error = -setattr_prepare(dentry, iattr);
        if (error)
                return XFS_ERROR(error);
 
@@ -778,7 +780,7 @@ xfs_setattr_size(
                 * Use the regular setattr path to update the timestamps.
                 */
                iattr->ia_valid &= ~ATTR_SIZE;
-               return xfs_setattr_nonsize(ip, iattr, 0);
+               return xfs_setattr_nonsize(dentry, ip, iattr, 0);
        }
 
        /*
@@ -939,10 +941,10 @@ xfs_vn_setattr(
 
        if (iattr->ia_valid & ATTR_SIZE) {
                xfs_ilock(ip, XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL);
-               error = xfs_setattr_size(ip, iattr);
+               error = xfs_setattr_size(dentry, iattr);
                xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL);
        } else {
-               error = xfs_setattr_nonsize(ip, iattr, 0);
+               error = xfs_setattr_nonsize(dentry, ip, iattr, 0);
        }
 
        return -error;
index 1c34e4335920021d5829c5507be2f2c6c6bf60e1..f66a37c0a88abe65aceba7e72c1e0a847a5390f9 100644 (file)
@@ -32,8 +32,8 @@ extern void xfs_setup_inode(struct xfs_inode *);
  */
 #define XFS_ATTR_NOACL         0x01    /* Don't call posix_acl_chmod */
 
-extern int xfs_setattr_nonsize(struct xfs_inode *ip, struct iattr *vap,
-                              int flags);
-extern int xfs_setattr_size(struct xfs_inode *ip, struct iattr *vap);
+extern int xfs_setattr_nonsize(struct dentry *dentry, struct xfs_inode *ip,
+                              struct iattr *vap, int flags);
+extern int xfs_setattr_size(struct dentry *dentry, struct iattr *vap);
 
 #endif /* __XFS_IOPS_H__ */
index 545837db946850c03f629b2d40c86e928f25457a..3b69a82bbdd95bf598e3e0a71cb374b3fd37b7fe 100644 (file)
@@ -2627,7 +2627,7 @@ extern int buffer_migrate_page(struct address_space *,
 #define buffer_migrate_page NULL
 #endif
 
-extern int inode_change_ok(const struct inode *, struct iattr *);
+extern int setattr_prepare(struct dentry *, struct iattr *);
 extern int inode_newsize_ok(const struct inode *, loff_t offset);
 extern void setattr_copy(struct inode *inode, const struct iattr *attr);
 
index a2b87affdc23660a437703b3e1e75c3ea9d98fbb..efab7a79b05faa0df758f539fd3d8d76883be224 100644 (file)
@@ -540,7 +540,7 @@ static int shmem_setattr(struct dentry *dentry, struct iattr *attr)
        struct inode *inode = dentry->d_inode;
        int error;
 
-       error = inode_change_ok(inode, attr);
+       error = setattr_prepare(dentry, attr);
        if (error)
                return error;