<div dir="ltr">Acked-by: Sunil Mushran &lt;<a href="mailto:sunil.mushran@gmail.com">sunil.mushran@gmail.com</a>&gt;<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 28, 2013 at 1:47 PM, Andrew Morton <span dir="ltr">&lt;<a href="mailto:akpm@linux-foundation.org" target="_blank">akpm@linux-foundation.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Sun, 23 Jun 2013 18:39:16 +0800 Jeff Liu &lt;<a href="mailto:jeff.liu@oracle.com">jeff.liu@oracle.com</a>&gt; wrote:<br>

<br>
&gt; Hi Jiufei,<br>
&gt;<br>
&gt; On 06/20/2013 07:13 PM, Xue jiufei wrote:<br>
&gt;<br>
&gt; &gt; Function dlmlock_master() returns DLM_RECOVERING/DLM_MIGRATING/<br>
&gt; &gt; DLM_FORWAR after adding lock to blocked list if lockres has the state<br>
&gt; &gt; DLM_LOCK_RES_RECOVERING/DLM_LOCK_RES_MIGRATING/<br>
&gt; &gt; DLM_LOCK_RES_IN_PROGRESS. so it will retry in dlmlock(). And this may<br>
&gt; &gt; cause dlm_thread fall into an infinite loop<br>
&gt; &gt;<br>
&gt; &gt;     Thread1                                  dlm_thread<br>
&gt; &gt; calls dlm_lock-&gt;dlmlock_master,<br>
&gt; &gt; if lockresA is in state<br>
&gt; &gt; DLM_LOCK_RES_RECOVERING, calls<br>
&gt; &gt; __dlm_wait_on_lockres() and waits<br>
&gt; &gt; until others threads clear this<br>
&gt; &gt; state;<br>
&gt; &gt;<br>
&gt; &gt; If cannot grant this lock,<br>
&gt; &gt; adding lock to blocked list,<br>
&gt; &gt; and return DLM_RECOVERING;<br>
&gt; &gt;<br>
&gt; &gt;                                         Grant this lock and move it to<br>
&gt; &gt;                                         grant list;<br>
&gt; &gt;<br>
&gt; &gt; After a while, retry and<br>
&gt; &gt; calls list_add_tail(), adding lock<br>
&gt; &gt; to blocked list again.<br>
&gt; &gt;<br>
&gt; &gt; Granted and blocked list of this lockres will become the following<br>
&gt; &gt; conditions:<br>
&gt; &gt;     lock_res-&gt;granted.next = dlm_lock-&gt;list_head;<br>
&gt; &gt;     lock_res-&gt;blocked.next = dlm_lock-&gt;list_head;<br>
&gt; &gt;     dlm_lock-&gt;list_head.next = dlm_lock_resource-&gt;blocked;<br>
&gt; &gt; When dlm_thread traverses the granted list, it will fall into an<br>
&gt; &gt; endless loop, checking dlm_lock.list_head, dlm_lock-&gt;list_head.next<br>
&gt; &gt; (i.e.lock_res-&gt;blocked), lock_res-&gt;blocked.next(i.e.dlm_lock.list_head<br>
&gt; &gt; again) .....<br>
&gt;<br>
&gt; Thanks for your nice description of this problem and this fix looks good.<br>
&gt; Let&#39;s waiting for an ACK from either Sunil, Mark or Joel.<br>
<br>
</div></div>Still waiting ;)<br>
<br>
<br>
From: Xue jiufei &lt;<a href="mailto:xuejiufei@huawei.com">xuejiufei@huawei.com</a>&gt;<br>
Subject: ocfs2: dlmlock_master() should return DLM_NORMAL after adding lock to blocked list<br>
<div><div class="h5"><br>
dlmlock_master() returns DLM_RECOVERING/DLM_MIGRATING/ DLM_FORWAR after<br>
adding lock to blocked list if lockres has the state<br>
DLM_LOCK_RES_RECOVERING/DLM_LOCK_RES_MIGRATING/ DLM_LOCK_RES_IN_PROGRESS.<br>
so it will retry in dlmlock().  And this may cause dlm_thread fall into an<br>
infinite loop<br>
<br>
        Thread1                                  dlm_thread<br>
