From patchwork Tue Jan 31 18:38:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 9548029 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 B03BA604DE for ; Tue, 31 Jan 2017 18:39:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A256928135 for ; Tue, 31 Jan 2017 18:39:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9757728384; Tue, 31 Jan 2017 18:39:00 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable 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 2F9DF28285 for ; Tue, 31 Jan 2017 18:39:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752007AbdAaSi6 (ORCPT ); Tue, 31 Jan 2017 13:38:58 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:33302 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751713AbdAaSi5 (ORCPT ); Tue, 31 Jan 2017 13:38:57 -0500 Received: by mail-io0-f194.google.com with SMTP id 101so18658766iom.0; Tue, 31 Jan 2017 10:38:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=FQXQsEhzgcIKsZz9104l3X5Hcmrifh7a+2w1RVZm630=; b=JN9FbanU1KgISScIWfmS/mQu8cTRbvpdtbI1Q6s4nilGQk116836OZ6ebu8EqcGQWk hwljFNIdORlQzzgHc1OilZ03DeA5KSOoMvYSvI5atKPn4uZZlAPNpT7WfUtYl3dvaX5/ 2l83WlEiNHWe47Dnfx7Ia/zlLUnQTDdlPl7sXxFXpUzWq9WswMbUO4ApRjyp0nsvn+Z0 jTmlr2ks/wbnwklKl3OZ1q6/jVL17km9Xk7zDOvSJBZ+kBjesy5nsWUwHieN1eNO9zVY LM8AM7FIw/Iu7Y8rqr9Lh/TjvhMnoI1KYvG4bNBPtFz8lo4CBPtRWrbBVHn8FpW4FCdW l/qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=FQXQsEhzgcIKsZz9104l3X5Hcmrifh7a+2w1RVZm630=; b=UUk7t4624zHrqWpHVy2FiRbJdoe8TUcabayKbmc9eTGhGhYzsJdwqytko7iGUpw2Xe ke6Assfahvui7MXtsG7klmc0pe2QFSKZdQun9ZgQ/xSkrKwK0YmkgNyLYFzsvKi+pYuh OT46HZYUkCsv9LI/FPr0764M/tXzWVzTObgHZVPY/29B35dP4gUrUnRPwTIE3RjcurpD pXxGw4Fv3WyMWYR8Zu3cSh7VbI9fVIq+C7TTBc534zbPaTvp2QErghuWHXsi5MsCz5ZU 6P2z/ZdyS3iJ+wGmofs/Rq2Tk/Bd8KB91t3IVQypLfmPM6piwrqJRvkmRRBULUZIFRhs TIwQ== X-Gm-Message-State: AIkVDXJVVimQtTe3MRuqy6FqIuBR8vc3/PDsWT2cO7xO1mFTPwBh0BqciErbBCEAHVG4Fg== X-Received: by 10.107.12.87 with SMTP id w84mr28188906ioi.108.1485887931097; Tue, 31 Jan 2017 10:38:51 -0800 (PST) Received: from manet.1015granger.net ([2604:8800:100:81fc:ec4:7aff:fe6c:1dce]) by smtp.gmail.com with ESMTPSA id j79sm8666552itb.0.2017.01.31.10.38.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Jan 2017 10:38:50 -0800 (PST) Subject: [PATCH v2 5/7] sunrpc: Enable calls to rpc_call_null_helper() from other modules From: Chuck Lever To: anna.schumaker@netapp.com Cc: linux-rdma@vger.kernel.org, linux-nfs@vger.kernel.org Date: Tue, 31 Jan 2017 13:38:50 -0500 Message-ID: <20170131183849.5325.78860.stgit@manet.1015granger.net> In-Reply-To: <20170131183345.5325.47072.stgit@manet.1015granger.net> References: <20170131183345.5325.47072.stgit@manet.1015granger.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 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 To help detect unreachable servers, I'd like to emit an RPC ping from rpcrdma.ko. authnull_ops is not visible outside the sunrpc.ko module, so fold the common case into rpc_call_null_helper, and export it, so that it can be invoked from other kernel modules. Signed-off-by: Chuck Lever --- fs/nfs/nfs4proc.c | 3 +-- fs/nfsd/nfs4callback.c | 2 +- include/linux/sunrpc/clnt.h | 5 +++++ include/linux/sunrpc/sched.h | 2 ++ net/sunrpc/clnt.c | 28 ++++++++++++++-------------- 5 files changed, 23 insertions(+), 17 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/nfs4proc.c b/fs/nfs/nfs4proc.c index 0a0eaec..0091e5a 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -7640,8 +7640,7 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred, if (xprt) { calldata->xprt = xprt; task_setup_data.rpc_xprt = xprt; - task_setup_data.flags = - RPC_TASK_SOFT|RPC_TASK_SOFTCONN|RPC_TASK_ASYNC; + task_setup_data.flags = RPC_TASK_SOFTPING | RPC_TASK_ASYNC; calldata->args.verifier = &clp->cl_confirm; } else { calldata->args.verifier = &verifier; diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index eb78109..e1e2224 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -1182,7 +1182,7 @@ static void nfsd4_process_cb_update(struct nfsd4_callback *cb) } cb->cb_msg.rpc_cred = clp->cl_cb_cred; - rpc_call_async(clnt, &cb->cb_msg, RPC_TASK_SOFT | RPC_TASK_SOFTCONN, + rpc_call_async(clnt, &cb->cb_msg, RPC_TASK_SOFTPING, cb->cb_ops ? &nfsd4_cb_ops : &nfsd4_cb_probe_ops, cb); } diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 333ad11..f576127 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -173,6 +173,11 @@ int rpc_call_async(struct rpc_clnt *clnt, void *calldata); int rpc_call_sync(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags); +struct rpc_task *rpc_call_null_helper(struct rpc_clnt *clnt, + struct rpc_xprt *xprt, + struct rpc_cred *cred, int flags, + const struct rpc_call_ops *ops, + void *data); struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, int flags); int rpc_restart_call_prepare(struct rpc_task *); diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index 7ba040c..13822e6 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h @@ -128,6 +128,8 @@ struct rpc_task_setup { #define RPC_TASK_NOCONNECT 0x2000 /* return ENOTCONN if not connected */ #define RPC_TASK_NO_RETRANS_TIMEOUT 0x4000 /* wait forever for a reply */ +#define RPC_TASK_SOFTPING (RPC_TASK_SOFT | RPC_TASK_SOFTCONN) + #define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC) #define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER) #define RPC_DO_ROOTOVERRIDE(t) ((t)->tk_flags & RPC_TASK_ROOTCREDS) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 1dc9f3b..642c93d 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2520,12 +2520,11 @@ static int rpc_ping(struct rpc_clnt *clnt) }; int err; msg.rpc_cred = authnull_ops.lookup_cred(NULL, NULL, 0); - err = rpc_call_sync(clnt, &msg, RPC_TASK_SOFT | RPC_TASK_SOFTCONN); + err = rpc_call_sync(clnt, &msg, RPC_TASK_SOFTPING); put_rpccred(msg.rpc_cred); return err; } -static struct rpc_task *rpc_call_null_helper(struct rpc_clnt *clnt, struct rpc_xprt *xprt, struct rpc_cred *cred, int flags, const struct rpc_call_ops *ops, void *data) @@ -2542,9 +2541,17 @@ struct rpc_task *rpc_call_null_helper(struct rpc_clnt *clnt, .callback_data = data, .flags = flags, }; + struct rpc_task *task; - return rpc_run_task(&task_setup_data); + if (!cred) + msg.rpc_cred = authnull_ops.lookup_cred(NULL, NULL, 0); + task = rpc_run_task(&task_setup_data); + if (!cred) + put_rpccred(msg.rpc_cred); + + return task; } +EXPORT_SYMBOL_GPL(rpc_call_null_helper); struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, int flags) { @@ -2591,7 +2598,6 @@ int rpc_clnt_test_and_add_xprt(struct rpc_clnt *clnt, void *dummy) { struct rpc_cb_add_xprt_calldata *data; - struct rpc_cred *cred; struct rpc_task *task; data = kmalloc(sizeof(*data), GFP_NOFS); @@ -2600,11 +2606,9 @@ int rpc_clnt_test_and_add_xprt(struct rpc_clnt *clnt, data->xps = xprt_switch_get(xps); data->xprt = xprt_get(xprt); - cred = authnull_ops.lookup_cred(NULL, NULL, 0); - task = rpc_call_null_helper(clnt, xprt, cred, - RPC_TASK_SOFT|RPC_TASK_SOFTCONN|RPC_TASK_ASYNC, - &rpc_cb_add_xprt_call_ops, data); - put_rpccred(cred); + task = rpc_call_null_helper(clnt, xprt, NULL, + RPC_TASK_SOFTPING | RPC_TASK_ASYNC, + &rpc_cb_add_xprt_call_ops, data); if (IS_ERR(task)) return PTR_ERR(task); rpc_put_task(task); @@ -2635,7 +2639,6 @@ int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *clnt, struct rpc_xprt *xprt, void *data) { - struct rpc_cred *cred; struct rpc_task *task; struct rpc_add_xprt_test *xtest = (struct rpc_add_xprt_test *)data; int status = -EADDRINUSE; @@ -2647,11 +2650,8 @@ int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *clnt, goto out_err; /* Test the connection */ - cred = authnull_ops.lookup_cred(NULL, NULL, 0); - task = rpc_call_null_helper(clnt, xprt, cred, - RPC_TASK_SOFT | RPC_TASK_SOFTCONN, + task = rpc_call_null_helper(clnt, xprt, NULL, RPC_TASK_SOFTPING, NULL, NULL); - put_rpccred(cred); if (IS_ERR(task)) { status = PTR_ERR(task); goto out_err;