2003-08-18 13:15:54

by Mark Hemment

[permalink] [raw]
Subject: [PATCH] reply-cache - RC_DELAY

Do not update 'c_timestamp' for a "too fast" retransmit. Otherwise, it
is possible we'll never re-send to a client which is constantly being
over-eager - or is this the idea?

Also, protect against jiffies wrap.

Thanks,
Mark


diff -urNp linux-2.6.0-test3/fs/nfsd/nfscache.c linux-2.6.0-test3-nfsd-age/fs/nfsd/nfscache.c
--- linux-2.6.0-test3/fs/nfsd/nfscache.c 2003-08-09 05:42:23.000000000 +0100
+++ linux-2.6.0-test3-nfsd-age/fs/nfsd/nfscache.c 2020-08-18 13:46:31.033864560 +0100
@@ -252,13 +252,25 @@ nfsd_cache_lookup(struct svc_rqst *rqstp

found_entry:
/* We found a matching entry which is either in progress or done. */
- age = jiffies - rp->c_timestamp;
+
+ /* careful of wrap */
+ age = jiffies;
+ if (age >= rp->c_timestamp) {
+ age -= rp->c_timestamp;
+ } else {
+ age += (~0UL - rp->c_timestamp);
+ }
+
+ /* Excessive fast rexmit? */
+ rtn = RC_DROPIT;
+ if (age < RC_DELAY)
+ goto out;
+
rp->c_timestamp = jiffies;
lru_put_front(rp);

- rtn = RC_DROPIT;
- /* Request being processed or excessive rexmits */
- if (rp->c_state == RC_INPROG || age < RC_DELAY)
+ /* Request being processed? */
+ if (rp->c_state == RC_INPROG)
goto out;

/* From the hall of fame of impractical attacks:



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs


2003-08-18 23:03:00

by NeilBrown

[permalink] [raw]
Subject: Re: [PATCH] reply-cache - RC_DELAY

On Monday August 18, [email protected] wrote:
> Do not update 'c_timestamp' for a "too fast" retransmit. Otherwise, it
> is possible we'll never re-send to a client which is constantly being
> over-eager - or is this the idea?
>
> Also, protect against jiffies wrap.
>

Best not to combine two changes in the one patch, incase I like one
but not the other....

In this case, I'm not at all convinced aboutt he jiffy-wrap thing.
As age, jiffies, and c_timestamp are all "unsigned long", I don't see
how the new code generates a different result...
Actually it does generate a different result, an incorrect result.
~0 == -1, so
age += ~0UL - rp->c_timestamp
is like
age = age - 1 - rp->c_timestamp

which is wrong.

The RC_DELAY bit is probably OK, but if we are getting the same
request every 200ms, then something is really wrong with the client,
and maybe we do want to ignore it altogether.

If you feel strongly enough about it to send it again without the
jiffy-wrap stuff, I'll accept it though.

NeilBrown

> Thanks,
> Mark
>
>
> diff -urNp linux-2.6.0-test3/fs/nfsd/nfscache.c linux-2.6.0-test3-nfsd-age/fs/nfsd/nfscache.c
> --- linux-2.6.0-test3/fs/nfsd/nfscache.c 2003-08-09 05:42:23.000000000 +0100
> +++ linux-2.6.0-test3-nfsd-age/fs/nfsd/nfscache.c 2020-08-18 13:46:31.033864560 +0100
> @@ -252,13 +252,25 @@ nfsd_cache_lookup(struct svc_rqst *rqstp
>
> found_entry:
> /* We found a matching entry which is either in progress or done. */
> - age = jiffies - rp->c_timestamp;
> +
> + /* careful of wrap */
> + age = jiffies;
> + if (age >= rp->c_timestamp) {
> + age -= rp->c_timestamp;
> + } else {
> + age += (~0UL - rp->c_timestamp);
> + }


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs