master - TEST: Add missing test for RAID module version
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5cdd7848f46305...
Commit: 5cdd7848f46305d3d5744c194d4e2d38b78f0ec7
Parent: 6d75ff138cb1614ee5e31bbd0c3c25721ff9514c
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Sep 12 06:27:37 2012 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Sep 12 06:27:37 2012 -0500
TEST: Add missing test for RAID module version
RAID10 was added to dm-raid module version 1.3.0. Omitted test for
this version is causing test suite to fail.
---
test/shell/lvresize-raid.sh | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvresize-raid.sh b/test/shell/lvresize-raid.sh
index e78eb8c..08382a5 100644
--- a/test/shell/lvresize-raid.sh
+++ b/test/shell/lvresize-raid.sh
@@ -79,6 +79,8 @@ for i in 4 5 6 ; do
done
done
+aux target_at_least dm-raid 1 3 0 || skip
+
# Extend RAID10 (2-stripes, 2-mirror)
for deactivate in true false; do
lvcreate --type raid10 -m 1 -i 2 -l 2 -n $lv1 $vg
11 years, 7 months
master - systemd: depend on systemd-udev-settle unit in activation unit
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6d75ff138cb161...
Commit: 6d75ff138cb1614ee5e31bbd0c3c25721ff9514c
Parent: 31271606265ec8f7c14734aedbb0a314dfea2cd1
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Sep 12 11:30:13 2012 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Sep 12 11:30:13 2012 +0200
systemd: depend on systemd-udev-settle unit in activation unit
The "fedora-wait-storage.service" that the "lvm2-activation.service"
had as a dependency (which was fedora-specific solution anyway)
is obsolete now as this unit called "modprobe scsi_wait_scan"
which is not used anymore.
The "fedora-wait-storage.service" had "systemd-udev-settle" as
its dependency, so let's depend on this one directly now,
bypassing the out-dated "fedora-wait-storage.service".
---
WHATS_NEW | 1 +
.../lvm2_activation_generator_systemd_red_hat.c | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4884626..2b897e8 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Depend on systemd-udev-settle in units generated by activation generator.
Fix vgchange -aay to activate proper logical volumes.
Properly handle 'resync' of RAID LVs.
Disallow addition of RAID images until the array is in-sync.
diff --git a/scripts/lvm2_activation_generator_systemd_red_hat.c b/scripts/lvm2_activation_generator_systemd_red_hat.c
index 9fcee20..786d795 100644
--- a/scripts/lvm2_activation_generator_systemd_red_hat.c
+++ b/scripts/lvm2_activation_generator_systemd_red_hat.c
@@ -116,12 +116,12 @@ static int generate_unit(const char *dir, int early)
"DefaultDependencies=no\n", f);
if (early)
- fputs("After=fedora-wait-storage.service\n", f);
+ fputs("After=systemd-udev-settle.service\n", f);
else
fputs("After=lvm2-activation-early.service cryptsetup.target\n", f);
fputs("Before=local-fs.target shutdown.target\n"
- "Wants=fedora-wait-storage.service\n\n"
+ "Wants=systemd-udev-settle.service\n\n"
"[Service]\n"
"ExecStart=/usr/sbin/lvm vgchange -aay --sysinit\n"
"Type=oneshot\n", f);
11 years, 7 months
master - vgchange: fix -aay to activate proper volumes
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=31271606265ec8...
Commit: 31271606265ec8f7c14734aedbb0a314dfea2cd1
Parent: 4ededc698f32a4cbabaf70bfd3835abab866cbb9
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Sep 12 09:47:40 2012 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Sep 12 09:47:40 2012 +0200
vgchange: fix -aay to activate proper volumes
Using 'activation/auto_activation_volume_list = [ "vg/lvol1" ]'.
Before this patch:
3 logical volume(s) in volume group "vg" now active
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
lvol0 vg -wi----- 4.00m
lvol1 vg -wi-a--- 4.00m
lvol2 vg -wi-a--- 4.00m
lvol3 vg -wi-a--- 4.00m
(vg/lvol1 activated as it passes the list and all subsequent volumes too - wrong!)
With this patch:
1 logical volume(s) in volume group "vg" now active
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
lvol0 vg -wi----- 4.00m
lvol1 vg -wi-a--- 4.00m
lvol2 vg -wi----- 4.00m
lvol3 vg -wi----- 4.00m
(only vg/lvol1 activated as it passes the list and no other - correct!)
---
WHATS_NEW | 1 +
tools/vgchange.c | 9 +++------
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0c3b591..4884626 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Fix vgchange -aay to activate proper logical volumes.
Properly handle 'resync' of RAID LVs.
Disallow addition of RAID images until the array is in-sync.
Fix RAID LV creation with '--test' so valid commands do not fail.
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 34f6167..fa129f8 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -131,11 +131,8 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
continue;
}
- if (activate == CHANGE_AAY) {
- if (!lv_passes_auto_activation_filter(cmd, lv))
- continue;
- activate = CHANGE_ALY;
- }
+ if (activate == CHANGE_AAY && !lv_passes_auto_activation_filter(cmd, lv))
+ continue;
expected_count++;
@@ -157,7 +154,7 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
stack;
continue;
}
- } else if (activate == CHANGE_ALY) {
+ } else if (activate == CHANGE_AAY || activate == CHANGE_ALY) {
if (!activate_lv_local(cmd, lv)) {
stack;
continue;
11 years, 7 months
master - RAID: Properly handle resync of RAID LVs
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4ededc698f32a4...
Commit: 4ededc698f32a4cbabaf70bfd3835abab866cbb9
Parent: a2d9b1a7e92aab78c80be0e0cbd45fde00d42aa4
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Tue Sep 11 13:09:35 2012 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Tue Sep 11 13:09:35 2012 -0500
RAID: Properly handle resync of RAID LVs
Issuing a 'lvchange --resync <VG>/<RAID_LV>' had no effect. This is
because the code to handle RAID LVs was not present. This patch adds
the code that will clear the metadata areas of RAID LVs - causing them
to resync upon activation.
---
WHATS_NEW | 1 +
tools/lvchange.c | 51 +++++++++++++++++++++++++++++++++++++--------------
2 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c0b84ab..0c3b591 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Properly handle 'resync' of RAID LVs.
Disallow addition of RAID images until the array is in-sync.
Fix RAID LV creation with '--test' so valid commands do not fail.
Add lvm_lv_rename() to lvm2api.
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 6972aac..0904e7b 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -258,29 +258,50 @@ static int lvchange_refresh(struct cmd_context *cmd, struct logical_volume *lv)
static int detach_metadata_devices(struct lv_segment *seg, struct dm_list *list)
{
+ uint32_t s;
+ uint32_t num_meta_lvs;
struct cmd_context *cmd = seg->lv->vg->cmd;
struct lv_list *lvl;
- if (seg_is_raid(seg)) {
- return 0;
- }
+ num_meta_lvs = seg_is_raid(seg) ? seg->area_count : !!seg->log_lv;
+
+ if (!num_meta_lvs)
+ return_0;
- if (!(lvl = dm_pool_alloc(cmd->mem, sizeof(*lvl))))
+ if (!(lvl = dm_pool_alloc(cmd->mem, sizeof(*lvl) * num_meta_lvs)))
return_0;
- lvl->lv = detach_mirror_log(seg);
- dm_list_add(list, &lvl->list);
+ if (seg_is_raid(seg)) {
+ for (s = 0; s < seg->area_count; s++) {
+ if (!seg_metalv(seg, s))
+ return_0; /* Trap this future possibility */
+
+ lvl[s].lv = seg_metalv(seg, s);
+ lv_set_visible(lvl[s].lv);
+
+ dm_list_add(list, &lvl[s].list);
+ }
+ return 1;
+ }
+
+ lvl[0].lv = detach_mirror_log(seg);
+ dm_list_add(list, &lvl[0].list);
return 1;
}
static int attach_metadata_devices(struct lv_segment *seg, struct dm_list *list)
{
+ uint32_t s = 0;
struct cmd_context *cmd = seg->lv->vg->cmd;
- struct lv_list *lvl;
+ struct lv_list *lvl, *tmp;
if (seg_is_raid(seg)) {
- return 0;
+ dm_list_iterate_items_safe(lvl, tmp, list) {
+ lv_set_hidden(lvl->lv);
+ dm_pool_free(cmd->mem, lvl);
+ }
+ return 1;
}
dm_list_iterate_items(lvl, list)
@@ -308,8 +329,8 @@ static int lvchange_resync(struct cmd_context *cmd,
dm_list_init(&device_list);
- if (!(lv->status & MIRRORED)) {
- log_error("Unable to resync %s because it is not mirrored.",
+ if (!(lv->status & MIRRORED) && !seg_is_raid(seg)) {
+ log_error("Unable to resync %s. It is not RAID or mirrored.",
lv->name);
return 1;
}
@@ -364,12 +385,14 @@ static int lvchange_resync(struct cmd_context *cmd,
}
init_dmeventd_monitor(monitored);
+ init_mirror_in_sync(0);
- log_very_verbose("Starting resync of %s%s%s mirror \"%s\"",
+ log_very_verbose("Starting resync of %s%s%s%s \"%s\"",
(active) ? "active " : "",
vg_is_clustered(lv->vg) ? "clustered " : "",
- (seg->log_lv) ? "disk-logged" : "core-logged",
- lv->name);
+ (seg->log_lv) ? "disk-logged " :
+ seg_is_raid(seg) ? "" : "core-logged ",
+ seg->segtype->ops->name(seg), lv->name);
/*
* If this mirror has a core log (i.e. !seg->log_lv),
@@ -377,7 +400,7 @@ static int lvchange_resync(struct cmd_context *cmd,
* it to reset the sync status. We only need to
* worry about persistent logs.
*/
- if (!seg->log_lv) {
+ if (!seg_is_raid(seg) && !seg->log_lv) {
if (!(lv->status & LV_NOTSYNCED)) {
lv->status &= ~LV_NOTSYNCED;
log_very_verbose("Updating logical volume \"%s\""
11 years, 7 months
master - cleanup: Restructure code that handles mirror resyncing
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a2d9b1a7e92aab...
Commit: a2d9b1a7e92aab78c80be0e0cbd45fde00d42aa4
Parent: 05131f5853e86419d9c726faa961b8d012298d9c
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Tue Sep 11 13:01:05 2012 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Tue Sep 11 13:01:05 2012 -0500
cleanup: Restructure code that handles mirror resyncing
When an LV is to be resynced, the metadata areas are cleared and the
LV is reactivated. This is true for mirroring and will also be true
for RAID LVs. We restructure the code in lvchange_resync() so that we
keep all the common steps necessary (validation of ability to resync,
deactivation, activation of meta/log devices, clearing of those devices,
etc) and place the code that will be divergent in separate functions:
detach_metadata_devices()
attach_metadata_devices()
The common steps will be processed on lists of metadata devices. Before
RAID capability is added, this will simply be the mirror log device (if
found).
This patch lays the ground-work for adding resync of RAID LVs.
---
tools/lvchange.c | 115 ++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 86 insertions(+), 29 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index cbdb353..6972aac 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -256,13 +256,57 @@ static int lvchange_refresh(struct cmd_context *cmd, struct logical_volume *lv)
return lv_refresh(cmd, lv);
}
+static int detach_metadata_devices(struct lv_segment *seg, struct dm_list *list)
+{
+ struct cmd_context *cmd = seg->lv->vg->cmd;
+ struct lv_list *lvl;
+
+ if (seg_is_raid(seg)) {
+ return 0;
+ }
+
+ if (!(lvl = dm_pool_alloc(cmd->mem, sizeof(*lvl))))
+ return_0;
+
+ lvl->lv = detach_mirror_log(seg);
+ dm_list_add(list, &lvl->list);
+
+ return 1;
+}
+
+static int attach_metadata_devices(struct lv_segment *seg, struct dm_list *list)
+{
+ struct cmd_context *cmd = seg->lv->vg->cmd;
+ struct lv_list *lvl;
+
+ if (seg_is_raid(seg)) {
+ return 0;
+ }
+
+ dm_list_iterate_items(lvl, list)
+ break; /* get first item */
+
+ if (!attach_mirror_log(seg, lvl->lv)) {
+ dm_pool_free(cmd->mem, lvl);
+ return_0;
+ }
+
+ dm_pool_free(cmd->mem, lvl);
+
+ return 1;
+}
+
static int lvchange_resync(struct cmd_context *cmd,
struct logical_volume *lv)
{
int active = 0;
int monitored;
struct lvinfo info;
- struct logical_volume *log_lv;
+ struct lv_segment *seg = first_seg(lv);
+ struct dm_list device_list;
+ struct lv_list *lvl;
+
+ dm_list_init(&device_list);
if (!(lv->status & MIRRORED)) {
log_error("Unable to resync %s because it is not mirrored.",
@@ -321,21 +365,19 @@ static int lvchange_resync(struct cmd_context *cmd,
init_dmeventd_monitor(monitored);
- log_lv = first_seg(lv)->log_lv;
-
log_very_verbose("Starting resync of %s%s%s mirror \"%s\"",
(active) ? "active " : "",
vg_is_clustered(lv->vg) ? "clustered " : "",
- (log_lv) ? "disk-logged" : "core-logged",
+ (seg->log_lv) ? "disk-logged" : "core-logged",
lv->name);
/*
- * If this mirror has a core log (i.e. !log_lv),
+ * If this mirror has a core log (i.e. !seg->log_lv),
* then simply deactivating/activating will cause
* it to reset the sync status. We only need to
* worry about persistent logs.
*/
- if (!log_lv) {
+ if (!seg->log_lv) {
if (!(lv->status & LV_NOTSYNCED)) {
lv->status &= ~LV_NOTSYNCED;
log_very_verbose("Updating logical volume \"%s\""
@@ -360,12 +402,17 @@ static int lvchange_resync(struct cmd_context *cmd,
*/
lv->status &= ~LV_NOTSYNCED;
- /* Separate mirror log so we can clear it */
- detach_mirror_log(first_seg(lv));
+ /* Separate mirror log or metadata devices so we can clear them */
+ if (!detach_metadata_devices(seg, &device_list)) {
+ log_error("Failed to clear %s %s for %s",
+ seg->segtype->name, seg_is_raid(seg) ?
+ "metadata area" : "mirror log", lv->name);
+ return 0;
+ }
if (!vg_write(lv->vg)) {
log_error("Failed to write intermediate VG metadata.");
- if (!attach_mirror_log(first_seg(lv), log_lv))
+ if (!attach_metadata_devices(seg, &device_list))
stack;
if (active && !activate_lv(cmd, lv))
stack;
@@ -374,7 +421,7 @@ static int lvchange_resync(struct cmd_context *cmd,
if (!vg_commit(lv->vg)) {
log_error("Failed to commit intermediate VG metadata.");
- if (!attach_mirror_log(first_seg(lv), log_lv))
+ if (!attach_metadata_devices(seg, &device_list))
stack;
if (active && !activate_lv(cmd, lv))
stack;
@@ -383,31 +430,41 @@ static int lvchange_resync(struct cmd_context *cmd,
backup(lv->vg);
- if (!activate_lv(cmd, log_lv)) {
- log_error("Unable to activate %s for mirror log resync",
- log_lv->name);
- return 0;
- }
+ dm_list_iterate_items(lvl, &device_list) {
+ if (!activate_lv(cmd, lvl->lv)) {
+ log_error("Unable to activate %s for mirror log resync",
+ lvl->lv->name);
+ return 0;
+ }
- log_very_verbose("Clearing log device %s", log_lv->name);
- if (!set_lv(cmd, log_lv, log_lv->size, 0)) {
- log_error("Unable to reset sync status for %s", lv->name);
- if (!deactivate_lv(cmd, log_lv))
- log_error("Failed to deactivate log LV after "
- "wiping failed");
- return 0;
+ log_very_verbose("Clearing %s device %s",
+ (seg_is_raid(seg)) ? "metadata" : "log",
+ lvl->lv->name);
+ if (!set_lv(cmd, lvl->lv, lvl->lv->size, 0)) {
+ log_error("Unable to reset sync status for %s",
+ lv->name);
+ if (!deactivate_lv(cmd, lvl->lv))
+ log_error("Failed to deactivate log LV after "
+ "wiping failed");
+ return 0;
+ }
+
+ if (!deactivate_lv(cmd, lvl->lv)) {
+ log_error("Unable to deactivate %s LV %s "
+ "after wiping for resync",
+ (seg_is_raid(seg)) ? "metadata" : "log",
+ lvl->lv->name);
+ return 0;
+ }
}
- if (!deactivate_lv(cmd, log_lv)) {
- log_error("Unable to deactivate log LV %s after wiping "
- "for resync", log_lv->name);
+ /* Put metadata sub-LVs back in place */
+ if (!attach_metadata_devices(seg, &device_list)) {
+ log_error("Failed to reattach %s device after clearing",
+ (seg_is_raid(seg)) ? "metadata" : "log");
return 0;
}
- /* Put mirror log back in place */
- if (!attach_mirror_log(first_seg(lv), log_lv))
- stack;
-
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
if (!vg_write(lv->vg) || !vg_commit(lv->vg)) {
log_error("Failed to update metadata on disk.");
11 years, 7 months
master - cleanup: Reduce indentation by short-circuiting function
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=05131f5853e864...
Commit: 05131f5853e86419d9c726faa961b8d012298d9c
Parent: cdb0339319c89b8d1e5611537e9775a8c3ce5844
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Tue Sep 11 12:55:17 2012 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Tue Sep 11 12:55:17 2012 -0500
cleanup: Reduce indentation by short-circuiting function
By changing the conditional for resyncing mirrors with core-logs a
bit, we can short-circuit the rest of the function for that case
and reduce the amount of indenting in the rest of the function.
This cleanup will simplify future patches aimed at properly handling
the resync of RAID LVs.
---
WHATS_NEW | 1 +
tools/lvchange.c | 98 ++++++++++++++++++++++++++++++-----------------------
2 files changed, 56 insertions(+), 43 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8718a0b..c0b84ab 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Disallow addition of RAID images until the array is in-sync.
Fix RAID LV creation with '--test' so valid commands do not fail.
Add lvm_lv_rename() to lvm2api.
Fix setvbuf code by closing and reopening stream before changing buffer.
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 1f32d5c..cbdb353 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -335,67 +335,79 @@ static int lvchange_resync(struct cmd_context *cmd,
* it to reset the sync status. We only need to
* worry about persistent logs.
*/
- if (!log_lv && !(lv->status & LV_NOTSYNCED)) {
+ if (!log_lv) {
+ if (!(lv->status & LV_NOTSYNCED)) {
+ lv->status &= ~LV_NOTSYNCED;
+ log_very_verbose("Updating logical volume \"%s\""
+ " on disk(s)", lv->name);
+ if (!vg_write(lv->vg) || !vg_commit(lv->vg)) {
+ log_error("Failed to update metadata on disk.");
+ return 0;
+ }
+ }
+
if (active && !activate_lv(cmd, lv)) {
log_error("Failed to reactivate %s to resynchronize "
"mirror", lv->name);
return 0;
}
+
return 1;
}
+ /*
+ * Now we handle mirrors with log devices
+ */
lv->status &= ~LV_NOTSYNCED;
- if (log_lv) {
- /* Separate mirror log so we can clear it */
- detach_mirror_log(first_seg(lv));
-
- if (!vg_write(lv->vg)) {
- log_error("Failed to write intermediate VG metadata.");
- if (!attach_mirror_log(first_seg(lv), log_lv))
- stack;
- if (active && !activate_lv(cmd, lv))
- stack;
- return 0;
- }
+ /* Separate mirror log so we can clear it */
+ detach_mirror_log(first_seg(lv));
- if (!vg_commit(lv->vg)) {
- log_error("Failed to commit intermediate VG metadata.");
- if (!attach_mirror_log(first_seg(lv), log_lv))
- stack;
- if (active && !activate_lv(cmd, lv))
- stack;
- return 0;
- }
+ if (!vg_write(lv->vg)) {
+ log_error("Failed to write intermediate VG metadata.");
+ if (!attach_mirror_log(first_seg(lv), log_lv))
+ stack;
+ if (active && !activate_lv(cmd, lv))
+ stack;
+ return 0;
+ }
- backup(lv->vg);
+ if (!vg_commit(lv->vg)) {
+ log_error("Failed to commit intermediate VG metadata.");
+ if (!attach_mirror_log(first_seg(lv), log_lv))
+ stack;
+ if (active && !activate_lv(cmd, lv))
+ stack;
+ return 0;
+ }
- if (!activate_lv(cmd, log_lv)) {
- log_error("Unable to activate %s for mirror log resync",
- log_lv->name);
- return 0;
- }
+ backup(lv->vg);
- log_very_verbose("Clearing log device %s", log_lv->name);
- if (!set_lv(cmd, log_lv, log_lv->size, 0)) {
- log_error("Unable to reset sync status for %s", lv->name);
- if (!deactivate_lv(cmd, log_lv))
- log_error("Failed to deactivate log LV after "
- "wiping failed");
- return 0;
- }
+ if (!activate_lv(cmd, log_lv)) {
+ log_error("Unable to activate %s for mirror log resync",
+ log_lv->name);
+ return 0;
+ }
- if (!deactivate_lv(cmd, log_lv)) {
- log_error("Unable to deactivate log LV %s after wiping "
- "for resync", log_lv->name);
- return 0;
- }
+ log_very_verbose("Clearing log device %s", log_lv->name);
+ if (!set_lv(cmd, log_lv, log_lv->size, 0)) {
+ log_error("Unable to reset sync status for %s", lv->name);
+ if (!deactivate_lv(cmd, log_lv))
+ log_error("Failed to deactivate log LV after "
+ "wiping failed");
+ return 0;
+ }
- /* Put mirror log back in place */
- if (!attach_mirror_log(first_seg(lv), log_lv))
- stack;
+ if (!deactivate_lv(cmd, log_lv)) {
+ log_error("Unable to deactivate log LV %s after wiping "
+ "for resync", log_lv->name);
+ return 0;
}
+ /* Put mirror log back in place */
+ if (!attach_mirror_log(first_seg(lv), log_lv))
+ stack;
+
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
if (!vg_write(lv->vg) || !vg_commit(lv->vg)) {
log_error("Failed to update metadata on disk.");
11 years, 7 months
master - RAID: Disallow addition of RAID images while array is not in-sync
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cdb0339319c89b...
Commit: cdb0339319c89b8d1e5611537e9775a8c3ce5844
Parent: b49b98d50c558a142d0a2ef55279eea00bd36eba
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Mon Sep 10 17:15:20 2012 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Mon Sep 10 17:15:20 2012 -0500
RAID: Disallow addition of RAID images while array is not in-sync
We cannot add images to a RAID array while it is not in-sync. The
kernel will simply reject the table, saying:
'rebuild' specified while array is not in-sync
Now we check to ensure the LV is in-sync before attempting image
additions.
---
lib/metadata/raid_manip.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index b5552cb..4eced6f 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -663,6 +663,10 @@ static int _raid_add_images(struct logical_volume *lv,
log_error("Unable to add RAID images to %s of segment type %s",
lv->name, seg->segtype->ops->name(seg));
return 0;
+ } else if (!_raid_in_sync(lv)) {
+ log_error("Unable to add RAID images until %s is in-sync",
+ lv->name);
+ return 0;
}
if (!_alloc_image_components(lv, pvs, count, &meta_lvs, &data_lvs)) {
11 years, 7 months
master - RAID: '--test' should not cause a valid create command to fail
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b49b98d50c558a...
Commit: b49b98d50c558a142d0a2ef55279eea00bd36eba
Parent: c3eb3a76875ccf8c544c991bc52b6b3061bf8f58
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Sep 5 14:32:06 2012 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Sep 5 14:32:06 2012 -0500
RAID: '--test' should not cause a valid create command to fail
It is necessary when creating a RAID LV to clear the new metadata areas.
Failure to do so could result in a prepopulated bitmap that would cause
the new array to skip syncing portions of the array. It is a requirement
that the metadata LVs be activated and cleared in the process of creating.
However in test mode, this requirement should be lifted - no new LVs should
be created or written to.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 6 ++++++
lib/metadata/raid_manip.c | 3 +++
3 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 28d1908..8718a0b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Fix RAID LV creation with '--test' so valid commands do not fail.
Add lvm_lv_rename() to lvm2api.
Fix setvbuf code by closing and reopening stream before changing buffer.
Disable private buffering when using liblvm.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 617d4b7..3702caf 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -2623,6 +2623,12 @@ static int _lv_extend_layered_lv(struct alloc_handle *ah,
for (s = 0; s < seg->area_count; s++) {
meta_lv = seg_metalv(seg, s);
+
+ if (test_mode()) {
+ lv_set_hidden(meta_lv);
+ continue;
+ }
+
if (!activate_lv(meta_lv->vg->cmd, meta_lv)) {
log_error("Failed to activate %s/%s for clearing",
meta_lv->vg->name, meta_lv->name);
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index c786a7d..b5552cb 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -304,6 +304,9 @@ static int _clear_lv(struct logical_volume *lv)
{
int was_active = lv_is_active(lv);
+ if (test_mode())
+ return 1;
+
if (!was_active && !activate_lv(lv->vg->cmd, lv)) {
log_error("Failed to activate %s for clearing",
lv->name);
11 years, 7 months
master - cleanup: Use segtype->ops->name() instead of segtype->name where applicable
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c3eb3a76875ccf...
Commit: c3eb3a76875ccf8c544c991bc52b6b3061bf8f58
Parent: 1b01a2f65a27b95717fa7b6d912271e330782873
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Sep 5 11:35:54 2012 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Sep 5 11:35:54 2012 -0500
cleanup: Use segtype->ops->name() instead of segtype->name where applicable
When printing a message for the user and the lv_segment pointer is available,
use segtype->ops->name() instead of segtype->name. This gives a better
user-readable name for the segment. This is especially true for the
'striped' segment type, which prints "linear" if there is an area_count of
one.
---
lib/metadata/merge.c | 3 ++-
lib/metadata/raid_manip.c | 11 ++++++-----
tools/lvconvert.c | 4 ++--
tools/lvresize.c | 2 +-
4 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c
index cc906d1..f7c05a2 100644
--- a/lib/metadata/merge.c
+++ b/lib/metadata/merge.c
@@ -429,7 +429,8 @@ static int _lv_split_segment(struct logical_volume *lv, struct lv_segment *seg,
if (!seg_can_split(seg)) {
log_error("Unable to split the %s segment at LE %" PRIu32
- " in LV %s", seg->segtype->name, le, lv->name);
+ " in LV %s", seg->segtype->ops->name(seg),
+ le, lv->name);
return 0;
}
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 1188891..c786a7d 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -252,7 +252,7 @@ static int _raid_remove_top_layer(struct logical_volume *lv,
if (!seg_is_mirrored(seg)) {
log_error(INTERNAL_ERROR
"Unable to remove RAID layer from segment type %s",
- seg->segtype->name);
+ seg->segtype->ops->name(seg));
return 0;
}
@@ -658,7 +658,7 @@ static int _raid_add_images(struct logical_volume *lv,
dm_list_add(&meta_lvs, &lvl->list);
} else if (!seg_is_raid(seg)) {
log_error("Unable to add RAID images to %s of segment type %s",
- lv->name, seg->segtype->name);
+ lv->name, seg->segtype->ops->name(seg));
return 0;
}
@@ -1126,7 +1126,7 @@ int lv_raid_split(struct logical_volume *lv, const char *split_name,
if (!seg_is_mirrored(first_seg(lv))) {
log_error("Unable to split logical volume of segment type, %s",
- first_seg(lv)->segtype->name);
+ first_seg(lv)->segtype->ops->name(first_seg(lv)));
return 0;
}
@@ -1561,7 +1561,7 @@ int lv_raid_reshape(struct logical_volume *lv,
log_error("Converting the segment type for %s/%s from %s to %s"
" is not yet supported.", lv->vg->name, lv->name,
- seg->segtype->name, new_segtype->name);
+ seg->segtype->ops->name(seg), new_segtype->name);
return 0;
}
@@ -1617,7 +1617,8 @@ int lv_raid_replace(struct logical_volume *lv,
(match_count > raid_seg->segtype->parity_devs)) {
log_error("Unable to replace more than %u PVs from (%s) %s/%s",
raid_seg->segtype->parity_devs,
- raid_seg->segtype->name, lv->vg->name, lv->name);
+ raid_seg->segtype->ops->name(raid_seg),
+ lv->vg->name, lv->name);
return 0;
} else if (!strcmp(raid_seg->segtype->name, "raid10")) {
uint32_t i, rebuilds_per_group = 0;
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index ddda2f1..7b284f0 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1577,14 +1577,14 @@ static int lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *lp
if (arg_count(cmd, mirrors_ARG) &&
!seg_is_mirrored(seg) && !seg_is_linear(seg)) {
log_error("'--mirrors/-m' is not compatible with %s",
- seg->segtype->name);
+ seg->segtype->ops->name(seg));
return 0;
}
if (!is_valid_raid_conversion(seg->segtype, lp->segtype)) {
log_error("Unable to convert %s/%s from %s to %s",
lv->vg->name, lv->name,
- seg->segtype->name, lp->segtype->name);
+ seg->segtype->ops->name(seg), lp->segtype->name);
return 0;
}
diff --git a/tools/lvresize.c b/tools/lvresize.c
index 5052bfb..18e5917 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -630,7 +630,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
lp->stripes = seg_stripes;
else if (seg_is_raid(first_seg(lv)) &&
(lp->stripes != seg_stripes)) {
- log_error("Unable to extend \"%s\" segment type with different number of stripes.", first_seg(lv)->segtype->name);
+ log_error("Unable to extend \"%s\" segment type with different number of stripes.", first_seg(lv)->segtype->ops->name(first_seg(lv)));
return ECMD_FAILED;
}
11 years, 7 months
master - TEST (lvresize-raid): Also test resizing of RAID10
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1b01a2f65a27b9...
Commit: 1b01a2f65a27b95717fa7b6d912271e330782873
Parent: 967b5eb1f3a25572448974f882e3bc8ba5d3fb9a
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Fri Aug 24 16:20:53 2012 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Sep 5 11:33:07 2012 -0500
TEST (lvresize-raid): Also test resizing of RAID10
---
test/shell/lvresize-raid.sh | 35 +++++++++++++++++++++++++++++++++--
1 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/test/shell/lvresize-raid.sh b/test/shell/lvresize-raid.sh
index ea5cc80..e78eb8c 100644
--- a/test/shell/lvresize-raid.sh
+++ b/test/shell/lvresize-raid.sh
@@ -38,7 +38,7 @@ for deactivate in true false; do
lvchange -an $vg/$lv1
fi
- should lvresize -l -2 $vg/$lv1
+ should lvresize -y -l -2 $vg/$lv1
#check raid_images_contiguous $vg $lv1
@@ -71,10 +71,41 @@ for i in 4 5 6 ; do
lvchange -an $vg/$lv1
fi
- should lvresize -l -3 $vg/$lv1
+ should lvresize -y -l -3 $vg/$lv1
#check raid_images_contiguous $vg $lv1
lvremove -ff $vg
done
done
+
+# Extend RAID10 (2-stripes, 2-mirror)
+for deactivate in true false; do
+ lvcreate --type raid10 -m 1 -i 2 -l 2 -n $lv1 $vg
+
+ if $deactivate; then
+ lvchange -an $vg/$lv1
+ fi
+
+ lvresize -l +2 $vg/$lv1
+
+ #check raid_images_contiguous $vg $lv1
+
+ lvremove -ff $vg
+done
+
+# Reduce RAID10 (2-stripes, 2-mirror)
+for deactivate in true false; do
+ lvcreate --type raid10 -m 1 -i 2 -l 4 -n $lv1 $vg
+
+ if $deactivate; then
+ lvchange -an $vg/$lv1
+ fi
+
+ should lvresize -y -l -2 $vg/$lv1
+
+ #check raid_images_contiguous $vg $lv1
+
+ lvremove -ff $vg
+done
+
11 years, 7 months