From patchwork Tue Jul 3 16:20:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Kinsbursky X-Patchwork-Id: 1152111 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 4B5493FE80 for ; Tue, 3 Jul 2012 16:23:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756051Ab2GCQXQ (ORCPT ); Tue, 3 Jul 2012 12:23:16 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:19033 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752181Ab2GCQXN (ORCPT ); Tue, 3 Jul 2012 12:23:13 -0400 Received: from localhost.localdomain ([10.30.21.131]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id q63GN6s2010994; Tue, 3 Jul 2012 20:23:06 +0400 (MSK) Subject: [PATCH v3 05/11] NFS: callback service start function introduced To: bfields@fieldses.org From: Stanislav Kinsbursky Cc: linux-nfs@vger.kernel.org, Trond.Myklebust@netapp.com, linux-kernel@vger.kernel.org, devel@openvz.org Date: Tue, 03 Jul 2012 20:20:01 +0400 Message-ID: <20120703162001.11911.6979.stgit@localhost.localdomain> In-Reply-To: <20120703161844.11911.92996.stgit@localhost.localdomain> References: <20120703161844.11911.92996.stgit@localhost.localdomain> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org This is just a code move, which from my POW makes code looks better. I.e. now on start we have 3 different stages: 1) Service creation. 2) Service per-net data allocation. 3) Service start. Patch also renames goto label "out_err:" into "err_start:" to reflect new changes. Signed-off-by: Stanislav Kinsbursky --- fs/nfs/callback.c | 77 +++++++++++++++++++++++++++++++---------------------- 1 files changed, 45 insertions(+), 32 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 41150ef..550d2a2 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c @@ -241,6 +241,46 @@ static inline void nfs_callback_bc_serv(u32 minorversion, struct rpc_xprt *xprt, } #endif /* CONFIG_NFS_V4_1 */ +static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, + struct svc_serv *serv) +{ + struct svc_rqst *rqstp; + int (*callback_svc)(void *vrqstp); + struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion]; + char svc_name[12]; + int ret; + int minorversion_setup; + + nfs_callback_bc_serv(minorversion, xprt, serv); + + minorversion_setup = nfs_minorversion_callback_svc_setup(minorversion, + serv, &rqstp, &callback_svc); + if (!minorversion_setup) { + /* v4.0 callback setup */ + rqstp = nfs4_callback_up(serv); + callback_svc = nfs4_callback_svc; + } + + if (IS_ERR(rqstp)) + return PTR_ERR(rqstp); + + svc_sock_update_bufs(serv); + + sprintf(svc_name, "nfsv4.%u-svc", minorversion); + cb_info->serv = serv; + cb_info->rqst = rqstp; + cb_info->task = kthread_run(callback_svc, cb_info->rqst, svc_name); + if (IS_ERR(cb_info->task)) { + ret = PTR_ERR(cb_info->task); + svc_exit_thread(cb_info->rqst); + cb_info->rqst = NULL; + cb_info->task = NULL; + return PTR_ERR(cb_info->task); + } + dprintk("nfs_callback_up: service started\n"); + return 0; +} + static int nfs_callback_up_net(int minorversion, struct svc_serv *serv, struct net *net) { int ret; @@ -311,12 +351,8 @@ static struct svc_serv *nfs_callback_create_svc(int minorversion) int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt) { struct svc_serv *serv; - struct svc_rqst *rqstp; - int (*callback_svc)(void *vrqstp); struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion]; - char svc_name[12]; int ret = 0; - int minorversion_setup; struct net *net = xprt->xprt_net; mutex_lock(&nfs_callback_mutex); @@ -336,34 +372,10 @@ int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt) if (ret < 0) goto err_net; - nfs_callback_bc_serv(minorversion, xprt, serv); - - minorversion_setup = nfs_minorversion_callback_svc_setup(minorversion, - serv, &rqstp, &callback_svc); - if (!minorversion_setup) { - /* v4.0 callback setup */ - rqstp = nfs4_callback_up(serv); - callback_svc = nfs4_callback_svc; - } - - if (IS_ERR(rqstp)) { - ret = PTR_ERR(rqstp); - goto out_err; - } - - svc_sock_update_bufs(serv); + ret = nfs_callback_start_svc(minorversion, xprt, serv); + if (ret < 0) + goto err_start; - sprintf(svc_name, "nfsv4.%u-svc", minorversion); - cb_info->serv = serv; - cb_info->rqst = rqstp; - cb_info->task = kthread_run(callback_svc, cb_info->rqst, svc_name); - if (IS_ERR(cb_info->task)) { - ret = PTR_ERR(cb_info->task); - svc_exit_thread(cb_info->rqst); - cb_info->rqst = NULL; - cb_info->task = NULL; - goto out_err; - } out: /* * svc_create creates the svc_serv with sv_nrthreads == 1, and then @@ -375,7 +387,8 @@ out: err_create: mutex_unlock(&nfs_callback_mutex); return ret; -out_err: + +err_start: svc_shutdown_net(serv, net); err_net: dprintk("NFS: Couldn't create callback socket or server thread; "