[PATCH 2/9] nfs: skip over stale rpc packets

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Fri Feb 7 03:20:29 EST 2014


Hello,

On Thu, Feb 06, 2014 at 05:40:47PM +0100, Uwe Kleine-König wrote:
> When a former transaction was aborted by hitting Ctrl-C the old reply might
> still hang in the ethernet controller making all further transactions fail.
> 
> So just skip over old replies.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
> ---
> An alternative would be to drain the ethernet queue before a new request is
> sent. Don't know how that works and I don't see much benefit, so I didn't
> try to find out :-)
> ---
>  fs/nfs.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfs.c b/fs/nfs.c
> index 717326435189..e9a6eede06bd 100644
> --- a/fs/nfs.c
> +++ b/fs/nfs.c
> @@ -275,8 +275,13 @@ static int rpc_check_reply(unsigned char *pkt, int rpc_prog, unsigned long rpc_i
>  
>  	memcpy(&rpc, pkt, sizeof(rpc));
>  
> -	if (ntohl(rpc.id) != rpc_id)
> +	if (ntohl(rpc.id) != rpc_id) {
> +		if (ntohl(rpc.id) < rpc_id)
> +			/* stale packet, wait a bit longer */
> +			return 0;
> +
>  		return -EINVAL;
> +	}
I have thought about this once more. Just compare using < is very lax
and fails when rpc_id overflows. I suggest to use

	if (rpc_id - ntohl(rpc.id) == 1)

instead. (Or draining the eth queue.)

Will fix accordingly in a v2 once I addressed all concerns.

Uwe
 
-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |



More information about the barebox mailing list