]> sourceware.org Git - lvm2.git/commitdiff
All LV locks are non-blocking so remove LCK_NONBLOCK from separate macros.
authorAlasdair Kergon <agk@redhat.com>
Fri, 24 Jul 2009 18:15:06 +0000 (18:15 +0000)
committerAlasdair Kergon <agk@redhat.com>
Fri, 24 Jul 2009 18:15:06 +0000 (18:15 +0000)
WHATS_NEW
daemons/clvmd/lvm-functions.c
lib/locking/locking.c
lib/locking/locking.h

index 9a36f32b520221741c724bc8d011191b25a51c78..1d183002743db1edf134e62950b87a509b9e8d1a 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.50 - 
 ================================
+  All LV locks are non-blocking so remove LCK_NONBLOCK from separate macros.
   Fix race condition with vgcreate and vgextend on same device (2.02.49).
   Remove redundant validate_name call from vgreduce.
   Add lvm_{pv|vg|lv}_get_{name|uuid} liblvm functions.
index a3e36f2a743aaa92e9b3982fbc4213d8df8208de..eb9ad6fb38268a3b5c36e357c173d77e532d4c81 100644 (file)
@@ -65,8 +65,6 @@ struct lv_info {
        int lock_mode;
 };
 
-#define LCK_MASK (LCK_TYPE_MASK | LCK_SCOPE_MASK)
-
 static const char *decode_locking_cmd(unsigned char cmdl)
 {
        static char buf[128];
@@ -482,28 +480,28 @@ int do_lock_lv(unsigned char command, unsigned char lock_flags, char *resource)
        cmd->partial_activation = (lock_flags & LCK_PARTIAL_MODE) ? 1 : 0;
 
        switch (command) {
-       case LCK_LV_EXCLUSIVE:
+       case LCK_LV_EXCLUSIVE & LCK_MASK:
                status = do_activate_lv(resource, lock_flags, LKM_EXMODE);
                break;
 
-       case LCK_LV_SUSPEND:
+       case LCK_LV_SUSPEND & LCK_MASK:
                status = do_suspend_lv(resource);
                if (!status)
                        suspended++;
                break;
 
        case LCK_UNLOCK:
-       case LCK_LV_RESUME:     /* if active */
+       case LCK_LV_RESUME & LCK_MASK:  /* if active */
                status = do_resume_lv(resource);
                if (!status)
                        suspended--;
                break;
 
-       case LCK_LV_ACTIVATE:
+       case LCK_LV_ACTIVATE & LCK_MASK:
                status = do_activate_lv(resource, lock_flags, LKM_CRMODE);
                break;
 
-       case LCK_LV_DEACTIVATE:
+       case LCK_LV_DEACTIVATE & LCK_MASK:
                status = do_deactivate_lv(resource, lock_flags);
                break;
 
index 32d54b7079be6065e5519885a9e2d136bf263077..6c4efce526c7313bf7caaca510f9c5c300453f9d 100644 (file)
@@ -386,9 +386,10 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
                /* If LVM1 driver knows about the VG, it can't be accessed. */
                if (!check_lvm1_vg_inactive(cmd, vol))
                        return 0;
+               break;
        case LCK_LV:
-               /* Suspend LV if it's active. */
-               strncpy(resource, vol, sizeof(resource));
+               /* All LV locks are non-blocking. */
+               flags |= LCK_NONBLOCK;
                break;
        default:
                log_error("Unrecognised lock scope: %d",
@@ -396,6 +397,8 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
                return 0;
        }
 
+       strncpy(resource, vol, sizeof(resource));
+
        if (!_lock_vol(cmd, resource, flags))
                return 0;
 
index 97cd42d3b8208c6b1cf8f9d41ef8fef2d2587340..c0f71733ca23c82366434638777864810ba32f6a 100644 (file)
@@ -106,17 +106,19 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
 #define LCK_VG_DROP_CACHE      (LCK_VG | LCK_WRITE | LCK_CACHE)
 #define LCK_VG_BACKUP          (LCK_VG | LCK_CACHE)
 
-#define LCK_LV_EXCLUSIVE       (LCK_LV | LCK_EXCL | LCK_NONBLOCK)
-#define LCK_LV_SUSPEND         (LCK_LV | LCK_WRITE | LCK_NONBLOCK)
-#define LCK_LV_RESUME          (LCK_LV | LCK_UNLOCK | LCK_NONBLOCK)
-#define LCK_LV_ACTIVATE                (LCK_LV | LCK_READ | LCK_NONBLOCK)
-#define LCK_LV_DEACTIVATE      (LCK_LV | LCK_NULL | LCK_NONBLOCK)
+#define LCK_LV_EXCLUSIVE       (LCK_LV | LCK_EXCL)
+#define LCK_LV_SUSPEND         (LCK_LV | LCK_WRITE)
+#define LCK_LV_RESUME          (LCK_LV | LCK_UNLOCK)
+#define LCK_LV_ACTIVATE                (LCK_LV | LCK_READ)
+#define LCK_LV_DEACTIVATE      (LCK_LV | LCK_NULL)
+
+#define LCK_MASK (LCK_TYPE_MASK | LCK_SCOPE_MASK)
 
 #define LCK_LV_CLUSTERED(lv)   \
        (vg_is_clustered((lv)->vg) ? LCK_CLUSTER_VG : 0)
 
 #define lock_lv_vol(cmd, lv, flags)    \
-       lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv))
+       lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv) | LCK_NONBLOCK)
 
 #define unlock_vg(cmd, vol)    lock_vol(cmd, vol, LCK_VG_UNLOCK)
 #define unlock_and_release_vg(cmd, vg, vol) \
This page took 0.057261 seconds and 5 git commands to generate.