calls dlm_lock-&gt;dlmlock_master,<br>
if lockresA is in state<br>
DLM_LOCK_RES_RECOVERING, calls<br>
__dlm_wait_on_lockres() and waits<br>
until others threads clear this<br>
state;<br>
<br>
If cannot grant this lock,<br>
adding lock to blocked list,<br>
and return DLM_RECOVERING;<br>
<br>
                                        Grant this lock and move it to<br>
                                        grant list;<br>
<br>
After a while, retry and<br>
calls list_add_tail(), adding lock<br>
to blocked list again.<br>
<br>
Granted and blocked list of this lockres will become the following<br>
conditions:<br>
<br>
    lock_res-&gt;granted.next = dlm_lock-&gt;list_head;<br>
    lock_res-&gt;blocked.next = dlm_lock-&gt;list_head;<br>
    dlm_lock-&gt;list_head.next = dlm_lock_resource-&gt;blocked;<br>
<br>
When dlm_thread traverses the granted list, it will fall into an endless<br>
loop, checking dlm_lock.list_head, dlm_lock-&gt;list_head.next<br>
(i.e.lock_res-&gt;blocked), lock_res-&gt;blocked.next(i.e.dlm_lock.list_head<br>
again) .....<br>
<br>
</div></div>Signed-off-by: joyce &lt;<a href="mailto:xuejiufei@huawei.com">xuejiufei@huawei.com</a>&gt;<br>
Reviewed-by: jensen &lt;<a href="mailto:shencanquan@huawei.com">shencanquan@huawei.com</a>&gt;<br>
Cc: Jeff Liu &lt;<a href="mailto:jeff.liu@oracle.com">jeff.liu@oracle.com</a>&gt;<br>
Cc: Sunil Mushran &lt;<a href="mailto:sunil.mushran@gmail.com">sunil.mushran@gmail.com</a>&gt;<br>
Cc: Mark Fasheh &lt;<a href="mailto:mfasheh@suse.com">mfasheh@suse.com</a>&gt;<br>
Cc: Joel Becker &lt;<a href="mailto:jlbec@evilplan.org">jlbec@evilplan.org</a>&gt;<br>
Signed-off-by: Andrew Morton &lt;<a href="mailto:akpm@linux-foundation.org">akpm@linux-foundation.org</a>&gt;<br>
<div class="im">---<br>
<br>
 fs/ocfs2/dlm/dlmlock.c |    1 +<br>
 1 file changed, 1 insertion(+)<br>
<br>
</div>diff -puN fs/ocfs2/dlm/dlmlock.c~ocfs2-dlmlock_master-should-return-dlm_normal-after-adding-lock-to-blocked-list fs/ocfs2/dlm/dlmlock.c<br>
--- a/fs/ocfs2/dlm/dlmlock.c~ocfs2-dlmlock_master-should-return-dlm_normal-after-adding-lock-to-blocked-list<br>
<div class="im HOEnZb">+++ a/fs/ocfs2/dlm/dlmlock.c<br>
@@ -178,6 +178,7 @@ static enum dlm_status dlmlock_master(st<br>
</div><div class="HOEnZb"><div class="h5">                                     lock-&gt;ml.node);<br>
                        }<br>
                } else {<br>
+                       status = DLM_NORMAL;<br>
                        dlm_lock_get(lock);<br>
                        list_add_tail(&amp;lock-&gt;list, &amp;res-&gt;blocked);<br>
                        kick_thread = 1;<br>
_<br>
<br>
<br>
_______________________________________________<br>
Ocfs2-devel mailing list<br>
<a href="mailto:Ocfs2-devel@oss.oracle.com">Ocfs2-devel@oss.oracle.com</a><br>
<a href="https://oss.oracle.com/mailman/listinfo/ocfs2-devel" target="_blank">https://oss.oracle.com/mailman/listinfo/ocfs2-devel</a><br>
</div></div></blockquote></div><br></div>