Skip to content

Commit

Permalink
NFS: Check size by inode_newsize_ok in nfs_setattr
Browse files Browse the repository at this point in the history
Set rlimit for NFS's files is useless right now.
For local process's rlimit, it should be checked by nfs client.

The same, CIFS also call inode_change_ok checking rlimit at its client
in cifs_setattr_nounix() and cifs_setattr_unix().

v3, fix bad using of error

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
  • Loading branch information
Kinglong Mee authored and Trond Myklebust committed Aug 27, 2015
1 parent 0bdb8fa commit ae57ca0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions fs/nfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
struct nfs_fattr *fattr;
int error = -ENOMEM;
int error = 0;

nfs_inc_stats(inode, NFSIOS_VFSSETATTR);

Expand All @@ -513,15 +513,14 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
attr->ia_valid &= ~ATTR_MODE;

if (attr->ia_valid & ATTR_SIZE) {
loff_t i_size;

BUG_ON(!S_ISREG(inode->i_mode));

i_size = i_size_read(inode);
if (attr->ia_size == i_size)
error = inode_newsize_ok(inode, attr->ia_size);
if (error)
return error;

if (attr->ia_size == i_size_read(inode))
attr->ia_valid &= ~ATTR_SIZE;
else if (attr->ia_size < i_size && IS_SWAPFILE(inode))
return -ETXTBSY;
}

/* Optimization: if the end result is no change, don't RPC */
Expand All @@ -536,8 +535,11 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
nfs_sync_inode(inode);

fattr = nfs_alloc_fattr();
if (fattr == NULL)
if (fattr == NULL) {
error = -ENOMEM;
goto out;
}

/*
* Return any delegations if we're going to change ACLs
*/
Expand Down

0 comments on commit ae57ca0

Please sign in to comment.