]> sourceware.org Git - lvm2.git/commitdiff
Skip unnecessary lock_vol() call after volume deactivation
authorZdenek Kabelac <zkabelac@redhat.com>
Thu, 13 Jan 2011 14:56:17 +0000 (14:56 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Thu, 13 Jan 2011 14:56:17 +0000 (14:56 +0000)
Improve condition within lock_vol so we are not calling extra unlock
if the volume just has been deactivated.

Patch uses lck_type and replaces negative 'and' condition to more
readable 'or' condition.
Few missing strace traces added.

WHATS_NEW
lib/locking/locking.c

index b4d63142d045ab92235a38f0ae6f2f191ae5dc77..df4da73d1bca31f9c33537242be2fea532c92bc6 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.81 -
 ===================================
+  Skip unnecessary lock_vol() call after volume deactivation.
   Extend exec_cmd params to specify, when device sync is needed.
   Replace fs_unlock by sync_local_dev_names to notify local clvmd. (2.02.80)
   Introduce sync_local_dev_names and CLVMD_CMD_SYNC_NAMES to issue fs_unlock.
index 2adf99786f704620891d3631b9082dffeb0ced4d..645f25d5709a9b9749a45e4c6d3cb537b2a00041 100644 (file)
@@ -406,6 +406,7 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
 {
        char resource[258] __attribute__((aligned(8)));
        lv_operation_t lv_op;
+       int lck_type = flags & LCK_TYPE_MASK;
 
        switch (flags & (LCK_SCOPE_MASK | LCK_TYPE_MASK)) {
                case LCK_LV_SUSPEND:
@@ -432,15 +433,15 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
                if (is_orphan_vg(vol))
                        vol = VG_ORPHANS;
                /* VG locks alphabetical, ORPHAN lock last */
-               if (((flags & LCK_TYPE_MASK) != LCK_UNLOCK) &&
-                        !(flags & LCK_CACHE) &&
-                        !lvmcache_verify_lock_order(vol))
-                       return 0;
+               if ((lck_type != LCK_UNLOCK) &&
+                   !(flags & LCK_CACHE) &&
+                   !lvmcache_verify_lock_order(vol))
+                       return_0;
 
                /* Lock VG to change on-disk metadata. */
                /* If LVM1 driver knows about the VG, it can't be accessed. */
                if (!check_lvm1_vg_inactive(cmd, vol))
-                       return 0;
+                       return_0;
                break;
        case LCK_LV:
                /* All LV locks are non-blocking. */
@@ -455,18 +456,18 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
        strncpy(resource, vol, sizeof(resource));
 
        if (!_lock_vol(cmd, resource, flags, lv_op))
-               return 0;
+               return_0;
 
        /*
         * If a real lock was acquired (i.e. not LCK_CACHE),
         * perform an immediate unlock unless LCK_HOLD was requested.
         */
-       if (!(flags & LCK_CACHE) && !(flags & LCK_HOLD) &&
-           ((flags & LCK_TYPE_MASK) != LCK_UNLOCK)) {
-               if (!_lock_vol(cmd, resource,
-                              (flags & ~LCK_TYPE_MASK) | LCK_UNLOCK, lv_op))
-                       return 0;
-       }
+       if ((lck_type == LCK_NULL) || (lck_type == LCK_UNLOCK) ||
+           (flags & (LCK_CACHE | LCK_HOLD)))
+               return 1;
+
+       if (!_lock_vol(cmd, resource, (flags & ~LCK_TYPE_MASK) | LCK_UNLOCK, lv_op))
+               return_0;
 
        return 1;
 }
This page took 0.049905 seconds and 5 git commands to generate.