<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"><<a href="mailto:joseph.qi@huawei.com" target="_blank">joseph.qi@huawei.com</a>></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 -> dlm_empty_lockres -> dlm_migrate_lockres -><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>
> Do you know under what conditions does it create a new lock when it<br>
> should not?<br>
><br>
> This code should only trigger if the lockres is/was mastered on another<br>
> node.<br>
> Meaning this node will not know about the newlock. Meaning that code should<br>
> never trigger.<br>
><br>
> 1949 if (lock->ml.cookie == ml->cookie) {<br>
> This if looks hacky.<br>
><br>
> If you have a reproducible case, it may be worthwhile to get some traces<br>
> to see<br>
> under what conditions this happens. Should be straight forward after that.<br>
><br>
> Thanks<br>
> Sunil<br>
><br>
><br>
><br>
> On Thu, May 2, 2013 at 5:56 AM, Joseph Qi <<a href="mailto:joseph.qi@huawei.com">joseph.qi@huawei.com</a><br>
</div><div class="im">> <mailto:<a href="mailto:joseph.qi@huawei.com">joseph.qi@huawei.com</a>>> wrote:<br>
><br>
> We found a possible memory leak in dlm_process_recovery_data when doing<br>
> code review. In dlm_process_recovery_data, it creates newlock each time,<br>
> but don't free when it is bad, and then it will lead to memory leak.<br>
><br>
</div>> Cc: <a href="mailto:stable@vger.kernel.org">stable@vger.kernel.org</a> <mailto:<a href="mailto:stable@vger.kernel.org">stable@vger.kernel.org</a>><br>
> Signed-off-by: Joseph Qi <<a href="mailto:joseph.qi@huawei.com">joseph.qi@huawei.com</a>> <mailto:<a href="mailto:joseph.qi@huawei.com">joseph.qi@huawei.com</a>><br>
> Reviewed-by: Jie Liu <<a href="mailto:jeff.liu@oracle.com">jeff.liu@oracle.com</a>> <mailto:<a href="mailto:jeff.liu@oracle.com">jeff.liu@oracle.com</a>><br>
<div class="im">><br>
> ---<br>
> fs/ocfs2/dlm/dlmrecovery.c | 4 ++++<br>
> 1 file changed, 4 insertions(+)<br>
><br>
> diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c<br>
> index eeac97b..9f08523 100644<br>
> --- a/fs/ocfs2/dlm/dlmrecovery.c<br>
> +++ b/fs/ocfs2/dlm/dlmrecovery.c<br>
> @@ -1974,6 +1974,10 @@ skip_lvb:<br>
</div>> res->lockname.len, res-><a href="http://lockname.name" target="_blank">lockname.name</a> <<a href="http://lockname.name" target="_blank">http://lockname.name</a>>, ml->node);<br>
<div class="im">> dlm_lockres_set_refmap_bit(dlm, res, ml->node);<br>
> added++;<br>
> + } else {<br>
> + /* Free the new lock if it is bad */<br>
> + dlm_lock_put(newlock);<br>
> + newlock = NULL;<br>
> }<br>
> spin_unlock(&res->spinlock);<br>
> }<br>
> --<br>
> 1.7.9.7<br>
><br>
><br>
> _______________________________________________<br>
> Ocfs2-devel mailing list<br>
</div>> <a href="mailto:Ocfs2-devel@oss.oracle.com">Ocfs2-devel@oss.oracle.com</a> <mailto:<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>
><br>
><br>
<br>
<br>
</blockquote></div><br></div>