From: Fabio Olive Leite <fleite@redhat.com>
To: linux-nfs <nfs@lists.sourceforge.net>
Subject: Re: [PATCH] Attribute timeout handling and wrapping u32 jiffies
Date: Thu, 26 Jul 2007 22:59:00 -0300 [thread overview]
Message-ID: <20070727015900.GA3000@sleipnir.redhat.com> (raw)
In-Reply-To: <1185373979.6585.81.camel@localhost>
On Wed, Jul 25, 2007 at 10:32:59AM -0400, Trond Myklebust wrote:
> =
> No. IMO [b;c] should be the range for the generic function, and it
> should be up to the NFS code to do the 'stored jiffies + constant
> timeout' calculation. You will note that time_in_range() does in any
> case return true if you are inside the valid time range, so you will
> usually want to do
> =
> if (!time_in_range())...
> =
> in order to do the timeout_or_wrap() test.
Tried it out and it behaves correctly. Thanks for your suggestions.
The patch below is the final version, and fixes the attribute timeout
issue with wrapping jiffies.
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index ea97408..54d3926 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1852,7 +1852,7 @@ int nfs_access_get_cached(struct inode *inode, struct=
rpc_cred *cred, struct nfs
cache =3D nfs_access_search_rbtree(inode, cred);
if (cache =3D=3D NULL)
goto out;
- if (time_after(jiffies, cache->jiffies + NFS_ATTRTIMEO(inode)))
+ if (!time_in_range(jiffies, cache->jiffies, cache->jiffies + NFS_ATTRTIME=
O(inode)))
goto out_stale;
res->jiffies =3D cache->jiffies;
res->cred =3D cache->cred;
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index bca6cdc..89c3e91 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -662,7 +662,7 @@ int nfs_attribute_timeout(struct inode *inode)
=
if (nfs_have_delegation(inode, FMODE_READ))
return 0;
- return time_after(jiffies, nfsi->read_cache_jiffies+nfsi->attrtimeo);
+ return !time_in_range(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache=
_jiffies + nfsi->attrtimeo);
}
=
/**
@@ -1061,7 +1061,7 @@ static int nfs_update_inode(struct inode *inode, stru=
ct nfs_fattr *fattr)
nfs_inc_stats(inode, NFSIOS_ATTRINVALIDATE);
nfsi->attrtimeo =3D NFS_MINATTRTIMEO(inode);
nfsi->attrtimeo_timestamp =3D now;
- } else if (time_after(now, nfsi->attrtimeo_timestamp+nfsi->attrtimeo)) {
+ } else if (!time_in_range(now, nfsi->attrtimeo_timestamp, nfsi->attrtimeo=
_timestamp + nfsi->attrtimeo)) {
if ((nfsi->attrtimeo <<=3D 1) > NFS_MAXATTRTIMEO(inode))
nfsi->attrtimeo =3D NFS_MAXATTRTIMEO(inode);
nfsi->attrtimeo_timestamp =3D now;
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index c080f61..f1c87ad 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -115,6 +115,10 @@ static inline u64 get_jiffies_64(void)
((long)(a) - (long)(b) >=3D 0))
#define time_before_eq(a,b) time_after_eq(b,a)
=
+#define time_in_range(a,b,c) \
+ (time_after_eq(a,b) && \
+ time_before_eq(a,c))
+
/* Same as above, but does so with platform independent 64bit types.
* These must be used when utilizing jiffies_64 (i.e. return value of
* get_jiffies_64() */
Cheers!
F=E1bio
-- =
ex sed lex awk yacc, e pluribus unix, amem
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
next prev parent reply other threads:[~2007-07-27 1:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-25 3:08 [PATCH] Attribute timeout handling and wrapping u32 jiffies Fabio Olive Leite
2007-07-25 14:00 ` Trond Myklebust
2007-07-25 14:28 ` Fabio Olive Leite
2007-07-25 14:32 ` Trond Myklebust
2007-07-25 14:54 ` Fabio Olive Leite
2007-07-27 1:59 ` Fabio Olive Leite [this message]
2007-07-31 16:25 ` Fabio Olive Leite
2007-07-31 19:47 ` Trond Myklebust
2007-08-22 18:25 ` Fabio Olive Leite
2007-08-22 18:47 ` J. Bruce Fields
2007-08-27 13:23 ` Trond Myklebust
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070727015900.GA3000@sleipnir.redhat.com \
--to=fleite@redhat.com \
--cc=nfs@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox