master - thin: merge support for device tree
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=664a695561c986...
Commit: 664a695561c98645dd557428108766b702db530d
Parent: e286904da6a253394c050abde780269571289268
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 29 21:18:34 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:25 2013 +0100
thin: merge support for device tree
When thin snapshot merge is requested, tree must detect
if user tries to active such LV while origin or
snapshost is still active.
---
lib/activate/dev_manager.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 24574ec..7b0b6e2 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1830,6 +1830,9 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
dm_list_iterate(snh, &lv->snapshot_segs)
if (!_add_lv_to_dtree(dm, dtree, dm_list_struct_base(snh, struct lv_segment, origin_list)->cow, 0))
return_0;
+ if (dm->activation && !origin_only && lv_is_merging_origin(lv) &&
+ !_add_lv_to_dtree(dm, dtree, find_snapshot(lv)->lv, 1))
+ return_0;
/* Add any LVs referencing a PVMOVE LV unless told not to. */
if (dm->track_pvmove_deps && lv->status & PVMOVE) {
@@ -1868,6 +1871,11 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
!_add_lv_to_dtree(dm, dtree, seg_metalv(seg, s), 0))
return_0;
}
+
+ /* When activating, detect merging LV presence */
+ if (dm->activation && seg->merge_lv &&
+ !_add_lv_to_dtree(dm, dtree, seg->merge_lv, 1))
+ return_0;
}
return 1;
@@ -2436,10 +2444,13 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
/* An activating merging origin won't have a node in the tree yet */
if (((dinfo = _cached_info(dm->mem, dtree, lv, NULL)) &&
dinfo->open_count) ||
- ((dinfo = _cached_info(dm->mem, dtree, seg->cow, NULL)) &&
+ ((dinfo = _cached_info(dm->mem, dtree,
+ seg_is_thin_volume(seg) ?
+ seg->lv : seg->cow, NULL)) &&
dinfo->open_count)) {
- /* FIXME Is there anything simpler to check for instead? */
- if (!lv_has_target_type(dm->mem, lv, NULL, "snapshot-merge"))
+ if (seg_is_thin_volume(seg) ||
+ /* FIXME Is there anything simpler to check for instead? */
+ !lv_has_target_type(dm->mem, lv, NULL, "snapshot-merge"))
laopts->no_merging = 1;
}
}
10 years, 3 months
master - thin: snapshot merge support
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e286904da6a253...
Commit: e286904da6a253394c050abde780269571289268
Parent: 572983d7931eac9347dad79b7d9b13f640bfaeaf
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 29 15:51:28 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:25 2013 +0100
thin: snapshot merge support
---
lib/metadata/lv_manip.c | 4 ++--
lib/metadata/merge.c | 13 +++++++++++++
lib/metadata/metadata-exported.h | 3 ++-
lib/metadata/metadata.h | 3 ++-
lib/metadata/snapshot_manip.c | 15 ++++++++++++++-
lib/metadata/thin_manip.c | 21 +++++++++++++++++++--
lib/thin/thin.c | 30 +++++++++++++++++++++++++++---
7 files changed, 79 insertions(+), 10 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 6846f4a..2458447 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -491,14 +491,14 @@ struct lv_segment *alloc_lv_segment(const struct segment_type *segtype,
/* If this is thin volume, thin snapshot is being created */
if (lv_is_thin_volume(thin_pool_lv)) {
seg->transaction_id = first_seg(first_seg(thin_pool_lv)->pool_lv)->transaction_id;
- if (!attach_pool_lv(seg, first_seg(thin_pool_lv)->pool_lv, thin_pool_lv))
+ if (!attach_pool_lv(seg, first_seg(thin_pool_lv)->pool_lv, thin_pool_lv, NULL))
return_NULL;
/* Use the same external origin */
if (!attach_thin_external_origin(seg, first_seg(thin_pool_lv)->external_lv))
return_NULL;
} else if (lv_is_thin_pool(thin_pool_lv)) {
seg->transaction_id = first_seg(thin_pool_lv)->transaction_id;
- if (!attach_pool_lv(seg, thin_pool_lv, NULL))
+ if (!attach_pool_lv(seg, thin_pool_lv, NULL, NULL))
return_NULL;
} else {
log_error(INTERNAL_ERROR "Volume %s is not thin volume or thin pool",
diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c
index c22e922..93e4bfa 100644
--- a/lib/metadata/merge.c
+++ b/lib/metadata/merge.c
@@ -258,6 +258,19 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg)
lv->name, seg->external_lv->name);
inc_error_count;
}
+
+ if (seg->merge_lv) {
+ if (!lv_is_thin_volume(seg->merge_lv)) {
+ log_error("LV %s: thin volume segment %u merging LV %s is not flagged as a thin LV",
+ lv->name, seg_count, seg->merge_lv->name);
+ inc_error_count;
+ }
+ if (!lv_is_merging_origin(seg->merge_lv)) {
+ log_error("LV %s: merging LV %s is not flagged as merging.",
+ lv->name, seg->merge_lv->name);
+ inc_error_count;
+ }
+ }
} else {
if (seg->pool_lv) {
log_error("LV %s: segment %u must not have thin pool LV set",
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 0186c61..9798197 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -360,6 +360,7 @@ struct lv_segment {
uint32_t chunk_size; /* For snapshots/thin_pool. In sectors. */
/* For thin_pool, 128..2097152. */
struct logical_volume *origin; /* snap and thin */
+ struct logical_volume *merge_lv; /* thin, merge descendent lv into this ancestor */
struct logical_volume *cow;
struct dm_list origin_list;
uint32_t region_size; /* For mirrors, replicators - in sectors */
@@ -881,7 +882,7 @@ int lv_is_visible(const struct logical_volume *lv);
int pv_is_in_vg(struct volume_group *vg, struct physical_volume *pv);
-/* Given a cow LV, return return the snapshot lv_segment that uses it */
+/* Given a cow or thin LV, return the snapshot lv_segment that uses it */
struct lv_segment *find_snapshot(const struct logical_volume *lv);
/* Given a cow LV, return its origin */
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 21ac204..0ab63f2 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -462,11 +462,12 @@ int fixup_imported_mirrors(struct volume_group *vg);
* From thin_manip.c
*/
int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv,
- struct logical_volume *origin_lv);
+ struct logical_volume *origin_lv, struct logical_volume *merge_lv);
int detach_pool_lv(struct lv_segment *seg);
int attach_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
struct logical_volume *lv, uint32_t delete_id,
int auto_increment);
+int lv_is_merging_thin_snapshot(const struct logical_volume *lv);
int pool_has_message(const struct lv_segment *seg,
const struct logical_volume *lv, uint32_t device_id);
int pool_below_threshold(const struct lv_segment *pool_seg);
diff --git a/lib/metadata/snapshot_manip.c b/lib/metadata/snapshot_manip.c
index e9a6d87..e563a78 100644
--- a/lib/metadata/snapshot_manip.c
+++ b/lib/metadata/snapshot_manip.c
@@ -27,7 +27,8 @@ int lv_is_origin(const struct logical_volume *lv)
int lv_is_cow(const struct logical_volume *lv)
{
- return (!lv_is_origin(lv) && lv->snapshot) ? 1 : 0;
+ /* Make sure a merging thin origin isn't confused as a cow LV */
+ return (!lv_is_thin_volume(lv) && !lv_is_origin(lv) && lv->snapshot) ? 1 : 0;
}
static uint64_t _cow_max_size(uint64_t origin_size, uint32_t chunk_size)
@@ -150,6 +151,13 @@ void init_snapshot_merge(struct lv_segment *snap_seg,
origin->snapshot = snap_seg;
origin->status |= MERGING;
+ if (lv_is_thin_volume(origin)) {
+ snap_seg->merge_lv = origin;
+ /* Making thin LV inivisible with regular log */
+ lv_set_hidden(snap_seg->lv);
+ return;
+ }
+
/*
* Even though lv_is_visible(snap_seg->lv) returns 0,
* the snap_seg->lv (name: snapshotX) is _not_ hidden;
@@ -166,6 +174,11 @@ void init_snapshot_merge(struct lv_segment *snap_seg,
void clear_snapshot_merge(struct logical_volume *origin)
{
/* clear merge attributes */
+ if (origin->snapshot->merge_lv)
+ /* Removed thin volume has to be visible */
+ lv_set_visible(origin->snapshot->lv);
+
+ origin->snapshot->merge_lv = NULL;
origin->snapshot->status &= ~MERGING;
origin->snapshot = NULL;
origin->status &= ~MERGING;
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index b3fedcf..0223752 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -60,7 +60,7 @@ int attach_pool_data_lv(struct lv_segment *pool_seg, struct logical_volume *pool
}
int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv,
- struct logical_volume *origin)
+ struct logical_volume *origin, struct logical_volume *merge_lv)
{
seg->pool_lv = pool_lv;
seg->lv->status |= THIN_VOLUME;
@@ -69,7 +69,19 @@ int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv,
if (origin && !add_seg_to_segs_using_this_lv(origin, seg))
return_0;
- return add_seg_to_segs_using_this_lv(pool_lv, seg);
+ if (!add_seg_to_segs_using_this_lv(pool_lv, seg))
+ return_0;
+
+ if (merge_lv) {
+ if (origin != merge_lv) {
+ if (!add_seg_to_segs_using_this_lv(merge_lv, seg))
+ return_0;
+ }
+
+ init_snapshot_merge(seg, merge_lv);
+ }
+
+ return 1;
}
int detach_pool_lv(struct lv_segment *seg)
@@ -247,6 +259,11 @@ int detach_thin_external_origin(struct lv_segment *seg)
return 1;
}
+int lv_is_merging_thin_snapshot(const struct logical_volume *lv)
+{
+ return (first_seg(lv)->status & MERGING) ? 1 : 0;
+}
+
/*
* Check whether pool has some message queued for LV or for device_id
* When LV is NULL and device_id is 0 it just checks for any message.
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index 8477aac..5f0c271 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -456,7 +456,7 @@ static int _thin_text_import(struct lv_segment *seg,
struct dm_hash_table *pv_hash __attribute__((unused)))
{
const char *lv_name;
- struct logical_volume *pool_lv, *origin = NULL, *external_lv = NULL;
+ struct logical_volume *pool_lv, *origin = NULL, *external_lv = NULL, *merge_lv = NULL;
if (!dm_config_get_str(sn, "thin_pool", &lv_name))
return SEG_LOG_ERROR("Thin pool must be a string in");
@@ -475,6 +475,13 @@ static int _thin_text_import(struct lv_segment *seg,
return SEG_LOG_ERROR("Unknown origin %s in", lv_name);
}
+ if (dm_config_has_node(sn, "merge")) {
+ if (!dm_config_get_str(sn, "merge", &lv_name))
+ return SEG_LOG_ERROR("Merge lv must be a string in");
+ if (!(merge_lv = find_lv(seg->lv->vg, lv_name)))
+ return SEG_LOG_ERROR("Unknown merge lv %s in", lv_name);
+ }
+
if (!dm_config_get_uint32(sn, "device_id", &seg->device_id))
return SEG_LOG_ERROR("Could not read device_id for");
@@ -490,7 +497,7 @@ static int _thin_text_import(struct lv_segment *seg,
return SEG_LOG_ERROR("Unknown external origin %s in", lv_name);
}
- if (!attach_pool_lv(seg, pool_lv, origin))
+ if (!attach_pool_lv(seg, pool_lv, origin, merge_lv))
return_0;
if (!attach_thin_external_origin(seg, external_lv))
@@ -509,6 +516,8 @@ static int _thin_text_export(const struct lv_segment *seg, struct formatter *f)
outf(f, "external_origin = \"%s\"", seg->external_lv->name);
if (seg->origin)
outf(f, "origin = \"%s\"", seg->origin->name);
+ if (seg->merge_lv)
+ outf(f, "merge = \"%s\"", seg->merge_lv->name);
return 1;
}
@@ -519,7 +528,7 @@ static int _thin_add_target_line(struct dev_manager *dm,
struct cmd_context *cmd __attribute__((unused)),
void **target_state __attribute__((unused)),
struct lv_segment *seg,
- const struct lv_activate_opts *laopts __attribute__((unused)),
+ const struct lv_activate_opts *laopts,
struct dm_tree_node *node, uint64_t len,
uint32_t *pvmove_mirror_count __attribute__((unused)))
{
@@ -537,6 +546,21 @@ static int _thin_add_target_line(struct dev_manager *dm,
return 0;
}
+ if (!laopts->no_merging) {
+ /*
+ * merge support for thinp snapshots is implemented by
+ * simply swapping the thinp device_id of the snapshot
+ * and origin.
+ */
+ if (seg->merge_lv) {
+ /* snapshot, use merging lv's device_id */
+ device_id = first_seg(seg->merge_lv)->device_id;
+ } else if (lv_is_merging_origin(seg->lv)) {
+ /* origin, use merging snapshot's device_id */
+ device_id = find_snapshot(seg->lv)->device_id;
+ }
+ }
+
if (!dm_tree_node_add_thin_target(node, len, pool_dlid, device_id))
return_0;
10 years, 3 months
master - thin: read table line with thin device id
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=572983d7931eac...
Commit: 572983d7931eac9347dad79b7d9b13f640bfaeaf
Parent: cf7f4512384bac494fd352762f685377e2f10034
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Dec 4 13:57:27 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:25 2013 +0100
thin: read table line with thin device id
Add functions to parse thin table line to
obtain thin device id.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 22 +++++++++++++++++++
lib/activate/activate.h | 1 +
lib/activate/dev_manager.c | 50 ++++++++++++++++++++++++++++++++++++++++++++
lib/activate/dev_manager.h | 3 ++
5 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index cba7c8f..c81cb7a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Add support to read thin device id from table line entry.
Drop extra test for origin when testing merging origin in lv_refresh().
Extend lv_remove_single() to not print info about removed LV.
Replace open_count check with lv_check_not_in_use() for snapshot open test.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index f75f1cf..80eef32 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1051,6 +1051,28 @@ int lv_thin_pool_transaction_id(const struct logical_volume *lv,
return r;
}
+int lv_thin_device_id(const struct logical_volume *lv, uint32_t *device_id)
+{
+ int r;
+ struct dev_manager *dm;
+
+ if (!activation())
+ return 0;
+
+ log_debug_activation("Checking device id for LV %s/%s",
+ lv->vg->name, lv->name);
+
+ if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
+ return_0;
+
+ if (!(r = dev_manager_thin_device_id(dm, lv, device_id)))
+ stack;
+
+ dev_manager_destroy(dm);
+
+ return r;
+}
+
static int _lv_active(struct cmd_context *cmd, const struct logical_volume *lv)
{
struct lvinfo info;
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index df888cd..1881f75 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -140,6 +140,7 @@ int lv_thin_percent(const struct logical_volume *lv, int mapped,
percent_t *percent);
int lv_thin_pool_transaction_id(const struct logical_volume *lv,
uint64_t *transaction_id);
+int lv_thin_device_id(const struct logical_volume *lv, uint32_t *device_id);
/*
* Return number of LVs in the VG that are active.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index bed4d60..24574ec 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1313,6 +1313,56 @@ int dev_manager_thin_percent(struct dev_manager *dm,
return 1;
}
+int dev_manager_thin_device_id(struct dev_manager *dm,
+ const struct logical_volume *lv,
+ uint32_t *device_id)
+{
+ const char *dlid;
+ struct dm_task *dmt;
+ struct dm_info info;
+ uint64_t start, length;
+ char *params, *target_type = NULL;
+ int r = 0;
+
+ /* Build dlid for the thin layer */
+ if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, lv_layer(lv))))
+ return_0;
+
+ log_debug_activation("Getting device id for %s.", dlid);
+
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_TABLE, 0, 0)))
+ return_0;
+
+ if (!dm_task_run(dmt))
+ goto_out;
+
+ if (!dm_task_get_info(dmt, &info) || !info.exists)
+ goto_out;
+
+ if (dm_get_next_target(dmt, NULL, &start, &length,
+ &target_type, ¶ms)) {
+ log_error("More then one table line found for %s.", lv->name);
+ goto out;
+ }
+
+ if (strcmp(target_type, "thin")) {
+ log_error("Unexpected target type %s found for thin %s.", target_type, lv->name);
+ goto out;
+ }
+
+ if (sscanf(params, "%*u:%*u %u", device_id) != 1) {
+ log_error("Cannot parse table like parameters %s for %s.", params, lv->name);
+ goto out;
+ }
+
+ r = 1;
+out:
+ dm_task_destroy(dmt);
+
+ return r;
+}
+
+
/*************************/
/* NEW CODE STARTS HERE */
/*************************/
diff --git a/lib/activate/dev_manager.h b/lib/activate/dev_manager.h
index ecf3c5f..032766e 100644
--- a/lib/activate/dev_manager.h
+++ b/lib/activate/dev_manager.h
@@ -70,6 +70,9 @@ int dev_manager_thin_pool_percent(struct dev_manager *dm,
int dev_manager_thin_percent(struct dev_manager *dm,
const struct logical_volume *lv,
int mapped, percent_t *percent);
+int dev_manager_thin_device_id(struct dev_manager *dm,
+ const struct logical_volume *lv,
+ uint32_t *device_id);
int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv,
struct lv_activate_opts *laopts, int lockfs, int flush_required);
int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv,
10 years, 3 months
master - merge: test only for meging origin
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cf7f4512384bac...
Commit: cf7f4512384bac494fd352762f685377e2f10034
Parent: 993831bdb15657b1fc6b9985cdaca9e3ccc1cfbc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 29 11:01:02 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:25 2013 +0100
merge: test only for meging origin
It's enough to check only for merging origin.
This will be also used for thin volume merges which
do not need to be origins.
---
WHATS_NEW | 1 +
tools/toollib.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c7c028a..cba7c8f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Drop extra test for origin when testing merging origin in lv_refresh().
Extend lv_remove_single() to not print info about removed LV.
Replace open_count check with lv_check_not_in_use() for snapshot open test.
Add error messages with LV names for failing lv refresh.
diff --git a/tools/toollib.c b/tools/toollib.c
index 868fc69..183d832 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1442,7 +1442,7 @@ int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv)
* - fortunately: polldaemon will immediately shutdown if the
* origin doesn't have a status with a snapshot percentage
*/
- if (background_polling() && lv_is_origin(lv) && lv_is_merging_origin(lv))
+ if (background_polling() && lv_is_merging_origin(lv))
lv_spawn_background_polling(cmd, lv);
return 1;
10 years, 3 months
master - cleanup: size is already 64bit value
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=993831bdb15657...
Commit: 993831bdb15657b1fc6b9985cdaca9e3ccc1cfbc
Parent: 51783676fb8036832a08094fa34fd9458ee13711
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 9 13:18:43 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:25 2013 +0100
cleanup: size is already 64bit value
Cast is not needed.
---
lib/metadata/metadata.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 61816e2..5f2addd 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -987,7 +987,7 @@ uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size,
return 0;
}
- return (uint64_t) size / extent_size;
+ return size / extent_size;
}
/*
10 years, 3 months
master - cleanup: swap condition logic
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=51783676fb8036...
Commit: 51783676fb8036832a08094fa34fd9458ee13711
Parent: 6d7a76ccbfcfe6579333a58c61a51d556ba8507f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 29 20:29:38 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:25 2013 +0100
cleanup: swap condition logic
Use easier to follow logic of code.
When checking for merging origin, do a merging.
---
tools/lvconvert.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 273f56a..84479fe 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -780,12 +780,12 @@ int lvconvert_poll(struct cmd_context *cmd, struct logical_volume *lv,
memcpy(uuid, &lv->lvid, sizeof(lv->lvid));
- if (!lv_is_merging_origin(lv))
- return poll_daemon(cmd, lv_full_name, uuid, background, 0,
- &_lvconvert_mirror_fns, "Converted");
- else
+ if (lv_is_merging_origin(lv))
return poll_daemon(cmd, lv_full_name, uuid, background, 0,
&_lvconvert_merge_fns, "Merged");
+
+ return poll_daemon(cmd, lv_full_name, uuid, background, 0,
+ &_lvconvert_mirror_fns, "Converted");
}
static int _insert_lvconvert_layer(struct cmd_context *cmd,
10 years, 3 months
master - cleanup: code move
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6d7a76ccbfcfe6...
Commit: 6d7a76ccbfcfe6579333a58c61a51d556ba8507f
Parent: 5a6794a2ce74416c399f8cf28f2625de8ba9cd55
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 29 17:20:56 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:25 2013 +0100
cleanup: code move
Move _swap_lv_identifiers() above _finish_lvconvert_merge()
so it could be used from this function.
---
tools/lvconvert.c | 38 +++++++++++++++++++-------------------
1 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index a0fa679..273f56a 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -670,6 +670,25 @@ static int _finish_lvconvert_mirror(struct cmd_context *cmd,
return 1;
}
+/* Swap lvid and LV names */
+static int _swap_lv_identifiers(struct cmd_context *cmd,
+ struct logical_volume *a, struct logical_volume *b)
+{
+ union lvid lvid;
+ const char *name;
+
+ lvid = a->lvid;
+ a->lvid = b->lvid;
+ b->lvid = lvid;
+
+ name = a->name;
+ a->name = b->name;
+ if (!lv_rename_update(cmd, b, name, 0))
+ return_0;
+
+ return 1;
+}
+
static int _finish_lvconvert_merge(struct cmd_context *cmd,
struct volume_group *vg,
struct logical_volume *lv,
@@ -723,25 +742,6 @@ static progress_t _poll_merge_progress(struct cmd_context *cmd,
return PROGRESS_UNFINISHED;
}
-/* Swap lvid and LV names */
-static int _swap_lv_identifiers(struct cmd_context *cmd,
- struct logical_volume *a, struct logical_volume *b)
-{
- union lvid lvid;
- const char *name;
-
- lvid = a->lvid;
- a->lvid = b->lvid;
- b->lvid = lvid;
-
- name = a->name;
- a->name = b->name;
- if (!lv_rename_update(cmd, b, name, 0))
- return_0;
-
- return 1;
-}
-
static struct poll_functions _lvconvert_mirror_fns = {
.get_copy_vg = _get_lvconvert_vg,
.get_copy_lv = _get_lvconvert_lv,
10 years, 3 months
master - lv_remove_single: add silent arg
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5a6794a2ce7441...
Commit: 5a6794a2ce74416c399f8cf28f2625de8ba9cd55
Parent: 84b3852ee5ed6d6a254ec4ffa9254db034c902bc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 29 17:00:55 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:25 2013 +0100
lv_remove_single: add silent arg
Support silence for removal message.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 6 +++---
lib/metadata/metadata-exported.h | 2 +-
liblvm/lvm_lv.c | 2 +-
tools/lvconvert.c | 2 +-
5 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index fa97962..c7c028a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Extend lv_remove_single() to not print info about removed LV.
Replace open_count check with lv_check_not_in_use() for snapshot open test.
Add error messages with LV names for failing lv refresh.
Compile/link daemons with RELRO and PIE options to harden daemon security.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index c67dd38..6846f4a 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4482,7 +4482,7 @@ void lv_set_hidden(struct logical_volume *lv)
}
int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
- const force_t force)
+ force_t force, int silent)
{
struct volume_group *vg;
struct lvinfo info;
@@ -4639,7 +4639,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
backup(vg);
- if (visible)
+ if (!silent && visible)
log_print_unless_silent("Logical volume \"%s\" successfully removed", lv->name);
return 1;
@@ -4764,7 +4764,7 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
"to a thin pool. Proceed? [y/n]: ", lv->name) == 'n'))
goto no_remove;
- return lv_remove_single(cmd, lv, force);
+ return lv_remove_single(cmd, lv, force, 0);
no_remove:
log_error("Logical volume \"%s\" not removed.", lv->name);
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index f205a14..0186c61 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -657,7 +657,7 @@ int lv_extend(struct logical_volume *lv,
int lv_remove(struct logical_volume *lv);
int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
- force_t force);
+ force_t force, int silent);
int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *lv,
force_t force, unsigned level);
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index f5c3ab9..b451c83 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -206,7 +206,7 @@ int lvm_vg_remove_lv(lv_t lv)
return -1;
if (!vg_check_write_mode(lv->vg))
return -1;
- if (!lv_remove_single(lv->vg->cmd, lv, DONT_PROMPT))
+ if (!lv_remove_single(lv->vg->cmd, lv, DONT_PROMPT, 0))
return -1;
return 0;
}
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index ab1d5a3..a0fa679 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -683,7 +683,7 @@ static int _finish_lvconvert_merge(struct cmd_context *cmd,
}
log_print_unless_silent("Merge of snapshot into logical volume %s has finished.", lv->name);
- if (!lv_remove_single(cmd, snap_seg->cow, DONT_PROMPT)) {
+ if (!lv_remove_single(cmd, snap_seg->cow, DONT_PROMPT, 0)) {
log_error("Could not remove snapshot %s merged into %s.",
snap_seg->cow->name, lv->name);
return 0;
10 years, 3 months
master - snapshots: use lv_check_not_in_use
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=84b3852ee5ed6d...
Commit: 84b3852ee5ed6d6a254ec4ffa9254db034c902bc
Parent: 778de22d51aae736d6891920617191a41c236596
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 29 15:02:57 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:24 2013 +0100
snapshots: use lv_check_not_in_use
Switch from a simple 'open_count' test on opened snaphost
to a more 'skilled' lv_check_not_in_use().
---
WHATS_NEW | 1 +
lib/activate/activate.c | 19 +++++++------------
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0689b18..fa97962 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Replace open_count check with lv_check_not_in_use() for snapshot open test.
Add error messages with LV names for failing lv refresh.
Compile/link daemons with RELRO and PIE options to harden daemon security.
Support per-object compilation cflags via CFLAGS_object.o.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 44dfeb6..f75f1cf 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1910,19 +1910,14 @@ static int _lv_has_open_snapshots(struct logical_volume *lv)
struct lvinfo info;
int r = 0;
- dm_list_iterate_items_gen(snap_seg, &lv->snapshot_segs, origin_list) {
- if (!lv_info(lv->vg->cmd, snap_seg->cow, 0, &info, 1, 0)) {
- r = 1;
- continue;
- }
+ dm_list_iterate_items_gen(snap_seg, &lv->snapshot_segs, origin_list)
+ if (!lv_info(lv->vg->cmd, snap_seg->cow, 0, &info, 1, 0) ||
+ !lv_check_not_in_use(lv->vg->cmd, snap_seg->cow, &info))
+ r++;
- if (info.exists && info.open_count) {
- log_error("LV %s/%s has open snapshot %s: "
- "not deactivating", lv->vg->name, lv->name,
- snap_seg->cow->name);
- r = 1;
- }
- }
+ if (r)
+ log_error("LV %s/%s has open %d snapshot(s), not deactivating.",
+ lv->vg->name, lv->name, r);
return r;
}
10 years, 3 months
master - refresh: print error message with failing lv name
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=778de22d51aae7...
Commit: 778de22d51aae736d6891920617191a41c236596
Parent: 37853cc7a9e60036134034718f22ec688917146b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 29 11:10:41 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:24 2013 +0100
refresh: print error message with failing lv name
If there is suspend/resume error, print error message
with lv name.
Drop goto.
---
WHATS_NEW | 1 +
tools/toollib.c | 21 ++++++++++-----------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index f299b84..0689b18 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Add error messages with LV names for failing lv refresh.
Compile/link daemons with RELRO and PIE options to harden daemon security.
Support per-object compilation cflags via CFLAGS_object.o.
Automatically detect support for compiler/linker options to use RELRO and PIE.
diff --git a/tools/toollib.c b/tools/toollib.c
index 654384d..868fc69 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1417,21 +1417,21 @@ int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv)
{
- int r = 0;
-
if (!cmd->partial_activation && (lv->status & PARTIAL_LV)) {
log_error("Refusing refresh of partial LV %s. Use --partial to override.",
lv->name);
- goto out;
+ return 0;
}
- r = suspend_lv(cmd, lv);
- if (!r)
- goto_out;
+ if (!suspend_lv(cmd, lv)) {
+ log_error("Failed to suspend %s.", lv->name);
+ return 0;
+ }
- r = resume_lv(cmd, lv);
- if (!r)
- goto_out;
+ if (!resume_lv(cmd, lv)) {
+ log_error("Failed to reactivate %s.", lv->name);
+ return 0;
+ }
/*
* check if snapshot merge should be polled
@@ -1445,8 +1445,7 @@ int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv)
if (background_polling() && lv_is_origin(lv) && lv_is_merging_origin(lv))
lv_spawn_background_polling(cmd, lv);
-out:
- return r;
+ return 1;
}
int vg_refresh_visible(struct cmd_context *cmd, struct volume_group *vg)
10 years, 3 months