diff mbox

[3/7,v2] NFS: Check size by inode_newsize_ok in nfs_setattr

Message ID 55BA2996.9030804@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kinglong Mee July 30, 2015, 1:41 p.m. UTC
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().

v2, same as v1.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 fs/nfs/inode.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Kinglong Mee Aug. 4, 2015, 10:43 a.m. UTC | #1
On 7/30/2015 21:41, Kinglong Mee wrote:
> 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().
> 
> v2, same as v1.
> 
> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
> ---
>  fs/nfs/inode.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> index 0adc7d2..9304dfd 100644
> --- a/fs/nfs/inode.c
> +++ b/fs/nfs/inode.c
> @@ -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;

So sorry!

Use "error" will cause a bug for the following code of error out.
I will update it in the new version.

thanks,
Kinglong Mee
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Trond Myklebust Aug. 26, 2015, 12:10 a.m. UTC | #2
Hi Kinglong,

On Tue, Aug 4, 2015 at 6:43 AM, Kinglong Mee <kinglongmee@gmail.com> wrote:
> On 7/30/2015 21:41, Kinglong Mee wrote:
>> 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().
>>
>> v2, same as v1.
>>
>> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
>> ---
>>  fs/nfs/inode.c | 11 +++++------
>>  1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
>> index 0adc7d2..9304dfd 100644
>> --- a/fs/nfs/inode.c
>> +++ b/fs/nfs/inode.c
>> @@ -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;
>
> So sorry!
>
> Use "error" will cause a bug for the following code of error out.
> I will update it in the new version.

Did you ever send the update for this? I don't seem to have it in my inbox.

Cheers
  Trond
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 0adc7d2..9304dfd 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -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 */