2012-05-31 18:08:51

by Sachin Prabhu

[permalink] [raw]
Subject: [PATCH] NFSv2: EOF incorrectly set on short read

In cases where the server returns fewer bytes then those requested, we
can incorrectly set the eof flag for the file. Fixing this allows the
request to be retried with updated offset and count arguments.

Signed-off-by: Sachin Prabhu <[email protected]>
---
fs/nfs/proc.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index a706b6b..617c741 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -651,7 +651,7 @@ static int nfs_read_done(struct rpc_task *task, struct nfs_read_data *data)
/* Emulate the eof flag, which isn't normally needed in NFSv2
* as it is guaranteed to always return the file attributes
*/
- if (data->args.offset + data->args.count >= data->res.fattr->size)
+ if (data->args.offset + data->res.count >= data->res.fattr->size)
data->res.eof = 1;
}
return 0;
--
1.7.7.6



2012-05-31 19:36:34

by Malahal Naineni

[permalink] [raw]
Subject: Re: [PATCH] NFSv2: EOF incorrectly set on short read

Sachin Prabhu [[email protected]] wrote:
> In cases where the server returns fewer bytes then those requested, we
> can incorrectly set the eof flag for the file. Fixing this allows the
> request to be retried with updated offset and count arguments.
>
> Signed-off-by: Sachin Prabhu <[email protected]>
> ---
> fs/nfs/proc.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
> index a706b6b..617c741 100644
> --- a/fs/nfs/proc.c
> +++ b/fs/nfs/proc.c
> @@ -651,7 +651,7 @@ static int nfs_read_done(struct rpc_task *task, struct nfs_read_data *data)
> /* Emulate the eof flag, which isn't normally needed in NFSv2
> * as it is guaranteed to always return the file attributes
> */
> - if (data->args.offset + data->args.count >= data->res.fattr->size)
> + if (data->args.offset + data->res.count >= data->res.fattr->size)
> data->res.eof = 1;
> }
> return 0;

Good catch!

Regards, Malahal.