From: Oleg Drokin <green@linuxhacker.ru>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org
Cc: Liang Zhen <liang.zhen@intel.com>, Oleg Drokin <oleg.drokin@intel.com>
Subject: [PATCH 14/17] lustre/ptlrpc: re-enqueue ptlrpcd worker
Date: Fri, 28 Feb 2014 21:16:43 -0500 [thread overview]
Message-ID: <1393640206-20286-15-git-send-email-green@linuxhacker.ru> (raw)
In-Reply-To: <1393640206-20286-1-git-send-email-green@linuxhacker.ru>
From: Liang Zhen <liang.zhen@intel.com>
osc_extent_wait can be stuck in scenario like this:
1) thread-1 held an active extent
2) thread-2 called flush cache, and marked this extent as "urgent"
and "sync_wait"
3) thread-3 wants to write to the same extent, osc_extent_find will
get "conflict" because this extent is "sync_wait", so it starts
to wait...
4) cl_writeback_work has been scheduled by thread-4 to write some
other extents, it has sent RPCs but not returned yet.
5) thread-1 finished his work, and called osc_extent_release()->
osc_io_unplug_async()->ptlrpcd_queue_work(), but found
cl_writeback_work is still running, so it's ignored (-EBUSY)
6) thread-3 is stuck because nobody will wake him up.
This patch allows ptlrpcd_work to be rescheduled, so it will not
miss request anymore
Signed-off-by: Liang Zhen <liang.zhen@intel.com>
Reviewed-on: http://review.whamcloud.com/8922
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4509
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
---
drivers/staging/lustre/lustre/ptlrpc/client.c | 64 +++++++++++++++++----------
1 file changed, 40 insertions(+), 24 deletions(-)
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index 7b97c64..4c9e006 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -48,6 +48,7 @@
#include "ptlrpc_internal.h"
static int ptlrpc_send_new_req(struct ptlrpc_request *req);
+static int ptlrpcd_check_work(struct ptlrpc_request *req);
/**
* Initialize passed in client structure \a cl.
@@ -1784,6 +1785,10 @@ interpret:
ptlrpc_req_interpret(env, req, req->rq_status);
+ if (ptlrpcd_check_work(req)) {
+ atomic_dec(&set->set_remaining);
+ continue;
+ }
ptlrpc_rqphase_move(req, RQ_PHASE_COMPLETE);
CDEBUG(req->rq_reqmsg != NULL ? D_RPCTRACE : 0,
@@ -2957,22 +2962,50 @@ EXPORT_SYMBOL(ptlrpc_sample_next_xid);
* have delay before it really runs by ptlrpcd thread.
*/
struct ptlrpc_work_async_args {
- __u64 magic;
int (*cb)(const struct lu_env *, void *);
void *cbdata;
};
-#define PTLRPC_WORK_MAGIC 0x6655436b676f4f44ULL /* magic code */
+static void ptlrpcd_add_work_req(struct ptlrpc_request *req)
+{
+ /* re-initialize the req */
+ req->rq_timeout = obd_timeout;
+ req->rq_sent = cfs_time_current_sec();
+ req->rq_deadline = req->rq_sent + req->rq_timeout;
+ req->rq_reply_deadline = req->rq_deadline;
+ req->rq_phase = RQ_PHASE_INTERPRET;
+ req->rq_next_phase = RQ_PHASE_COMPLETE;
+ req->rq_xid = ptlrpc_next_xid();
+ req->rq_import_generation = req->rq_import->imp_generation;
+
+ ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
+}
static int work_interpreter(const struct lu_env *env,
struct ptlrpc_request *req, void *data, int rc)
{
struct ptlrpc_work_async_args *arg = data;
- LASSERT(arg->magic == PTLRPC_WORK_MAGIC);
+ LASSERT(ptlrpcd_check_work(req));
LASSERT(arg->cb != NULL);
- return arg->cb(env, arg->cbdata);
+ rc = arg->cb(env, arg->cbdata);
+
+ list_del_init(&req->rq_set_chain);
+ req->rq_set = NULL;
+
+ if (atomic_dec_return(&req->rq_refcount) > 1) {
+ atomic_set(&req->rq_refcount, 2);
+ ptlrpcd_add_work_req(req);
+ }
+ return rc;
+}
+
+static int worker_format;
+
+static int ptlrpcd_check_work(struct ptlrpc_request *req)
+{
+ return req->rq_pill.rc_fmt == (void *)&worker_format;
}
/**
@@ -3005,6 +3038,7 @@ void *ptlrpcd_alloc_work(struct obd_import *imp,
req->rq_receiving_reply = 0;
req->rq_must_unlink = 0;
req->rq_no_delay = req->rq_no_resend = 1;
+ req->rq_pill.rc_fmt = (void *)&worker_format;
spin_lock_init(&req->rq_lock);
INIT_LIST_HEAD(&req->rq_list);
@@ -3018,7 +3052,6 @@ void *ptlrpcd_alloc_work(struct obd_import *imp,
CLASSERT(sizeof(*args) <= sizeof(req->rq_async_args));
args = ptlrpc_req_async_args(req);
- args->magic = PTLRPC_WORK_MAGIC;
args->cb = cb;
args->cbdata = cbdata;
@@ -3048,25 +3081,8 @@ int ptlrpcd_queue_work(void *handler)
* req as opaque data. - Jinshan
*/
LASSERT(atomic_read(&req->rq_refcount) > 0);
- if (atomic_read(&req->rq_refcount) > 1)
- return -EBUSY;
-
- if (atomic_inc_return(&req->rq_refcount) > 2) { /* race */
- atomic_dec(&req->rq_refcount);
- return -EBUSY;
- }
-
- /* re-initialize the req */
- req->rq_timeout = obd_timeout;
- req->rq_sent = cfs_time_current_sec();
- req->rq_deadline = req->rq_sent + req->rq_timeout;
- req->rq_reply_deadline = req->rq_deadline;
- req->rq_phase = RQ_PHASE_INTERPRET;
- req->rq_next_phase = RQ_PHASE_COMPLETE;
- req->rq_xid = ptlrpc_next_xid();
- req->rq_import_generation = req->rq_import->imp_generation;
-
- ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
+ if (atomic_inc_return(&req->rq_refcount) == 2)
+ ptlrpcd_add_work_req(req);
return 0;
}
EXPORT_SYMBOL(ptlrpcd_queue_work);
--
1.8.5.3
next prev parent reply other threads:[~2014-03-01 2:17 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-01 2:16 [PATCH 00/17] Lustre stability patches Oleg Drokin
2014-03-01 2:16 ` [PATCH 01/17] staging/lustre/llite: fix open lock matching in ll_md_blocking_ast() Oleg Drokin
2014-03-03 10:01 ` Dan Carpenter
2014-03-01 2:16 ` [PATCH 02/17] lustre/mdc: Check for all attributes validity in revalidate Oleg Drokin
2014-03-01 2:16 ` [PATCH 03/17] lustre/llite: Do not send parent dir fid in getattr by fid Oleg Drokin
2014-03-01 2:16 ` [PATCH 04/17] lustre/mdc: comments on LOOKUP and PERM lock Oleg Drokin
2014-03-01 2:16 ` [PATCH 05/17] lustre/mdc: use ibits_known mask for lock match Oleg Drokin
2014-03-01 2:16 ` [PATCH 06/17] lustre/clio: honor O_NOATIME Oleg Drokin
2014-03-01 2:16 ` [PATCH 07/17] lustre/mdc: fix bad ERR_PTR usage in mdc_locks.c Oleg Drokin
2014-03-01 2:16 ` [PATCH 08/17] lustre/recovery: free open/close request promptly Oleg Drokin
2014-03-01 2:16 ` [PATCH 09/17] lustre/llite: simplify dentry revalidate Oleg Drokin
2014-03-01 2:16 ` [PATCH 10/17] lustre/ldlm: set l_lvb_type coherent when layout is returned Oleg Drokin
2014-03-01 2:16 ` [PATCH 11/17] lustre/ptlrpc: rq_commit_cb is called for twice Oleg Drokin
2014-03-01 2:16 ` [PATCH 12/17] lustre/ptlrpc: skip rpcs that fail ptl_send_rpc Oleg Drokin
2014-03-01 2:16 ` [PATCH 13/17] lustre/ptlrpc: fix 'data race condition' issues Oleg Drokin
2014-03-01 2:16 ` Oleg Drokin [this message]
2014-03-01 2:16 ` [PATCH 15/17] lustre/osc: Don't flush active extents Oleg Drokin
2014-03-01 2:16 ` [PATCH 16/17] lustre/quota: improper assert in osc_quota_chkdq() Oleg Drokin
2014-03-01 2:16 ` [PATCH 17/17] lustre/libcfs: warn if all HTs in a core are gone Oleg Drokin
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=1393640206-20286-15-git-send-email-green@linuxhacker.ru \
--to=green@linuxhacker.ru \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=liang.zhen@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg.drokin@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).