Skip to content

Commit

Permalink
nfs: setattr can only change regular file sizes
Browse files Browse the repository at this point in the history
The VFS never calls setattr with ATTR_SIZE on anything but regular
files.  Remove the if check and turn it into an assert similar to
what some other file systems do.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
  • Loading branch information
Christoph Hellwig authored and Trond Myklebust committed Sep 10, 2014
1 parent 20d655d commit 08a899d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/nfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,9 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
attr->ia_valid &= ~ATTR_MODE;

if (attr->ia_valid & ATTR_SIZE) {
if (!S_ISREG(inode->i_mode) || attr->ia_size == i_size_read(inode))
BUG_ON(!S_ISREG(inode->i_mode));

if (attr->ia_size == i_size_read(inode))
attr->ia_valid &= ~ATTR_SIZE;
}

Expand Down

0 comments on commit 08a899d

Please sign in to comment.