All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH] ocfs2: oldmle should be put while -EEXIST returned, and the new mle should not be get once at that time.
@ 2016-09-14  2:30 Guozhonghua
  2016-09-14  2:54 ` Joseph Qi
  0 siblings, 1 reply; 3+ messages in thread
From: Guozhonghua @ 2016-09-14  2:30 UTC (permalink / raw)
  To: ocfs2-devel


In the function dlm_migrate_lockres, while calling dlm_add_migration_mle, and the ret is --EEXIST.
At this time, the oldmle should be put one time for it had been get once in dlm_find_mle.
And the new mle should not get once for it had not been initialized before goto fail.

Signed-off-by: Guozhonghua <guozhonghua@h3c.com>

--- ocfs2.orig/dlm/dlmmaster.c  2016-09-13 15:18:13.602684325 +0800
+++ ocfs2/dlm/dlmmaster.c       2016-09-14 10:15:10.496873879 +0800
@@ -2573,8 +2573,6 @@ static int dlm_is_lockres_migrateable(st
 /*
  * DLM_MIGRATE_LOCKRES
  */
-
-
 static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
                               struct dlm_lock_resource *res, u8 target)
 {
@@ -2621,20 +2619,26 @@ static int dlm_migrate_lockres(struct dl
        spin_lock(&dlm->master_lock);
        ret = dlm_add_migration_mle(dlm, res, mle, &oldmle, name,
                                    namelen, target, dlm->node_num);
+       if (ret == -EEXIST) {
+               if(oldmle)
+                       __dlm_put_mle(oldmle);
+
+               spin_unlock(&dlm->master_lock);
+               spin_unlock(&dlm->spinlock);
+               mlog(0, "another process is already migrating it\n");
+               goto fail;
+       }
+
        /* get an extra reference on the mle.
         * otherwise the assert_master from the new
         * master will destroy this.
         */
        dlm_get_mle_inuse(mle);
+       mle_added = 1;
+
        spin_unlock(&dlm->master_lock);
        spin_unlock(&dlm->spinlock);

-       if (ret == -EEXIST) {
-               mlog(0, "another process is already migrating it\n");
-               goto fail;
-       }
-       mle_added = 1;
-
        /*
         * set the MIGRATING flag and flush asts
         * if we fail after this we need to re-dirty the lockres

-------------------------------------------------------------------------------------------------------------------------------------
????????????????????????????????????????
????????????????????????????????????????
????????????????????????????????????????
???
This e-mail and its attachments contain confidential information from H3C, which is
intended only for the person or entity whose address is listed above. Any use of the
information contained herein in any way (including, but not limited to, total or partial
disclosure, reproduction, or dissemination) by persons other than the intended
recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender
by phone or email immediately and delete it!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Ocfs2-devel] [PATCH] ocfs2: oldmle should be put while -EEXIST returned, and the new mle should not be get once at that time.
  2016-09-14  2:30 [Ocfs2-devel] [PATCH] ocfs2: oldmle should be put while -EEXIST returned, and the new mle should not be get once at that time Guozhonghua
@ 2016-09-14  2:54 ` Joseph Qi
  2016-09-14  3:41   ` [Ocfs2-devel] 答复: " Guozhonghua
  0 siblings, 1 reply; 3+ messages in thread
From: Joseph Qi @ 2016-09-14  2:54 UTC (permalink / raw)
  To: ocfs2-devel

NAK. This has already been fixed by commit 32e493265b2b ("ocfs2/dlm:
do not insert a new mle when another process is already migrating").
Please submit patch based on the latest kernel.

Thanks,
Joseph

On 2016/9/14 10:30, Guozhonghua wrote:
> 
> In the function dlm_migrate_lockres, while calling dlm_add_migration_mle, and the ret is --EEXIST.
> At this time, the oldmle should be put one time for it had been get once in dlm_find_mle.
> And the new mle should not get once for it had not been initialized before goto fail.
> 
> Signed-off-by: Guozhonghua <guozhonghua@h3c.com>
> 
> --- ocfs2.orig/dlm/dlmmaster.c  2016-09-13 15:18:13.602684325 +0800
> +++ ocfs2/dlm/dlmmaster.c       2016-09-14 10:15:10.496873879 +0800
> @@ -2573,8 +2573,6 @@ static int dlm_is_lockres_migrateable(st
>  /*
>   * DLM_MIGRATE_LOCKRES
>   */
> -
> -
>  static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
>                                struct dlm_lock_resource *res, u8 target)
>  {
> @@ -2621,20 +2619,26 @@ static int dlm_migrate_lockres(struct dl
>         spin_lock(&dlm->master_lock);
>         ret = dlm_add_migration_mle(dlm, res, mle, &oldmle, name,
>                                     namelen, target, dlm->node_num);
> +       if (ret == -EEXIST) {
> +               if(oldmle)
> +                       __dlm_put_mle(oldmle);
> +
> +               spin_unlock(&dlm->master_lock);
> +               spin_unlock(&dlm->spinlock);
> +               mlog(0, "another process is already migrating it\n");
> +               goto fail;
> +       }
> +
>         /* get an extra reference on the mle.
>          * otherwise the assert_master from the new
>          * master will destroy this.
>          */
>         dlm_get_mle_inuse(mle);
> +       mle_added = 1;
> +
>         spin_unlock(&dlm->master_lock);
>         spin_unlock(&dlm->spinlock);
> 
> -       if (ret == -EEXIST) {
> -               mlog(0, "another process is already migrating it\n");
> -               goto fail;
> -       }
> -       mle_added = 1;
> -
>         /*
>          * set the MIGRATING flag and flush asts
>          * if we fail after this we need to re-dirty the lockres
> 
> -------------------------------------------------------------------------------------------------------------------------------------
> ????????????????????????????????????????
> ????????????????????????????????????????
> ????????????????????????????????????????
> ???
> This e-mail and its attachments contain confidential information from H3C, which is
> intended only for the person or entity whose address is listed above. Any use of the
> information contained herein in any way (including, but not limited to, total or partial
> disclosure, reproduction, or dissemination) by persons other than the intended
> recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender
> by phone or email immediately and delete it!
> _______________________________________________
> Ocfs2-devel mailing list
> Ocfs2-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/ocfs2-devel
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Ocfs2-devel] 答复:  [PATCH] ocfs2: oldmle should be put while -EEXIST returned, and the new mle should not be get once at that time.
  2016-09-14  2:54 ` Joseph Qi
@ 2016-09-14  3:41   ` Guozhonghua
  0 siblings, 0 replies; 3+ messages in thread
From: Guozhonghua @ 2016-09-14  3:41 UTC (permalink / raw)
  To: ocfs2-devel

Hi, Joseph

I reviewed the patch of 32e493265b2b.
If the ret is --EEXIST, the oldmle will not be put.

As the fucntion dlm_add_migration_mle called, the return value is -EEXIST.
The oldmle had been gotten once and goto fail.

The fail code, ret is -EEXIST, so there is not anyway for the oldmle to be put.
fail:
        if (ret != -EEXIST && oldmle) {
                /* master is known, detach if not already detached */
                dlm_mle_detach_hb_events(dlm, oldmle);
                dlm_put_mle(oldmle);
        }

Same thing, the new mle is allocated
It will not initialized with the ret --EEXIST while call dlm_add_migration_mle.
So it is wrong to call dlm_get_mle_inuse(mle) for the new mle before goto fail.

I review these code and find that is not well.
Please have a check, and your comments will be good for me.
Thank You.

-------------------------------------------------------------------------------------------------------------------------------------
????????????????????????????????????????
????????????????????????????????????????
????????????????????????????????????????
???
This e-mail and its attachments contain confidential information from H3C, which is
intended only for the person or entity whose address is listed above. Any use of the
information contained herein in any way (including, but not limited to, total or partial
disclosure, reproduction, or dissemination) by persons other than the intended
recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender
by phone or email immediately and delete it!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-14  3:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-14  2:30 [Ocfs2-devel] [PATCH] ocfs2: oldmle should be put while -EEXIST returned, and the new mle should not be get once at that time Guozhonghua
2016-09-14  2:54 ` Joseph Qi
2016-09-14  3:41   ` [Ocfs2-devel] 答复: " Guozhonghua

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.