All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Dickson <SteveD@redhat.com>
To: nfs@lists.sourceforge.net
Subject: Re: [PATCH]  Reinstantiating stale inodes
Date: Thu, 06 May 2004 13:39:17 -0400	[thread overview]
Message-ID: <409A7845.8090607@RedHat.com> (raw)
In-Reply-To: <40892507.2030004@RedHat.com>

[-- Attachment #1: Type: text/plain, Size: 68 bytes --]


Here is a proper way of reinstantiating stale inodes....

SteveD.


[-- Attachment #2: linux-2.4.21-nfs-estale4.patch --]
[-- Type: text/plain, Size: 5362 bytes --]

--- linux/fs/nfs/inode.c.orig	2004-05-06 11:31:23.000000000 -0400
+++ linux/fs/nfs/inode.c	2004-05-06 13:03:27.000000000 -0400
@@ -958,8 +958,17 @@ nfs_wait_on_inode(struct inode *inode, i
 int
 nfs_revalidate(struct dentry *dentry)
 {
+	int error;
 	struct inode *inode = dentry->d_inode;
-	return nfs_revalidate_inode(NFS_SERVER(inode), inode);
+	
+	error = nfs_revalidate_inode(NFS_SERVER(inode), inode);
+	if (error == -ESTALE) {
+		struct inode *dir = dentry->d_parent->d_inode;
+		nfs_zap_caches(dir);	
+		d_drop(dentry);
+	}
+
+	return error;
 }
 
 /*
--- linux/fs/stat.c.orig	2004-05-06 11:31:23.000000000 -0400
+++ linux/fs/stat.c	2004-05-06 13:03:27.000000000 -0400
@@ -143,8 +143,9 @@ static int cp_new_stat(struct inode * in
 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
 {
 	struct nameidata nd;
-	int error;
+	int error, errcnt = 0;
 
+again:
 	error = user_path_walk(filename, &nd);
 	if (!error) {
 		error = do_revalidate(nd.dentry);
@@ -152,6 +153,10 @@ asmlinkage long sys_stat(char * filename
 			error = cp_old_stat(nd.dentry->d_inode, statbuf);
 		path_release(&nd);
 	}
+	if (error == -ESTALE && !errcnt) {
+		errcnt++;
+		goto again;
+	}
 	return error;
 }
 #endif
@@ -159,8 +164,9 @@ asmlinkage long sys_stat(char * filename
 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
 {
 	struct nameidata nd;
-	int error;
+	int error, errcnt = 0;
 
+again:
 	error = user_path_walk(filename, &nd);
 	if (!error) {
 		error = do_revalidate(nd.dentry);
@@ -168,6 +174,11 @@ asmlinkage long sys_newstat(char * filen
 			error = cp_new_stat(nd.dentry->d_inode, statbuf);
 		path_release(&nd);
 	}
+	if (error == -ESTALE && !errcnt) {
+		errcnt++;
+		goto again;
+	}
+
 	return error;
 }
 
@@ -180,8 +191,9 @@ asmlinkage long sys_newstat(char * filen
 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
 {
 	struct nameidata nd;
-	int error;
+	int error, errcnt = 0;
 
+again:
 	error = user_path_walk_link(filename, &nd);
 	if (!error) {
 		error = do_revalidate(nd.dentry);
@@ -189,6 +201,11 @@ asmlinkage long sys_lstat(char * filenam
 			error = cp_old_stat(nd.dentry->d_inode, statbuf);
 		path_release(&nd);
 	}
+	if (error == -ESTALE && !errcnt) {
+		errcnt++;
+		goto again;
+	}
+
 	return error;
 }
 
@@ -197,8 +214,9 @@ asmlinkage long sys_lstat(char * filenam
 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
 {
 	struct nameidata nd;
-	int error;
+	int error, errcnt = 0;
 
+again:
 	error = user_path_walk_link(filename, &nd);
 	if (!error) {
 		error = do_revalidate(nd.dentry);
@@ -206,6 +224,12 @@ asmlinkage long sys_newlstat(char * file
 			error = cp_new_stat(nd.dentry->d_inode, statbuf);
 		path_release(&nd);
 	}
+
+	if (error == -ESTALE && !errcnt) {
+		errcnt++;
+		goto again;
+	}
+
 	return error;
 }
 
@@ -218,8 +242,10 @@ asmlinkage long sys_newlstat(char * file
 asmlinkage long sys_fstat(unsigned int fd, struct __old_kernel_stat * statbuf)
 {
 	struct file * f;
-	int err = -EBADF;
+	int err, errcnt = 0;
 
+again:
+	err = -EBADF;
 	f = fget(fd);
 	if (f) {
 		struct dentry * dentry = f->f_dentry;
@@ -229,6 +255,11 @@ asmlinkage long sys_fstat(unsigned int f
 			err = cp_old_stat(dentry->d_inode, statbuf);
 		fput(f);
 	}
+	if (err == -ESTALE && !errcnt) {
+		errcnt++;
+		goto again;
+	}
+
 	return err;
 }
 
@@ -237,8 +268,10 @@ asmlinkage long sys_fstat(unsigned int f
 asmlinkage long sys_newfstat(unsigned int fd, struct stat * statbuf)
 {
 	struct file * f;
-	int err = -EBADF;
+	int err, errcnt = 0;
 
+again:
+	err = -EBADF;
 	f = fget(fd);
 	if (f) {
 		struct dentry * dentry = f->f_dentry;
@@ -248,6 +281,11 @@ asmlinkage long sys_newfstat(unsigned in
 			err = cp_new_stat(dentry->d_inode, statbuf);
 		fput(f);
 	}
+	if (err == -ESTALE && !errcnt) {
+		errcnt++;
+		goto again;
+	}
+
 	return err;
 }
 
@@ -340,8 +378,9 @@ static long cp_new_stat64(struct inode *
 asmlinkage long sys_stat64(char * filename, struct stat64 * statbuf, long flags)
 {
 	struct nameidata nd;
-	int error;
+	int error, errcnt = 0;
 
+again:
 	error = user_path_walk(filename, &nd);
 	if (!error) {
 		error = do_revalidate(nd.dentry);
@@ -349,14 +388,20 @@ asmlinkage long sys_stat64(char * filena
 			error = cp_new_stat64(nd.dentry->d_inode, statbuf);
 		path_release(&nd);
 	}
+	if (error == -ESTALE && !errcnt) {
+		errcnt++;
+		goto again;
+	}
+
 	return error;
 }
 
 asmlinkage long sys_lstat64(char * filename, struct stat64 * statbuf, long flags)
 {
 	struct nameidata nd;
-	int error;
+	int error, errcnt= 0;
 
+again:
 	error = user_path_walk_link(filename, &nd);
 	if (!error) {
 		error = do_revalidate(nd.dentry);
@@ -364,14 +409,21 @@ asmlinkage long sys_lstat64(char * filen
 			error = cp_new_stat64(nd.dentry->d_inode, statbuf);
 		path_release(&nd);
 	}
+	if (error == -ESTALE && !errcnt) {
+		errcnt++;
+		goto again;
+	}
+
 	return error;
 }
 
 asmlinkage long sys_fstat64(unsigned long fd, struct stat64 * statbuf, long flags)
 {
 	struct file * f;
-	int err = -EBADF;
+	int err, errcnt = 0;
 
+again:
+	err = -EBADF;
 	f = fget(fd);
 	if (f) {
 		struct dentry * dentry = f->f_dentry;
@@ -381,6 +433,10 @@ asmlinkage long sys_fstat64(unsigned lon
 			err = cp_new_stat64(dentry->d_inode, statbuf);
 		fput(f);
 	}
+	if (err == -ESTALE && !errcnt) {
+		errcnt++;
+		goto again;
+	}
 	return err;
 }
 

  parent reply	other threads:[~2004-05-06 17:38 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
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 [this message]
  -- 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=409A7845.8090607@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.