From: Steve Dickson <SteveD@redhat.com>
To: nfs@lists.sourceforge.net
Subject: Re: [PATCH] Reinstantiating stale inodes
Date: Sat, 01 May 2004 12:13:42 -0400 [thread overview]
Message-ID: <4093CCB6.1040500@RedHat.com> (raw)
In-Reply-To: <40892507.2030004@RedHat.com>
[-- Attachment #1: Type: text/plain, Size: 924 bytes --]
Steve Dickson wrote:
> Here is a 2.4 patch that will reinstantiate an inode
> when a ESTALE error is returned on a getattr. When
> the error occurs, a lookup is immediately issued
> to get a new fh.
>
> The fixes the problem of a server rsync -a directory
> that a client has mounted. The key being the -a flag
> since it causes the server not to update the mtime on
> the directory.
It turns out there is a much easier and simpler (safer)
way to reinstantiate inodes than my original patch.
Realizing only parts of an inode needed to be reinstantiated
not the entire thing, this second patch only reinstantiates
two parts of the inode (i.e. fhandle and fattrs) instead of the
entire inode like my original patch did.
I had to export the new nfs_reinstantiate() function because
the ACL code needs to use it, so things like ls -l will work....
Comments? Is this something Marcelo might be interested in?
SteveD.
[-- Attachment #2: linux-2.4.21-nfs-estale2.patch --]
[-- Type: text/plain, Size: 1772 bytes --]
--- linux-2.4.21/fs/nfs/inode.c.org 2004-04-17 18:26:32.000000000 -0400
+++ linux-2.4.21/fs/nfs/inode.c 2004-05-01 11:11:12.000000000 -0400
@@ -953,13 +953,48 @@ nfs_wait_on_inode(struct inode *inode, i
}
/*
+ * Reinstantiate an inode that has gone stale
+ */
+int
+nfs_reinstantiate(struct dentry *dentry)
+{
+ int error;
+ struct nfs_fh fhandle;
+ struct inode *dir = dentry->d_parent->d_inode;
+ struct inode *inode = dentry->d_inode;
+ struct nfs_fattr fattr;
+
+ nfs_zap_caches(dir);
+ nfs_zap_caches(inode);
+
+ error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, &fhandle, &fattr);
+ if (!error) {
+ memcpy(&inode->u.nfs_i.fh, &fhandle, sizeof(struct nfs_fh));
+ nfs_refresh_inode(inode, &fattr);
+ }
+
+ return error;
+}
+
+/*
* Externally visible revalidation function
*/
int
nfs_revalidate(struct dentry *dentry)
{
struct inode *inode = dentry->d_inode;
- return nfs_revalidate_inode(NFS_SERVER(inode), inode);
+ int error;
+
+ error = nfs_revalidate_inode(NFS_SERVER(inode), inode);
+ if (!error || error != -ESTALE)
+ return error;
+ /*
+ * We have a stale fh so ask the server for another one
+ */
+ if (nfs_reinstantiate(dentry) == 0)
+ error = 0;
+
+ return error;
}
/*
--- linux-2.4.21/include/linux/nfs_fs.h.org 2004-04-17 18:40:02.000000000 -0400
+++ linux-2.4.21/include/linux/nfs_fs.h 2004-05-01 10:55:59.000000000 -0400
@@ -159,6 +159,7 @@ extern struct inode *nfs_fhget(struct de
struct nfs_fattr *);
extern int __nfs_refresh_inode(struct inode *, struct nfs_fattr *);
extern int nfs_revalidate(struct dentry *);
+extern int nfs_reinstantiate(struct dentry *);
extern int nfs_permission(struct inode *, int);
extern int nfs_open(struct inode *, struct file *);
extern int nfs_release(struct inode *, struct file *);
next prev parent reply other threads:[~2004-05-01 16:13 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-23 14:15 [PATCH] Reinstantiating stale inodes Steve Dickson
2004-04-23 14:33 ` Olaf Kirch
2004-04-23 15:50 ` Steve Dickson
2004-04-23 17:55 ` Olaf Kirch
2004-04-23 18:43 ` Steve Dickson
2004-04-23 18:50 ` Olaf Kirch
2004-04-23 20:07 ` Steve Dickson
2004-04-23 14:36 ` Trond Myklebust
2004-04-23 16:01 ` Steve Dickson
2004-04-23 16:21 ` Trond Myklebust
2004-04-23 17:21 ` Steve Dickson
2004-04-23 17:49 ` Trond Myklebust
2004-04-23 19:14 ` Steve Dickson
[not found] ` <40892DC0.1010001@redhat.com>
2004-04-23 16:04 ` Steve Dickson
2004-05-01 16:13 ` Steve Dickson [this message]
2004-05-01 19:25 ` Trond Myklebust
2004-05-01 23:57 ` Steve Dickson
2004-05-02 0:22 ` Trond Myklebust
2004-05-02 3:19 ` Steve Dickson
2004-05-02 3:28 ` Trond Myklebust
2004-05-03 19:50 ` Steve Dickson
2004-05-03 20:15 ` Trond Myklebust
2004-05-03 20:33 ` Steve Dickson
2004-05-03 21:27 ` Trond Myklebust
2004-05-04 19:05 ` Steve Dickson
2004-05-06 17:39 ` Steve Dickson
-- strict thread matches above, loose matches on Subject: below --
2004-04-23 14:48 Lever, Charles
2004-04-23 15:00 ` Trond Myklebust
2004-04-23 16:16 ` Steve Dickson
2004-04-23 15:08 ` Olaf Kirch
2004-04-23 15:17 Lever, Charles
2004-04-23 16:16 Lever, Charles
2004-04-23 16:27 ` Steve Dickson
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=4093CCB6.1040500@RedHat.com \
--to=steved@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.