From: Peter Staubach <staubach@redhat.com> Date: Mon, 9 Jun 2008 15:14:40 -0400 Subject: [nfs] ensure that options turn off attribute caching Message-id: 484D8120.4070300@redhat.com O-Subject: [RHEL-5.3 PATCH] Ensure that 'noac' and/or 'actimeo=0' turn off attribute caching Bugzilla: 450184 RH-Acked-by: Steve Dickson <SteveD@redhat.com> RH-Acked-by: Jeff Layton <jlayton@redhat.com> Hi. Attached is a patch to address bz450184, "Ensure that 'noac' and/or 'actimeo=0' turn off attribute caching". The problem is that the mount options, "noac" and/or "actimeo=0", are supposed to stop the NFS client from doing attribute caching. This means that when the attributes of a file are requested, they are retrieved from the server instead of being satisfied locally on the client. However, the attribute cache timeout is based on jiffies. The cache timeout algorithm works by comparing the current jiffies value against the sum of the jiffies value that was stored when the attributes were previously retrieved and the cache duration time value. If the current jiffies value is greater than that sum, then the attribute cache is deemed to be timed out and a new set of attributes are retrieved from the server. Unfortunately, this allows the attributes to be cached for 1 jiffie longer than the cache timeout is supposed to be. For the most part, this does not matter. Cache timeouts are normally expressed in seconds and the jiffies values are usually in units 1/1000 of a second, so the additional jiffie isn't a big deal. However, when the timeout is supposed to be 0, then the additional jiffie can be significant. Some applications, notably Oracle 10G, depend upon being able to detect file attribute changes, all of which can occur during the same jiffies value. They use one or the other of the two listed NFS mount options in order to be able to detect those changes. However, since the attribute cache timeouts are off by one, then these applications can not correctly detect the file attribute changes in a timely enough fashion. This patch was constructed by Trond, the upstream maintainer. Comments? ps diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 53f96fa..ff11522 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -671,6 +671,13 @@ int nfs_attribute_timeout(struct inode *inode) if (nfs_have_delegation(inode, FMODE_READ)) return 0; + /* + * Special case: if the attribute timeout is set to 0, then we + * treat the cache as having expired (unless we + * have a delegation). + */ + if (nfsi->attrtimeo == 0) + return 1; return time_after(jiffies, nfsi->read_cache_jiffies+nfsi->attrtimeo); }