From: Trond Myklebust <trondmy@gmail.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 11/25] SUNRPC: Start the first major timeout calculation at task creation
Date: Thu, 28 Mar 2019 16:52:25 -0400 [thread overview]
Message-ID: <20190328205239.29674-12-trond.myklebust@hammerspace.com> (raw)
In-Reply-To: <20190328205239.29674-11-trond.myklebust@hammerspace.com>
When calculating the major timeout for a new task, when we know that the
connection has been broken, use the task->tk_start to ensure that we also
take into account the time spent waiting for a slot or session slot. This
ensures that we fail over soft requests relatively quickly once the
connection has actually been broken, and the first requests have
started to fail.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
net/sunrpc/xprt.c | 44 ++++++++++++++++++++++++++++++++++----------
1 file changed, 34 insertions(+), 10 deletions(-)
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 6b2b71a2ec43..fcd827f032c0 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -569,18 +569,44 @@ bool xprt_write_space(struct rpc_xprt *xprt)
}
EXPORT_SYMBOL_GPL(xprt_write_space);
-static void xprt_reset_majortimeo(struct rpc_rqst *req)
+static unsigned long xprt_abs_ktime_to_jiffies(ktime_t abstime)
+{
+ s64 delta = ktime_to_ns(ktime_get() - abstime);
+ return likely(delta >= 0) ?
+ jiffies - nsecs_to_jiffies(delta) :
+ jiffies + nsecs_to_jiffies(-delta);
+}
+
+static unsigned long xprt_calc_majortimeo(struct rpc_rqst *req)
{
const struct rpc_timeout *to = req->rq_task->tk_client->cl_timeout;
+ unsigned long majortimeo = req->rq_timeout;
- req->rq_majortimeo = req->rq_timeout;
if (to->to_exponential)
- req->rq_majortimeo <<= to->to_retries;
+ majortimeo <<= to->to_retries;
+ else
+ majortimeo += to->to_increment * to->to_retries;
+ if (majortimeo > to->to_maxval || majortimeo == 0)
+ majortimeo = to->to_maxval;
+ return majortimeo;
+}
+
+static void xprt_reset_majortimeo(struct rpc_rqst *req)
+{
+ req->rq_majortimeo += xprt_calc_majortimeo(req);
+}
+
+static void xprt_init_majortimeo(struct rpc_task *task, struct rpc_rqst *req)
+{
+ unsigned long time_init;
+ struct rpc_xprt *xprt = req->rq_xprt;
+
+ if (likely(xprt && xprt_connected(xprt)))
+ time_init = jiffies;
else
- req->rq_majortimeo += to->to_increment * to->to_retries;
- if (req->rq_majortimeo > to->to_maxval || req->rq_majortimeo == 0)
- req->rq_majortimeo = to->to_maxval;
- req->rq_majortimeo += jiffies;
+ time_init = xprt_abs_ktime_to_jiffies(task->tk_start);
+ req->rq_timeout = task->tk_client->cl_timeout->to_initval;
+ req->rq_majortimeo = time_init + xprt_calc_majortimeo(req);
}
/**
@@ -997,7 +1023,6 @@ xprt_request_enqueue_receive(struct rpc_task *task)
set_bit(RPC_TASK_NEED_RECV, &task->tk_runstate);
spin_unlock(&xprt->queue_lock);
- xprt_reset_majortimeo(req);
/* Turn off autodisconnect */
del_singleshot_timer_sync(&xprt->timer);
}
@@ -1631,7 +1656,6 @@ xprt_request_init(struct rpc_task *task)
struct rpc_xprt *xprt = task->tk_xprt;
struct rpc_rqst *req = task->tk_rqstp;
- req->rq_timeout = task->tk_client->cl_timeout->to_initval;
req->rq_task = task;
req->rq_xprt = xprt;
req->rq_buffer = NULL;
@@ -1644,7 +1668,7 @@ xprt_request_init(struct rpc_task *task)
req->rq_snd_buf.bvec = NULL;
req->rq_rcv_buf.bvec = NULL;
req->rq_release_snd_buf = NULL;
- xprt_reset_majortimeo(req);
+ xprt_init_majortimeo(task, req);
dprintk("RPC: %5u reserved req %p xid %08x\n", task->tk_pid,
req, ntohl(req->rq_xid));
}
--
2.20.1
next prev parent reply other threads:[~2019-03-28 20:56 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-28 20:52 [PATCH 00/25] Fix up soft mounts for NFSv4.x Trond Myklebust
2019-03-28 20:52 ` [PATCH 01/25] SUNRPC: Fix up task signalling Trond Myklebust
2019-03-28 20:52 ` [PATCH 02/25] SUNRPC: Refactor rpc_restart_call/rpc_restart_call_prepare Trond Myklebust
2019-03-28 20:52 ` [PATCH 03/25] SUNRPC: Refactor xprt_request_wait_receive() Trond Myklebust
2019-03-28 20:52 ` [PATCH 04/25] SUNRPC: Refactor rpc_sleep_on() Trond Myklebust
2019-03-28 20:52 ` [PATCH 05/25] SUNRPC: Remove unused argument 'action' from rpc_sleep_on_priority() Trond Myklebust
2019-03-28 20:52 ` [PATCH 06/25] SUNRPC: Add function rpc_sleep_on_timeout() Trond Myklebust
2019-03-28 20:52 ` [PATCH 07/25] SUNRPC: Fix up tracking of timeouts Trond Myklebust
2019-03-28 20:52 ` [PATCH 08/25] SUNRPC: Ensure that the transport layer respect major timeouts Trond Myklebust
2019-03-28 20:52 ` [PATCH 09/25] SUNRPC: Add tracking of RPC level errors Trond Myklebust
2019-03-28 20:52 ` [PATCH 10/25] SUNRPC: Make "no retrans timeout" soft tasks behave like softconn for timeouts Trond Myklebust
2019-03-28 20:52 ` Trond Myklebust [this message]
2019-03-28 20:52 ` [PATCH 12/25] SUNRPC: Add the 'softerr' rpc_client flag Trond Myklebust
2019-03-28 20:52 ` [PATCH 13/25] NFS: Consider ETIMEDOUT to be a fatal error Trond Myklebust
2019-03-28 20:52 ` [PATCH 14/25] NFS: Move internal constants out of uapi/linux/nfs_mount.h Trond Myklebust
2019-03-28 20:52 ` [PATCH 15/25] NFS: Add a mount option "softerr" to allow clients to see ETIMEDOUT errors Trond Myklebust
2019-03-28 20:52 ` [PATCH 16/25] NFS: Don't interrupt file writeout due to fatal errors Trond Myklebust
2019-03-28 20:52 ` [PATCH 17/25] NFS: Don't call generic_error_remove_page() while holding locks Trond Myklebust
2019-03-28 20:52 ` [PATCH 18/25] NFS: Don't inadvertently clear writeback errors Trond Myklebust
2019-03-28 20:52 ` [PATCH 19/25] NFS: Replace custom error reporting mechanism with generic one Trond Myklebust
2019-03-28 20:52 ` [PATCH 20/25] NFS: Fix up NFS I/O subrequest creation Trond Myklebust
2019-03-28 20:52 ` [PATCH 21/25] NFS: Remove unused argument from nfs_create_request() Trond Myklebust
2019-03-28 20:52 ` [PATCH 22/25] pNFS: Add tracking to limit the number of pNFS retries Trond Myklebust
2019-03-28 20:52 ` [PATCH 23/25] NFS: Allow signal interruption of NFS4ERR_DELAYed operations Trond Myklebust
2019-03-28 20:52 ` [PATCH 24/25] NFS: Add a helper to return a pointer to the open context of a struct nfs_page Trond Myklebust
2019-03-28 20:52 ` [PATCH 25/25] NFS: Remove redundant open context from nfs_page Trond Myklebust
2019-04-01 6:37 ` Dan Carpenter
2019-04-01 6:36 ` [PATCH 19/25] NFS: Replace custom error reporting mechanism with generic one Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190328205239.29674-12-trond.myklebust@hammerspace.com \
--to=trondmy@gmail.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox