From mboxrd@z Thu Jan 1 00:00:00 1970 From: Trond Myklebust Subject: [PATCH] Allow kernel-only mount interfaces... Date: Thu, 10 Feb 2005 13:41:23 -0500 Message-ID: <1108060883.9757.33.camel@lade.trondhjem.org> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Received: from pat.uio.no ([129.240.130.16]:2449 "EHLO pat.uio.no") by vger.kernel.org with ESMTP id S261191AbVBJSlb (ORCPT ); Thu, 10 Feb 2005 13:41:31 -0500 Received: from mail-mx4.uio.no ([129.240.10.45] ident=7411) by pat.uio.no with esmtp (Exim 4.43) id 1CzJFp-0006R1-Vr for linux-fsdevel@vger.kernel.org; Thu, 10 Feb 2005 19:41:30 +0100 Received: from dh138.citi.umich.edu ([141.211.133.138]) by mail-mx4.uio.no with esmtpsa (SSLv3:RC4-MD5:128) (Exim 4.43) id 1CzJFn-0005Ye-BN for linux-fsdevel@vger.kernel.org; Thu, 10 Feb 2005 19:41:27 +0100 To: Linux Filesystem Development Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org 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 --- 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