Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ecryptfs...
[sfrench/cifs-2.6.git] / fs / ecryptfs / inode.c
index a8acfc5d34765f940c9a03f4ce864e1b84be846f..6c55113e72222cf473f92b16277056561ebbf55d 100644 (file)
@@ -870,10 +870,20 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia,
                size_t num_zeros = (PAGE_CACHE_SIZE
                                    - (ia->ia_size & ~PAGE_CACHE_MASK));
 
+
+               /*
+                * XXX(truncate) this should really happen at the begginning
+                * of ->setattr.  But the code is too messy to that as part
+                * of a larger patch.  ecryptfs is also totally missing out
+                * on the inode_change_ok check at the beginning of
+                * ->setattr while would include this.
+                */
+               rc = inode_newsize_ok(inode, ia->ia_size);
+               if (rc)
+                       goto out;
+
                if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
-                       rc = simple_setsize(inode, ia->ia_size);
-                       if (rc)
-                               goto out;
+                       truncate_setsize(inode, ia->ia_size);
                        lower_ia->ia_size = ia->ia_size;
                        lower_ia->ia_valid |= ATTR_SIZE;
                        goto out;
@@ -896,7 +906,7 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia,
                                goto out;
                        }
                }
-               simple_setsize(inode, ia->ia_size);
+               truncate_setsize(inode, ia->ia_size);
                rc = ecryptfs_write_inode_size_to_metadata(inode);
                if (rc) {
                        printk(KERN_ERR "Problem with "