master - cov: declaration matching
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4a33e4c509fb72...
Commit: 4a33e4c509fb72bf3540d20bd35e1f0944e1d37a
Parent: b8c729efd094146437c3ed5b336b929608401535
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 9 23:10:00 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 11 23:24:19 2016 +0100
cov: declaration matching
---
lib/format_text/format-text.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/format_text/format-text.h b/lib/format_text/format-text.h
index bfabdfd..d6e6b03 100644
--- a/lib/format_text/format-text.h
+++ b/lib/format_text/format-text.h
@@ -59,7 +59,7 @@ int add_da(struct dm_pool *mem, struct dm_list *das,
void del_das(struct dm_list *das);
int add_ba(struct dm_pool *mem, struct dm_list *eas,
uint64_t start, uint64_t size);
-void del_bas(struct dm_list *eas);
+void del_bas(struct dm_list *bas);
int add_mda(const struct format_type *fmt, struct dm_pool *mem, struct dm_list *mdas,
struct device *dev, uint64_t start, uint64_t size, unsigned ignored);
void del_mdas(struct dm_list *mdas);
6 years, 6 months
master - cov: add internal error for impossible code path
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b8c729efd09414...
Commit: b8c729efd094146437c3ed5b336b929608401535
Parent: 794093722c657780171486dbfd8cd0ec392e4019
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 9 22:55:25 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 11 23:24:19 2016 +0100
cov: add internal error for impossible code path
---
tools/vgchange.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 910f33a..455f688 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -533,6 +533,11 @@ static int _vgchange_locktype(struct cmd_context *cmd,
struct logical_volume *lv;
int lv_lock_count = 0;
+ if (!lock_type) {
+ log_error(INTERNAL_ERROR "No locktype_ARG.");
+ return 0;
+ }
+
/*
* This is a special/forced exception to change the lock type to none.
* It's needed for recovery cases and skips the normal steps of undoing
6 years, 6 months
master - debug: missing stack traces
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=794093722c6577...
Commit: 794093722c657780171486dbfd8cd0ec392e4019
Parent: dc7d3dd5eda43186829ac4237ab049fe50cbc12a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Dec 10 22:37:34 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 11 23:24:19 2016 +0100
debug: missing stack traces
---
lib/metadata/raid_manip.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 58e3bcf..98f30e2 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -3248,24 +3248,24 @@ static int _striped_or_raid0_to_raid45610_wrapper(TAKEOVER_FN_ARGS)
log_debug_metadata("Converting LV %s from %s to %s",
display_lvname(lv), SEG_TYPE_NAME_STRIPED, SEG_TYPE_NAME_RAID0);
if (!(seg = _convert_striped_to_raid0(lv, 1 /* alloc_metadata_devs */, 0 /* update_and_reload */, allocate_pvs)))
- return 0;
+ return_0;
}
/* Add metadata LVs */
if (seg_is_raid0(seg)) {
log_debug_metadata("Adding metadata LVs to %s", display_lvname(lv));
if (!_raid0_add_or_remove_metadata_lvs(lv, 1 /* update_and_reload */, allocate_pvs, NULL))
- return 0;
+ return_0;
/* raid0_meta -> raid4 needs clearing of MetaLVs in order to avoid raid disk role cahnge issues in the kernel */
} else if (segtype_is_raid4(new_segtype) &&
!_clear_meta_lvs(lv))
- return 0;
+ return_0;
/* Add the additional component LV pairs */
log_debug_metadata("Adding %" PRIu32 " component LV pair(s) to %s", new_image_count - lv_raid_image_count(lv),
display_lvname(lv));
if (!_lv_raid_change_image_count(lv, new_image_count, allocate_pvs, NULL, 0, 1))
- return 0;
+ return_0;
if (segtype_is_raid4(new_segtype) &&
(!_shift_parity_dev(seg) ||
@@ -3289,7 +3289,7 @@ static int _striped_or_raid0_to_raid45610_wrapper(TAKEOVER_FN_ARGS)
if (segtype_is_raid4(new_segtype)) {
/* We had to rename SubLVs because of collision free sgifting, rename back... */
if (!_rename_area_lvs(lv, NULL))
- return 0;
+ return_0;
if (!lv_update_and_reload(lv))
return_0;
}
6 years, 6 months
master - cleanup: use NAME_LEN stack buffer
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=dc7d3dd5eda431...
Commit: dc7d3dd5eda43186829ac4237ab049fe50cbc12a
Parent: 6cd68c55ddc280bcba72961944d24c6a66da1c18
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Dec 11 12:19:38 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 11 23:24:19 2016 +0100
cleanup: use NAME_LEN stack buffer
Using NAME_LEN we get at least easy max LV name size validation.
Also code gets more simple.
---
lib/metadata/mirror.c | 42 +++++++++++++++---------------------------
1 files changed, 15 insertions(+), 27 deletions(-)
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 73b1110..c668ea0 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -661,6 +661,7 @@ static int _split_mirror_images(struct logical_volume *lv,
struct dm_list split_images;
struct lv_list *lvl;
struct cmd_context *cmd = lv->vg->cmd;
+ char layer_name[NAME_LEN], format[NAME_LEN];
if (!lv_is_mirrored(lv)) {
log_error("Unable to split non-mirrored LV %s.",
@@ -728,9 +729,6 @@ static int _split_mirror_images(struct logical_volume *lv,
}
if (!dm_list_empty(&split_images)) {
- size_t len = strlen(new_lv->name) + 32;
- char *layer_name, format[len];
-
/*
* A number of images have been split and
* a new mirror layer must be formed
@@ -747,23 +745,21 @@ static int _split_mirror_images(struct logical_volume *lv,
dm_list_iterate_items(lvl, &split_images) {
sub_lv = lvl->lv;
- if (dm_snprintf(format, len, "%s_mimage_%%d",
+ if (dm_snprintf(format, sizeof(format), "%s_mimage_%%d",
new_lv->name) < 0) {
log_error("Failed to build new image name for %s.",
display_lvname(new_lv));
return 0;
}
- if (!(layer_name = dm_pool_alloc(lv->vg->vgmem, len))) {
- log_error("Unable to allocate memory.");
- return 0;
- }
- if (!generate_lv_name(lv->vg, format, layer_name, len)||
- sscanf(layer_name, format, &i) != 1) {
+ if (!generate_lv_name(lv->vg, format, layer_name, sizeof(layer_name))) {
log_error("Failed to generate new image names for %s.",
display_lvname(new_lv));
return 0;
}
- sub_lv->name = layer_name;
+ if (!(sub_lv->name = dm_pool_strdup(lv->vg->vgmem, layer_name))) {
+ log_error("Unable to allocate memory.");
+ return 0;
+ }
}
if (!_merge_mirror_images(new_lv, &split_images)) {
@@ -1403,15 +1399,11 @@ static int _create_mimage_lvs(struct alloc_handle *ah,
int log)
{
uint32_t m, first_area;
- char *img_name;
- size_t len;
-
- len = strlen(lv->name) + 32;
- img_name = alloca(len);
+ char img_name[NAME_LEN];
- if (dm_snprintf(img_name, len, "%s_mimage_%%d", lv->name) < 0) {
- log_error("img_name allocation failed. "
- "Remove new LV and retry.");
+ if (dm_snprintf(img_name, sizeof(img_name), "%s_mimage_%%d", lv->name) < 0) {
+ log_error("Failed to build new mirror image name for %s.",
+ display_lvname(lv));
return 0;
}
@@ -1784,14 +1776,10 @@ static struct logical_volume *_create_mirror_log(struct logical_volume *lv,
const char *suffix)
{
struct logical_volume *log_lv;
- char *log_name;
- size_t len;
-
- len = strlen(lv_name) + 32;
- log_name = alloca(len); /* alloca never fails */
+ char log_name[NAME_LEN];
- if (dm_snprintf(log_name, len, "%s%s", lv_name, suffix) < 0) {
- log_error("log_name allocation failed.");
+ if (dm_snprintf(log_name, sizeof(log_name), "%s%s", lv_name, suffix) < 0) {
+ log_error("Failed to build new mirror log name for %s.", lv_name);
return NULL;
}
6 years, 6 months
master - cleanup: reuse existing function
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6cd68c55ddc280...
Commit: 6cd68c55ddc280bcba72961944d24c6a66da1c18
Parent: 6f84d3c69cdc161508fcc29e82f1167334466084
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Dec 11 14:31:47 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 11 23:24:19 2016 +0100
cleanup: reuse existing function
Call lv_update_and_reload implementation.
---
tools/pvmove_poll.c | 34 ++--------------------------------
1 files changed, 2 insertions(+), 32 deletions(-)
diff --git a/tools/pvmove_poll.c b/tools/pvmove_poll.c
index 2cd746b..438d458 100644
--- a/tools/pvmove_poll.c
+++ b/tools/pvmove_poll.c
@@ -83,38 +83,8 @@ int pvmove_update_metadata(struct cmd_context *cmd, struct volume_group *vg,
struct dm_list *lvs_changed __attribute__((unused)),
unsigned flags __attribute__((unused)))
{
- log_verbose("Updating volume group metadata.");
- if (!vg_write(vg)) {
- log_error("ABORTING: Volume group metadata update failed.");
- return 0;
- }
-
- if (!suspend_lv(cmd, lv_mirr)) {
- vg_revert(vg);
- log_error("ABORTING: Temporary pvmove mirror reload failed.");
- if (!revert_lv(cmd, lv_mirr))
- stack;
- return 0;
- }
-
- /* Commit on-disk metadata */
- if (!vg_commit(vg)) {
- log_error("ABORTING: Volume group metadata update failed.");
- if (!resume_lv(cmd, lv_mirr))
- log_error("Unable to reactivate logical volume \"%s\".",
- lv_mirr->name);
- if (!revert_lv(cmd, lv_mirr))
- stack;
- return 0;
- }
-
- if (!resume_lv(cmd, lv_mirr)) {
- log_error("Unable to reactivate logical volume \"%s\".",
- lv_mirr->name);
- return 0;
- }
-
- backup(vg);
+ if (!lv_update_and_reload(lv_mirr))
+ return_0;
return 1;
}
6 years, 6 months
master - libdm: validate vsnprintf
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6f84d3c69cdc16...
Commit: 6f84d3c69cdc161508fcc29e82f1167334466084
Parent: 3903f915f83634f91946550fda85d60b72ce3a88
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 9 22:54:08 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 11 23:24:17 2016 +0100
libdm: validate vsnprintf
Avoid using buffer when no output has been generated.
Missed in ee13f265f043b47a1b023321fb9e8470fb5703c1.
---
WHATS_NEW_DM | 1 +
libdm/libdm-common.c | 12 ++++++++----
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 73707b6..f402113 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.138 -
=====================================
+ Validation vsnprintf result in runtime translate of dm_log (1.02.136).
Separate filemap extent allocation from region table.
Fix segmentation fault when filemap region creation fails
Fix performance of region cleanup for failed filemap creation.
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index 476f018..d8cf946 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -173,14 +173,16 @@ static void _log_to_default_log(int level,
const char *file, int line, int dm_errno_or_class,
const char *f, ...)
{
+ int n;
va_list ap;
char buf[2 * PATH_MAX + 256]; /* big enough for most messages */
va_start(ap, f);
- vsnprintf(buf, sizeof(buf), f, ap);
+ n = vsnprintf(buf, sizeof(buf), f, ap);
va_end(ap);
- dm_log(level, file, line, "%s", buf);
+ if (n > 0) /* Could be truncated */
+ dm_log(level, file, line, "%s", buf);
}
/*
@@ -195,14 +197,16 @@ __attribute__((format(printf, 4, 5)))
static void _log_to_default_log_with_errno(int level,
const char *file, int line, const char *f, ...)
{
+ int n;
va_list ap;
char buf[2 * PATH_MAX + 256]; /* big enough for most messages */
va_start(ap, f);
- vsnprintf(buf, sizeof(buf), f, ap);
+ n = vsnprintf(buf, sizeof(buf), f, ap);
va_end(ap);
- dm_log_with_errno(level, file, line, 0, "%s", buf);
+ if (n > 0) /* Could be truncated */
+ dm_log_with_errno(level, file, line, 0, "%s", buf);
}
void dm_log_init(dm_log_fn fn)
6 years, 6 months
master - pvmove: fix activation order
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3903f915f83634...
Commit: 3903f915f83634f91946550fda85d60b72ce3a88
Parent: 67f9e6b175815d7a91a10ecc3d5098d30dbfed91
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Dec 11 14:26:17 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 11 23:22:36 2016 +0100
pvmove: fix activation order
For proper locking we need to gain lock first for mirror which
needs to be deactivated later to be working in cluster.
---
WHATS_NEW | 1 +
tools/pvmove_poll.c | 10 +++++-----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 63cdb89..ea15903 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Fix pvmove leaving -pvmove0 error device in clustered VG.
Avoid adding extra '_' at end of raid extracted images or metadata.
Optimize another _rmeta clearing code.
Fix deactivation of raid orphan devices for clustered VG.
diff --git a/tools/pvmove_poll.c b/tools/pvmove_poll.c
index ea4be24..2cd746b 100644
--- a/tools/pvmove_poll.c
+++ b/tools/pvmove_poll.c
@@ -157,17 +157,17 @@ int pvmove_finish(struct cmd_context *cmd, struct volume_group *vg,
return 0;
}
+ /* Unsuspend LVs */
+ if (!resume_lvs(cmd, lvs_changed))
+ stack;
+
/* Release mirror LV. (No pending I/O because it's been suspended.) */
- if (!resume_lv(cmd, lv_mirr)) {
+ if (!activate_lv_excl_local(cmd, lv_mirr)) {
log_error("Unable to reactivate logical volume \"%s\"",
lv_mirr->name);
r = 0;
}
- /* Unsuspend LVs */
- if (!resume_lvs(cmd, lvs_changed))
- stack;
-
/* Deactivate mirror LV */
if (!deactivate_lv(cmd, lv_mirr)) {
log_error("ABORTING: Unable to deactivate temporary logical "
6 years, 6 months
master - raid: avoid _ at end of name of extracted metadata LV
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=67f9e6b175815d...
Commit: 67f9e6b175815d7a91a10ecc3d5098d30dbfed91
Parent: 55ca8043d4bb0ef4435a24728cad34f8b0ff6c8c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Dec 10 14:51:00 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 11 23:20:51 2016 +0100
raid: avoid _ at end of name of extracted metadata LV
Do not generate @PREFIX@vg/LV1_rmeta_1_extracted_.
---
WHATS_NEW | 1 +
lib/metadata/raid_manip.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9e95792..63cdb89 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Avoid adding extra '_' at end of raid extracted images or metadata.
Optimize another _rmeta clearing code.
Fix deactivation of raid orphan devices for clustered VG.
Fix lvconvert raid1 to mirror table reload order.
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 159bfa2..58e3bcf 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1785,7 +1785,7 @@ static int _extract_image_component_error_seg(struct lv_segment *seg,
if (!remove_seg_from_segs_using_this_lv(lv, seg))
return_0;
- if (!(lv->name = _generate_raid_name(lv, "extracted_", -1)))
+ if (!(lv->name = _generate_raid_name(lv, "extracted", -1)))
return_0;
if (set_error_seg && !replace_lv_with_error_segment(lv))
6 years, 6 months
master - raid: optimize clearing of lvs
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=55ca8043d4bb0e...
Commit: 55ca8043d4bb0ef4435a24728cad34f8b0ff6c8c
Parent: 8831a541a831a2d25cb96ee09f6739526d29e5c1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Dec 10 20:53:17 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 11 23:19:41 2016 +0100
raid: optimize clearing of lvs
Activate whole list of metadata lvs first before clearing them.
(Similar to commit ada5733c5652d456ffa138b0d07e6897824813b0)
TODO: make this clearing in a single common function.
---
WHATS_NEW | 1 +
lib/metadata/raid_manip.c | 92 ++++++++++++++++++++++----------------------
2 files changed, 47 insertions(+), 46 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index b6f74ec..9e95792 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Optimize another _rmeta clearing code.
Fix deactivation of raid orphan devices for clustered VG.
Fix lvconvert raid1 to mirror table reload order.
Add internal function for separate mirror log preparation.
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 661c39b..159bfa2 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -379,10 +379,7 @@ static int _raid_remove_top_layer(struct logical_volume *lv,
return 1;
}
-/*
- * _clear_lv
- * @lv
- *
+/* Makes on-disk metadata changes
* If LV is active:
* clear first block of device
* otherwise:
@@ -390,50 +387,15 @@ static int _raid_remove_top_layer(struct logical_volume *lv,
*
* Returns: 1 on success, 0 on failure
*/
-static int _clear_lv(struct logical_volume *lv)
-{
- int was_active = lv_is_active_locally(lv);
-
- if (test_mode())
- return 1;
-
- lv->status |= LV_TEMPORARY;
- if (!was_active && !activate_lv_local(lv->vg->cmd, lv)) {
- log_error("Failed to activate localy %s for clearing.",
- display_lvname(lv));
- return 0;
- }
- lv->status &= ~LV_TEMPORARY;
-
- log_verbose("Clearing metadata area of %s",
- display_lvname(lv));
- /*
- * Rather than wiping lv->size, we can simply
- * wipe the first sector to remove the superblock of any previous
- * RAID devices. It is much quicker.
- */
- if (!wipe_lv(lv, (struct wipe_params) { .do_zero = 1, .zero_sectors = 1 })) {
- log_error("Failed to zero %s.",
- display_lvname(lv));
- return 0;
- }
-
- if (!was_active && !deactivate_lv(lv->vg->cmd, lv)) {
- log_error("Failed to deactivate %s.",
- display_lvname(lv));
- return 0;
- }
-
- return 1;
-}
-
-/* Makes on-disk metadata changes */
static int _clear_lvs(struct dm_list *lv_list)
{
struct lv_list *lvl;
struct volume_group *vg = NULL;
+ unsigned i = 0, sz = dm_list_size(lv_list);
+ char *was_active;
+ int r = 1;
- if (dm_list_empty(lv_list)) {
+ if (!sz) {
log_debug_metadata(INTERNAL_ERROR "Empty list of LVs given for clearing.");
return 1;
}
@@ -447,6 +409,9 @@ static int _clear_lvs(struct dm_list *lv_list)
vg = lvl->lv->vg;
}
+ if (test_mode())
+ return 1;
+
/*
* FIXME: only vg_[write|commit] if LVs are not already written
* as visible in the LVM metadata (which is never the case yet).
@@ -454,11 +419,46 @@ static int _clear_lvs(struct dm_list *lv_list)
if (!vg || !vg_write(vg) || !vg_commit(vg))
return_0;
+ was_active = alloca(sz);
+
dm_list_iterate_items(lvl, lv_list)
- if (!_clear_lv(lvl->lv))
- return 0;
+ if (!(was_active[i++] = lv_is_active_locally(lvl->lv))) {
+ lvl->lv->status |= LV_TEMPORARY;
+ if (!activate_lv_excl_local(vg->cmd, lvl->lv)) {
+ log_error("Failed to activate localy %s for clearing.",
+ display_lvname(lvl->lv));
+ r = 0;
+ goto out;
+ }
+ lvl->lv->status &= ~LV_TEMPORARY;
+ }
- return 1;
+ dm_list_iterate_items(lvl, lv_list) {
+ log_verbose("Clearing metadata area %s.", display_lvname(lvl->lv));
+ /*
+ * Rather than wiping lv->size, we can simply
+ * wipe the first sector to remove the superblock of any previous
+ * RAID devices. It is much quicker.
+ */
+ if (!wipe_lv(lvl->lv, (struct wipe_params) { .do_zero = 1, .zero_sectors = 1 })) {
+ log_error("Failed to zero %s.", display_lvname(lvl->lv));
+ r = 0;
+ goto out;
+ }
+ }
+out:
+ /* TODO: deactivation is only needed with clustered locking
+ * in normal case we should keep device active
+ */
+ sz = 0;
+ dm_list_iterate_items(lvl, lv_list)
+ if ((i > sz) && !was_active[sz++] &&
+ !deactivate_lv(vg->cmd, lvl->lv)) {
+ log_error("Failed to deactivate %s.", display_lvname(lvl->lv));
+ r = 0; /* continue deactivating */
+ }
+
+ return r;
}
/*
6 years, 6 months
master - raid: fix delete on clustered vg
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8831a541a831a2...
Commit: 8831a541a831a2d25cb96ee09f6739526d29e5c1
Parent: 0c8369099bc6105f39982b3e36dd9a53c347b07a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Dec 10 20:00:32 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 11 23:18:22 2016 +0100
raid: fix delete on clustered vg
For clustered VG ensure lock is grabbed first,
so later deactivation works.
TODO: fix tree to solve device removal automatically.
---
WHATS_NEW | 1 +
lib/metadata/raid_manip.c | 12 ++++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 74627ba..b6f74ec 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Fix deactivation of raid orphan devices for clustered VG.
Fix lvconvert raid1 to mirror table reload order.
Add internal function for separate mirror log preparation.
Fix segfault in lvmetad from missing NULL in daemon_reply_simple.
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 5cbd819..661c39b 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -248,6 +248,12 @@ static int _deactivate_and_remove_lvs(struct volume_group *vg, struct dm_list *r
{
struct lv_list *lvl;
+ if (vg_is_clustered(vg))
+ /* Need to take lock for proper deactivation */
+ dm_list_iterate_items(lvl, removal_lvs)
+ if (!activate_lv_excl_local(vg->cmd, lvl->lv))
+ return_0;
+
dm_list_iterate_items(lvl, removal_lvs) {
if (!deactivate_lv(vg->cmd, lvl->lv))
return_0;
@@ -2968,6 +2974,12 @@ static int _clear_meta_lvs(struct logical_volume *lv)
!lv_update_and_reload(lv))
return_0;
+ /* Note: detached rmeta are NOT renamed */
+ /* Grab locks first in case of clustered VG */
+ if (vg_is_clustered(lv->vg))
+ dm_list_iterate_items(lvl, &meta_lvs)
+ if (!activate_lv_excl_local(lv->vg->cmd, lvl->lv))
+ return_0;
/*
* Now deactivate the MetaLVs before clearing, so
* that _clear_lvs() will activate them visible.
6 years, 6 months