linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: torvalds@osdl.org, akpm@osdl.org, steved@redhat.com,
	trond.myklebust@fys.uio.no, aviro@redhat.com
Cc: linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com,
	nfsv4@linux-nfs.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/5] NFS: Permit filesystem to override root dentry on mount
Date: Wed, 22 Feb 2006 20:21:42 GMT	[thread overview]
Message-ID: <dhowells1140639702@warthog.cambridge.redhat.com> (raw)

The attached patch extends the get_sb() filesystem operation to take an extra
argument that permits the default root dentry choice (sb->s_root) to be
overridden by the filesystem that owns the superblock.

If the dentry pointer pointed to by that argument is left unchanged, then
do_kern_mount() will use sb->s_root as the root of the mount. If the filesystem
sets the pointer to a dentry of its choice, then that will be used as the root
for that particular mount.

This patch permits a superblock to be implicitly shared amongst several mount
points, such as can be done with NFS to avoid potential inode aliasing (see
patch 5/5).

Signed-Off-By: David Howells <dhowells@redhat.com>
---
warthog>diffstat -p1 getsb-2616rc4.diff
 Documentation/filesystems/porting |    2 +-
 fs/super.c                        |   10 +++++++---
 include/linux/fs.h                |    2 +-
 3 files changed, 9 insertions(+), 5 deletions(-)

diff -uNrp linux-2.6.16-rc4/Documentation/filesystems/porting linux-2.6.16-rc4-getsb/Documentation/filesystems/porting
--- linux-2.6.16-rc4/Documentation/filesystems/porting	2004-06-18 13:42:30.000000000 +0100
+++ linux-2.6.16-rc4-getsb/Documentation/filesystems/porting	2006-02-22 17:11:59.000000000 +0000
@@ -51,7 +51,7 @@ success and negative number in case of e
 informative error value to report).  Call it foo_fill_super().  Now declare
 
 struct super_block foo_get_sb(struct file_system_type *fs_type,
-	int flags, const char *dev_name, void *data)
+	int flags, const char *dev_name, void *data, struct dentry **_root)
 {
 	return get_sb_bdev(fs_type, flags, dev_name, data, ext2_fill_super);
 }
diff -uNrp linux-2.6.16-rc4/include/linux/fs.h linux-2.6.16-rc4-getsb/include/linux/fs.h
--- linux-2.6.16-rc4/include/linux/fs.h	2006-02-22 17:00:41.000000000 +0000
+++ linux-2.6.16-rc4-getsb/include/linux/fs.h	2006-02-22 17:08:45.000000000 +0000
@@ -1240,7 +1240,7 @@ struct file_system_type {
 	const char *name;
 	int fs_flags;
 	struct super_block *(*get_sb) (struct file_system_type *, int,
-				       const char *, void *);
+				       const char *, void *, struct dentry **);
 	void (*kill_sb) (struct super_block *);
 	struct module *owner;
 	struct file_system_type * next;
diff -uNrp linux-2.6.16-rc4/fs/super.c linux-2.6.16-rc4-getsb/fs/super.c
--- linux-2.6.16-rc4/fs/super.c	2006-02-22 17:00:38.000000000 +0000
+++ linux-2.6.16-rc4-getsb/fs/super.c	2006-02-22 17:08:45.000000000 +0000
@@ -792,6 +792,7 @@ do_kern_mount(const char *fstype, int fl
 	struct file_system_type *type = get_fs_type(fstype);
 	struct super_block *sb = ERR_PTR(-ENOMEM);
 	struct vfsmount *mnt;
+	struct dentry *root;
 	int error;
 	char *secdata = NULL;
 
@@ -816,15 +817,18 @@ do_kern_mount(const char *fstype, int fl
 		}
 	}
 
-	sb = type->get_sb(type, flags, name, data);
+	root = NULL;
+	sb = type->get_sb(type, flags, name, data, &root);
 	if (IS_ERR(sb))
 		goto out_free_secdata;
+	if (!root)
+		root = dget(sb->s_root);
  	error = security_sb_kern_mount(sb, secdata);
  	if (error)
  		goto out_sb;
 	mnt->mnt_sb = sb;
-	mnt->mnt_root = dget(sb->s_root);
-	mnt->mnt_mountpoint = sb->s_root;
+	mnt->mnt_root = root;
+	mnt->mnt_mountpoint = root;
 	mnt->mnt_parent = mnt;
 	up_write(&sb->s_umount);
 	free_secdata(secdata);

             reply	other threads:[~2006-02-22 20:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-22 20:21 David Howells [this message]
2006-02-22 20:21 ` [PATCH 2/5] NFS: Apply mount root dentry override to filesystems David Howells
2006-02-22 20:21 ` [PATCH 4/5] NFS: Add dentry materialisation op David Howells
2006-02-22 20:21 ` [PATCH 5/5] NFS: Unify NFS superblocks per-protocol per-server David Howells
2006-02-22 20:21 ` [PATCH 3/5] NFS: Abstract out namespace initialisation David Howells

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=dhowells1140639702@warthog.cambridge.redhat.com \
    --to=dhowells@redhat.com \
    --cc=akpm@osdl.org \
    --cc=aviro@redhat.com \
    --cc=linux-cachefs@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nfsv4@linux-nfs.org \
    --cc=steved@redhat.com \
    --cc=torvalds@osdl.org \
    --cc=trond.myklebust@fys.uio.no \
    /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 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).