diff mbox

[v3] ocfs2/dlm: Optimization of code while free dead node locks.

Message ID 71604351584F6A4EBAE558C676F37CA4C4AF898E@H3CMLB12-EX.srv.huawei-3com.com (mailing list archive)
State New, archived
Headers show

Commit Message

Guozhonghua Jan. 17, 2017, 11:22 a.m. UTC
Three loops can be optimized into one and its sub loops, so as small code can do the same work.

From 8a1e682503f4e5a5299fe8316cbf559f9b9701f1 Mon Sep 17 00:00:00 2001
From: Guozhonghua <guozhonghua@h3c.com>
Date: Fri, 13 Jan 2017 11:27:32 +0800
Subject: [PATCH] Optimization of code while free dead locks, changed for
 reviews.


Signed-off-by: Guozhonghua <guozhonghua@h3c.com>
---
 fs/ocfs2/dlm/dlmrecovery.c |   39 ++++++++++++++-------------------------
 1 file changed, 14 insertions(+), 25 deletions(-)

--
1.7.9.5
-------------------------------------------------------------------------------------------------------------------------------------
本邮件及其附件含有杭州华三通信技术有限公司的保密信息,仅限于发送给上面地址中列出
的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、
或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本
邮件!
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!

Comments

Zhen Ren Jan. 19, 2017, 2:37 a.m. UTC | #1
Hi,

On 01/17/2017 07:22 PM, Guozhonghua wrote:
> Three loops can be optimized into one and its sub loops, so as small code can do the same work.  ===> (1)
>
>  From 8a1e682503f4e5a5299fe8316cbf559f9b9701f1 Mon Sep 17 00:00:00 2001
> From: Guozhonghua <guozhonghua@h3c.com>
> Date: Fri, 13 Jan 2017 11:27:32 +0800
> Subject: [PATCH] Optimization of code while free dead locks, changed for
>   reviews.
>                                                                                                  ===> (2)
>
> Signed-off-by: Guozhonghua <guozhonghua@h3c.com>
The patch looks good to me, except some formatting issues:
1. The commit message at (1) should be placed at (2);
2. Change log is still missing;

I think it's not a big deal, though. The fix is quite simple. Wish your patch has good
formatting next time;-)

Reviewed-by: Eric Ren <zren@suse.com>

Eric

> ---
>   fs/ocfs2/dlm/dlmrecovery.c |   39 ++++++++++++++-------------------------
>   1 file changed, 14 insertions(+), 25 deletions(-)
>
> diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
> index dd5cb8b..93b71dd 100644
> --- a/fs/ocfs2/dlm/dlmrecovery.c
> +++ b/fs/ocfs2/dlm/dlmrecovery.c
> @@ -2268,6 +2268,8 @@ static void dlm_free_dead_locks(struct dlm_ctxt *dlm,
>   {
>          struct dlm_lock *lock, *next;
>          unsigned int freed = 0;
> +       struct list_head *queue = NULL;
> +       int i;
>
>          /* this node is the lockres master:
>           * 1) remove any stale locks for the dead node
> @@ -2280,31 +2282,18 @@ static void dlm_free_dead_locks(struct dlm_ctxt *dlm,
>           * to force the DLM_UNLOCK_FREE_LOCK action so as to free the locks */
>
>          /* TODO: check pending_asts, pending_basts here */
> -       list_for_each_entry_safe(lock, next, &res->granted, list) {
> -               if (lock->ml.node == dead_node) {
> -                       list_del_init(&lock->list);
> -                       dlm_lock_put(lock);
> -                       /* Can't schedule DLM_UNLOCK_FREE_LOCK - do manually */
> -                       dlm_lock_put(lock);
> -                       freed++;
> -               }
> -       }
> -       list_for_each_entry_safe(lock, next, &res->converting, list) {
> -               if (lock->ml.node == dead_node) {
> -                       list_del_init(&lock->list);
> -                       dlm_lock_put(lock);
> -                       /* Can't schedule DLM_UNLOCK_FREE_LOCK - do manually */
> -                       dlm_lock_put(lock);
> -                       freed++;
> -               }
> -       }
> -       list_for_each_entry_safe(lock, next, &res->blocked, list) {
> -               if (lock->ml.node == dead_node) {
> -                       list_del_init(&lock->list);
> -                       dlm_lock_put(lock);
> -                       /* Can't schedule DLM_UNLOCK_FREE_LOCK - do manually */
> -                       dlm_lock_put(lock);
> -                       freed++;
> +       for (i = DLM_GRANTED_LIST; i <= DLM_BLOCKED_LIST; i++) {
> +               queue = dlm_list_idx_to_ptr(res, i);
> +               list_for_each_entry_safe(lock, next, queue, list) {
> +                       if (lock->ml.node == dead_node) {
> +                               list_del_init(&lock->list);
> +                               dlm_lock_put(lock);
> +                               /* Can't schedule DLM_UNLOCK_FREE_LOCK
> +                                * do manually
> +                                */
> +                               dlm_lock_put(lock);
> +                               freed++;
> +                       }
>                  }
>          }
>
> --
> 1.7.9.5
> -------------------------------------------------------------------------------------------------------------------------------------
> 本邮件及其附件含有杭州华三通信技术有限公司的保密信息,仅限于发送给上面地址中列出
> 的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、
> 或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本
> 邮件!
> 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@oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/ocfs2-devel
diff mbox

Patch

diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index dd5cb8b..93b71dd 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -2268,6 +2268,8 @@  static void dlm_free_dead_locks(struct dlm_ctxt *dlm,
 {
        struct dlm_lock *lock, *next;
        unsigned int freed = 0;
+       struct list_head *queue = NULL;
+       int i;

        /* this node is the lockres master:
         * 1) remove any stale locks for the dead node
@@ -2280,31 +2282,18 @@  static void dlm_free_dead_locks(struct dlm_ctxt *dlm,
         * to force the DLM_UNLOCK_FREE_LOCK action so as to free the locks */

        /* TODO: check pending_asts, pending_basts here */
-       list_for_each_entry_safe(lock, next, &res->granted, list) {
-               if (lock->ml.node == dead_node) {
-                       list_del_init(&lock->list);
-                       dlm_lock_put(lock);
-                       /* Can't schedule DLM_UNLOCK_FREE_LOCK - do manually */
-                       dlm_lock_put(lock);
-                       freed++;
-               }
-       }
-       list_for_each_entry_safe(lock, next, &res->converting, list) {
-               if (lock->ml.node == dead_node) {
-                       list_del_init(&lock->list);
-                       dlm_lock_put(lock);
-                       /* Can't schedule DLM_UNLOCK_FREE_LOCK - do manually */
-                       dlm_lock_put(lock);
-                       freed++;
-               }
-       }
-       list_for_each_entry_safe(lock, next, &res->blocked, list) {
-               if (lock->ml.node == dead_node) {
-                       list_del_init(&lock->list);
-                       dlm_lock_put(lock);
-                       /* Can't schedule DLM_UNLOCK_FREE_LOCK - do manually */
-                       dlm_lock_put(lock);
-                       freed++;
+       for (i = DLM_GRANTED_LIST; i <= DLM_BLOCKED_LIST; i++) {
+               queue = dlm_list_idx_to_ptr(res, i);
+               list_for_each_entry_safe(lock, next, queue, list) {
+                       if (lock->ml.node == dead_node) {
+                               list_del_init(&lock->list);
+                               dlm_lock_put(lock);
+                               /* Can't schedule DLM_UNLOCK_FREE_LOCK
+                                * do manually
+                                */
+                               dlm_lock_put(lock);
+                               freed++;
+                       }
                }
        }