All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Cusack <fcusack@fcusack.com>
To: viro@parcelfarce.linux.theplanet.co.uk,
	Linus Torvalds <torvalds@transmeta.com>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>,
	marcelo@conectiva.com.br, lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] NFS sillyrename fixes (was: [PATCH] nfs_unlink() race)
Date: Wed, 11 Jun 2003 00:22:26 -0700	[thread overview]
Message-ID: <20030611002226.A19078@google.com> (raw)
In-Reply-To: <20030611030041.GE6754@parcelfarce.linux.theplanet.co.uk>; from viro@parcelfarce.linux.theplanet.co.uk on Wed, Jun 11, 2003 at 04:00:41AM +0100

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

On Wed, Jun 11, 2003 at 04:00:41AM +0100, viro@parcelfarce.linux.theplanet.co.uk wrote:
> FWIW, we could probably simply do the following: have nfs_lookup()
> return ERR_PTR(-EINVAL) if it notices that it's about to give us
> such alias.  IOW, no access to such guys at all - if it's going
> to die, we refuse to do anything with it.  I'll try to do that
> variant when I get some sleep - I'd rather not mess with anything
> in that area until I'm completely awake...

Sounds ok to me, except that Linus says

On Tue, Jun 10, 2003 at 10:30:10PM -0700, Linus Torvalds wrote:
> 
> On Wed, 11 Jun 2003 viro@parcelfarce.linux.theplanet.co.uk wrote:
> > 
> > Two different dentries for the same file is obviously not a problem...
> 
> It _is_ a problem. It does the wrong thing on any subsequent directory
> operation (move or unlink). 
> 
> Multiple aliased dentries have never been ok, unless the filesystem 
> explicitly handles them and invalidates them (ie ntfs/fat kind of things).

so anyway, please find attached a 2.4.21-rc7 and 2.5.70 patch which
prevents removal or rename of unlinked-but-open files.  You can see
the rename bug by doing something like

mkdir d1 d2
hold a file open in d1 and rm it; it gets sillyrenamed
move sillyrenamed file to d2
rmdir d1
close file => "inode number mismatch" (data->dir isn't "live", ie it
doesn't follow the rename, and d1 is gone)

/fc

[-- Attachment #2: linux-2.4.21-rc7-silly-1.patch --]
[-- Type: text/plain, Size: 878 bytes --]

--- linux-2.4.21-rc7/fs/namei.c	Sun Jun  8 23:57:33 2003
+++ linux-2.4.21-rc7-silly/fs/namei.c	Tue Jun 10 23:49:08 2003
@@ -1482,13 +1482,14 @@ int vfs_unlink(struct inode *dir, struct
 				lock_kernel();
 				error = dir->i_op->unlink(dir, dentry);
 				unlock_kernel();
-				if (!error)
+				if (!error &&
+				    !(dentry->d_flags & DCACHE_NFSFS_RENAMED))
 					d_delete(dentry);
 			}
 		}
 	}
 	up(&dir->i_zombie);
-	if (!error)
+	if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED))
 		inode_dir_notify(dir, DN_DELETE);
 	return error;
 }
@@ -1830,6 +1831,10 @@ int vfs_rename(struct inode *old_dir, st
 	       struct inode *new_dir, struct dentry *new_dentry)
 {
 	int error;
+
+	if (old_dentry->d_flags & DCACHE_NFSFS_RENAMED)
+		return -EBUSY;
+
 	if (S_ISDIR(old_dentry->d_inode->i_mode))
 		error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry);
 	else

[-- Attachment #3: linux-2.5.70-silly-1.patch --]
[-- Type: text/plain, Size: 803 bytes --]

--- linux-2.5.70/fs/namei.c	Sun Jun  1 23:30:30 2003
+++ linux-2.5.70-silly/fs/namei.c	Tue Jun 10 23:44:14 2003
@@ -1631,7 +1631,9 @@ int vfs_unlink(struct inode *dir, struct
 			error = dir->i_op->unlink(dir, dentry);
 	}
 	up(&dentry->d_inode->i_sem);
-	if (!error) {
+
+	/* We don't d_delete() NFS sillyrenamed files--they still exist. */
+	if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) {
 		d_delete(dentry);
 		inode_dir_notify(dir, DN_DELETE);
 	}
@@ -1949,6 +1951,10 @@ int vfs_rename(struct inode *old_dir, st
 
 	if (old_dentry->d_inode == new_dentry->d_inode)
  		return 0;
+
+	/* Don't allow sillyrenamed files to move; messes up async_unlink */
+	if (old_dentry->d_flags & DCACHE_NFSFS_RENAMED)
+		return -EBUSY;
  
 	error = may_delete(old_dir, old_dentry, is_dir);
 	if (error)

  reply	other threads:[~2003-06-11  7:09 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-03 23:54 nfs_refresh_inode: inode number mismatch Frank Cusack
2003-06-04 14:19 ` Trond Myklebust
2003-06-04 21:20   ` Frank Cusack
2003-06-04 21:28     ` Trond Myklebust
2003-06-05  9:11     ` Adrian Cox
2003-06-05  9:13       ` Russell King
2003-06-05 13:51         ` Trond Myklebust
2003-06-09 13:51 ` [PATCH] nfs_unlink() race (was: nfs_refresh_inode: inode number mismatch) Frank Cusack
2003-06-09 13:55   ` Frank Cusack
2003-06-09 15:53   ` Linus Torvalds
2003-06-09 16:40     ` Trond Myklebust
2003-06-09 20:46       ` Frank Cusack
2003-06-10  0:01         ` Trond Myklebust
2003-06-11  0:54   ` viro
2003-06-11  1:28     ` Frank Cusack
2003-06-11  1:47       ` viro
2003-06-11  2:32         ` Frank Cusack
2003-06-11  2:37           ` viro
2003-06-11  1:59     ` Trond Myklebust
2003-06-11  2:27       ` viro
2003-06-11  2:43         ` Frank Cusack
2003-06-11  2:50           ` Frank Cusack
2003-06-11  3:00           ` viro
2003-06-11  7:22             ` Frank Cusack [this message]
2003-06-13  0:19               ` [PATCH] NFS sillyrename fixes take 3 Frank Cusack
2003-06-11  3:00         ` [PATCH] nfs_unlink() race (was: nfs_refresh_inode: inode number mismatch) Trond Myklebust
2003-06-11  5:30     ` Linus Torvalds
2003-06-11  6:16       ` Andreas Dilger
2003-06-11 12:33       ` Alan Cox
2003-06-11 15:08         ` Linus Torvalds
2003-06-11 15:51           ` Alan Cox
2003-06-11 16:11             ` Linus Torvalds
2003-06-11 16:21               ` Alan Cox
2003-06-11 16:31                 ` Linus Torvalds
2003-06-11 16:34                   ` viro
2003-06-11 17:22                   ` Alan Cox
2003-06-11 17:37                     ` Trond Myklebust
2003-06-11 17:47                       ` Trond Myklebust
2003-06-12 21:59                         ` Jan Harkes
     [not found]                       ` <16103.29804.198545.680701@charged.uio.no>
2003-06-11 22:24                         ` Frank Cusack
2003-06-11 23:16                           ` Trond Myklebust
2003-06-11 23:35                             ` [PATCH] nfs_unlink() race Frank Cusack

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=20030611002226.A19078@google.com \
    --to=fcusack@fcusack.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    --cc=torvalds@transmeta.com \
    --cc=trond.myklebust@fys.uio.no \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    /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.