From patchwork Mon Dec 20 11:54:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A . Shutemov" X-Patchwork-Id: 420431 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBKBvwUY006919 for ; Mon, 20 Dec 2010 11:57:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757174Ab0LTL4L (ORCPT ); Mon, 20 Dec 2010 06:56:11 -0500 Received: from shutemov.name ([188.40.19.243]:38492 "EHLO shutemov.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757412Ab0LTLyo (ORCPT ); Mon, 20 Dec 2010 06:54:44 -0500 Received: by shutemov.name (Postfix, from userid 500) id 44F44D421E; Mon, 20 Dec 2010 13:54:41 +0200 (EET) From: "Kirill A. Shutsemov" To: Trond Myklebust , "J. Bruce Fields" , Neil Brown Cc: Pavel Emelyanov , linux-nfs@vger.kernel.org, "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCH 12/12] sunrpc: make rpc_pipefs be mountable multiple times Date: Mon, 20 Dec 2010 13:54:38 +0200 Message-Id: <1292846078-31793-13-git-send-email-kirill@shutemov.name> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1292846078-31793-1-git-send-email-kirill@shutemov.name> References: <1292846078-31793-1-git-send-email-kirill@shutemov.name> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 20 Dec 2010 11:57:59 +0000 (UTC) diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index c48f7a5..836e725 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -38,6 +39,49 @@ static struct kmem_cache *rpc_inode_cachep __read_mostly; #define RPC_UPCALL_TIMEOUT (30*HZ) +struct rpc_mount_opts { + int newinstance; +}; + +enum { + Opt_newinstance, + + Opt_err +}; + +static const match_table_t tokens = { + {Opt_newinstance, "newinstance"}, + + {Opt_err, NULL} +}; + +static int +parse_mount_options(char *data, struct rpc_mount_opts *opts) +{ + char *p; + + opts->newinstance = 0; + + while ((p = strsep(&data, ",")) != NULL) { + substring_t args[MAX_OPT_ARGS]; + int token; + + if (!*p) + continue; + + token = match_token(p, tokens, args); + switch (token) { + case Opt_newinstance: + opts->newinstance = 1; + break; + default: + return -EINVAL; + } + } + + return 0; +} + static void rpc_purge_list(struct rpc_inode *rpci, struct list_head *head, void (*destroy_msg)(struct rpc_pipe_msg *), int err) { @@ -1025,11 +1069,45 @@ rpc_fill_super(struct super_block *sb, void *data, int silent) return 0; } +static int +compare_rpc_mnt_sb(struct super_block *s, void *p) +{ + if (init_rpc_pipefs) + return init_rpc_pipefs->mnt_sb == s; + return 0; +} + static struct dentry * rpc_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { - return mount_single(fs_type, flags, data, rpc_fill_super); + int error; + struct rpc_mount_opts opts; + struct super_block *s; + + error = parse_mount_options(data, &opts); + if (error) + return ERR_PTR(error); + + if (opts.newinstance) + s = sget(fs_type, NULL, set_anon_super, NULL); + else + s = sget(fs_type, compare_rpc_mnt_sb, set_anon_super, NULL); + + if (IS_ERR(s)) + return ERR_CAST(s); + + if (!s->s_root) { + s->s_flags = flags; + error = rpc_fill_super(s, data, flags & MS_SILENT ? 1 : 0); + if (error) { + deactivate_locked_super(s); + return ERR_PTR(error); + } + s->s_flags |= MS_ACTIVE; + } + + return dget(s->s_root); } static struct file_system_type rpc_pipe_fs_type = {