From patchwork Tue Aug 30 00:03:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9304659 X-Patchwork-Delegate: Trond.Myklebust@netapp.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 054826077C for ; Tue, 30 Aug 2016 00:04:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAED928970 for ; Tue, 30 Aug 2016 00:04:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF9B0289E1; Tue, 30 Aug 2016 00:04:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65C6E28970 for ; Tue, 30 Aug 2016 00:04:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757110AbcH3AEj (ORCPT ); Mon, 29 Aug 2016 20:04:39 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:35860 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757097AbcH3AEi (ORCPT ); Mon, 29 Aug 2016 20:04:38 -0400 Received: by mail-it0-f65.google.com with SMTP id x131so619544ite.3 for ; Mon, 29 Aug 2016 17:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=5O1PoLtbJ1q86ZWXqIrxIjUuGfVGFt6zuioUmUOjiE0=; b=C2YFQ0R6zVkrOAu+U0XplN4A53d6ityO72ZoloIqDbi7ccCpgJ7d2D/w4OJ2zfnUvw 04yfv8mKrhaFQwVWiKbDelTe10ercRE9RgaacgmAJmxOyNoJCXUzPxjkCFz1TrY5UbN9 SnUKKpgwKyR07AR7SoV1129y8HJUWOkbI9lMiSvCJuBW0E6KVcnKZ9bPR+qPpsd5qf4f gOj//cTfA4pPVxIr7yj5v9cF8GZXkDvTfkxYXWnPn7xXfLDta2FkVHOLp3ETB375JCgc OWJ8x0cjA8zjJl/qmDW+7BI2y4OI9iY+X6nTHEhd8lZfCk6pNy12Sm7+KirhIPXy6mYL m/Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=5O1PoLtbJ1q86ZWXqIrxIjUuGfVGFt6zuioUmUOjiE0=; b=LCR4sFu1N/a4HGi7N9jcA+MZdhDBaqfbnTE+ynyFUb08Du+iVWfkTiDysg31buDkSX eYbdtVquBygrArcAi6BAjao4fygPq3Cc5KuzSWR/pOJziQtsAHBX9tDKEkstGpe5lQ6Y DTIrF/ur4044jWD4t1UbobD+kyZKmeBnrRTp8GbPzziBeQHyIXcr57JW3ZP1z6mi4g0n p3rauTRbie3GVO1VzttOzStHtqi98Yl/ARd3WNDpqomXf3xzd47Katcdmwpw2u3F+ec1 s97uk//VNgSF6F9Gso4St8lWUUEYMsE7uqCX36PuNY0Br1YHsteY+oFG+Qpxes6suGDb rQ5g== X-Gm-Message-State: AE9vXwPYNzQfntj4Cf8JaXsxeWJSJoXoup0hdK5hM93zZiYnDVMVrte/cnqOzza9a6UB+Q== X-Received: by 10.36.46.136 with SMTP id i130mr1952067ita.62.1472515476741; Mon, 29 Aug 2016 17:04:36 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (c-68-49-162-121.hsd1.mi.comcast.net. [68.49.162.121]) by smtp.gmail.com with ESMTPSA id 140sm7994943itl.4.2016.08.29.17.04.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Aug 2016 17:04:36 -0700 (PDT) From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 2/6] NFSv4.x: Set up struct svc_serv_ops for the callback channel Date: Mon, 29 Aug 2016 20:03:48 -0400 Message-Id: <1472515432-54202-3-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472515432-54202-2-git-send-email-trond.myklebust@primarydata.com> References: <1472515432-54202-1-git-send-email-trond.myklebust@primarydata.com> <1472515432-54202-2-git-send-email-trond.myklebust@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to manage the threads using svc_set_num_threads, we need to fill in a few extra fields. Signed-off-by: Trond Myklebust --- fs/nfs/callback.c | 57 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 52a28311e2a4..478bb0a7effe 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c @@ -155,13 +155,6 @@ nfs41_callback_up(struct svc_serv *serv) return rqstp; } -static void nfs_minorversion_callback_svc_setup(struct svc_serv *serv, - struct svc_rqst **rqstpp, int (**callback_svc)(void *vrqstp)) -{ - *rqstpp = nfs41_callback_up(serv); - *callback_svc = nfs41_callback_svc; -} - static inline void nfs_callback_bc_serv(u32 minorversion, struct rpc_xprt *xprt, struct svc_serv *serv) { @@ -173,11 +166,10 @@ static inline void nfs_callback_bc_serv(u32 minorversion, struct rpc_xprt *xprt, xprt->bc_serv = serv; } #else -static void nfs_minorversion_callback_svc_setup(struct svc_serv *serv, - struct svc_rqst **rqstpp, int (**callback_svc)(void *vrqstp)) +static struct svc_rqst * +nfs41_callback_up(struct svc_serv *serv) { - *rqstpp = ERR_PTR(-ENOTSUPP); - *callback_svc = ERR_PTR(-ENOTSUPP); + return ERR_PTR(-ENOTSUPP); } static inline void nfs_callback_bc_serv(u32 minorversion, struct rpc_xprt *xprt, @@ -190,7 +182,6 @@ 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]; int ret; @@ -203,11 +194,9 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, case 0: /* v4.0 callback setup */ rqstp = nfs4_callback_up(serv); - callback_svc = nfs4_callback_svc; break; default: - nfs_minorversion_callback_svc_setup(serv, - &rqstp, &callback_svc); + rqstp = nfs41_callback_up(serv); } if (IS_ERR(rqstp)) @@ -217,7 +206,8 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, cb_info->serv = serv; cb_info->rqst = rqstp; - cb_info->task = kthread_create(callback_svc, cb_info->rqst, + cb_info->task = kthread_create(serv->sv_ops->svo_function, + cb_info->rqst, "nfsv4.%u-svc", minorversion); if (IS_ERR(cb_info->task)) { ret = PTR_ERR(cb_info->task); @@ -281,14 +271,34 @@ err_bind: return ret; } -static struct svc_serv_ops nfs_cb_sv_ops = { +static struct svc_serv_ops nfs40_cb_sv_ops = { + .svo_function = nfs4_callback_svc, .svo_enqueue_xprt = svc_xprt_do_enqueue, + .svo_module = THIS_MODULE, +}; +#if defined(CONFIG_NFS_V4_1) +static struct svc_serv_ops nfs41_cb_sv_ops = { + .svo_function = nfs41_callback_svc, + .svo_enqueue_xprt = svc_xprt_do_enqueue, + .svo_module = THIS_MODULE, }; +struct svc_serv_ops *nfs4_cb_sv_ops[] = { + [0] = &nfs40_cb_sv_ops, + [1] = &nfs41_cb_sv_ops, +}; +#else +struct svc_serv_ops *nfs4_cb_sv_ops[] = { + [0] = &nfs40_cb_sv_ops, + [1] = NULL, +}; +#endif + static struct svc_serv *nfs_callback_create_svc(int minorversion) { struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion]; struct svc_serv *serv; + struct svc_serv_ops *sv_ops; /* * Check whether we're already up and running. @@ -302,6 +312,17 @@ static struct svc_serv *nfs_callback_create_svc(int minorversion) return cb_info->serv; } + switch (minorversion) { + case 0: + sv_ops = nfs4_cb_sv_ops[0]; + break; + default: + sv_ops = nfs4_cb_sv_ops[1]; + } + + if (sv_ops == NULL) + return ERR_PTR(-ENOTSUPP); + /* * Sanity check: if there's no task, * we should be the first user ... @@ -310,7 +331,7 @@ static struct svc_serv *nfs_callback_create_svc(int minorversion) printk(KERN_WARNING "nfs_callback_create_svc: no kthread, %d users??\n", cb_info->users); - serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, &nfs_cb_sv_ops); + serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, sv_ops); if (!serv) { printk(KERN_ERR "nfs_callback_create_svc: create service failed\n"); return ERR_PTR(-ENOMEM);