From patchwork Wed Nov 4 19:57:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 7552981 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D64BCBEEA4 for ; Wed, 4 Nov 2015 19:57:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A2EEE2053A for ; Wed, 4 Nov 2015 19:57:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D2C0120445 for ; Wed, 4 Nov 2015 19:57:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932067AbbKDT53 (ORCPT ); Wed, 4 Nov 2015 14:57:29 -0500 Received: from mail-qk0-f175.google.com ([209.85.220.175]:36165 "EHLO mail-qk0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755390AbbKDT50 (ORCPT ); Wed, 4 Nov 2015 14:57:26 -0500 Received: by qkcl124 with SMTP id l124so24422710qkc.3 for ; Wed, 04 Nov 2015 11:57:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poochiereds_net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3UdyYVyeqkI6fVSKpzrrF5fzIxxY2nkb8xbuTLA/cik=; b=hqEi+d3GlyuwSErJQWz9zLwmkSh9uWOfUyjuDDDviKXWfPR+0dQ0kliLj42DNxsMP+ EJGwVGC9Oh/53LuZFZq2ZYQdnPDTS30eW0/lDAYVLXKIooQiqCgj7PIBWw6JFjqSHrb1 mW3XIFgoMVV2sZjxgJeqisGqRsCQ6tEG3TlkvyOIhtQ3HEtvqVtflSwYUhlK3XatORih +j8LM7C6HrKK2si7cybPGU4M6sMxx+vST0SaFWjrZZBMmYl8gZFk8PZBmdY0V5hYXLDq UnawpW2IKynxMhqDusV/cOqEWB/Ai/DZuxptYu0fjPMVXC0o0k55RCaiGFoz702/LV5s 5uIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3UdyYVyeqkI6fVSKpzrrF5fzIxxY2nkb8xbuTLA/cik=; b=foK1jwUMDkKWog8dLgN/nPyavojJlsDWhNgoFtakltVhG2UDZcDhDfOb0+0Hcafw4h q4IH4XfU1EaZJlOMBzTT9mXi2tumGXFLA6gQ6r0M+iAQQ3VtRdvgjsvfgLhXJeV64RWc WxyNycDt7HNoOnepm4iDnPbsh5vgcRqAT7cWlytubj5aLfGKgn6nIfT6k5YXhPjsGzHx kU+F9xQ6ryHNjdvF3WHsGHgpnKEIOrnMk6B3FY/VG12QnejBBkQ4QTtxIYGM2y5O5/eW OuC9r0a6JbTrPoAVGpYqCVkpx0pvAIJdmgBh0zfsU5UI9b0Y54qYbSaEMuPwUY/UVAnX DXAg== X-Gm-Message-State: ALoCoQk4/JhcxO8/HA9J1eT7MlxfUrgHBPq81zRrJA8OAWTbVo9lcZ0iwdTw2TKcGva7zJoXD/I8 X-Received: by 10.55.49.197 with SMTP id x188mr2896188qkx.45.1446667045043; Wed, 04 Nov 2015 11:57:25 -0800 (PST) Received: from tlielax.poochiereds.net ([2606:a000:1125:6079::d5a]) by smtp.googlemail.com with ESMTPSA id g140sm725255qhc.22.2015.11.04.11.57.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Nov 2015 11:57:23 -0800 (PST) From: Jeff Layton X-Google-Original-From: Jeff Layton To: Trond Myklebust Cc: Anna Schumaker , linux-nfs@vger.kernel.org Subject: [PATCH v2] nfs4: use sliding delay in async calls that get NFS4ERR_DELAY Date: Wed, 4 Nov 2015 14:57:17 -0500 Message-Id: <1446667037-28753-1-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1446583411-9901-1-git-send-email-jeff.layton@primarydata.com> References: <1446583411-9901-1-git-send-email-jeff.layton@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Most of the async calls in the client pass in a NULL instead of a pointer to a timeout value. This causes them to wait a full 15s before retrying the call again. In some cases (e.g. RELEASE_LOCKOWNER), that delay is harmless (though 15s is a _really_ long time). For something like a LAYOUTGET or LOCKU though, we really don't want to wait that long before trying again. The machinery to handle an exponential backoff is already present in most of this code. We just need to add a timeout value to the RPC calldata so that it can keep track of it. Add that to all of the calls that use nfs4_async_handle_error, so they don't wait quite so long before retrying in this situation. Signed-off-by: Jeff Layton --- fs/nfs/nfs4proc.c | 34 +++++++++++++++++++++------------- include/linux/nfs_xdr.h | 5 +++++ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 5133bb18830e..a71e84f354ae 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2685,6 +2685,7 @@ struct nfs4_closedata { struct nfs_closeres res; struct nfs_fattr fattr; unsigned long timestamp; + long timeout; bool roc; u32 roc_barrier; }; @@ -2739,7 +2740,8 @@ static void nfs4_close_done(struct rpc_task *task, void *data) if (calldata->arg.fmode == 0) break; default: - if (nfs4_async_handle_error(task, server, state, NULL) == -EAGAIN) { + if (nfs4_async_handle_error(task, server, state, + &calldata->timeout) == -EAGAIN) { rpc_restart_call_prepare(task); goto out_release; } @@ -2884,7 +2886,6 @@ int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait) calldata->arg.seqid = alloc_seqid(&state->owner->so_seqid, gfp_mask); if (IS_ERR(calldata->arg.seqid)) goto out_free_calldata; - calldata->arg.fmode = 0; calldata->arg.bitmask = server->cache_consistency_bitmask; calldata->res.fattr = &calldata->fattr; calldata->res.seqid = calldata->arg.seqid; @@ -4250,7 +4251,7 @@ static int nfs4_read_done_cb(struct rpc_task *task, struct nfs_pgio_header *hdr) trace_nfs4_read(hdr, task->tk_status); if (nfs4_async_handle_error(task, server, hdr->args.context->state, - NULL) == -EAGAIN) { + &hdr->timeout) == -EAGAIN) { rpc_restart_call_prepare(task); return -EAGAIN; } @@ -4322,7 +4323,7 @@ static int nfs4_write_done_cb(struct rpc_task *task, trace_nfs4_write(hdr, task->tk_status); if (nfs4_async_handle_error(task, NFS_SERVER(inode), hdr->args.context->state, - NULL) == -EAGAIN) { + &hdr->timeout) == -EAGAIN) { rpc_restart_call_prepare(task); return -EAGAIN; } @@ -4403,7 +4404,7 @@ static int nfs4_commit_done_cb(struct rpc_task *task, struct nfs_commit_data *da trace_nfs4_commit(data, task->tk_status); if (nfs4_async_handle_error(task, NFS_SERVER(inode), - NULL, NULL) == -EAGAIN) { + NULL, &data->timeout) == -EAGAIN) { rpc_restart_call_prepare(task); return -EAGAIN; } @@ -5289,6 +5290,7 @@ struct nfs4_delegreturndata { struct nfs_fh fh; nfs4_stateid stateid; unsigned long timestamp; + long timeout; struct nfs_fattr fattr; int rpc_status; struct inode *inode; @@ -5319,7 +5321,7 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) break; default: if (nfs4_async_handle_error(task, data->res.server, - NULL, NULL) == -EAGAIN) { + NULL, &data->timeout) == -EAGAIN) { rpc_restart_call_prepare(task); return; } @@ -5394,7 +5396,6 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co data->res.server = server; nfs_fattr_init(data->res.fattr); data->timestamp = jiffies; - data->rpc_status = 0; data->inode = nfs_igrab_and_active(inode); if (data->inode) data->roc = nfs4_roc(inode); @@ -5535,6 +5536,7 @@ struct nfs4_unlockdata { struct file_lock fl; const struct nfs_server *server; unsigned long timestamp; + long timeout; }; static struct nfs4_unlockdata *nfs4_alloc_unlockdata(struct file_lock *fl, @@ -5593,7 +5595,7 @@ static void nfs4_locku_done(struct rpc_task *task, void *data) break; default: if (nfs4_async_handle_error(task, calldata->server, - NULL, NULL) == -EAGAIN) + NULL, &calldata->timeout) == -EAGAIN) rpc_restart_call_prepare(task); } nfs_release_seqid(calldata->arg.seqid); @@ -6184,6 +6186,7 @@ struct nfs_release_lockowner_data { struct nfs_release_lockowner_args args; struct nfs_release_lockowner_res res; unsigned long timestamp; + long timeout; }; static void nfs4_release_lockowner_prepare(struct rpc_task *task, void *calldata) @@ -6214,7 +6217,7 @@ static void nfs4_release_lockowner_done(struct rpc_task *task, void *calldata) case -NFS4ERR_LEASE_MOVED: case -NFS4ERR_DELAY: if (nfs4_async_handle_error(task, server, - NULL, NULL) == -EAGAIN) + NULL, &data->timeout) == -EAGAIN) rpc_restart_call_prepare(task); } } @@ -6251,6 +6254,7 @@ nfs4_release_lockowner(struct nfs_server *server, struct nfs4_lock_state *lsp) data->args.lock_owner.clientid = server->nfs_client->cl_clientid; data->args.lock_owner.id = lsp->ls_seqid.owner_id; data->args.lock_owner.s_dev = server->s_dev; + data->timeout = 0; msg.rpc_argp = &data->args; msg.rpc_resp = &data->res; @@ -7872,7 +7876,7 @@ static void nfs4_layoutget_done(struct rpc_task *task, void *calldata) spin_unlock(&inode->i_lock); goto out_restart; } - if (nfs4_async_handle_error(task, server, state, NULL) == -EAGAIN) + if (nfs4_async_handle_error(task, server, state, &lgp->timeout) == -EAGAIN) goto out_restart; out: dprintk("<-- %s\n", __func__); @@ -8040,7 +8044,7 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) case 0: break; case -NFS4ERR_DELAY: - if (nfs4_async_handle_error(task, server, NULL, NULL) != -EAGAIN) + if (nfs4_async_handle_error(task, server, NULL, &lrp->timeout) != -EAGAIN) break; rpc_restart_call_prepare(task); return; @@ -8192,7 +8196,8 @@ nfs4_layoutcommit_done(struct rpc_task *task, void *calldata) case 0: break; default: - if (nfs4_async_handle_error(task, server, NULL, NULL) == -EAGAIN) { + if (nfs4_async_handle_error(task, server, NULL, + &data->timeout) == -EAGAIN) { rpc_restart_call_prepare(task); return; } @@ -8469,6 +8474,7 @@ static int nfs41_test_stateid(struct nfs_server *server, struct nfs_free_stateid_data { struct nfs_server *server; + long timeout; struct nfs41_free_stateid_args args; struct nfs41_free_stateid_res res; }; @@ -8490,7 +8496,8 @@ static void nfs41_free_stateid_done(struct rpc_task *task, void *calldata) switch (task->tk_status) { case -NFS4ERR_DELAY: - if (nfs4_async_handle_error(task, data->server, NULL, NULL) == -EAGAIN) + if (nfs4_async_handle_error(task, data->server, NULL, + &data->timeout) == -EAGAIN) rpc_restart_call_prepare(task); } } @@ -8531,6 +8538,7 @@ static struct rpc_task *_nfs41_free_stateid(struct nfs_server *server, if (!data) return ERR_PTR(-ENOMEM); data->server = server; + data->timeout = 0; nfs4_stateid_copy(&data->args.stateid, stateid); task_setup.callback_data = data; diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 52faf7e96c65..4b8f68568c99 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -250,6 +250,7 @@ struct nfs4_layoutget { struct nfs4_layoutget_res res; struct rpc_cred *cred; gfp_t gfp_flags; + long timeout; }; struct nfs4_getdeviceinfo_args { @@ -288,6 +289,7 @@ struct nfs4_layoutcommit_data { struct list_head lseg_list; struct rpc_cred *cred; struct inode *inode; + long timeout; struct nfs4_layoutcommit_args args; struct nfs4_layoutcommit_res res; }; @@ -313,6 +315,7 @@ struct nfs4_layoutreturn { struct rpc_cred *cred; struct nfs_client *clp; struct inode *inode; + long timeout; int rpc_status; }; @@ -1378,6 +1381,7 @@ struct nfs_pgio_header { int error; /* merge with pnfs_error */ unsigned long good_bytes; /* boundary of good data */ unsigned long flags; + long timeout; /* * rpc data @@ -1430,6 +1434,7 @@ struct nfs_commit_data { struct nfs_open_context *context; struct pnfs_layout_segment *lseg; struct nfs_client *ds_clp; /* pNFS data server */ + long timeout; int ds_commit_index; loff_t lwb; const struct rpc_call_ops *mds_ops;