Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1b7631101b2ac34d…
Commit: 1b7631101b2ac34d25cd5d3140001e86371997f9
Parent: 48df36b8c531a43da8602b50759c9e841e1d9f44
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 16 10:11:37 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 16 10:53:01 2013 +0200
thin: fix lvconvert for active pool.
Prohibit conversion of pool device with active thin volumes.
Properly restore active states only for active thin pool volume.
Use new LV_NOSCAN when converting volume into thin pool's metadata.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 16 +++++++++++++++-
2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index f5f0256..79a960c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104
===================================
+ Fix lvconvert swap of poolmetadata volume for active thin pool.
Check for open count with a timeout before removal/deactivation of an LV.
Report RAID images split with tracking as out-of-sync ("I").
Improve parsing of snapshot lv segment.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index ee6d868..eaac565 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2275,6 +2275,7 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
struct logical_volume *pool_metadata_lv;
struct logical_volume *external_lv = NULL;
char metadata_name[NAME_LEN], data_name[NAME_LEN];
+ int activate_pool;
if (!lv_is_visible(pool_lv)) {
log_error("Can't convert internal LV %s/%s.",
@@ -2303,6 +2304,7 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
}
if (lv_is_thin_pool(pool_lv)) {
+ activate_pool = lv_is_active(pool_lv);
r = 1; /* Already existing thin pool */
goto out;
}
@@ -2315,6 +2317,9 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
return 0;
}
+ /* Allow to have only thinpool active and restore it's active state */
+ activate_pool = lv_is_active(pool_lv);
+
/* We are changing target type, so deactivate first */
if (!deactivate_lv(cmd, pool_lv)) {
log_error("Aborting. Failed to deactivate logical volume %s/%s.",
@@ -2322,6 +2327,13 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
return 0;
}
+ if (pool_is_active(pool_lv)) {
+ /* If any thin volume is also active - abort here */
+ log_error("Cannot convert pool %s/%s with active thin volumes.",
+ pool_lv->vg->name, pool_lv->name);
+ return 0;
+ }
+
if ((dm_snprintf(metadata_name, sizeof(metadata_name), "%s_tmeta",
pool_lv->name) < 0) ||
(dm_snprintf(data_name, sizeof(data_name), "%s_tdata",
@@ -2423,6 +2435,7 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
goto mda_write;
}
+ metadata_lv->status |= LV_NOSCAN;
if (!lv_is_active(metadata_lv) &&
!activate_lv_local(cmd, metadata_lv)) {
log_error("Aborting. Failed to activate thin metadata lv.");
@@ -2515,7 +2528,8 @@ mda_write:
if (!vg_write(pool_lv->vg) || !vg_commit(pool_lv->vg))
return_0;
- if (!activate_lv_excl(cmd, pool_lv)) {
+ if (activate_pool &&
+ !activate_lv_excl(cmd, pool_lv)) {
log_error("Failed to activate pool logical volume %s/%s.",
pool_lv->vg->name, pool_lv->name);
/* Deactivate subvolumes */
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=48df36b8c531a43d…
Commit: 48df36b8c531a43da8602b50759c9e841e1d9f44
Parent: d97583cfd395e5e31888558361ae9467cea60260
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Oct 15 12:44:42 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Oct 15 12:44:42 2013 +0200
activation: check for open count with a timeout before removal/deactivation of an LV
This patch reinstates the lv_info call to check for open count of
the LV we're removing/deactivating - this was changed with commit 125712b
some time ago and we relied on the ioctl retry logic deeper in the libdm
while calling the exact 'remove' ioctl.
However, there are still some situations in which it's still required to
check for open count before we do any 'remove' actions - this mainly
applies to LVs which consist of several sub LVs, like it is for
virtual snapshot devices.
The commit 1146691 fixed the issue with ordering of actions during
virtual snapshot removal while the snapshot is still open. But
the check for the open status of the snapshot is still prone to
marking the snapshot as in use with an immediate exit even though
this could be a temporary asynchronous open only, most notably
because of udev and its WATCH udev rule with accompanying scans
for the event which is asynchronous. The situation where this crops
up most often is when we're closing the LV that was open for read-write
and then calling lvremove immediately.
This patch reinstates the original lv_info call for the open status
of the LV in the lv_check_not_in_use fn that gets called before
we do any LV removal/deactivation. In addition to original logic,
this patch adds its own retry loop with a delay (25x0.2 seconds)
besides the existing ioctl retry loop.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 51 ++++++++++++++++++++++++++++++----------------
2 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 04be5f1..f5f0256 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104
===================================
+ Check for open count with a timeout before removal/deactivation of an LV.
Report RAID images split with tracking as out-of-sync ("I").
Improve parsing of snapshot lv segment.
Add workaround for deactivation problem of opened virtual snapshot.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 6948060..131a093 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -251,8 +251,8 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,
{
return 0;
}
-int lv_check_not_in_use(struct cmd_context *cmd __attribute__((unused)),
- struct logical_volume *lv, struct lvinfo *info)
+int lv_check_not_in_use(struct cmd_context *cmd, struct logical_volume *lv,
+ struct lvinfo *info)
{
return 0;
}
@@ -676,33 +676,48 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,
return r;
}
-int lv_check_not_in_use(struct cmd_context *cmd __attribute__((unused)),
- struct logical_volume *lv, struct lvinfo *info)
+#define OPEN_COUNT_CHECK_RETRIES 25
+#define OPEN_COUNT_CHECK_USLEEP_DELAY 200000
+
+int lv_check_not_in_use(struct cmd_context *cmd, struct logical_volume *lv,
+ struct lvinfo *info)
{
+ unsigned int open_count_check_retries;
+
if (!info->exists)
return 1;
/* If sysfs is not used, use open_count information only. */
- if (!*dm_sysfs_dir()) {
- if (info->open_count) {
- log_error("Logical volume %s/%s in use.",
+ if (dm_sysfs_dir()) {
+ if (dm_device_has_holders(info->major, info->minor)) {
+ log_error("Logical volume %s/%s is used by another device.",
lv->vg->name, lv->name);
return 0;
}
- return 1;
- }
-
- if (dm_device_has_holders(info->major, info->minor)) {
- log_error("Logical volume %s/%s is used by another device.",
- lv->vg->name, lv->name);
- return 0;
+ if (dm_device_has_mounted_fs(info->major, info->minor)) {
+ log_error("Logical volume %s/%s contains a filesystem in use.",
+ lv->vg->name, lv->name);
+ return 0;
+ }
}
- if (dm_device_has_mounted_fs(info->major, info->minor)) {
- log_error("Logical volume %s/%s contains a filesystem in use.",
- lv->vg->name, lv->name);
- return 0;
+ open_count_check_retries = retry_deactivation() ? OPEN_COUNT_CHECK_RETRIES : 1;
+ while (open_count_check_retries--) {
+ if (info->open_count > 0) {
+ if (open_count_check_retries) {
+ usleep(OPEN_COUNT_CHECK_USLEEP_DELAY);
+ log_debug_activation("Retrying open_count check for %s/%s.",
+ lv->vg->name, lv->name);
+ if (!lv_info(cmd, lv, 0, info, 1, 0))
+ return -1;
+ continue;
+ }
+ log_error("Logical volume %s/%s in use.",
+ lv->vg->name, lv->name);
+ return 0;
+ } else
+ break;
}
return 1;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d97583cfd395e5e3…
Commit: d97583cfd395e5e31888558361ae9467cea60260
Parent: f58b26b6338b2939e6a88174ac2dc185b345118b
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Mon Oct 14 15:14:16 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Mon Oct 14 15:14:16 2013 -0500
RAID: Better error message when attempting scrubbing op on thinpool LV
Component LVs of a thinpool can be RAID LVs. Users who attempt a
scrubbing operation directly on a thinpool will be prompted to
specify the sub-LV they wish the operation to be performed on. If
neither of the sub-LVs are RAID, then a message telling them that
the operation can only be performed on a RAID LV will be given.
---
lib/activate/activate.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 7621f44..6948060 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -888,6 +888,18 @@ int lv_raid_message(const struct logical_volume *lv, const char *msg)
struct dm_status_raid *status;
if (!seg_is_raid(first_seg(lv))) {
+ /*
+ * Make it easier for user to know what to do when
+ * they are using thinpool.
+ */
+ if (lv_is_thin_pool(lv) &&
+ (lv_is_raid(seg_lv(first_seg(lv), 0)) ||
+ lv_is_raid(first_seg(lv)->metadata_lv))) {
+ log_error("Thinpool data or metadata volume"
+ " must be specified. (e.g. \"%s/%s_tdata\")",
+ lv->vg->name, lv->name);
+ return 0;
+ }
log_error("%s/%s must be a RAID logical volume to"
" perform this action.", lv->vg->name, lv->name);
return 0;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f58b26b6338b2939…
Commit: f58b26b6338b2939e6a88174ac2dc185b345118b
Parent: 0f55d7ccccb2c274f31760d1c97286ee03e24e4c
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Mon Oct 14 10:48:44 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Mon Oct 14 10:48:44 2013 -0500
RAID: Report RAID images split with tracking as out-of-sync ("I").
Split image should have an out-of-sync attr ('I') - always. Even if
the RAID LV has not been written to since the LV was split off, it is
still not part of the group that makes up the RAID and is therefore
"out-of-sync".
---
WHATS_NEW | 1 +
lib/metadata/lv.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 887a256..04be5f1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104
===================================
+ Report RAID images split with tracking as out-of-sync ("I").
Improve parsing of snapshot lv segment.
Add workaround for deactivation problem of opened virtual snapshot.
Disable unsupported merge for virtual snapshot.
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index e3fda18..e59bd8e 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -565,7 +565,13 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv)
else if (lv->status & MIRROR_IMAGE)
repstr[0] = (_lv_mimage_in_sync(lv)) ? 'i' : 'I';
else if (lv->status & RAID_IMAGE)
- repstr[0] = (_lv_raid_image_in_sync(lv)) ? 'i' : 'I';
+ /*
+ * Visible RAID_IMAGES are sub-LVs that have been exposed for
+ * top-level use by being split from the RAID array with
+ * '--splitmirrors 1 --trackchanges'. They always report 'I'.
+ */
+ repstr[0] = (!lv_is_visible(lv) && _lv_raid_image_in_sync(lv)) ?
+ 'i' : 'I';
else if (lv->status & MIRROR_LOG)
repstr[0] = 'l';
else if (lv_is_cow(lv))
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1146691afc740257…
Commit: 1146691afc740257d03c7ca53bfa07918a4bc715
Parent: ac961087b0fe9846f95bedee7687d9ca840b217d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 11 23:53:28 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 14 00:25:15 2013 +0200
snapshot: deactivate virtual snapshot first
Since the virtual snapshot has no reason to stay alive once we
detach related snapshot - deactivate whole thing in front of
snapshot removal - otherwice the code would get tricky for
support in cluster.
The correct full solution would require to have transactions
for libdm operations.
Also enable to the check for snapshot being opened prior
the origin deactivation, otherwise we could easily end
with the origin being deactivate, but snapshot still kept
active, desynchronizing locking state in cluster.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 2 +-
lib/metadata/snapshot_manip.c | 10 ++++++++++
3 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 37fe7ad..6539f19 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104
===================================
+ Add workaround for deactivation problem of opened virtual snapshot.
Disable unsupported merge for virtual snapshot.
Move code to remove virtual snapshot from tools to lib for lvm2app.
Fix possible race during daemon worker thread creation (lvmetad).
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index c077113..7621f44 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1929,7 +1929,7 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, struct logical_vo
goto out;
}
- if (lv_is_visible(lv)) {
+ if (lv_is_visible(lv) || lv_is_virtual_origin(lv)) {
if (!lv_check_not_in_use(cmd, lv, &info))
goto_out;
diff --git a/lib/metadata/snapshot_manip.c b/lib/metadata/snapshot_manip.c
index 325a4e8..fc1273e 100644
--- a/lib/metadata/snapshot_manip.c
+++ b/lib/metadata/snapshot_manip.c
@@ -227,6 +227,16 @@ int vg_remove_snapshot(struct logical_volume *cow)
struct logical_volume *origin = origin_from_cow(cow);
int is_origin_active = lv_is_active(origin);
+ if (is_origin_active &&
+ lv_is_virtual_origin(origin)) {
+ if (!deactivate_lv(origin->vg->cmd, origin)) {
+ log_error("Failed to deactivate logical volume \"%s\"",
+ origin->name);
+ return 0;
+ }
+ is_origin_active = 0;
+ }
+
dm_list_del(&cow->snapshot->origin_list);
origin->origin_count--;