* [PATCH] Allow kernel-only mount interfaces...
@ 2005-02-10 18:41 Trond Myklebust
2005-02-10 19:01 ` Andreas Dilger
0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2005-02-10 18:41 UTC (permalink / raw)
To: Linux Filesystem Development
Hi,
I'm working on straightening out a problem we have with NFSv4 in the
case where the server exports a tree of filesystems (as we also do in
NFSv2/v3 with the "nohide" option).
If the client mounts such a tree, it is supposed to detect whenever it
crosses a mountpoint on the server, and basically automount the new
filesystem in-place. The main reason for wanting to do so is that NFSv4
allows for individual filesystems to be migrated and/or replicated to
other servers.
In order to respect atomicity guarantees, it would be nice to do this
automounting in-kernel within nfs_lookup(). For efficiency reasons, it
would be nice to be able to pass the old superblock as a parameter to
the mount code. The problem is that the current mount interfaces do not
allow the kernel to have a private api that differs from the standard
userland mount.
Would something like the appended patch be an acceptable method of
implementing such a private mount api?
Cheers,
Trond
VFS: Add GPL_EXPORTED function vfs_kern_mount()
do_kern_mount() does not allow the kernel to use private mount interfaces
without exposing the same interfaces to userland. The problem is that the
filesystem is referenced by name, thus meaning that it and its mount
interface must be registered in the global filesystem list.
vfs_kern_mount() passes the struct file_system_type as an explicit
parameter in order to overcome this limitation.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---
super.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
Index: linux-2.6.11-rc3/fs/super.c
===================================================================
--- linux-2.6.11-rc3.orig/fs/super.c
+++ linux-2.6.11-rc3/fs/super.c
@@ -794,9 +794,8 @@ struct super_block *get_sb_single(struct
EXPORT_SYMBOL(get_sb_single);
struct vfsmount *
-do_kern_mount(const char *fstype, int flags, const char *name, void *data)
+vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
{
- struct file_system_type *type = get_fs_type(fstype);
struct super_block *sb = ERR_PTR(-ENOMEM);
struct vfsmount *mnt;
int error;
@@ -835,7 +834,6 @@ do_kern_mount(const char *fstype, int fl
mnt->mnt_parent = mnt;
mnt->mnt_namespace = current->namespace;
up_write(&sb->s_umount);
- put_filesystem(type);
return mnt;
out_sb:
up_write(&sb->s_umount);
@@ -846,10 +844,20 @@ out_free_secdata:
out_mnt:
free_vfsmnt(mnt);
out:
- put_filesystem(type);
return (struct vfsmount *)sb;
}
+EXPORT_SYMBOL_GPL(vfs_kern_mount);
+
+struct vfsmount *
+do_kern_mount(const char *fstype, int flags, const char *name, void *data)
+{
+ struct file_system_type *type = get_fs_type(fstype);
+ struct vfsmount *mnt = vfs_kern_mount(type, flags, name, data);
+ put_filesystem(type);
+ return mnt;
+}
+
EXPORT_SYMBOL_GPL(do_kern_mount);
struct vfsmount *kern_mount(struct file_system_type *type)
--
Trond Myklebust <trond.myklebust@fys.uio.no>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] Allow kernel-only mount interfaces...
2005-02-10 18:41 [PATCH] Allow kernel-only mount interfaces Trond Myklebust
@ 2005-02-10 19:01 ` Andreas Dilger
2005-02-10 19:14 ` Trond Myklebust
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Dilger @ 2005-02-10 19:01 UTC (permalink / raw)
To: Trond Myklebust; +Cc: Linux Filesystem Development
[-- Attachment #1: Type: text/plain, Size: 656 bytes --]
On Feb 10, 2005 13:41 -0500, Trond Myklebust wrote:
> +struct vfsmount *
> +do_kern_mount(const char *fstype, int flags, const char *name, void *data)
> +{
> + struct file_system_type *type = get_fs_type(fstype);
> + struct vfsmount *mnt = vfs_kern_mount(type, flags, name, data);
> + put_filesystem(type);
> + return mnt;
> +}
This will OOPS if fstype is bad, since you unconditionally put_filesystem()
on a possible PTR_ERR() type. You need an extra
if (!IS_ERR(type))
put_filesystem(type);
Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://members.shaw.ca/adilger/ http://members.shaw.ca/golinux/
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] Allow kernel-only mount interfaces...
2005-02-10 19:01 ` Andreas Dilger
@ 2005-02-10 19:14 ` Trond Myklebust
0 siblings, 0 replies; 3+ messages in thread
From: Trond Myklebust @ 2005-02-10 19:14 UTC (permalink / raw)
To: Andreas Dilger; +Cc: Linux Filesystem Development
to den 10.02.2005 Klokka 12:01 (-0700) skreiv Andreas Dilger:
> This will OOPS if fstype is bad, since you unconditionally put_filesystem()
> on a possible PTR_ERR() type. You need an extra
>
> if (!IS_ERR(type))
> put_filesystem(type);
>
Agreed. That was not a final patch, but just a first untested draft in
order to test the waters.
I'm mainly wanting to hear whether or not anyone has major objections
(Al ?) against the new function itself.
Here's an update, though ;-)
Cheers,
Trond
VFS: Add GPL_EXPORTED function vfs_kern_mount()
do_kern_mount() does not allow the kernel to use private mount interfaces
without exposing the same interfaces to userland. The problem is that the
filesystem is referenced by name, thus meaning that it and its mount
interface must be registered in the global filesystem list.
vfs_kern_mount() passes the struct file_system_type as an explicit
parameter in order to overcome this limitation.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
super.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
Index: linux-2.6.11-rc3/fs/super.c
===================================================================
--- linux-2.6.11-rc3.orig/fs/super.c
+++ linux-2.6.11-rc3/fs/super.c
@@ -794,17 +794,13 @@ struct super_block *get_sb_single(struct
EXPORT_SYMBOL(get_sb_single);
struct vfsmount *
-do_kern_mount(const char *fstype, int flags, const char *name, void *data)
+vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
{
- struct file_system_type *type = get_fs_type(fstype);
struct super_block *sb = ERR_PTR(-ENOMEM);
struct vfsmount *mnt;
int error;
char *secdata = NULL;
- if (!type)
- return ERR_PTR(-ENODEV);
-
mnt = alloc_vfsmnt(name);
if (!mnt)
goto out;
@@ -835,7 +831,6 @@ do_kern_mount(const char *fstype, int fl
mnt->mnt_parent = mnt;
mnt->mnt_namespace = current->namespace;
up_write(&sb->s_umount);
- put_filesystem(type);
return mnt;
out_sb:
up_write(&sb->s_umount);
@@ -846,10 +841,23 @@ out_free_secdata:
out_mnt:
free_vfsmnt(mnt);
out:
- put_filesystem(type);
return (struct vfsmount *)sb;
}
+EXPORT_SYMBOL_GPL(vfs_kern_mount);
+
+struct vfsmount *
+do_kern_mount(const char *fstype, int flags, const char *name, void *data)
+{
+ struct file_system_type *type = get_fs_type(fstype);
+ struct vfsmount *mnt;
+ if (!type)
+ return ERR_PTR(-ENODEV);
+ mnt = vfs_kern_mount(type, flags, name, data);
+ put_filesystem(type);
+ return mnt;
+}
+
EXPORT_SYMBOL_GPL(do_kern_mount);
struct vfsmount *kern_mount(struct file_system_type *type)
--
Trond Myklebust <trond.myklebust@fys.uio.no>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-02-10 19:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-10 18:41 [PATCH] Allow kernel-only mount interfaces Trond Myklebust
2005-02-10 19:01 ` Andreas Dilger
2005-02-10 19:14 ` Trond Myklebust
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).