<div dir="ltr">Any reason we cannot add the existence check to before the create and thus skip creation altogether.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 3, 2013 at 6:02 PM, Joseph Qi <span dir="ltr">&lt;<a href="mailto:joseph.qi@huawei.com" target="_blank">joseph.qi@huawei.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Please consider the belowing case:<br>
dlm_migrate_all_locks -&gt; dlm_empty_lockres -&gt; dlm_migrate_lockres -&gt;<br>
dlm_send_one_lockres, if we have already sent some locks, say<br>
DLM_MAX_MIGRATABLE_LOCKS for the first time, and then<br>
dlm_send_mig_lockres_msg failed because of network down, it will redo<br>
it. During the redo_bucket, the lockres can be hashed and migrated<br>
again.<br>
<div class="im"><br>
On 2013/5/3 1:19, Sunil Mushran wrote:<br>
&gt; Do you know under what conditions does it create a new lock when it<br>
&gt; should not?<br>
&gt;<br>
&gt; This code should only trigger if the lockres is/was mastered on another<br>
&gt; node.<br>
&gt; Meaning this node will not know about the newlock. Meaning that code should<br>
&gt; never trigger.<br>
&gt;<br>
&gt; 1949                         if (lock-&gt;ml.cookie == ml-&gt;cookie) {<br>
&gt; This if looks hacky.<br>
&gt;<br>
&gt; If you have a reproducible case, it may be worthwhile to get some traces<br>
&gt; to see<br>
&gt; under what conditions this happens. Should be straight forward after that.<br>
&gt;<br>
&gt; Thanks<br>
&gt; Sunil<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Thu, May 2, 2013 at 5:56 AM, Joseph Qi &lt;<a href="mailto:joseph.qi@huawei.com">joseph.qi@huawei.com</a><br>
</div><div class="im">&gt; &lt;mailto:<a href="mailto:joseph.qi@huawei.com">joseph.qi@huawei.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     We found a possible memory leak in dlm_process_recovery_data when doing<br>
&gt;     code review. In dlm_process_recovery_data, it creates newlock each time,<br>
&gt;     but don&#39;t free when it is bad, and then it will lead to memory leak.<br>
&gt;<br>
</div>&gt;     Cc: <a href="mailto:stable@vger.kernel.org">stable@vger.kernel.org</a> &lt;mailto:<a href="mailto:stable@vger.kernel.org">stable@vger.kernel.org</a>&gt;<br>
&gt;     Signed-off-by: Joseph Qi &lt;<a href="mailto:joseph.qi@huawei.com">joseph.qi@huawei.com</a>&gt; &lt;mailto:<a href="mailto:joseph.qi@huawei.com">joseph.qi@huawei.com</a>&gt;<br>
&gt;     Reviewed-by: Jie Liu &lt;<a href="mailto:jeff.liu@oracle.com">jeff.liu@oracle.com</a>&gt; &lt;mailto:<a href="mailto:jeff.liu@oracle.com">jeff.liu@oracle.com</a>&gt;<br>
<div class="im">&gt;<br>
&gt;     ---<br>
&gt;      fs/ocfs2/dlm/dlmrecovery.c |    4 ++++<br>
&gt;      1 file changed, 4 insertions(+)<br>
&gt;<br>
&gt;     diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c<br>
&gt;     index eeac97b..9f08523 100644<br>
&gt;     --- a/fs/ocfs2/dlm/dlmrecovery.c<br>
&gt;     +++ b/fs/ocfs2/dlm/dlmrecovery.c<br>
&gt;     @@ -1974,6 +1974,10 @@ skip_lvb:<br>
</div>&gt;                            res-&gt;lockname.len, res-&gt;<a href="http://lockname.name" target="_blank">lockname.name</a> &lt;<a href="http://lockname.name" target="_blank">http://lockname.name</a>&gt;, ml-&gt;node);<br>

<div class="im">&gt;                       dlm_lockres_set_refmap_bit(dlm, res, ml-&gt;node);<br>
&gt;                       added++;<br>
&gt;     +         } else {<br>
&gt;     +                 /* Free the new lock if it is bad */<br>
&gt;     +                 dlm_lock_put(newlock);<br>
&gt;     +                 newlock = NULL;<br>
&gt;               }<br>
&gt;               spin_unlock(&amp;res-&gt;spinlock);<br>
&gt;       }<br>
&gt;     --<br>
&gt;     1.7.9.7<br>
&gt;<br>
&gt;<br>
&gt;     _______________________________________________<br>
&gt;     Ocfs2-devel mailing list<br>
</div>&gt;     <a href="mailto:Ocfs2-devel@oss.oracle.com">Ocfs2-devel@oss.oracle.com</a> &lt;mailto:<a href="mailto:Ocfs2-devel@oss.oracle.com">Ocfs2-devel@oss.oracle.com</a>&gt;<br>
&gt;     <a href="https://oss.oracle.com/mailman/listinfo/ocfs2-devel" target="_blank">https://oss.oracle.com/mailman/listinfo/ocfs2-devel</a><br>
&gt;<br>
&gt;<br>
<br>
<br>
</blockquote></div><br></div>