From: Joseph Qi <joseph.qi@huawei.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH v2] ocfs2: retry once dlm_dispatch_assert_master failed with ENOMEM
Date: Tue, 8 Apr 2014 18:47:04 +0800 [thread overview]
Message-ID: <5343D3A8.1080302@huawei.com> (raw)
Once dlm_dispatch_assert_master failed in dlm_master_requery_handler,
the only reason is ENOMEM.
Add retry logic to avoid BUG() in case of not enough memory
temporarily.
Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
---
fs/ocfs2/dlm/dlmrecovery.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 7035af0..7db0465 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -1676,6 +1676,9 @@ int dlm_master_requery_handler(struct o2net_msg *msg, u32 len, void *data,
unsigned int hash;
int master = DLM_LOCK_RES_OWNER_UNKNOWN;
u32 flags = DLM_ASSERT_MASTER_REQUERY;
+ int ret, retries = 0;
+
+#define DISPATCH_ASSERT_RETRY_TIMES 3
if (!dlm_grab(dlm)) {
/* since the domain has gone away on this
@@ -1685,18 +1688,30 @@ int dlm_master_requery_handler(struct o2net_msg *msg, u32 len, void *data,
hash = dlm_lockid_hash(req->name, req->namelen);
+retry:
spin_lock(&dlm->spinlock);
res = __dlm_lookup_lockres(dlm, req->name, req->namelen, hash);
if (res) {
spin_lock(&res->spinlock);
master = res->owner;
if (master == dlm->node_num) {
- int ret = dlm_dispatch_assert_master(dlm, res,
- 0, 0, flags);
+ ret = dlm_dispatch_assert_master(dlm, res,
+ 0, 0, flags);
if (ret < 0) {
- mlog_errno(-ENOMEM);
- /* retry!? */
- BUG();
+ mlog_errno(ret);
+
+ /* ENOMEM returns, retry until
+ * DISPATCH_ASSERT_RETRY_TIMES reached */
+ if (retries < DISPATCH_ASSERT_RETRY_TIMES) {
+ spin_unlock(&res->spinlock);
+ dlm_lockres_put(res);
+ spin_unlock(&dlm->spinlock);
+ msleep(50);
+ retries++;
+ goto retry;
+ } else {
+ BUG();
+ }
}
} else /* put.. incase we are not the master */
dlm_lockres_put(res);
--
1.8.4.3
next reply other threads:[~2014-04-08 10:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-08 10:47 Joseph Qi [this message]
2014-04-09 21:44 ` [Ocfs2-devel] [PATCH v2] ocfs2: retry once dlm_dispatch_assert_master failed with ENOMEM Andrew Morton
2014-04-10 1:16 ` Wengang
2014-04-10 22:14 ` Andrew Morton
2014-04-11 1:32 ` Wengang
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=5343D3A8.1080302@huawei.com \
--to=joseph.qi@huawei.com \
--cc=ocfs2-devel@oss.oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.