master - raid: add validation checks for reshape flags
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=93c02e2532c71f5afe9...
Commit: 93c02e2532c71f5afe91605442a8acc059df982c
Parent: b0618f90116bb723e568e3aeec6cdcfde342d6b2
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Wed Nov 15 21:24:44 2017 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Wed Nov 15 21:24:44 2017 +0100
raid: add validation checks for reshape flags
Enhance vg_validate() raid checking functions to check for
flags LV_RESHAPE and LV_RESHAPE_DELTA_DISKS_(MINUS|PLUS).
---
lib/metadata/merge.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c
index d5024cf..f0da2fe 100644
--- a/lib/metadata/merge.c
+++ b/lib/metadata/merge.c
@@ -98,6 +98,14 @@ int lv_merge_segments(struct logical_volume *lv)
return; \
}
+/* Check segment LV for reshape flags. */
+static int _check_raid_seg_reshape_flags(struct lv_segment *seg)
+{
+ return ((seg->lv->status & LV_RESHAPE) ||
+ (seg->lv->status & LV_RESHAPE_DELTA_DISKS_MINUS) ||
+ (seg->lv->status & LV_RESHAPE_DELTA_DISKS_PLUS));
+}
+
/* Check raid0 segment properties in @seg */
static void _check_raid0_seg(struct lv_segment *seg, int *error_count)
{
@@ -121,6 +129,8 @@ static void _check_raid0_seg(struct lv_segment *seg, int *error_count)
raid_seg_error_val("non-zero max recovery rate", seg->max_recovery_rate);
if ((seg->lv->status & LV_RESHAPE_DATA_OFFSET) || seg->data_offset > 1)
raid_seg_error_val("data_offset", seg->data_offset);
+ if (_check_raid_seg_reshape_flags(seg))
+ raid_seg_error("reshape");
}
/* Check RAID @seg for non-zero, power of 2 region size and min recovery rate <= max */
@@ -145,6 +155,8 @@ static void _check_raid1_seg(struct lv_segment *seg, int *error_count)
raid_seg_error_val("non-zero stripe size", seg->stripe_size);
if ((seg->lv->status & LV_RESHAPE_DATA_OFFSET) || seg->data_offset > 1)
raid_seg_error_val("data_offset", seg->data_offset);
+ if (_check_raid_seg_reshape_flags(seg))
+ raid_seg_error("reshape");
_check_raid_region_recovery(seg, error_count);
}
@@ -388,6 +400,9 @@ static void _check_lv_segment(struct logical_volume *lv, struct lv_segment *seg,
if (seg_is_raid(seg))
_check_raid_seg(seg, error_count);
+ else if (!lv_is_raid_type(lv) &&
+ _check_raid_seg_reshape_flags(seg))
+ seg_error("reshape");
if (seg_is_pool(seg)) {
if ((seg->area_count != 1) || (seg_type(seg, 0) != AREA_LV)) {
6 years, 4 months
master - tests: pvmove supports more cases
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b0618f90116bb723e56...
Commit: b0618f90116bb723e568e3aeec6cdcfde342d6b2
Parent: 0f0dc1a2a5f779fbdae7bddd12c3e56397636833
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Nov 11 00:15:15 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Nov 15 21:00:29 2017 +0100
tests: pvmove supports more cases
pvmove handles cached LVs as well as snapshots now.
---
test/shell/pvmove-cache-segtypes.sh | 37 ++++++++++++----------------------
test/shell/pvmove-raid-segtypes.sh | 1 -
test/shell/pvmove-thin-segtypes.sh | 1 -
3 files changed, 13 insertions(+), 26 deletions(-)
diff --git a/test/shell/pvmove-cache-segtypes.sh b/test/shell/pvmove-cache-segtypes.sh
index f95ba72..b5b341d 100644
--- a/test/shell/pvmove-cache-segtypes.sh
+++ b/test/shell/pvmove-cache-segtypes.sh
@@ -12,7 +12,6 @@
test_description="ensure pvmove works with the cache segment types"
SKIP_WITH_LVMLOCKD=1
-SKIP_WITH_CLVMD=1
. lib/inittest
@@ -41,28 +40,22 @@ do
# Testing pvmove of cache-pool LV (can't check contents though)
###############################################################
-lvcreate -l 2 -n ${lv1}_foo $vg "$dev1"
+lvcreate -aey -l 2 -n ${lv1}_foo $vg "$dev1"
lvcreate --type cache-pool -n ${lv1}_pool -l 4 $vg "$dev1"
check lv_tree_on $vg ${lv1}_foo "$dev1"
check lv_tree_on $vg ${lv1}_pool "$dev1"
pvmove $mode "$dev1" "$dev5" 2>&1 | tee out
-grep "Skipping cache-pool LV, ${lv1}_pool" out
-grep "Skipping cache-related LV, ${lv1}_pool_cmeta" out
-grep "Skipping cache-related LV, ${lv1}_pool_cdata" out
+lvs -a -o+devices $vg
+check lv_tree_on $vg ${lv1}_pool "$dev5"
check lv_tree_on $vg ${lv1}_foo "$dev5"
-not check lv_tree_on $vg ${lv1}_pool "$dev5"
-
-#pvmove $mode -n ${lv1}_pool "$dev5" "$dev4"
-#check lv_tree_on $vg ${lv1}_pool "$dev4"
-#check lv_tree_on $vg ${lv1}_foo "$dev5"
lvremove -ff $vg
dmsetup info -c | not grep $vg
# Testing pvmove of origin LV
#############################
-lvcreate -l 2 -n ${lv1}_foo $vg "$dev1"
+lvcreate -aey -l 2 -n ${lv1}_foo $vg "$dev1"
lvcreate --type cache-pool -n ${lv1}_pool -l 4 $vg "$dev5"
lvcreate --type cache -n $lv1 -l 8 $vg/${lv1}_pool "$dev1"
@@ -72,11 +65,10 @@ check lv_tree_on $vg ${lv1} "$dev1"
aux mkdev_md5sum $vg $lv1
pvmove $mode "$dev1" "$dev3" 2>&1 | tee out
-grep "Skipping cache LV, ${lv1}" out
check lv_tree_on $vg ${lv1}_foo "$dev3"
#check lv_tree_on $vg ${lv1}_pool "$dev5"
lvs -a -o name,attr,devices $vg
-not check lv_tree_on $vg ${lv1} "$dev3"
+check lv_tree_on $vg ${lv1} "$dev3"
#check dev_md5sum $vg $lv1
#pvmove $mode -n $lv1 "$dev3" "$dev1"
@@ -89,7 +81,7 @@ dmsetup info -c | not grep $vg
# Testing pvmove of a RAID origin LV
####################################
-lvcreate -l 2 -n ${lv1}_foo $vg "$dev1"
+lvcreate -aey -l 2 -n ${lv1}_foo $vg "$dev1"
lvcreate --type raid1 -m 1 -l 8 -n $lv1 $vg "$dev1" "$dev2"
lvcreate --type cache -l 4 -n ${lv1}_pool $vg/$lv1 "$dev5"
check lv_tree_on $vg ${lv1}_foo "$dev1"
@@ -98,9 +90,9 @@ check lv_tree_on $vg ${lv1}_pool "$dev5"
aux mkdev_md5sum $vg $lv1
pvmove $mode "$dev1" "$dev3" 2>&1 | tee out
-grep "Skipping cache LV, ${lv1}" out
check lv_tree_on $vg ${lv1}_foo "$dev3"
-not check lv_tree_on $vg ${lv1} "$dev2" "$dev3"
+lvs -a -o+devices $vg
+not check lv_tree_on $vg ${lv1} "$dev1"
#check lv_tree_on $vg ${lv1}_pool "$dev5"
#check dev_md5sum $vg $lv1 -- THIS IS WHERE THINGS FAIL IF PVMOVE NOT DISALLOWED
@@ -114,7 +106,7 @@ dmsetup info -c | not grep $vg
# Testing pvmove of a RAID cachepool (metadata and data)
########################################################
-lvcreate -l 2 -n ${lv1}_foo $vg "$dev1"
+lvcreate -aey -l 2 -n ${lv1}_foo $vg "$dev1"
lvcreate --type raid1 -L 6M -n meta $vg "$dev1" "$dev2"
lvcreate --type raid1 -L 4M -n ${lv1}_pool $vg "$dev1" "$dev2"
lvconvert --yes --type cache-pool $vg/${lv1}_pool --poolmetadata $vg/meta
@@ -128,11 +120,8 @@ aux mkdev_md5sum $vg $lv1
# This will move ${lv1}_foo and the cache-pool data & meta
# LVs, both of which contain a RAID1 _rimage & _rmeta LV - 5 total LVs
pvmove $mode "$dev1" "$dev3" 2>&1 | tee out
-grep "Skipping cache-pool LV, ${lv1}_pool" out
-grep "Skipping cache-related LV, ${lv1}_pool_cmeta" out
-grep "Skipping cache-related LV, ${lv1}_pool_cdata" out
check lv_tree_on $vg ${lv1}_foo "$dev3"
-not check lv_tree_on $vg ${lv1}_pool "$dev2" "$dev3"
+not check lv_tree_on $vg ${lv1}_pool "$dev1"
#check lv_tree_on $vg ${lv1} "$dev5"
#check dev_md5sum $vg $lv1
@@ -146,7 +135,7 @@ dmsetup info -c | not grep $vg
# Testing pvmove of Thin-pool on cache LV on RAID
#################################################
-lvcreate -l 2 -n ${lv1}_foo $vg "$dev1"
+lvcreate -aey -l 2 -n ${lv1}_foo $vg "$dev1"
# RAID for cachepool
lvcreate --type raid1 -m 1 -L 6M -n meta $vg "$dev1" "$dev2"
lvcreate --type raid1 -m 1 -L 4M -n cachepool $vg "$dev1" "$dev2"
@@ -156,7 +145,7 @@ lvcreate --type raid1 -m 1 -L 8 -n thinpool $vg "$dev3" "$dev4"
# Convert thin pool data to a cached LV
lvconvert --type cache -Zy $vg/thinpool --cachepool $vg/cachepool
# Create simple thin pool meta
-lvcreate -L 2M -n meta $vg "$dev1"
+lvcreate -aey -L 2M -n meta $vg "$dev1"
# Use thin pool data LV to build a thin pool
lvconvert --yes --thinpool $vg/thinpool --poolmetadata $vg/meta
# Create a thin lv for fun
@@ -172,7 +161,7 @@ lvs -a -o name,attr,devices $vg
pvmove $mode "$dev1" "$dev5" 2>&1 | tee out
lvs -a -o name,attr,devices $vg
check lv_tree_on $vg ${lv1}_foo "$dev5"
-not check lv_tree_on $vg cachepool "$dev5" "$dev2"
+not check lv_tree_on $vg cachepool "$dev1"
check lv_tree_on $vg thinpool "$dev3" "$dev4" "$dev5" # Move non-cache tmeta
#check dev_md5sum $vg/thin_lv
diff --git a/test/shell/pvmove-raid-segtypes.sh b/test/shell/pvmove-raid-segtypes.sh
index 667c7d9..be41547 100644
--- a/test/shell/pvmove-raid-segtypes.sh
+++ b/test/shell/pvmove-raid-segtypes.sh
@@ -12,7 +12,6 @@
test_description="ensure pvmove works with raid segment types"
SKIP_WITH_LVMLOCKD=1
-SKIP_WITH_CLVMD=1
. lib/inittest
diff --git a/test/shell/pvmove-thin-segtypes.sh b/test/shell/pvmove-thin-segtypes.sh
index 28f5233..01d98b4 100644
--- a/test/shell/pvmove-thin-segtypes.sh
+++ b/test/shell/pvmove-thin-segtypes.sh
@@ -12,7 +12,6 @@
test_description="ensure pvmove works with thin segment types"
SKIP_WITH_LVMLOCKD=1
-SKIP_WITH_CLVMD=1
. lib/inittest
6 years, 4 months
master - pvmove: remove unusued code
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0f0dc1a2a5f779fbdae...
Commit: 0f0dc1a2a5f779fbdae7bddd12c3e56397636833
Parent: b978f505ff05c3581ccc633442b04c5d391add04
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 10 21:48:33 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Nov 15 21:00:29 2017 +0100
pvmove: remove unusued code
Support for snapshot and cache LVs should now work.
Remove protection rejecting pvmove for them.
---
lib/locking/locking.c | 61 -------------------------------------------
lib/locking/locking.h | 4 ---
tools/pvmove.c | 68 -------------------------------------------------
3 files changed, 0 insertions(+), 133 deletions(-)
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index acf3327..c68d4c7 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -371,67 +371,6 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, const str
return 1;
}
-/* Unlock list of LVs */
-int resume_lvs(struct cmd_context *cmd, struct dm_list *lvs)
-{
- struct lv_list *lvl;
- int r = 1;
-
- dm_list_iterate_items(lvl, lvs)
- if (!resume_lv(cmd, lvl->lv)) {
- r = 0;
- stack;
- }
-
- return r;
-}
-
-/* Unlock and revert list of LVs */
-int revert_lvs(struct cmd_context *cmd, struct dm_list *lvs)
-{
- struct lv_list *lvl;
- int r = 1;
-
- dm_list_iterate_items(lvl, lvs)
- if (!revert_lv(cmd, lvl->lv)) {
- r = 0;
- stack;
- }
-
- return r;
-}
-/*
- * Lock a list of LVs.
- * On failure to lock any LV, calls vg_revert() if vg_to_revert is set and
- * then unlocks any LVs on the list already successfully locked.
- */
-int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs,
- struct volume_group *vg_to_revert)
-{
- struct lv_list *lvl;
-
- dm_list_iterate_items(lvl, lvs) {
- if (!suspend_lv(cmd, lvl->lv)) {
- log_error("Failed to suspend %s", display_lvname(lvl->lv));
- if (vg_to_revert)
- vg_revert(vg_to_revert);
- /*
- * FIXME Should be
- * dm_list_uniterate(lvh, lvs, &lvl->list) {
- * lvl = dm_list_item(lvh, struct lv_list);
- * but revert would need fixing to use identical tree deps first.
- */
- dm_list_iterate_items(lvl, lvs)
- if (!revert_lv(cmd, lvl->lv))
- stack;
-
- return 0;
- }
- }
-
- return 1;
-}
-
/*
* First try to activate exclusively locally.
* Then if the VG is clustered and the LV is not yet active (e.g. due to
diff --git a/lib/locking/locking.h b/lib/locking/locking.h
index 4b5490e..47841ed 100644
--- a/lib/locking/locking.h
+++ b/lib/locking/locking.h
@@ -262,10 +262,6 @@ int sync_dev_names(struct cmd_context* cmd);
/* Process list of LVs */
struct volume_group;
-int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs,
- struct volume_group *vg_to_revert);
-int resume_lvs(struct cmd_context *cmd, struct dm_list *lvs);
-int revert_lvs(struct cmd_context *cmd, struct dm_list *lvs);
int activate_lvs(struct cmd_context *cmd, struct dm_list *lvs);
#endif
diff --git a/tools/pvmove.c b/tools/pvmove.c
index ff36b55..7bf1713 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -303,32 +303,6 @@ static int _sub_lv_of(struct logical_volume *lv, const char *lv_name)
return _sub_lv_of(seg->lv, lv_name);
}
-/*
- * parent_lv_is_cache_type
- *
- * FIXME: This function can be removed when 'pvmove' is supported for
- * cache types.
- *
- * If this LV is below a cache LV (at any depth), return 1.
- */
-static int _parent_lv_is_cache_type(struct logical_volume *lv)
-{
- struct lv_segment *seg;
-
- /* Sub-LVs only ever have one segment using them */
- if (dm_list_size(&lv->segs_using_this_lv) != 1)
- return 0;
-
- if (!(seg = get_only_segment_using_this_lv(lv)))
- return_0;
-
- if (lv_is_cache_type(seg->lv))
- return 1;
-
- /* Continue up the tree */
- return _parent_lv_is_cache_type(seg->lv);
-}
-
/* Create new LV with mirror segments for the required copies */
static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
struct volume_group *vg,
@@ -450,48 +424,6 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
if (!lv_is_on_pvs(lv, source_pvl))
continue;
- if (lv_is_cache_type(lv)) {
- log_print_unless_silent("Skipping %s LV, %s.",
- lv_is_cache(lv) ? "cache" :
- lv_is_cache_pool(lv) ?
- "cache-pool" : "cache-related",
- lv->name);
- lv_skipped = 1;
- continue;
- }
-
- if (_parent_lv_is_cache_type(lv)) {
- log_print_unless_silent("Skipping %s because a parent"
- " is of cache type.", lv->name);
- lv_skipped = 1;
- continue;
- }
-
- /*
- * If the VG is clustered, we are unable to handle
- * snapshots, origins, thin types, RAID or mirror
- */
- if ((vg_is_clustered(vg) || is_lockd_type(vg->lock_type)) &&
- (lv_is_origin(lv) || lv_is_cow(lv) ||
- lv_is_thin_type(lv) || lv_is_raid_type(lv))) {
- log_print_unless_silent("Skipping %s LV %s.",
- lv_is_origin(lv) ? "origin" :
- lv_is_cow(lv) ?
- "snapshot-related" :
- lv_is_thin_volume(lv) ? "thin" :
- lv_is_thin_pool(lv) ?
- "thin-pool" :
- lv_is_thin_type(lv) ?
- "thin-related" :
- seg_is_raid(first_seg(lv)) ?
- "RAID" :
- lv_is_raid_type(lv) ?
- "RAID-related" : "",
- lv->name);
- lv_skipped = 1;
- continue;
- }
-
seg = first_seg(lv);
if (seg_is_raid(seg) || seg_is_mirrored(seg) ||
lv_is_thin_volume(lv) || lv_is_thin_pool(lv)) {
6 years, 4 months
master - pvmove: activation changes
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b978f505ff05c3581cc...
Commit: b978f505ff05c3581ccc633442b04c5d391add04
Parent: a25f9b210692fe5cd164441b76a78b11fb4ee4e5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Nov 15 14:26:10 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Nov 15 21:00:26 2017 +0100
pvmove: activation changes
Do not use precommitted LV for suspend of pvmoving LVs.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 32 ++++----------------------------
2 files changed, 5 insertions(+), 28 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index b1454a3..ff60758 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.177 -
====================================
+ Avoid using precommitted metadata for suspending pvmove tree.
Ehnance pvmove locking.
Deactivate activated LVs on error path when pvmove activation fails.
Add "io" to log/debug_classes for logging low-level I/O.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index d6189bb..efcecde 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2214,10 +2214,6 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
/* FIXME Consider aborting here */
stack;
- critical_section_inc(cmd, "suspending");
- if (pvmove_lv)
- critical_section_inc(cmd, "suspending pvmove LV");
-
if (!laopts->origin_only &&
(lv_is_origin(lv_pre) || lv_is_cow(lv_pre)))
lockfs = 1;
@@ -2229,30 +2225,10 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
if (laopts->origin_only && lv_is_thin_volume(lv) && lv_is_thin_volume(lv_pre))
lockfs = 1;
- /*
- * Suspending an LV directly above a PVMOVE LV also
- * suspends other LVs using that same PVMOVE LV.
- * FIXME Remove this and delay the 'clear node' until
- * after the code knows whether there's a different
- * inactive table to load or not instead so lv_suspend
- * can be called separately for each LV safely.
- */
- if ((lv_pre->vg->status & PRECOMMITTED) &&
- lv_is_locked(lv_pre) && find_pvmove_lv_in_lv(lv_pre)) {
- if (!_lv_suspend_lv(lv_pre, laopts, lockfs, flush_required)) {
- critical_section_dec(cmd, "failed precommitted suspend");
- if (pvmove_lv)
- critical_section_dec(cmd, "failed precommitted suspend (pvmove)");
- goto_out;
- }
- } else {
- /* Normal suspend */
- if (!_lv_suspend_lv(lv, laopts, lockfs, flush_required)) {
- critical_section_dec(cmd, "failed suspend");
- if (pvmove_lv)
- critical_section_dec(cmd, "failed suspend (pvmove)");
- goto_out;
- }
+ critical_section_inc(cmd, "suspending");
+ if (!_lv_suspend_lv(lv, laopts, lockfs, flush_required)) {
+ critical_section_dec(cmd, "failed suspend");
+ goto_out;
}
r = 1;
6 years, 4 months
master - pvmove: change locking on finish
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a25f9b210692fe5cd16...
Commit: a25f9b210692fe5cd164441b76a78b11fb4ee4e5
Parent: 9d04ecc7b3574efb1772e84e8796b7044b830220
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 14 20:53:55 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Nov 15 14:07:00 2017 +0100
pvmove: change locking on finish
---
WHATS_NEW | 1 +
tools/pvmove_poll.c | 49 +++++++++++++++----------------------------------
2 files changed, 16 insertions(+), 34 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 728cc4f..b1454a3 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.177 -
====================================
+ Ehnance pvmove locking.
Deactivate activated LVs on error path when pvmove activation fails.
Add "io" to log/debug_classes for logging low-level I/O.
Eliminate redundant nested VG metadata in VG struct.
diff --git a/tools/pvmove_poll.c b/tools/pvmove_poll.c
index 5bddee4..36c2d0c 100644
--- a/tools/pvmove_poll.c
+++ b/tools/pvmove_poll.c
@@ -92,6 +92,8 @@ int pvmove_update_metadata(struct cmd_context *cmd, struct volume_group *vg,
int pvmove_finish(struct cmd_context *cmd, struct volume_group *vg,
struct logical_volume *lv_mirr, struct dm_list *lvs_changed)
{
+ struct lv_list *lvl;
+ struct logical_volume *holder;
int r = 1;
if (!dm_list_empty(lvs_changed) &&
@@ -101,48 +103,27 @@ int pvmove_finish(struct cmd_context *cmd, struct volume_group *vg,
return 0;
}
- /* Store metadata without dependencies on mirror segments */
- if (!vg_write(vg)) {
- log_error("ABORTING: Failed to write new data locations "
- "to disk.");
- return 0;
- }
+ if (!lv_update_and_reload(lv_mirr))
+ return_0;
- /* Suspend LVs changed (implicitly suspends lv_mirr) */
- if (!suspend_lvs(cmd, lvs_changed, vg)) {
- log_error("ABORTING: Locking LVs to remove temporary mirror failed");
- if (!revert_lv(cmd, lv_mirr))
- stack;
- return 0;
+ /* Takes locks and resumed volumes (should be still suspended, but preloaded) */
+ dm_list_iterate_items(lvl, lvs_changed) {
+ holder = (struct logical_volume *) lv_lock_holder(lvl->lv);
+ if (!resume_lv(cmd, holder)) {
+ log_error("Failed to reactivate logical volume %s.",
+ display_lvname(holder));
+ r = 0; /* But try to resume as much as we can */
+ }
}
- /* Store metadata without dependencies on mirror segments */
- if (!vg_commit(vg)) {
- log_error("ABORTING: Failed to write new data locations "
- "to disk.");
- if (!revert_lv(cmd, lv_mirr))
- stack;
- if (!revert_lvs(cmd, lvs_changed))
- stack;
+ if (!r)
return 0;
- }
-
- /* Unsuspend LVs */
- if (!resume_lvs(cmd, lvs_changed))
- stack;
-
- /* Release mirror LV. (No pending I/O because it's been suspended.) */
- if (!activate_lv_excl_local(cmd, lv_mirr)) {
- log_error("Unable to reactivate logical volume \"%s\"",
- lv_mirr->name);
- r = 0;
- }
/* Deactivate mirror LV */
if (!deactivate_lv(cmd, lv_mirr)) {
log_error("ABORTING: Unable to deactivate temporary logical "
"volume %s.", display_lvname(lv_mirr));
- r = 0;
+ return 0;
}
log_verbose("Removing temporary pvmove LV");
@@ -162,5 +143,5 @@ int pvmove_finish(struct cmd_context *cmd, struct volume_group *vg,
/* FIXME backup positioning */
backup(vg);
- return r;
+ return 1;
}
6 years, 4 months
master - cleanup: update log messages
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9d04ecc7b3574efb177...
Commit: 9d04ecc7b3574efb1772e84e8796b7044b830220
Parent: 838592a17119814adc5564569ef431fb0000c639
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 14 11:35:25 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Nov 15 14:03:22 2017 +0100
cleanup: update log messages
---
lib/locking/locking.c | 2 +-
tools/pvmove_poll.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index 0426744..acf3327 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -412,7 +412,7 @@ int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs,
dm_list_iterate_items(lvl, lvs) {
if (!suspend_lv(cmd, lvl->lv)) {
- log_error("Failed to suspend %s", lvl->lv->name);
+ log_error("Failed to suspend %s", display_lvname(lvl->lv));
if (vg_to_revert)
vg_revert(vg_to_revert);
/*
diff --git a/tools/pvmove_poll.c b/tools/pvmove_poll.c
index 438d458..5bddee4 100644
--- a/tools/pvmove_poll.c
+++ b/tools/pvmove_poll.c
@@ -141,7 +141,7 @@ int pvmove_finish(struct cmd_context *cmd, struct volume_group *vg,
/* Deactivate mirror LV */
if (!deactivate_lv(cmd, lv_mirr)) {
log_error("ABORTING: Unable to deactivate temporary logical "
- "volume \"%s\"", lv_mirr->name);
+ "volume %s.", display_lvname(lv_mirr));
r = 0;
}
6 years, 4 months
master - activate_lvs: use exclusive activation
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=838592a17119814adc5...
Commit: 838592a17119814adc5564569ef431fb0000c639
Parent: 8212e1047e2f42f4e13e2aadec5cf73b8d3a082e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 14 11:46:43 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Nov 15 14:03:22 2017 +0100
activate_lvs: use exclusive activation
There is no need to differentiation between clustered VG and normal VG.
As the activation depends on locking type.
Use unconditionally locally exclusive activation for pvmove.
---
lib/locking/locking.c | 11 +---
lib/locking/locking.h | 2 +-
tools/pvmove.c | 119 ++++++++----------------------------------------
3 files changed, 24 insertions(+), 108 deletions(-)
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index 067cd69..0426744 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -460,19 +460,14 @@ int activate_lv_excl(struct cmd_context *cmd, const struct logical_volume *lv)
}
/* Lock a list of LVs */
-int activate_lvs(struct cmd_context *cmd, struct dm_list *lvs, unsigned exclusive)
+int activate_lvs(struct cmd_context *cmd, struct dm_list *lvs)
{
struct dm_list *lvh;
struct lv_list *lvl;
dm_list_iterate_items(lvl, lvs) {
- if (!exclusive && !lv_is_active_exclusive(lvl->lv)) {
- if (!activate_lv(cmd, lvl->lv)) {
- log_error("Failed to activate %s", lvl->lv->name);
- return 0;
- }
- } else if (!activate_lv_excl(cmd, lvl->lv)) {
- log_error("Failed to activate %s", lvl->lv->name);
+ if (!activate_lv_excl_local(cmd, lvl->lv)) {
+ log_error("Failed to activate %s", display_lvname(lvl->lv));
dm_list_uniterate(lvh, lvs, &lvl->list) {
lvl = dm_list_item(lvh, struct lv_list);
if (!deactivate_lv(cmd, lvl->lv))
diff --git a/lib/locking/locking.h b/lib/locking/locking.h
index d39a725..4b5490e 100644
--- a/lib/locking/locking.h
+++ b/lib/locking/locking.h
@@ -266,6 +266,6 @@ int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs,
struct volume_group *vg_to_revert);
int resume_lvs(struct cmd_context *cmd, struct dm_list *lvs);
int revert_lvs(struct cmd_context *cmd, struct dm_list *lvs);
-int activate_lvs(struct cmd_context *cmd, struct dm_list *lvs, unsigned exclusive);
+int activate_lvs(struct cmd_context *cmd, struct dm_list *lvs);
#endif
diff --git a/tools/pvmove.c b/tools/pvmove.c
index 0f54a50..ff36b55 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -64,16 +64,6 @@ static int _pvmove_target_present(struct cmd_context *cmd, int clustered)
return found;
}
-static unsigned _pvmove_is_exclusive(struct cmd_context *cmd,
- struct volume_group *vg)
-{
- if (vg_is_clustered(vg))
- if (!_pvmove_target_present(cmd, 1))
- return 1;
-
- return 0;
-}
-
/* Allow /dev/vgname/lvname, vgname/lvname or lvname */
static const char *_extract_lvname(struct cmd_context *cmd, const char *vgname,
const char *arg)
@@ -346,8 +336,7 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
const char *lv_name,
struct dm_list *allocatable_pvs,
alloc_policy_t alloc,
- struct dm_list **lvs_changed,
- unsigned *exclusive)
+ struct dm_list **lvs_changed)
{
struct logical_volume *lv_mirr, *lv;
struct lv_segment *seg;
@@ -555,25 +544,6 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
return NULL;
}
- if (vg_is_clustered(vg) && lv_active_count && *exclusive) {
- log_error("Cannot move in clustered VG %s, "
- "clustered mirror (cmirror) not detected "
- "and LVs are activated non-exclusively.",
- vg->name);
- return NULL;
- }
-
- if (vg_is_clustered(vg) && lv_exclusive_count) {
- if (lv_active_count) {
- log_error("Cannot move in clustered VG %s "
- "if some LVs are activated "
- "exclusively while others don't.",
- vg->name);
- return NULL;
- }
- *exclusive = 1;
- }
-
if (!lv_add_mirrors(cmd, lv_mirr, 1, 1, 0, 0, log_count,
allocatable_pvs, alloc,
(arg_is_set(cmd, atomic_ARG)) ?
@@ -590,83 +560,37 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
return lv_mirr;
}
-static int _activate_lv(struct cmd_context *cmd, struct logical_volume *lv_mirr,
- unsigned exclusive)
-{
- int r = 0;
-
- if (exclusive || lv_is_active_exclusive(lv_mirr))
- r = activate_lv_excl(cmd, lv_mirr);
- else
- r = activate_lv(cmd, lv_mirr);
-
- if (!r)
- stack;
-
- return r;
-}
-
/*
* Called to set up initial pvmove LV only.
* (Not called after first or any other section completes.)
*/
-static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
- struct logical_volume *lv_mirr,
- struct dm_list *lvs_changed, unsigned exclusive)
+static int _update_metadata(struct logical_volume *lv_mirr,
+ struct dm_list *lvs_changed)
{
- int r = 0;
-
- log_verbose("Setting up pvmove in on-disk volume group metadata.");
- if (!vg_write(vg)) {
- log_error("ABORTING: Volume group metadata update failed.");
- return 0;
- }
-
- if (!suspend_lvs(cmd, lvs_changed, vg)) {
- log_error("ABORTING: Temporary pvmove mirror activation failed.");
- /* FIXME Add a recovery path for first time too. */
- return 0;
- }
+ struct lv_list *lvl;
+ struct logical_volume *lv = lv_mirr;
- /* Commit on-disk metadata */
- if (!vg_commit(vg)) {
- log_error("ABORTING: Volume group metadata update failed.");
- if (!resume_lvs(cmd, lvs_changed))
- log_error("Unable to resume logical volumes.");
- return 0;
+ dm_list_iterate_items(lvl, lvs_changed) {
+ lv = lvl->lv;
+ break;
}
- /* Activate the temporary mirror LV */
- /* Only the first mirror segment gets activated as a mirror */
- /* FIXME: Add option to use a log */
- if (!exclusive && _pvmove_is_exclusive(cmd, vg))
- exclusive = 1;
+ if (!lv_update_and_reload(lv))
+ return_0;
- if (!_activate_lv(cmd, lv_mirr, exclusive)) {
- if (test_mode()) {
- r = 1;
- goto out;
- }
+ /* Ensure mirror LV is active */
+ if (!activate_lv_excl_local(lv_mirr->vg->cmd, lv_mirr)) {
+ if (test_mode())
+ return 1;
/*
* FIXME Run --abort internally here.
*/
log_error("ABORTING: Temporary pvmove mirror activation failed. Run pvmove --abort.");
- goto out;
- }
-
- r = 1;
-
-out:
- if (!resume_lvs(cmd, lvs_changed)) {
- log_error("Unable to resume logical volumes.");
- r = 0;
+ return 0;
}
- if (r)
- backup(vg);
-
- return r;
+ return 1;
}
static int _copy_id_components(struct cmd_context *cmd,
@@ -698,7 +622,6 @@ static int _pvmove_setup_single(struct cmd_context *cmd,
struct logical_volume *lv = NULL;
const char *pv_name = pv_dev_name(pv);
unsigned flags = PVMOVE_FIRST_TIME;
- unsigned exclusive;
int r = ECMD_FAILED;
pp->found_pv = 1;
@@ -745,8 +668,6 @@ static int _pvmove_setup_single(struct cmd_context *cmd,
}
}
- exclusive = _pvmove_is_exclusive(cmd, vg);
-
if ((lv_mirr = find_pvmove_lv(vg, pv_dev(pv), PVMOVE))) {
log_print_unless_silent("Detected pvmove in progress for %s.", pv_name);
if (pp->pv_count || lv_name)
@@ -758,7 +679,7 @@ static int _pvmove_setup_single(struct cmd_context *cmd,
}
/* Ensure mirror LV is active */
- if (!_activate_lv(cmd, lv_mirr, exclusive)) {
+ if (!activate_lv_excl_local(cmd, lv_mirr)) {
log_error("ABORTING: Temporary mirror activation failed.");
goto out;
}
@@ -783,12 +704,12 @@ static int _pvmove_setup_single(struct cmd_context *cmd,
if (!(lv_mirr = _set_up_pvmove_lv(cmd, vg, source_pvl, lv_name,
allocatable_pvs, pp->alloc,
- &lvs_changed, &exclusive)))
+ &lvs_changed)))
goto_out;
}
/* Lock lvs_changed and activate (with old metadata) */
- if (!activate_lvs(cmd, lvs_changed, exclusive))
+ if (!activate_lvs(cmd, lvs_changed))
goto_out;
/* FIXME Presence of a mirror once set PVMOVE - now remove associated logic */
@@ -799,7 +720,7 @@ static int _pvmove_setup_single(struct cmd_context *cmd,
goto out;
if (flags & PVMOVE_FIRST_TIME)
- if (!_update_metadata(cmd, vg, lv_mirr, lvs_changed, exclusive))
+ if (!_update_metadata(lv_mirr, lvs_changed))
goto_out;
/* LVs are all in status LOCKED */
6 years, 4 months
master - pvmove: always flush when working with pvmove tree
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8212e1047e2f42f4e13...
Commit: 8212e1047e2f42f4e13e2aadec5cf73b8d3a082e
Parent: 35b207946a514c411e4d7c9be235e093ae5adf7d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Nov 15 12:07:47 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Nov 15 14:03:22 2017 +0100
pvmove: always flush when working with pvmove tree
---
lib/activate/activate.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 0dc67f2..d6189bb 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2204,7 +2204,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
* NOTE: Mirror repair requires noflush for proper repair!
* TODO: Relax this limiting condition further */
if (!flush_required &&
- (lv_is_pvmove(lv) ||
+ (lv_is_pvmove(lv) || pvmove_lv ||
(!lv_is_mirror(lv) && !lv_is_thin_pool(lv) && !lv_is_thin_volume(lv)))) {
log_debug("Requiring flush for LV %s.", display_lvname(lv));
flush_required = 1;
6 years, 4 months
master - activation: suspend pvmove using lv.
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=35b207946a514c411e4...
Commit: 35b207946a514c411e4d7c9be235e093ae5adf7d
Parent: 9e2a68a981a44579b19108554b8f89a860eb9d59
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Nov 15 12:08:33 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Nov 15 14:03:22 2017 +0100
activation: suspend pvmove using lv.
Whenever pvmove tree is going to be generated for suspend
and such LV has a user - use this 'using LV' to generate
correct dm tree holding all components.
---
lib/activate/activate.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 05aea85..0dc67f2 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2161,6 +2161,12 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
}
if (!_lv_preload(lv_pre_tmp, laopts, &flush_required))
goto_out;
+
+ /* Suspending 1st. LV above PVMOVE suspends whole tree */
+ dm_list_iterate_items(sl, &pvmove_lv->segs_using_this_lv) {
+ lv = sl->seg->lv;
+ break;
+ }
} else {
if (!_lv_preload(lv_pre, laopts, &flush_required))
/* FIXME Revert preloading */
6 years, 4 months
master - activation: check subLV before skipping resume
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9e2a68a981a44579b19...
Commit: 9e2a68a981a44579b19108554b8f89a860eb9d59
Parent: c820b43fc053689eac0a60cd732347c8eb30ad5d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 10 21:15:50 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Nov 15 14:03:22 2017 +0100
activation: check subLV before skipping resume
LV is asked for resume, and its already resume and tool
is inside 'critical_section()' check if there is any suspended sub LV.
In that case 'resume' operation will not be skipped.
---
lib/activate/activate.c | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 5542f84..05aea85 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2276,6 +2276,17 @@ int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned o
return _lv_suspend(cmd, lvid_s, &laopts, 0, lv, lv_pre);
}
+static int _check_suspended_lv(struct logical_volume *lv, void *data)
+{
+ struct lvinfo info;
+
+ if (lv_info(lv->vg->cmd, lv, 0, &info, 0, 0) && info.exists && info.suspended) {
+ log_debug("Found suspended LV %s in critical section().", display_lvname(lv));
+ return 0; /* There is suspended subLV in the tree */
+ }
+
+ return 1;
+}
static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
struct lv_activate_opts *laopts, int error_if_not_active,
@@ -2315,10 +2326,18 @@ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
if (!info.exists || !info.suspended) {
if (error_if_not_active)
goto_out;
- r = 1;
- if (!info.suspended)
- critical_section_dec(cmd, "already resumed");
- goto out;
+
+ if (!info.suspended && critical_section()) {
+ /* check if any subLV is suspended */
+ if ((r = for_each_sub_lv((struct logical_volume *)lv, &_check_suspended_lv, NULL))) {
+ /* Everything seems resumed */
+ critical_section_dec(cmd, "already resumed");
+ goto out;
+ }
+ } else {
+ r = 1;
+ goto out;
+ }
}
laopts->read_only = _passes_readonly_filter(cmd, lv);
6 years, 4 months