linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Can't unmount bad inode
@ 2005-01-19 21:20 Miklos Szeredi
  2005-01-19 21:45 ` Al Viro
  0 siblings, 1 reply; 3+ messages in thread
From: Miklos Szeredi @ 2005-01-19 21:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

Andrew,

This patch fixes a problem when a inode which is the root of a mount
becomes bad (make_bad_inode()).  In this case follow_link will return
-EIO, so the name resolution fails, and umount won't work.  The
solution is just to remove the follow_link method from bad_inode_ops.
Any filesystem operation (other than unmount) will still fail, since
every other method returns -EIO.

A test case for this is:

 1) export an smbfs on A and mount the share on B

 2) create directory X on A

 3) bind mount X to Y on B

 4) remove directory X, and create regular file X (same name) on A

 5) stat X on B, this will make X a bad inode (file type changed)

 6) umount Y

Without the patch applied, umount won't succeed, and a reboot is
necessary to get rid of the mount.

With the patch applied, umount will succeed.

The same is true for any filesystem which uses make_bad_inode() to
mark an existing inode bad (NFS, SMBFS, FUSE, etc...).

Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>

--- linux-2.6.10/fs/bad_inode.c.orig	2005-01-19 21:48:24.000000000 +0100
+++ linux-2.6.10/fs/bad_inode.c	2005-01-19 22:07:56.000000000 +0100
@@ -15,17 +15,6 @@
 #include <linux/smp_lock.h>
 #include <linux/namei.h>
 
-/*
- * The follow_link operation is special: it must behave as a no-op
- * so that a bad root inode can at least be unmounted. To do this
- * we must dput() the base and return the dentry with a dget().
- */
-static int bad_follow_link(struct dentry *dent, struct nameidata *nd)
-{
-	nd_set_link(nd, ERR_PTR(-EIO));
-	return 0;
-}
-
 static int return_EIO(void)
 {
 	return -EIO;
@@ -70,7 +59,8 @@ struct inode_operations bad_inode_ops =
 	.mknod		= EIO_ERROR,
 	.rename		= EIO_ERROR,
 	.readlink	= EIO_ERROR,
-	.follow_link	= bad_follow_link,
+	/* follow_link must be no-op, otherwise unmounting this inode
+	   won't work */
 	.truncate	= EIO_ERROR,
 	.permission	= EIO_ERROR,
 	.getattr	= EIO_ERROR,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Can't unmount bad inode
  2005-01-19 21:20 [PATCH] Can't unmount bad inode Miklos Szeredi
@ 2005-01-19 21:45 ` Al Viro
  2005-01-19 21:58   ` Miklos Szeredi
  0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2005-01-19 21:45 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: akpm, linux-kernel

On Wed, Jan 19, 2005 at 10:20:51PM +0100, Miklos Szeredi wrote:
> Andrew,
> 
> This patch fixes a problem when a inode which is the root of a mount
> becomes bad (make_bad_inode()).  In this case follow_link will return
> -EIO, so the name resolution fails, and umount won't work.  The
> solution is just to remove the follow_link method from bad_inode_ops.
> Any filesystem operation (other than unmount) will still fail, since
> every other method returns -EIO.

I'm not all that sure that we want to follow symlinks in the last
pathname component upon umount, actually...

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Can't unmount bad inode
  2005-01-19 21:45 ` Al Viro
@ 2005-01-19 21:58   ` Miklos Szeredi
  0 siblings, 0 replies; 3+ messages in thread
From: Miklos Szeredi @ 2005-01-19 21:58 UTC (permalink / raw)
  To: viro; +Cc: akpm, linux-kernel

> > This patch fixes a problem when a inode which is the root of a mount
> > becomes bad (make_bad_inode()).  In this case follow_link will return
> > -EIO, so the name resolution fails, and umount won't work.  The
> > solution is just to remove the follow_link method from bad_inode_ops.
> > Any filesystem operation (other than unmount) will still fail, since
> > every other method returns -EIO.
> 
> I'm not all that sure that we want to follow symlinks in the last
> pathname component upon umount, actually...

That could break existing usage, couldn't it?  The damage wouldn't be
too bad I guess, but still it would be a bigger change, than fixing
bad_inode.

Miklos


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-01-19 22:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-19 21:20 [PATCH] Can't unmount bad inode Miklos Szeredi
2005-01-19 21:45 ` Al Viro
2005-01-19 21:58   ` Miklos Szeredi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).