Commit 1e589581 authored by Joseph Qi's avatar Joseph Qi Committed by Linus Torvalds

ocfs2/dlm: fix race between dispatched_work and dlm_lockres_grab_inflight_worker

Commit ac4fef4d ("ocfs2/dlm: do not purge lockres that is queued for
assert master") may have the following possible race case:

  dlm_dispatch_assert_master       dlm_wq
  ========================================================================
  queue_work(dlm->quedlm_worker,
      &dlm->dispatched_work);
                                 dispatch work,
                                 dlm_lockres_drop_inflight_worker
                                 *BUG_ON(res->inflight_assert_workers == 0)*
  dlm_lockres_grab_inflight_worker
  inflight_assert_workers++

So ensure inflight_assert_workers to be increased first.
Signed-off-by: default avatarJoseph Qi <joseph.qi@huawei.com>
Signed-off-by: default avatarXue jiufei <xuejiufei@huawei.com>
Cc: Joel Becker <jlbec@evilplan.org>
Reviewed-by: default avatarMark Fasheh <mfasheh@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f62f12b3
...@@ -695,14 +695,6 @@ void __dlm_lockres_grab_inflight_worker(struct dlm_ctxt *dlm, ...@@ -695,14 +695,6 @@ void __dlm_lockres_grab_inflight_worker(struct dlm_ctxt *dlm,
res->inflight_assert_workers); res->inflight_assert_workers);
} }
static void dlm_lockres_grab_inflight_worker(struct dlm_ctxt *dlm,
struct dlm_lock_resource *res)
{
spin_lock(&res->spinlock);
__dlm_lockres_grab_inflight_worker(dlm, res);
spin_unlock(&res->spinlock);
}
static void __dlm_lockres_drop_inflight_worker(struct dlm_ctxt *dlm, static void __dlm_lockres_drop_inflight_worker(struct dlm_ctxt *dlm,
struct dlm_lock_resource *res) struct dlm_lock_resource *res)
{ {
...@@ -1646,6 +1638,7 @@ int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data, ...@@ -1646,6 +1638,7 @@ int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data,
} }
mlog(0, "%u is the owner of %.*s, cleaning everyone else\n", mlog(0, "%u is the owner of %.*s, cleaning everyone else\n",
dlm->node_num, res->lockname.len, res->lockname.name); dlm->node_num, res->lockname.len, res->lockname.name);
spin_lock(&res->spinlock);
ret = dlm_dispatch_assert_master(dlm, res, 0, request->node_idx, ret = dlm_dispatch_assert_master(dlm, res, 0, request->node_idx,
DLM_ASSERT_MASTER_MLE_CLEANUP); DLM_ASSERT_MASTER_MLE_CLEANUP);
if (ret < 0) { if (ret < 0) {
...@@ -1653,7 +1646,8 @@ int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data, ...@@ -1653,7 +1646,8 @@ int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data,
response = DLM_MASTER_RESP_ERROR; response = DLM_MASTER_RESP_ERROR;
dlm_lockres_put(res); dlm_lockres_put(res);
} else } else
dlm_lockres_grab_inflight_worker(dlm, res); __dlm_lockres_grab_inflight_worker(dlm, res);
spin_unlock(&res->spinlock);
} else { } else {
if (res) if (res)
dlm_lockres_put(res); dlm_lockres_put(res);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment