diff mbox

ocfs2: Optimization of code while free dead locks, changed for reviews.

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

Commit Message

Guozhonghua Nov. 28, 2016, 9:05 a.m. UTC
Changed the free order and code styles with reviews. Based on Linux-4.9-rc6. Thanks.

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

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

I am tired telling you things about patch format... won't do any response until you really 
model after
a correct patch.

Eric

On 11/28/2016 05:05 PM, Guozhonghua wrote:
> Changed the free order and code styles with reviews. Based on Linux-4.9-rc6. Thanks.
>
> Signed-off-by: guozhonghua <guozhonghua@h3c.com>
>
> diff -uprN ocfs2.orig/dlm/dlmrecovery.c ocfs2/dlm/dlmrecovery.c
> --- ocfs2.orig/dlm/dlmrecovery.c        2016-11-28 16:26:45.890934481 +0800
> +++ ocfs2/dlm/dlmrecovery.c     2016-11-28 16:32:04.982940629 +0800
> @@ -2268,6 +2268,9 @@ static void dlm_free_dead_locks(struct d
>   {
>          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,33 +2283,19 @@ static void dlm_free_dead_locks(struct d
>           * 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++;
> +                       }
> +               }
> +       }
>
>          if (freed) {
>                  mlog(0, "%s:%.*s: freed %u locks for dead node %u, "
> -------------------------------------------------------------------------------------------------------------------------------------
> 本邮件及其附件含有杭州华三通信技术有限公司的保密信息,仅限于发送给上面地址中列出
> 的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、
> 或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本
> 邮件!
> 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!
diff mbox

Patch

diff -uprN ocfs2.orig/dlm/dlmrecovery.c ocfs2/dlm/dlmrecovery.c
--- ocfs2.orig/dlm/dlmrecovery.c        2016-11-28 16:26:45.890934481 +0800
+++ ocfs2/dlm/dlmrecovery.c     2016-11-28 16:32:04.982940629 +0800
@@ -2268,6 +2268,9 @@  static void dlm_free_dead_locks(struct d
 {
        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,33 +2283,19 @@  static void dlm_free_dead_locks(struct d
         * 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++;
+                       }
+               }
+       }

        if (freed) {
                mlog(0, "%s:%.*s: freed %u locks for dead node %u, "