]> sourceware.org Git - lvm2.git/commitdiff
locking: Make it possible to pass down an LV to activation code.
authorPetr Rockai <me@mornfall.net>
Sun, 17 Mar 2013 20:29:58 +0000 (21:29 +0100)
committerPetr Rockai <prockai@redhat.com>
Mon, 10 Jun 2013 15:26:38 +0000 (17:26 +0200)
Previously, we have relied on UUIDs alone, and on lvmcache to make getting a
"new copy" of VG metadata fast. If the code which triggers the activation has
the correct VG metadata at hand (the version which is currently on disk), it can
now hand it to the activation code directly.

24 files changed:
daemons/clvmd/lvm-functions.c
lib/activate/activate.c
lib/activate/activate.h
lib/locking/cluster_locking.c
lib/locking/external_locking.c
lib/locking/file_locking.c
lib/locking/locking.c
lib/locking/locking.h
lib/locking/locking_types.h
lib/locking/no_locking.c
lib/metadata/metadata.c
liblvm/lvm_vg.c
tools/lvconvert.c
tools/pvchange.c
tools/pvcreate.c
tools/pvremove.c
tools/pvresize.c
tools/pvscan.c
tools/toollib.c
tools/vgcfgrestore.c
tools/vgcreate.c
tools/vgextend.c
tools/vgreduce.c
tools/vgscan.c

index 5e83454b5918c25e589ba80ff1df9f72d97cf5bc..99d2eb386970a4868cc5ce29c4d0bce2a3298294 100644 (file)
@@ -356,7 +356,7 @@ static int do_activate_lv(char *resource, unsigned char command, unsigned char l
        }
 
        /* Does the config file want us to activate this LV ? */
-       if (!lv_activation_filter(cmd, resource, &activate_lv))
+       if (!lv_activation_filter(cmd, resource, &activate_lv, NULL))
                return EIO;
 
        if (!activate_lv)
@@ -394,14 +394,14 @@ static int do_activate_lv(char *resource, unsigned char command, unsigned char l
 
        if (lvi.suspended) {
                critical_section_inc(cmd, "resuming");
-               if (!lv_resume(cmd, resource, 0)) {
+               if (!lv_resume(cmd, resource, 0, NULL)) {
                        critical_section_dec(cmd, "resumed");
                        goto error;
                }
        }
 
        /* Now activate it */
-       if (!lv_activate(cmd, resource, exclusive))
+       if (!lv_activate(cmd, resource, exclusive, NULL))
                goto error;
 
        return 0;
@@ -427,7 +427,7 @@ static int do_resume_lv(char *resource, unsigned char command, unsigned char loc
        exclusive = (oldmode == LCK_EXCL) ? 1 : 0;
        revert = (lock_flags & LCK_REVERT_MODE) ? 1 : 0;
 
-       if (!lv_resume_if_active(cmd, resource, origin_only, exclusive, revert))
+       if (!lv_resume_if_active(cmd, resource, origin_only, exclusive, revert, NULL))
                return EIO;
 
        return 0;
@@ -450,7 +450,7 @@ static int do_suspend_lv(char *resource, unsigned char command, unsigned char lo
        exclusive = (oldmode == LCK_EXCL) ? 1 : 0;
 
        /* Always call lv_suspend to read commited and precommited data */
-       if (!lv_suspend_if_active(cmd, resource, origin_only, exclusive))
+       if (!lv_suspend_if_active(cmd, resource, origin_only, exclusive, NULL))
                return EIO;
 
        return 0;
@@ -468,7 +468,7 @@ static int do_deactivate_lv(char *resource, unsigned char command, unsigned char
                return 0;       /* We don't need to do anything */
        }
 
-       if (!lv_deactivate(cmd, resource))
+       if (!lv_deactivate(cmd, resource, NULL))
                return EIO;
 
        if (command & LCK_CLUSTER_VG) {
index 7f3d7c6c093ff1e49096c720be95cd1977f580d6..15e684ae8cc78eeed4c7d27053e4ad76544b64ff 100644 (file)
@@ -1615,9 +1615,10 @@ static int _preload_detached_lv(struct cmd_context *cmd, struct logical_volume *
 }
 
 static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
-                      struct lv_activate_opts *laopts, int error_if_not_suspended)
+                      struct lv_activate_opts *laopts, int error_if_not_suspended,
+                      struct logical_volume *lv)
 {
-       struct logical_volume *lv = NULL, *lv_pre = NULL, *pvmove_lv = NULL;
+       struct logical_volume *lv_pre = NULL, *pvmove_lv = NULL, *lv_to_free = NULL;
        struct lv_list *lvl_pre;
        struct seg_list *sl;
         struct lv_segment *snap_seg;
@@ -1628,7 +1629,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
        if (!activation())
                return 1;
 
-       if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
+       if (!lv && !(lv_to_free = lv = lv_from_lvid(cmd, lvid_s, 0)))
                goto_out;
 
        /* Use precommitted metadata if present */
@@ -1769,9 +1770,9 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
 out:
        if (lv_pre)
                release_vg(lv_pre->vg);
-       if (lv) {
-               lv_release_replicator_vgs(lv);
-               release_vg(lv->vg);
+       if (lv_to_free) {
+               lv_release_replicator_vgs(lv_to_free);
+               release_vg(lv_to_free->vg);
        }
 
        return r;
@@ -1783,14 +1784,14 @@ out:
  *
  * Returns success if the device is not active
  */
-int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive)
+int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive, struct logical_volume *lv)
 {
        struct lv_activate_opts laopts = {
                .origin_only = origin_only,
                .exclusive = exclusive
        };
 
-       return _lv_suspend(cmd, lvid_s, &laopts, 0);
+       return _lv_suspend(cmd, lvid_s, &laopts, 0, lv);
 }
 
 /* No longer used */
@@ -1802,9 +1803,10 @@ int lv_suspend(struct cmd_context *cmd, const char *lvid_s)
 ***********/
 
 static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
-                     struct lv_activate_opts *laopts, int error_if_not_active)
+                     struct lv_activate_opts *laopts, int error_if_not_active,
+                     struct logical_volume *lv)
 {
-       struct logical_volume *lv;
+       struct logical_volume *lv_to_free = NULL;
        struct lvinfo info;
        int r = 0;
        int messages_only = 0;
@@ -1812,7 +1814,7 @@ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
        if (!activation())
                return 1;
 
-       if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
+       if (!lv && !(lv_to_free = lv = lv_from_lvid(cmd, lvid_s, 0)))
                goto_out;
 
        if (lv_is_thin_pool(lv) && laopts->origin_only)
@@ -1857,8 +1859,8 @@ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
 
        r = 1;
 out:
-       if (lv)
-               release_vg(lv->vg);
+       if (lv_to_free)
+               release_vg(lv_to_free->vg);
 
        return r;
 }
@@ -1875,7 +1877,7 @@ out:
  */
 int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
                        unsigned origin_only, unsigned exclusive,
-                       unsigned revert)
+                       unsigned revert, struct logical_volume *lv)
 {
        struct lv_activate_opts laopts = {
                .origin_only = origin_only,
@@ -1883,14 +1885,14 @@ int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
                .revert = revert
        };
 
-       return _lv_resume(cmd, lvid_s, &laopts, 0);
+       return _lv_resume(cmd, lvid_s, &laopts, 0, lv);
 }
 
-int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only)
+int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, struct logical_volume *lv)
 {
        struct lv_activate_opts laopts = { .origin_only = origin_only, };
 
-       return _lv_resume(cmd, lvid_s, &laopts, 1);
+       return _lv_resume(cmd, lvid_s, &laopts, 1, lv);
 }
 
 static int _lv_has_open_snapshots(struct logical_volume *lv)
@@ -1916,16 +1918,16 @@ static int _lv_has_open_snapshots(struct logical_volume *lv)
        return r;
 }
 
-int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
+int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, struct logical_volume *lv)
 {
-       struct logical_volume *lv;
+       struct logical_volume *lv_to_free = NULL;
        struct lvinfo info;
        int r = 0;
 
        if (!activation())
                return 1;
 
-       if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
+       if (!lv && !(lv_to_free = lv = lv_from_lvid(cmd, lvid_s, 0)))
                goto out;
 
        if (test_mode()) {
@@ -1967,9 +1969,9 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
        if (!lv_info(cmd, lv, 0, &info, 0, 0) || info.exists)
                r = 0;
 out:
-       if (lv) {
-               lv_release_replicator_vgs(lv);
-               release_vg(lv->vg);
+       if (lv_to_free) {
+               lv_release_replicator_vgs(lv_to_free);
+               release_vg(lv_to_free->vg);
        }
 
        return r;
@@ -1977,9 +1979,9 @@ out:
 
 /* Test if LV passes filter */
 int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
-                        int *activate_lv)
+                        int *activate_lv, struct logical_volume *lv)
 {
-       struct logical_volume *lv;
+       struct logical_volume *lv_to_free = NULL;
        int r = 0;
 
        if (!activation()) {
@@ -1987,7 +1989,7 @@ int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
                return 1;
        }
 
-       if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
+       if (!lv && !(lv_to_free = lv = lv_from_lvid(cmd, lvid_s, 0)))
                goto out;
 
        if (!_passes_activation_filter(cmd, lv)) {
@@ -1998,23 +2000,24 @@ int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
                *activate_lv = 1;
        r = 1;
 out:
-       if (lv)
-               release_vg(lv->vg);
+       if (lv_to_free)
+               release_vg(lv_to_free->vg);
 
        return r;
 }
 
 static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
-                       struct lv_activate_opts *laopts, int filter)
+                       struct lv_activate_opts *laopts, int filter,
+                       struct logical_volume *lv)
 {
-       struct logical_volume *lv;
+       struct logical_volume *lv_to_free = NULL;
        struct lvinfo info;
        int r = 0;
 
        if (!activation())
                return 1;
 
-       if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
+       if (!lv && !(lv_to_free = lv = lv_from_lvid(cmd, lvid_s, 0)))
                goto out;
 
        if (filter && !_passes_activation_filter(cmd, lv)) {
@@ -2074,31 +2077,31 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
                stack;
 
 out:
-       if (lv) {
-               lv_release_replicator_vgs(lv);
-               release_vg(lv->vg);
+       if (lv_to_free) {
+               lv_release_replicator_vgs(lv_to_free);
+               release_vg(lv_to_free->vg);
        }
 
        return r;
 }
 
 /* Activate LV */
-int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive)
+int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive, struct logical_volume *lv)
 {
        struct lv_activate_opts laopts = { .exclusive = exclusive };
 
-       if (!_lv_activate(cmd, lvid_s, &laopts, 0))
+       if (!_lv_activate(cmd, lvid_s, &laopts, 0, lv))
                return_0;
 
        return 1;
 }
 
 /* Activate LV only if it passes filter */
-int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s, int exclusive)
+int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s, int exclusive, struct logical_volume *lv)
 {
        struct lv_activate_opts laopts = { .exclusive = exclusive };
 
-       if (!_lv_activate(cmd, lvid_s, &laopts, 1))
+       if (!_lv_activate(cmd, lvid_s, &laopts, 1, lv))
                return_0;
 
        return 1;
index e80115af4927273498f6ef734a94c4a7996dc512..7446becd6f3425131ce8a74821800ee6491117d2 100644 (file)
@@ -75,14 +75,14 @@ void activation_release(void);
 void activation_exit(void);
 
 /* int lv_suspend(struct cmd_context *cmd, const char *lvid_s); */
-int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive);
-int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only);
+int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive, struct logical_volume *lv);
+int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, struct logical_volume *lv);
 int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
-                       unsigned origin_only, unsigned exclusive, unsigned revert);
-int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive);
+                       unsigned origin_only, unsigned exclusive, unsigned revert, struct logical_volume *lv);
+int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive, struct logical_volume *lv);
 int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s,
-                           int exclusive);
-int lv_deactivate(struct cmd_context *cmd, const char *lvid_s);
+                           int exclusive, struct logical_volume *lv);
+int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, struct logical_volume *lv);
 
 int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv);
 
@@ -101,7 +101,7 @@ int lv_check_not_in_use(struct cmd_context *cmd, struct logical_volume *lv,
  * Returns 1 if activate_lv has been set: 1 = activate; 0 = don't.
  */
 int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
-                        int *activate_lv);
+                        int *activate_lv, struct logical_volume *lv);
 /*
  * Checks against the auto_activation_volume_list and
  * returns 1 if the LV should be activated, 0 otherwise.
index 3169f0da49d34e4f224b2538021e1bda1470d8c1..1350d18dd493cea90fa412d1984e325dbf9c6ee6 100644 (file)
@@ -403,9 +403,9 @@ static int _lock_for_cluster(struct cmd_context *cmd, unsigned char clvmd_cmd,
 /* API entry point for LVM */
 #ifdef CLUSTER_LOCKING_INTERNAL
 static int _lock_resource(struct cmd_context *cmd, const char *resource,
-                         uint32_t flags)
+                         uint32_t flags, struct logical_volume *lv __attribute__((unused)))
 #else
-int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags)
+       int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags, struct logical_volume *lv __attribute__((unused)))
 #endif
 {
        char lockname[PATH_MAX];
index 10761749a492c8bef5284505a2f97129dc63ff2f..d5c39d795d3253ac1d6ed8b17ffe1877cd16d188 100644 (file)
@@ -31,7 +31,7 @@ static int (*_init_fn) (int type, struct dm_config_tree * cft,
 static int (*_lock_query_fn) (const char *resource, int *mode) = NULL;
 
 static int _lock_resource(struct cmd_context *cmd, const char *resource,
-                         uint32_t flags)
+                         uint32_t flags, struct logical_volume *lv __attribute__((unused)))
 {
        if (!_lock_fn)
                return 0;
index 4711fa2e522ab1359a92f0f6d99e34a9298e8af0..1f2468d0e6009eefca44996d1717d5cd9386fb22 100644 (file)
@@ -254,7 +254,7 @@ static int _lock_file(const char *file, uint32_t flags)
 }
 
 static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
-                              uint32_t flags)
+                              uint32_t flags, struct logical_volume *lv)
 {
        char lockfile[PATH_MAX];
        unsigned origin_only = (flags & LCK_ORIGIN_ONLY) ? 1 : 0;
@@ -295,17 +295,17 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
                switch (flags & LCK_TYPE_MASK) {
                case LCK_UNLOCK:
                        log_very_verbose("Unlocking LV %s%s%s", resource, origin_only ? " without snapshots" : "", revert ? " (reverting)" : "");
-                       if (!lv_resume_if_active(cmd, resource, origin_only, 0, revert))
+                       if (!lv_resume_if_active(cmd, resource, origin_only, 0, revert, NULL))
                                return 0;
                        break;
                case LCK_NULL:
                        log_very_verbose("Locking LV %s (NL)", resource);
-                       if (!lv_deactivate(cmd, resource))
+                       if (!lv_deactivate(cmd, resource, NULL))
                                return 0;
                        break;
                case LCK_READ:
                        log_very_verbose("Locking LV %s (R)", resource);
-                       if (!lv_activate_with_filter(cmd, resource, 0))
+                       if (!lv_activate_with_filter(cmd, resource, 0, NULL))
                                return 0;
                        break;
                case LCK_PREAD:
@@ -313,12 +313,12 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
                        break;
                case LCK_WRITE:
                        log_very_verbose("Locking LV %s (W)%s", resource, origin_only ? " without snapshots" : "");
-                       if (!lv_suspend_if_active(cmd, resource, origin_only, 0))
+                       if (!lv_suspend_if_active(cmd, resource, origin_only, 0, NULL))
                                return 0;
                        break;
                case LCK_EXCL:
                        log_very_verbose("Locking LV %s (EX)", resource);
-                       if (!lv_activate_with_filter(cmd, resource, 1))
+                       if (!lv_activate_with_filter(cmd, resource, 1, NULL))
                                return 0;
                        break;
                default:
index 63f946fbf7bded8b14841063798857ca86c6fe4b..044570f393e349edfe36a35709f78656482b96e8 100644 (file)
@@ -352,7 +352,7 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname)
  * FIXME This should become VG uuid.
  */
 static int _lock_vol(struct cmd_context *cmd, const char *resource,
-                    uint32_t flags, lv_operation_t lv_op)
+                    uint32_t flags, lv_operation_t lv_op, struct logical_volume *lv)
 {
        uint32_t lck_type = flags & LCK_TYPE_MASK;
        uint32_t lck_scope = flags & LCK_SCOPE_MASK;
@@ -379,7 +379,7 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,
                return 0;
        }
 
-       if ((ret = _locking.lock_resource(cmd, resource, flags))) {
+       if ((ret = _locking.lock_resource(cmd, resource, flags, lv))) {
                if (lck_scope == LCK_VG && !(flags & LCK_CACHE)) {
                        if (lck_type != LCK_UNLOCK)
                                lvmcache_lock_vgname(resource, lck_type == LCK_READ);
@@ -403,7 +403,7 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,
        return ret;
 }
 
-int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
+int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, struct logical_volume *lv)
 {
        char resource[258] __attribute__((aligned(8)));
        lv_operation_t lv_op;
@@ -457,7 +457,7 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
        strncpy(resource, vol, sizeof(resource) - 1);
        resource[sizeof(resource) - 1] = '\0';
 
-       if (!_lock_vol(cmd, resource, flags, lv_op))
+       if (!_lock_vol(cmd, resource, flags, lv_op, lv))
                return_0;
 
        /*
@@ -468,7 +468,7 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
            (flags & (LCK_CACHE | LCK_HOLD)))
                return 1;
 
-       if (!_lock_vol(cmd, resource, (flags & ~LCK_TYPE_MASK) | LCK_UNLOCK, lv_op))
+       if (!_lock_vol(cmd, resource, (flags & ~LCK_TYPE_MASK) | LCK_UNLOCK, lv_op, lv))
                return_0;
 
        return 1;
@@ -626,12 +626,12 @@ int sync_local_dev_names(struct cmd_context* cmd)
 {
        memlock_unlock(cmd);
 
-       return lock_vol(cmd, VG_SYNC_NAMES, LCK_VG_SYNC_LOCAL);
+       return lock_vol(cmd, VG_SYNC_NAMES, LCK_VG_SYNC_LOCAL, NULL);
 }
 
 int sync_dev_names(struct cmd_context* cmd)
 {
        memlock_unlock(cmd);
 
-       return lock_vol(cmd, VG_SYNC_NAMES, LCK_VG_SYNC);
+       return lock_vol(cmd, VG_SYNC_NAMES, LCK_VG_SYNC, NULL);
 }
index 23c312d8e7040f921137743275284d47b98132a7..aa42138193c42dd3b49495e2a892246936292524 100644 (file)
@@ -19,6 +19,8 @@
 #include "uuid.h"
 #include "config.h"
 
+struct logical_volume;
+
 int init_locking(int type, struct cmd_context *cmd, int suppress_messages);
 void fin_locking(void);
 void reset_locking(void);
@@ -46,7 +48,7 @@ int remote_lock_held(const char *vol, int *exclusive);
  *   Lock/unlock an individual logical volume
  *   char *vol holds lvid
  */
-int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags);
+int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, struct logical_volume *lv);
 
 /*
  * Internal locking representation.
@@ -156,14 +158,14 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
 
 #define lock_lv_vol(cmd, lv, flags)    \
        (find_replicator_vgs((lv)) ? \
-               lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv)) : \
+                lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv), lv) :        \
                0)
 
 #define unlock_vg(cmd, vol)    \
        do { \
                if (is_real_vg(vol)) \
                        sync_dev_names(cmd); \
-               (void) lock_vol(cmd, vol, LCK_VG_UNLOCK); \
+               (void) lock_vol(cmd, vol, LCK_VG_UNLOCK, NULL); \
        } while (0)
 #define unlock_and_release_vg(cmd, vg, vol) \
        do { \
@@ -192,13 +194,13 @@ int activate_lv_excl(struct cmd_context *cmd, struct logical_volume *lv);
 #define deactivate_lv_local(cmd, lv)   \
        lock_lv_vol(cmd, lv, LCK_LV_DEACTIVATE | LCK_LOCAL)
 #define drop_cached_metadata(vg)       \
-       lock_vol((vg)->cmd, (vg)->name, LCK_VG_DROP_CACHE)
+       lock_vol((vg)->cmd, (vg)->name, LCK_VG_DROP_CACHE, NULL)
 #define remote_commit_cached_metadata(vg)      \
-       lock_vol((vg)->cmd, (vg)->name, LCK_VG_COMMIT)
+       lock_vol((vg)->cmd, (vg)->name, LCK_VG_COMMIT, NULL)
 #define remote_revert_cached_metadata(vg)      \
-       lock_vol((vg)->cmd, (vg)->name, LCK_VG_REVERT)
+       lock_vol((vg)->cmd, (vg)->name, LCK_VG_REVERT, NULL)
 #define remote_backup_metadata(vg)     \
-       lock_vol((vg)->cmd, (vg)->name, LCK_VG_BACKUP)
+       lock_vol((vg)->cmd, (vg)->name, LCK_VG_BACKUP, NULL)
 
 int sync_local_dev_names(struct cmd_context* cmd);
 int sync_dev_names(struct cmd_context* cmd);
index 53c7016e0df0f290f9568fcf8a769eda6ad84c23..30094909680686a5402b594f8cc7750d5293eec0 100644 (file)
@@ -17,7 +17,7 @@
 #include "config.h"
 
 typedef int (*lock_resource_fn) (struct cmd_context * cmd, const char *resource,
-                                uint32_t flags);
+                                uint32_t flags, struct logical_volume *lv);
 typedef int (*query_resource_fn) (const char *resource, int *mode);
 
 typedef void (*fin_lock_fn) (void);
index 53a59480f87efd7a21be01f77b64e5684e10de6f..715cc10ffebbd5147e745f20a9e9aa69ffc907ee 100644 (file)
@@ -34,7 +34,7 @@ static void _no_reset_locking(void)
 }
 
 static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
-                            uint32_t flags)
+                            uint32_t flags, struct logical_volume *lv)
 {
        switch (flags & LCK_SCOPE_MASK) {
        case LCK_VG:
@@ -44,15 +44,15 @@ static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
        case LCK_LV:
                switch (flags & LCK_TYPE_MASK) {
                case LCK_NULL:
-                       return lv_deactivate(cmd, resource);
+                       return lv_deactivate(cmd, resource, lv);
                case LCK_UNLOCK:
-                       return lv_resume_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1: 0, 0, (flags & LCK_REVERT) ? 1 : 0);
+                       return lv_resume_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1: 0, 0, (flags & LCK_REVERT) ? 1 : 0, NULL);
                case LCK_READ:
-                       return lv_activate_with_filter(cmd, resource, 0);
+                       return lv_activate_with_filter(cmd, resource, 0, NULL);
                case LCK_WRITE:
-                       return lv_suspend_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1 : 0, 0);
+                       return lv_suspend_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1 : 0, 0, lv);
                case LCK_EXCL:
-                       return lv_activate_with_filter(cmd, resource, 1);
+                       return lv_activate_with_filter(cmd, resource, 1, NULL);
                default:
                        break;
                }
@@ -68,7 +68,7 @@ static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
 
 static int _readonly_lock_resource(struct cmd_context *cmd,
                                   const char *resource,
-                                  uint32_t flags)
+                                  uint32_t flags, struct logical_volume *lv)
 {
        if ((flags & LCK_TYPE_MASK) == LCK_WRITE &&
            (flags & LCK_SCOPE_MASK) == LCK_VG &&
@@ -79,7 +79,7 @@ static int _readonly_lock_resource(struct cmd_context *cmd,
                return 0;
        }
 
-       return _no_lock_resource(cmd, resource, flags);
+       return _no_lock_resource(cmd, resource, flags, lv);
 }
 
 int init_no_locking(struct locking_type *locking, struct cmd_context *cmd __attribute__((unused)),
index 6cee8d53adcd2750362d46c6b387e57f7efb8b1b..922e82ec16c49271685ebdaa6e6ecdc0e079f4d3 100644 (file)
@@ -562,7 +562,7 @@ int vg_remove(struct volume_group *vg)
        struct pv_list *pvl;
        int ret = 1;
 
-       if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+       if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
                log_error("Can't get lock for orphan PVs");
                return 0;
        }
@@ -3971,7 +3971,7 @@ static struct volume_group *_recover_vg(struct cmd_context *cmd,
 
        dev_close_all();
 
-       if (!lock_vol(cmd, vg_name, LCK_VG_WRITE))
+       if (!lock_vol(cmd, vg_name, LCK_VG_WRITE, NULL))
                return_NULL;
 
        if (!(vg = vg_read_internal(cmd, vg_name, vgid, 1, &consistent)))
@@ -4018,7 +4018,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
        already_locked = lvmcache_vgname_is_locked(vg_name);
 
        if (!already_locked && !(misc_flags & READ_WITHOUT_LOCK) &&
-           !lock_vol(cmd, vg_name, lock_flags)) {
+           !lock_vol(cmd, vg_name, lock_flags, NULL)) {
                log_error("Can't get lock for %s", vg_name);
                return _vg_make_handle(cmd, vg, FAILED_LOCKING);
        }
@@ -4173,7 +4173,7 @@ uint32_t vg_read_error(struct volume_group *vg_handle)
  */
 uint32_t vg_lock_newname(struct cmd_context *cmd, const char *vgname)
 {
-       if (!lock_vol(cmd, vgname, LCK_VG_WRITE)) {
+       if (!lock_vol(cmd, vgname, LCK_VG_WRITE, NULL)) {
                return FAILED_LOCKING;
        }
 
index 405a91a1044e7316aa2fccdc121cf0ae75b93c44..b090b84f4846344fbce0903e4c896e79e7ab4f8b 100644 (file)
@@ -73,7 +73,7 @@ int lvm_vg_extend(vg_t vg, const char *device)
        if (!vg_check_write_mode(vg))
                return -1;
 
-       if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+       if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
                log_error("Can't get lock for orphan PVs");
                return -1;
        }
@@ -131,7 +131,7 @@ int lvm_vg_write(vg_t vg)
        }
 
        if (! dm_list_empty(&vg->removed_pvs)) {
-               if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+               if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
                        log_error("Can't get lock for orphan PVs");
                        return 0;
                }
index 718f49cae4dedc95b9b55c860092f4e8cb26379d..46f996a79da0880d6d396b8789f71b0ef47aed7c 100644 (file)
@@ -2503,7 +2503,7 @@ static int lvconvert_merge_single(struct cmd_context *cmd, struct logical_volume
                                          lp->wait_completion);
 
                /* use LCK_VG_WRITE to match lvconvert()'s READ_FOR_UPDATE */
-               if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
+               if (!lock_vol(cmd, vg_name, LCK_VG_WRITE, NULL)) {
                        log_error("ABORTING: Can't relock VG for %s "
                                  "after polling finished", vg_name);
                        ret = ECMD_FAILED;
index 1458e926525667ee51e8660eecc636d1e59ab5a1..d2a3d9bfa572006deee11c1bde8c22be549dff2e 100644 (file)
@@ -219,7 +219,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
                 * take the lock here, pvs with 0 mdas in a non-orphan VG will
                 * be processed twice.
                 */
-               if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE)) {
+               if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE, NULL)) {
                        log_error("Unable to obtain global lock.");
                        return ECMD_FAILED;
                }
index 91562d2100f56a11381ee3b7da69ab6b717b7b74..d3703b465433947ca1852fb70356dfab1a64b7ba 100644 (file)
@@ -108,7 +108,7 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
        }
 
        for (i = 0; i < argc; i++) {
-               if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+               if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
                        log_error("Can't get lock for orphan PVs");
                        return ECMD_FAILED;
                }
index 823c069d0ee3cd977091979ccac4114f7606d12a..cbbf6e2c4ef65d9ab697aabfabe02a651f0b1ade 100644 (file)
@@ -101,7 +101,7 @@ static int pvremove_single(struct cmd_context *cmd, const char *pv_name,
        struct device *dev;
        int ret = ECMD_FAILED;
 
-       if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+       if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
                log_error("Can't get lock for orphan PVs");
                return ECMD_FAILED;
        }
index 2f0693aa3c87441751bdfe39addef6b52270cc14..26959e840a05e06993313ac637e5ebe517f610fb 100644 (file)
@@ -38,7 +38,7 @@ static int _pv_resize_single(struct cmd_context *cmd,
        int vg_needs_pv_write = 0;
 
        if (is_orphan_vg(vg_name)) {
-               if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
+               if (!lock_vol(cmd, vg_name, LCK_VG_WRITE, NULL)) {
                        log_error("Can't get lock for orphans");
                        return 0;
                }
index 7c55faa12e3cc6a8743cde0e8208a02d643e8f71..12b9a2d5c8746172e1d0ef5bdbfc36f9e0a59dd5 100644 (file)
@@ -170,7 +170,7 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
                return EINVALID_CMD_LINE;
        }
        
-       if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_READ)) {
+       if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_READ, NULL)) {
                log_error("Unable to obtain global lock.");
                return ECMD_FAILED;
        }
@@ -288,7 +288,7 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
                          arg_count(cmd, exported_ARG) ?
                          "of exported volume group(s)" : "in no volume group");
 
-       if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE)) {
+       if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE, NULL)) {
                log_error("Unable to obtain global lock.");
                return ECMD_FAILED;
        }
index 6e004f367c527e16ceec454482b2e9a7176a91d6..b238a61cf32b52f61a88854aca0976692137454f 100644 (file)
@@ -712,7 +712,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
 
        dm_list_init(&tags);
 
-       if (lock_global && !lock_vol(cmd, VG_GLOBAL, LCK_VG_READ)) {
+       if (lock_global && !lock_vol(cmd, VG_GLOBAL, LCK_VG_READ, NULL)) {
                log_error("Unable to obtain global lock.");
                return ECMD_FAILED;
        }
index 20ca16b35fa58bc9d91db3daaebc61e00ec4f394..618fa7e71d40264b375659ce96a6b6dfd57dfc8f 100644 (file)
@@ -47,12 +47,12 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
 
        lvmcache_seed_infos_from_lvmetad(cmd);
 
-       if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
+       if (!lock_vol(cmd, vg_name, LCK_VG_WRITE, NULL)) {
                log_error("Unable to lock volume group %s", vg_name);
                return ECMD_FAILED;
        }
 
-       if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+       if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
                log_error("Unable to lock orphans");
                unlock_vg(cmd, vg_name);
                return ECMD_FAILED;
index 8ce7803ae789dcc667eacd1303520d913cecae1b..9be9416d244543993abde6b1a92583d2825a3ff9 100644 (file)
@@ -70,7 +70,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
            !vg_set_mda_copies(vg, vp_new.vgmetadatacopies))
                goto bad_orphan;
 
-       if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+       if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
                log_error("Can't get lock for orphan PVs");
                goto bad_orphan;
        }
index 93d55a043f662e9b96e971b2485a7f601adf00f8..1f482b407788ae52c42b4f04c5a97e90a727a73c 100644 (file)
@@ -95,7 +95,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
                        goto bad;
                }
        } else { /* no --restore, normal vgextend */
-               if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+               if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
                        log_error("Can't get lock for orphan PVs");
                        unlock_and_release_vg(cmd, vg, vg_name);
                        return ECMD_FAILED;
index c068b26ed63aa0f7e3a6aaa34960325fab6f732f..880389933155ac84c282519d1916353c95d6cdea 100644 (file)
@@ -146,7 +146,7 @@ static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
                return ECMD_FAILED;
        }
 
-       if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+       if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
                log_error("Can't get lock for orphan PVs");
                return ECMD_FAILED;
        }
index 99124ef1c4be7ff2a81d9bf320a121aced8a81f8..baf25b002702d1b36676ff8638c55ad39149ba1b 100644 (file)
@@ -37,7 +37,7 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)
                return EINVALID_CMD_LINE;
        }
 
-       if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE)) {
+       if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE, NULL)) {
                log_error("Unable to obtain global lock.");
                return ECMD_FAILED;
        }
This page took 0.080335 seconds and 5 git commands to generate.