master - lv_manip: remove_layer_from_lv restore lv name
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ff30783a4f44c8...
Commit: ff30783a4f44c823544133260acb8c5171fbd0a6
Parent: 979d12eb4a69ad328a8583eaafc4d3d30e4d1771
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Nov 9 19:48:39 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 10 22:05:48 2014 +0100
lv_manip: remove_layer_from_lv restore lv name
Since we 'layer' for cache origin which and we support dropping
cache layer - we need to restore origin name in case
the origin LV is more complex target - i.e. raid.
Drop _corig from name
Cleanup and rename parent -> parent_lv.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 33 +++++++++++++++++++++++++--------
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6084ee7..f70c657 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ When remove_layer_from_lv() removes layer, restore subLV names.
Cache-pool in use becomes invisible LV.
Don't prompt for removal of _pmspare in VG without pool metadata LV.
Deactivation of snapshot origin detects and deactivates left-over snapshots.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 1943c07..99ed6d1 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5948,9 +5948,12 @@ int move_lv_segments(struct logical_volume *lv_to,
int remove_layer_from_lv(struct logical_volume *lv,
struct logical_volume *layer_lv)
{
- struct logical_volume *parent;
+ static const char _suffixes[][8] = { "_tdata", "_cdata", "_corig" };
+ struct logical_volume *parent_lv;
struct lv_segment *parent_seg;
struct segment_type *segtype;
+ struct lv_names lv_names;
+ int r;
log_very_verbose("Removing layer %s for %s", layer_lv->name, lv->name);
@@ -5959,8 +5962,8 @@ int remove_layer_from_lv(struct logical_volume *lv,
layer_lv->name, lv->name);
return 0;
}
- parent = parent_seg->lv;
- if (parent != lv) {
+ parent_lv = parent_seg->lv;
+ if (parent_lv != lv) {
log_error(INTERNAL_ERROR "Wrong layer %s in %s",
layer_lv->name, lv->name);
return 0;
@@ -5970,25 +5973,39 @@ int remove_layer_from_lv(struct logical_volume *lv,
* Before removal, the layer should be cleaned up,
* i.e. additional segments and areas should have been removed.
*/
- if (dm_list_size(&parent->segments) != 1 ||
+ if (dm_list_size(&parent_lv->segments) != 1 ||
parent_seg->area_count != 1 ||
seg_type(parent_seg, 0) != AREA_LV ||
layer_lv != seg_lv(parent_seg, 0) ||
- parent->le_count != layer_lv->le_count)
+ parent_lv->le_count != layer_lv->le_count)
return_0;
- if (!lv_empty(parent))
+ if (!lv_empty(parent_lv))
return_0;
- if (!move_lv_segments(parent, layer_lv, 0, 0))
+ if (!move_lv_segments(parent_lv, layer_lv, 0, 0))
return_0;
/* Replace the empty layer with error segment */
if (!(segtype = get_segtype_from_string(lv->vg->cmd, "error")))
return_0;
- if (!lv_add_virtual_segment(layer_lv, 0, parent->le_count, segtype))
+ if (!lv_add_virtual_segment(layer_lv, 0, parent_lv->le_count, segtype))
return_0;
+ /*
+ * recuresively rename sub LVs
+ * currently supported only for thin data layer
+ * FIXME: without strcmp it breaks mirrors....
+ */
+ for (r = 0; r < DM_ARRAY_SIZE(_suffixes); ++r)
+ if (strstr(layer_lv->name, _suffixes[r]) == 0) {
+ lv_names.old = layer_lv->name;
+ lv_names.new = parent_lv->name;
+ if (!for_each_sub_lv(parent_lv, _rename_cb, (void *) &lv_names))
+ return_0;
+ break;
+ }
+
return 1;
}
9 years, 7 months
master - lvremove: few more validation before archive
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=979d12eb4a69ad...
Commit: 979d12eb4a69ad328a8583eaafc4d3d30e4d1771
Parent: e2c4a3ef67261d4a8d32b62906b05e4292b47f90
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Nov 8 23:15:15 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 10 22:05:48 2014 +0100
lvremove: few more validation before archive
Before we finally call archive, we still can do a few more validation
without modifying VG. So delay archive() call few lines.
---
lib/metadata/lv_manip.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index b029395..1943c07 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5404,9 +5404,6 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
return 0;
}
- if (!archive(vg))
- return 0;
-
if (lv_is_cache(lv)) {
if (!lv_remove_single(cmd, first_seg(lv)->pool_lv, force,
suppress_remove_message)) {
@@ -5420,6 +5417,9 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
}
}
+ if (!archive(vg))
+ return 0;
+
if (lv_is_cow(lv)) {
/* Old format1 code */
if (!(lv->vg->fid->fmt->features & FMT_MDAS))
9 years, 7 months
master - segtype: add SEG_ONLY_EXCLUSIVE flag
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e2c4a3ef67261d...
Commit: e2c4a3ef67261d4a8d32b62906b05e4292b47f90
Parent: 0dc73f7dbd49308b1864444d1decfaf8e10d2d81
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 10 18:44:37 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 10 22:05:48 2014 +0100
segtype: add SEG_ONLY_EXCLUSIVE flag
Mark segtypes which do require exclusive activation in cluster.r
---
lib/cache_segtype/cache.c | 4 ++--
lib/metadata/lv.c | 15 ++++++++++-----
lib/metadata/segtype.h | 2 ++
lib/raid/raid.c | 2 +-
lib/snapshot/snapshot.c | 2 +-
lib/thin/thin.c | 4 ++--
6 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index 93027d7..dceb3c0 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -390,7 +390,7 @@ int init_cache_segtypes(struct cmd_context *cmd,
}
segtype->name = "cache-pool";
- segtype->flags = SEG_CACHE_POOL | SEG_CANNOT_BE_ZEROED;
+ segtype->flags = SEG_CACHE_POOL | SEG_CANNOT_BE_ZEROED | SEG_ONLY_EXCLUSIVE;
segtype->ops = &_cache_pool_ops;
if (!lvm_register_segtype(seglib, segtype))
@@ -404,7 +404,7 @@ int init_cache_segtypes(struct cmd_context *cmd,
}
segtype->name = "cache";
- segtype->flags = SEG_CACHE;
+ segtype->flags = SEG_CACHE | SEG_ONLY_EXCLUSIVE;
segtype->ops = &_cache_ops;
if (!lvm_register_segtype(seglib, segtype))
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index ed21894..bdf98f8 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -858,11 +858,16 @@ char *lv_host_dup(struct dm_pool *mem, const struct logical_volume *lv)
static int _lv_is_exclusive(struct logical_volume *lv)
{
- /* Some devices require exlusiveness */
- return lv_is_raid(lv) ||
- lv_is_origin(lv) ||
- lv_is_thin_type(lv) ||
- lv_is_cache_type(lv);
+ struct lv_segment *seg;
+
+ /* Some seg types require exclusive activation */
+ /* TODO: deep-scan of every segtype in use */
+ dm_list_iterate_items(seg, &lv->segments)
+ if (seg_only_exclusive(seg))
+ return 1;
+
+ /* Origin has no seg type require exlusiveness */
+ return lv_is_origin(lv);
}
int lv_active_change(struct cmd_context *cmd, struct logical_volume *lv,
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index 4635681..ecb598d 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -44,6 +44,7 @@ struct dev_manager;
#define SEG_CACHE 0x00002000U
#define SEG_CACHE_POOL 0x00004000U
#define SEG_MIRROR 0x00008000U
+#define SEG_ONLY_EXCLUSIVE 0x00010000U /* In cluster only exlusive activation */
#define SEG_UNKNOWN 0x80000000U
#define segtype_is_cache(segtype) ((segtype)->flags & SEG_CACHE ? 1 : 0)
@@ -78,6 +79,7 @@ struct dev_manager;
#define seg_can_split(seg) ((seg)->segtype->flags & SEG_CAN_SPLIT ? 1 : 0)
#define seg_cannot_be_zeroed(seg) ((seg)->segtype->flags & SEG_CANNOT_BE_ZEROED ? 1 : 0)
#define seg_monitored(seg) ((seg)->segtype->flags & SEG_MONITORED ? 1 : 0)
+#define seg_only_exclusive(seg) ((seg)->segtype->flags & SEG_ONLY_EXCLUSIVE ? 1 : 0)
struct segment_type {
struct dm_list list; /* Internal */
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index 6f4fe27..39e3a06 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -465,7 +465,7 @@ static struct segment_type *_init_raid_segtype(struct cmd_context *cmd,
segtype->ops = &_raid_ops;
segtype->name = rt->name;
- segtype->flags = SEG_RAID | rt->extra_flags | monitored;
+ segtype->flags = SEG_RAID | SEG_ONLY_EXCLUSIVE | rt->extra_flags | monitored;
segtype->parity_devs = rt->parity;
log_very_verbose("Initialised segtype: %s", segtype->name);
diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c
index b64e533..0886206 100644
--- a/lib/snapshot/snapshot.c
+++ b/lib/snapshot/snapshot.c
@@ -260,7 +260,7 @@ struct segment_type *init_segtype(struct cmd_context *cmd)
segtype->ops = &_snapshot_ops;
segtype->name = "snapshot";
- segtype->flags = SEG_SNAPSHOT | SEG_CANNOT_BE_ZEROED;
+ segtype->flags = SEG_SNAPSHOT | SEG_CANNOT_BE_ZEROED | SEG_ONLY_EXCLUSIVE;
#ifdef DEVMAPPER_SUPPORT
# ifdef DMEVENTD
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index bb13b2b..f921bef 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -753,9 +753,9 @@ int init_multiple_segtypes(struct cmd_context *cmd, struct segtype_library *segl
const char name[16];
uint32_t flags;
} reg_segtypes[] = {
- { &_thin_pool_ops, "thin-pool", SEG_THIN_POOL | SEG_CANNOT_BE_ZEROED },
+ { &_thin_pool_ops, "thin-pool", SEG_THIN_POOL | SEG_CANNOT_BE_ZEROED | SEG_ONLY_EXCLUSIVE },
/* FIXME Maybe use SEG_THIN_VOLUME instead of SEG_VIRTUAL */
- { &_thin_ops, "thin", SEG_THIN_VOLUME | SEG_VIRTUAL }
+ { &_thin_ops, "thin", SEG_THIN_VOLUME | SEG_VIRTUAL | SEG_ONLY_EXCLUSIVE }
};
struct segment_type *segtype;
9 years, 7 months
master - dmeventd: time scaling for status retry
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0dc73f7dbd4930...
Commit: 0dc73f7dbd49308b1864444d1decfaf8e10d2d81
Parent: 62c7027a7c675dfef8f772b1e20ac18705b847a9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Nov 8 01:29:01 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 10 22:05:48 2014 +0100
dmeventd: time scaling for status retry
In normal case it's too slow to wait 1 second for default.
So rather start with short time and increase sleep between status
retesting.
---
lib/activate/activate.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index ac6330f..7adb90f 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1649,7 +1649,7 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume
/* Check [un]monitor results */
/* Try a couple times if pending, but not forever... */
- for (i = 0; i < 10; i++) {
+ for (i = 0; i < 40; i++) {
pending = 0;
monitored = seg->segtype->ops->target_monitored(seg, &pending);
if (pending ||
@@ -1659,7 +1659,7 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume
lv->vg->name, lv->name, monitor ? "" : "un");
else
break;
- sleep(1);
+ usleep(10000 * i);
}
if (r)
9 years, 7 months
master - raid: fix activation order
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=62c7027a7c675d...
Commit: 62c7027a7c675dfef8f772b1e20ac18705b847a9
Parent: 32e4af6479689c4e25ecd273368d22136c93a75d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 10 22:04:44 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 10 22:05:48 2014 +0100
raid: fix activation order
Cannot 'activate' volumes in suspend state and we need to use
lock holding LV for suspend/resume.
---
lib/metadata/raid_manip.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 5237dc9..5eab551 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1136,7 +1136,7 @@ int lv_raid_split(struct logical_volume *lv, const char *split_name,
return 0;
}
- if (!suspend_lv(cmd, lv)) {
+ if (!suspend_lv(cmd, lv_lock_holder(lv))) {
log_error("Failed to suspend %s/%s before committing changes",
lv->vg->name, lv->name);
vg_revert(lv->vg);
@@ -1149,6 +1149,12 @@ int lv_raid_split(struct logical_volume *lv, const char *split_name,
return 0;
}
+ if (!resume_lv(lv->vg->cmd, lv_lock_holder(lv))) {
+ log_error("Failed to resume %s/%s after committing changes",
+ lv->vg->name, lv->name);
+ return 0;
+ }
+
/*
* First activate the newly split LV and LVs on the removal list.
* This is necessary so that there are no name collisions due to
@@ -1162,11 +1168,6 @@ int lv_raid_split(struct logical_volume *lv, const char *split_name,
if (!activate_lv_excl_local(cmd, lvl->lv))
return_0;
- if (!resume_lv(lv->vg->cmd, lv)) {
- log_error("Failed to resume %s/%s after committing changes",
- lv->vg->name, lv->name);
- return 0;
- }
/*
* Eliminate the residual LVs
9 years, 7 months
master - cache: used cache-pool becomes invisible
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=32e4af6479689c...
Commit: 32e4af6479689c4e25ecd273368d22136c93a75d
Parent: 09e32e4addd63d232ea98b0c6d633efbfc503daf
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Nov 9 21:04:33 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 10 21:36:21 2014 +0100
cache: used cache-pool becomes invisible
While cache-pool is in use - it is considered invisible.
---
WHATS_NEW | 1 +
lib/metadata/pool_manip.c | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8c0a85d..6084ee7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Cache-pool in use becomes invisible LV.
Don't prompt for removal of _pmspare in VG without pool metadata LV.
Deactivation of snapshot origin detects and deactivates left-over snapshots.
Properly report error when taking snapshot of any cache type LV.
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index 7152c51..b2e99f1 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -102,6 +102,9 @@ int attach_pool_lv(struct lv_segment *seg,
seg->origin = origin;
seg->lv->status |= seg_is_cache(seg) ? CACHE : THIN_VOLUME;
+ if (seg_is_cache(seg))
+ lv_set_hidden(pool_lv); /* Used cache-pool is hidden */
+
if (origin && !add_seg_to_segs_using_this_lv(origin, seg))
return_0;
@@ -137,6 +140,7 @@ int detach_pool_lv(struct lv_segment *seg)
if (!remove_seg_from_segs_using_this_lv(seg->pool_lv, seg))
return_0;
seg->lv->status &= ~CACHE;
+ lv_set_visible(seg->pool_lv);
seg->pool_lv = NULL;
return 1;
}
9 years, 7 months
master - pools: prompt only when metadata lv exists
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=09e32e4addd63d...
Commit: 09e32e4addd63d232ea98b0c6d633efbfc503daf
Parent: 138c2417c070eef5cdb9839a88efae5b601f4a49
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Nov 8 13:53:13 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 10 21:35:56 2014 +0100
pools: prompt only when metadata lv exists
If the VG has no pool metadata volume, don't prompt about
removal of _pmspare.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 18 ++++++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 06d3b9b..8c0a85d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Don't prompt for removal of _pmspare in VG without pool metadata LV.
Deactivation of snapshot origin detects and deactivates left-over snapshots.
Properly report error when taking snapshot of any cache type LV.
Add basic thread debugging messages to dmeventd.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index bedf4b6..b029395 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5570,6 +5570,7 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
dm_percent_t snap_percent;
struct dm_list *snh, *snht;
struct lvinfo info;
+ struct lv_list *lvl;
struct logical_volume *origin;
if (lv_is_cow(lv)) {
@@ -5649,12 +5650,17 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
return_0;
if (lv_is_pool_metadata_spare(lv) &&
- (force == PROMPT) &&
- (yes_no_prompt("Removal of pool metadata spare logical volume"
- " \"%s\" disables automatic recovery attempts"
- " after damage to a thin or cache pool."
- " Proceed? [y/n]: ", lv->name) == 'n'))
- goto no_remove;
+ (force == PROMPT)) {
+ dm_list_iterate_items(lvl, &lv->vg->lvs)
+ if (lv_is_pool_metadata(lvl->lv)) {
+ if (yes_no_prompt("Removal of pool metadata spare logical volume"
+ " \"%s\" disables automatic recovery attempts"
+ " after damage to a thin or cache pool."
+ " Proceed? [y/n]: ", lv->name) == 'n')
+ goto no_remove;
+ break;
+ }
+ }
return lv_remove_single(cmd, lv, force, 0);
9 years, 7 months
master - pools: after fail of vg_write no restore
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=138c2417c070ee...
Commit: 138c2417c070eef5cdb9839a88efae5b601f4a49
Parent: 94e4d5fcf51abdfd42df9299109fbc9d22f2f92b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Nov 5 20:27:51 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 10 21:34:02 2014 +0100
pools: after fail of vg_write no restore
Revert part of commit 51a29e60564d537,
it's probably bad idea to continue with any recovery, when
vg_write() or vg_commit() fail - so it's better to leave it as it is.
---
lib/metadata/lv_manip.c | 9 ++-------
1 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 6292626..bedf4b6 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6971,14 +6971,9 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
lp->activate = CHANGE_AN;
/* store vg on disk(s) */
- if (!vg_write(vg) || !vg_commit(vg)) {
- if (seg_is_pool(lp)) {
- /* Pool volumes have already created metadata LV */
- stack;
- goto revert_new_lv;
- }
+ if (!vg_write(vg) || !vg_commit(vg))
+ /* Pool created metadata LV, but better avoid recover when vg_write/commit fails */
return_NULL;
- }
backup(vg);
9 years, 7 months
master - cleanup: avoid dm_list size calc in common path
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=94e4d5fcf51abd...
Commit: 94e4d5fcf51abdfd42df9299109fbc9d22f2f92b
Parent: 6e5790f2d24d798e217fc005522c07e06c97adc9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 4 23:06:21 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Nov 5 15:30:59 2014 +0100
cleanup: avoid dm_list size calc in common path
Calculate dm_list_size only when there is not just a single
ont segment in list - so it's only counted on error path.
---
lib/metadata/lv_manip.c | 31 ++++++++++++++++---------------
1 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 30188e4..6292626 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -826,24 +826,25 @@ struct lv_segment *get_only_segment_using_this_lv(const struct logical_volume *l
return NULL;
}
- if (dm_list_size(&lv->segs_using_this_lv) != 1) {
- log_error("%s is expected to have only one segment using it, "
- "while it has %d", lv->name,
- dm_list_size(&lv->segs_using_this_lv));
- return NULL;
- }
+ dm_list_iterate_items(sl, &lv->segs_using_this_lv) {
+ /* Needs to be he only item in list */
+ if (!dm_list_end(&lv->segs_using_this_lv, &sl->list))
+ break;
- dm_list_iterate_items(sl, &lv->segs_using_this_lv)
- break; /* first item */
+ if (sl->count != 1) {
+ log_error("%s is expected to have only one segment using it, "
+ "while %s:%" PRIu32 " uses it %d times.",
+ display_lvname(lv), sl->seg->lv->name, sl->seg->le, sl->count);
+ return NULL;
+ }
- if (sl->count != 1) {
- log_error("%s is expected to have only one segment using it, "
- "while %s:%" PRIu32 " uses it %d times",
- lv->name, sl->seg->lv->name, sl->seg->le, sl->count);
- return NULL;
+ return sl->seg;
}
- return sl->seg;
+ log_error("%s is expected to have only one segment using it, while it has %d.",
+ display_lvname(lv), dm_list_size(&lv->segs_using_this_lv));
+
+ return NULL;
}
/*
9 years, 7 months
master - activate: check all snap segs are inactive
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6e5790f2d24d79...
Commit: 6e5790f2d24d798e217fc005522c07e06c97adc9
Parent: a3a2c792a87054ab78a1b8e54b99db1c24739fb8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Nov 5 11:53:11 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Nov 5 15:30:58 2014 +0100
activate: check all snap segs are inactive
When deactivating origin, we may have possibly left table in broken state,
where origin is not active, but snapshot volume is still present.
Let's ensure deactivation of origin detects also all associated
snapshots are inactive - otherwise do not skip deactivation.
(so i.e. 'vgchange -an' would detect errors)
---
WHATS_NEW | 1 +
lib/activate/activate.c | 15 ++++++++++++++-
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 03baa06..06d3b9b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Deactivation of snapshot origin detects and deactivates left-over snapshots.
Properly report error when taking snapshot of any cache type LV.
Add basic thread debugging messages to dmeventd.
Include threads being shutdown in dmeventd device registration responses.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index c2a662f..ac6330f 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2002,6 +2002,7 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, const struct logi
const struct logical_volume *lv_to_free = NULL;
struct lvinfo info;
static const struct lv_activate_opts laopts = { .skip_in_use = 1 };
+ struct dm_list *snh;
int r = 0;
if (!activation())
@@ -2023,7 +2024,19 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, const struct logi
if (!info.exists) {
r = 1;
- goto out;
+ /* Check attached snapshot segments are also inactive */
+ dm_list_iterate(snh, &lv->snapshot_segs) {
+ if (!lv_info(cmd, dm_list_struct_base(snh, struct lv_segment, origin_list)->cow,
+ 0, &info, 0, 0))
+ goto_out;
+ if (info.exists) {
+ r = 0; /* Snapshot left in table? */
+ break;
+ }
+ }
+
+ if (r)
+ goto out;
}
if (lv_is_visible(lv) || lv_is_virtual_origin(lv) ||
9 years, 7 months