Commit ae57ca0f authored by Kinglong Mee's avatar Kinglong Mee Committed by Trond Myklebust

NFS: Check size by inode_newsize_ok in nfs_setattr

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: default avatarKinglong Mee <kinglongmee@gmail.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent 0bdb8fa6
...@@ -504,7 +504,7 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -504,7 +504,7 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
{ {
struct inode *inode = d_inode(dentry); struct inode *inode = d_inode(dentry);
struct nfs_fattr *fattr; struct nfs_fattr *fattr;
int error = -ENOMEM; int error = 0;
nfs_inc_stats(inode, NFSIOS_VFSSETATTR); nfs_inc_stats(inode, NFSIOS_VFSSETATTR);
...@@ -513,15 +513,14 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -513,15 +513,14 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
attr->ia_valid &= ~ATTR_MODE; attr->ia_valid &= ~ATTR_MODE;
if (attr->ia_valid & ATTR_SIZE) { if (attr->ia_valid & ATTR_SIZE) {
loff_t i_size;
BUG_ON(!S_ISREG(inode->i_mode)); BUG_ON(!S_ISREG(inode->i_mode));
i_size = i_size_read(inode); error = inode_newsize_ok(inode, attr->ia_size);
if (attr->ia_size == i_size) if (error)
return error;
if (attr->ia_size == i_size_read(inode))
attr->ia_valid &= ~ATTR_SIZE; 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 */ /* Optimization: if the end result is no change, don't RPC */
...@@ -536,8 +535,11 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -536,8 +535,11 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
nfs_sync_inode(inode); nfs_sync_inode(inode);
fattr = nfs_alloc_fattr(); fattr = nfs_alloc_fattr();
if (fattr == NULL) if (fattr == NULL) {
error = -ENOMEM;
goto out; goto out;
}
/* /*
* Return any delegations if we're going to change ACLs * Return any delegations if we're going to change ACLs
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment