]> sourceware.org Git - lvm2.git/commitdiff
Change LV locking macros to take lv instead of lvid.
authorAlasdair Kergon <agk@redhat.com>
Mon, 15 Aug 2005 12:00:04 +0000 (12:00 +0000)
committerAlasdair Kergon <agk@redhat.com>
Mon, 15 Aug 2005 12:00:04 +0000 (12:00 +0000)
12 files changed:
WHATS_NEW
lib/locking/locking.c
lib/locking/locking.h
tools/lvchange.c
tools/lvconvert.c
tools/lvcreate.c
tools/lvremove.c
tools/lvrename.c
tools/lvresize.c
tools/pvmove.c
tools/vgchange.c
tools/vgreduce.c

index 4af0990fbaf765b19a438c9bb7952e4e51f3925c..d309658eedecf2cacc1121335da3e30532374ec3 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.01.15 - 
 =================================
+  Change LV locking macros to take lv instead of lvid.
   Prepend 'cluster' activation parameter to mirror log when appropriate.
   Pass exclusive flag to lv_activate and on to target activation code.
   Prevent snapshot creation in a clustered VG for now.
index 0e90aa3a89641c5e5e26796936185f7675345fe9..4437c3d5f4fcaa322aff4fe7d76ea216837e1e8b 100644 (file)
@@ -268,7 +268,7 @@ int resume_lvs(struct cmd_context *cmd, struct list *lvs)
        struct lv_list *lvl;
 
        list_iterate_items(lvl, lvs)
-               resume_lv(cmd, lvl->lv->lvid.s);
+               resume_lv(cmd, lvl->lv);
 
        return 1;
 }
@@ -280,11 +280,11 @@ int suspend_lvs(struct cmd_context *cmd, struct list *lvs)
        struct lv_list *lvl;
 
        list_iterate_items(lvl, lvs) {
-               if (!suspend_lv(cmd, lvl->lv->lvid.s)) {
+               if (!suspend_lv(cmd, lvl->lv)) {
                        log_error("Failed to suspend %s", lvl->lv->name);
                        list_uniterate(lvh, lvs, &lvl->list) {
                                lvl = list_item(lvh, struct lv_list);
-                               resume_lv(cmd, lvl->lv->lvid.s);
+                               resume_lv(cmd, lvl->lv);
                        }
 
                        return 0;
@@ -301,11 +301,11 @@ int activate_lvs_excl(struct cmd_context *cmd, struct list *lvs)
        struct lv_list *lvl;
 
        list_iterate_items(lvl, lvs) {
-               if (!activate_lv_excl(cmd, lvl->lv->lvid.s)) {
+               if (!activate_lv_excl(cmd, lvl->lv)) {
                        log_error("Failed to activate %s", lvl->lv->name);
                        list_uniterate(lvh, lvs, &lvl->list) {
                                lvl = list_item(lvh, struct lv_list);
-                               activate_lv(cmd, lvl->lv->lvid.s);
+                               activate_lv(cmd, lvl->lv);
                        }
 
                        return 0;
index c2fcb5a9b2cbcc395d096a0dbf0d4f6edc6e9b9b..ad0cada069bad66f28483a8971585b0866830b83 100644 (file)
@@ -81,16 +81,16 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
 
 #define unlock_vg(cmd, vol)    lock_vol(cmd, vol, LCK_VG_UNLOCK)
 
-#define resume_lv(cmd, vol)    lock_vol(cmd, vol, LCK_LV_RESUME)
-#define suspend_lv(cmd, vol)   lock_vol(cmd, vol, LCK_LV_SUSPEND | LCK_HOLD)
-#define deactivate_lv(cmd, vol)        lock_vol(cmd, vol, LCK_LV_DEACTIVATE)
-#define activate_lv(cmd, vol)  lock_vol(cmd, vol, LCK_LV_ACTIVATE | LCK_HOLD)
-#define activate_lv_excl(cmd, vol)     \
-                               lock_vol(cmd, vol, LCK_LV_EXCLUSIVE | LCK_HOLD)
-#define activate_lv_local(cmd, vol)    \
-       lock_vol(cmd, vol, LCK_LV_ACTIVATE | LCK_HOLD | LCK_LOCAL)
-#define deactivate_lv_local(cmd, vol)  \
-       lock_vol(cmd, vol, LCK_LV_DEACTIVATE | LCK_LOCAL)
+#define resume_lv(cmd, lv)     lock_vol(cmd, (lv)->lvid.s, LCK_LV_RESUME)
+#define suspend_lv(cmd, lv)    lock_vol(cmd, (lv)->lvid.s, LCK_LV_SUSPEND | LCK_HOLD)
+#define deactivate_lv(cmd, lv) lock_vol(cmd, (lv)->lvid.s, LCK_LV_DEACTIVATE)
+#define activate_lv(cmd, lv)   lock_vol(cmd, (lv)->lvid.s, LCK_LV_ACTIVATE | LCK_HOLD)
+#define activate_lv_excl(cmd, lv)      \
+                               lock_vol(cmd, (lv)->lvid.s, LCK_LV_EXCLUSIVE | LCK_HOLD)
+#define activate_lv_local(cmd, lv)     \
+       lock_vol(cmd, (lv)->lvid.s, LCK_LV_ACTIVATE | LCK_HOLD | LCK_LOCAL)
+#define deactivate_lv_local(cmd, lv)   \
+       lock_vol(cmd, (lv)->lvid.s, LCK_LV_DEACTIVATE | LCK_LOCAL)
 
 /* Process list of LVs */
 int suspend_lvs(struct cmd_context *cmd, struct list *lvs);
index 036ba6092da03d62017788291cd0515286764d1c..b1b1434e5b3d6c9eae31feb02749f998692a5a9e 100644 (file)
@@ -52,19 +52,19 @@ static int lvchange_permission(struct cmd_context *cmd,
 
        backup(lv->vg);
 
-       if (!suspend_lv(cmd, lv->lvid.s)) {
+       if (!suspend_lv(cmd, lv)) {
                log_error("Failed to lock %s", lv->name);
                vg_revert(lv->vg);
                return 0;
        }
 
        if (!vg_commit(lv->vg)) {
-               resume_lv(cmd, lv->lvid.s);
+               resume_lv(cmd, lv);
                return 0;
        }
 
        log_very_verbose("Updating permissions for \"%s\" in kernel", lv->name);
-       if (!resume_lv(cmd, lv->lvid.s)) {
+       if (!resume_lv(cmd, lv)) {
                log_error("Problem reactivating %s", lv->name);
                return 0;
        }
@@ -83,13 +83,13 @@ static int lvchange_availability(struct cmd_context *cmd,
        if (activate == CHANGE_ALN) {
                log_verbose("Deactivating logical volume \"%s\" locally",
                            lv->name);
-               if (!deactivate_lv_local(cmd, lv->lvid.s)) {
+               if (!deactivate_lv_local(cmd, lv)) {
                        stack;
                        return 0;
                }
        } else if (activate == CHANGE_AN) {
                log_verbose("Deactivating logical volume \"%s\"", lv->name);
-               if (!deactivate_lv(cmd, lv->lvid.s)) {
+               if (!deactivate_lv(cmd, lv)) {
                        stack;
                        return 0;
                }
@@ -103,21 +103,21 @@ static int lvchange_availability(struct cmd_context *cmd,
                if (lv_is_origin(lv) || (activate == CHANGE_AE)) {
                        log_verbose("Activating logical volume \"%s\" "
                                    "exclusively", lv->name);
-                       if (!activate_lv_excl(cmd, lv->lvid.s)) {
+                       if (!activate_lv_excl(cmd, lv)) {
                                stack;
                                return 0;
                        }
                } else if (activate == CHANGE_ALY) {
                        log_verbose("Activating logical volume \"%s\" locally",
                                    lv->name);
-                       if (!activate_lv_local(cmd, lv->lvid.s)) {
+                       if (!activate_lv_local(cmd, lv)) {
                                stack;
                                return 0;
                        }
                } else {
                        log_verbose("Activating logical volume \"%s\"",
                                    lv->name);
-                       if (!activate_lv(cmd, lv->lvid.s)) {
+                       if (!activate_lv(cmd, lv)) {
                                stack;
                                return 0;
                        }
@@ -137,7 +137,7 @@ static int lvchange_availability(struct cmd_context *cmd,
 static int lvchange_refresh(struct cmd_context *cmd, struct logical_volume *lv)
 {
        log_verbose("Refreshing logical volume \"%s\" (if active)", lv->name);
-       if (!suspend_lv(cmd, lv->lvid.s) || !resume_lv(cmd, lv->lvid.s))
+       if (!suspend_lv(cmd, lv) || !resume_lv(cmd, lv))
                return 0;
 
        return 1;
@@ -216,19 +216,19 @@ static int lvchange_readahead(struct cmd_context *cmd,
 
        backup(lv->vg);
 
-       if (!suspend_lv(cmd, lv->lvid.s)) {
+       if (!suspend_lv(cmd, lv)) {
                log_error("Failed to lock %s", lv->name);
                vg_revert(lv->vg);
                return 0;
        }
 
        if (!vg_commit(lv->vg)) {
-               resume_lv(cmd, lv->lvid.s);
+               resume_lv(cmd, lv);
                return 0;
        }
 
        log_very_verbose("Updating permissions for \"%s\" in kernel", lv->name);
-       if (!resume_lv(cmd, lv->lvid.s)) {
+       if (!resume_lv(cmd, lv)) {
                log_error("Problem reactivating %s", lv->name);
                return 0;
        }
@@ -274,7 +274,7 @@ static int lvchange_persistent(struct cmd_context *cmd,
                        active = 1;
                }
                log_verbose("Ensuring %s is inactive.", lv->name);
-               if (!deactivate_lv(cmd, lv->lvid.s)) {
+               if (!deactivate_lv(cmd, lv)) {
                        log_error("%s: deactivation failed", lv->name);
                        return 0;
                }
@@ -286,7 +286,7 @@ static int lvchange_persistent(struct cmd_context *cmd,
                if (active) {
                        log_verbose("Re-activating logical volume \"%s\"",
                                    lv->name);
-                       if (!activate_lv(cmd, lv->lvid.s)) {
+                       if (!activate_lv(cmd, lv)) {
                                log_error("%s: reactivation failed", lv->name);
                                return 0;
                        }
@@ -301,19 +301,19 @@ static int lvchange_persistent(struct cmd_context *cmd,
 
        backup(lv->vg);
 
-       if (!suspend_lv(cmd, lv->lvid.s)) {
+       if (!suspend_lv(cmd, lv)) {
                log_error("Failed to lock %s", lv->name);
                vg_revert(lv->vg);
                return 0;
        }
 
        if (!vg_commit(lv->vg)) {
-               resume_lv(cmd, lv->lvid.s);
+               resume_lv(cmd, lv);
                return 0;
        }
 
        log_very_verbose("Updating permissions for \"%s\" in kernel", lv->name);
-       if (!resume_lv(cmd, lv->lvid.s)) {
+       if (!resume_lv(cmd, lv)) {
                log_error("Problem reactivating %s", lv->name);
                return 0;
        }
index 8f2ba8e51c8510cc4493c97c29938802d357c79d..d1d01b73789c3ab074e98a9bfbcc26f907f312fd 100644 (file)
@@ -93,20 +93,20 @@ static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * l
 
        backup(lv->vg);
 
-       if (!suspend_lv(cmd, lv->lvid.s)) {
+       if (!suspend_lv(cmd, lv)) {
                log_error("Failed to lock %s", lv->name);
                vg_revert(lv->vg);
                return 0;
        }
 
        if (!vg_commit(lv->vg)) {
-               resume_lv(cmd, lv->lvid.s);
+               resume_lv(cmd, lv);
                return 0;
        }
 
        log_very_verbose("Updating \"%s\" in kernel", lv->name);
 
-       if (!resume_lv(cmd, lv->lvid.s)) {
+       if (!resume_lv(cmd, lv)) {
                log_error("Problem reactivating %s", lv->name);
                return 0;
        }
index 74a4ce68c4c65f77a70782a1996f43a9bda520a1..aa3440d955b31dfb07152fd24d9276819683027b 100644 (file)
@@ -623,7 +623,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
                        goto error;
                }
 
-               if (!activate_lv(cmd, log_lv->lvid.s)) {
+               if (!activate_lv(cmd, log_lv)) {
                        log_error("Aborting. Failed to activate mirror log. "
                                  "Remove new LVs and retry.");
                        goto error;
@@ -635,7 +635,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
                        goto error;
                }
 
-               if (!deactivate_lv(cmd, log_lv->lvid.s)) {
+               if (!deactivate_lv(cmd, log_lv)) {
                        log_error("Aborting. Failed to deactivate mirror log. "
                                  "Remove new LV and retry.");
                        goto error;
@@ -711,7 +711,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
                return 0;
        }
 
-       if (!activate_lv(cmd, lv->lvid.s)) {
+       if (!activate_lv(cmd, lv)) {
                if (lp->snapshot)
                        /* FIXME Remove the failed lv we just added */
                        log_error("Aborting. Failed to activate snapshot "
@@ -737,13 +737,13 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
                /* Reset permission after zeroing */
                if (!(lp->permission & LVM_WRITE))
                        lv->status &= ~LVM_WRITE;
-               if (!deactivate_lv(cmd, lv->lvid.s)) {
+               if (!deactivate_lv(cmd, lv)) {
                        log_err("Couldn't deactivate new snapshot.");
                        return 0;
                }
 
                /* FIXME write/commit/backup sequence issue */
-               if (!suspend_lv(cmd, org->lvid.s)) {
+               if (!suspend_lv(cmd, org)) {
                        log_error("Failed to suspend origin %s", org->name);
                        return 0;
                }
@@ -758,7 +758,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
                if (!vg_write(vg) || !vg_commit(vg))
                        return 0;
 
-               if (!resume_lv(cmd, org->lvid.s)) {
+               if (!resume_lv(cmd, org)) {
                        log_error("Problem reactivating origin %s", org->name);
                        return 0;
                }
index 18cac809ca3370b8148440469813d31e832dfb5a..a523c7084222a308faf11971aeb602cc007d576a 100644 (file)
@@ -74,7 +74,7 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
        if (!archive(vg))
                return ECMD_FAILED;
 
-       if (!deactivate_lv(cmd, lv->lvid.s)) {
+       if (!deactivate_lv(cmd, lv)) {
                log_error("Unable to deactivate logical volume \"%s\"",
                          lv->name);
                return ECMD_FAILED;
index bc042acbde800d13b8f4c7ca98561cb7c2eaed5e..a86385d0c163299062f371267a4dc8a789eb900d 100644 (file)
@@ -158,18 +158,18 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
 
        backup(lv->vg);
 
-       if (!suspend_lv(cmd, lv->lvid.s)) {
+       if (!suspend_lv(cmd, lv)) {
                stack;
                goto error;
        }
 
        if (!vg_commit(vg)) {
                stack;
-               resume_lv(cmd, lv->lvid.s);
+               resume_lv(cmd, lv);
                goto error;
        }
 
-       resume_lv(cmd, lv->lvid.s);
+       resume_lv(cmd, lv);
 
        unlock_vg(cmd, vg_name);
 
index 6ee149c0b3c96c91fd83f28e2a585853310768c8..f32801f5e0326e955920867b806df695bbcd40c3 100644 (file)
@@ -124,7 +124,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
        uint32_t extents_used = 0;
        uint32_t size_rest;
        alloc_policy_t alloc;
-       char *lock_lvid;
+       struct logical_volume *lock_lv;
        struct lv_list *lvl;
        int consistent = 1;
        struct lv_segment *seg;
@@ -518,11 +518,11 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
 
        /* If snapshot, must suspend all associated devices */
        if ((snap_seg = find_cow(lv)))
-               lock_lvid = snap_seg->origin->lvid.s;
+               lock_lv = snap_seg->origin;
        else
-               lock_lvid = lv->lvid.s;
+               lock_lv = lv;
 
-       if (!suspend_lv(cmd, lock_lvid)) {
+       if (!suspend_lv(cmd, lock_lv)) {
                log_error("Failed to suspend %s", lp->lv_name);
                vg_revert(vg);
                return ECMD_FAILED;
@@ -530,11 +530,11 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
 
        if (!vg_commit(vg)) {
                stack;
-               resume_lv(cmd, lock_lvid);
+               resume_lv(cmd, lock_lv);
                return ECMD_FAILED;
        }
 
-       if (!resume_lv(cmd, lock_lvid)) {
+       if (!resume_lv(cmd, lock_lv)) {
                log_error("Problem reactivating %s", lp->lv_name);
                return ECMD_FAILED;
        }
index b51164598df0f91bf4c31a4609295dc4f06d3c6d..4348c4eed80d4f36cd9bbfcee2ca42e9febef06b 100644 (file)
@@ -219,7 +219,7 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
 
        /* Suspend mirrors on subsequent calls */
        if (!first_time) {
-               if (!suspend_lv(cmd, lv_mirr->lvid.s)) {
+               if (!suspend_lv(cmd, lv_mirr)) {
                        stack;
                        resume_lvs(cmd, lvs_changed);
                        vg_revert(vg);
@@ -231,7 +231,7 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
        if (!vg_commit(vg)) {
                log_error("ABORTING: Volume group metadata update failed.");
                if (!first_time)
-                       resume_lv(cmd, lv_mirr->lvid.s);
+                       resume_lv(cmd, lv_mirr);
                resume_lvs(cmd, lvs_changed);
                return 0;
        }
@@ -240,7 +240,7 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
        /* Only the first mirror segment gets activated as a mirror */
        /* FIXME: Add option to use a log */
        if (first_time) {
-               if (!activate_lv_excl(cmd, lv_mirr->lvid.s)) {
+               if (!activate_lv_excl(cmd, lv_mirr)) {
                        if (!test_mode())
                                log_error("ABORTING: Temporary mirror "
                                          "activation failed.  "
@@ -249,7 +249,7 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
                        resume_lvs(cmd, lvs_changed);
                        return 0;
                }
-       } else if (!resume_lv(cmd, lv_mirr->lvid.s)) {
+       } else if (!resume_lv(cmd, lv_mirr)) {
                log_error("Unable to reactivate logical volume \"%s\"",
                          lv_mirr->name);
                resume_lvs(cmd, lvs_changed);
@@ -318,7 +318,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
                }
 
                /* Ensure mirror LV is active */
-               if (!activate_lv_excl(cmd, lv_mirr->lvid.s)) {
+               if (!activate_lv_excl(cmd, lv_mirr)) {
                        log_error
                            ("ABORTING: Temporary mirror activation failed.");
                        unlock_vg(cmd, pv->vg_name);
@@ -415,7 +415,7 @@ static int _finish_pvmove(struct cmd_context *cmd, struct volume_group *vg,
        }
 
        /* Suspend mirror LV to flush pending I/O */
-       if (!suspend_lv(cmd, lv_mirr->lvid.s)) {
+       if (!suspend_lv(cmd, lv_mirr)) {
                log_error("Suspension of temporary mirror LV failed");
                r = 0;
        }
@@ -425,13 +425,13 @@ static int _finish_pvmove(struct cmd_context *cmd, struct volume_group *vg,
                log_error("ABORTING: Failed to write new data locations "
                          "to disk.");
                vg_revert(vg);
-               resume_lv(cmd, lv_mirr->lvid.s);
+               resume_lv(cmd, lv_mirr);
                resume_lvs(cmd, lvs_changed);
                return 0;
        }
 
        /* Release mirror LV.  (No pending I/O because it's been suspended.) */
-       if (!resume_lv(cmd, lv_mirr->lvid.s)) {
+       if (!resume_lv(cmd, lv_mirr)) {
                log_error("Unable to reactivate logical volume \"%s\"",
                          lv_mirr->name);
                r = 0;
@@ -441,7 +441,7 @@ static int _finish_pvmove(struct cmd_context *cmd, struct volume_group *vg,
        resume_lvs(cmd, lvs_changed);
 
        /* Deactivate mirror LV */
-       if (!deactivate_lv(cmd, lv_mirr->lvid.s)) {
+       if (!deactivate_lv(cmd, lv_mirr)) {
                log_error("ABORTING: Unable to deactivate temporary logical "
                          "volume \"%s\"", lv_mirr->name);
                r = 0;
index a1c9c80a55ca3976abac65c7080dc5ddd8741906..461caa940d7571d02eee4c2aa2f2ba83e302372d 100644 (file)
@@ -37,18 +37,18 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd,
                        continue;
 
                if (activate == CHANGE_AN) {
-                       if (!deactivate_lv(cmd, lv->lvid.s))
+                       if (!deactivate_lv(cmd, lv))
                                continue;
                } else if (activate == CHANGE_ALN) {
-                       if (!deactivate_lv_local(cmd, lv->lvid.s))
+                       if (!deactivate_lv_local(cmd, lv))
                                continue;
                } else if (lv_is_origin(lv) || (activate == CHANGE_AE)) {
-                       if (!activate_lv_excl(cmd, lv->lvid.s))
+                       if (!activate_lv_excl(cmd, lv))
                                continue;
                } else if (activate == CHANGE_ALY) {
-                       if (!activate_lv_local(cmd, lv->lvid.s))
+                       if (!activate_lv_local(cmd, lv))
                                continue;
-               } else if (!activate_lv(cmd, lv->lvid.s))
+               } else if (!activate_lv(cmd, lv))
                        continue;
 
                if ((lv->status & PVMOVE) &&
index 64b797d3975260fc37021733d9ea2faff9e7692f..c75b195a5b5d85318ff87ab6d53ab3c6d3530070 100644 (file)
@@ -61,7 +61,7 @@ static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv,
                log_verbose("Deactivating (if active) logical volume %s",
                            lv->name);
 
-               if (!deactivate_lv(cmd, lv->lvid.s)) {
+               if (!deactivate_lv(cmd, lv)) {
                        log_error("Failed to deactivate LV %s", lv->name);
                        return 0;
                }
@@ -69,7 +69,7 @@ static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv,
                log_verbose("Deactivating (if active) logical volume %s "
                            "(origin of %s)", snap_seg->origin->name, lv->name);
 
-               if (!deactivate_lv(cmd, snap_seg->origin->lvid.s)) {
+               if (!deactivate_lv(cmd, snap_seg->origin)) {
                        log_error("Failed to deactivate LV %s",
                                  snap_seg->origin->name);
                        return 0;
This page took 2.099823 seconds and 5 git commands to generate.