* [PATCH] Restrict lvm1 partial mode.
@ 2010-10-04 16:48 Milan Broz
2010-10-04 17:20 ` Petr Rockai
0 siblings, 1 reply; 4+ messages in thread
From: Milan Broz @ 2010-10-04 16:48 UTC (permalink / raw)
To: lvm-devel
Current lvm1 allocation code seems to not properly
map segments on missing PVs.
For now disable this functionality.
(It never worked and previous commit just introduced segfault here.)
So the partial mode in lvm1 can only process missing PVs
with no LV segments only.
Also do not use random PV UUID for missing part but use fixed
string derived from VG UUID (to not confuse clvmd tests).
Signed-off-by: Milan Broz <mbroz@redhat.com>
---
lib/format1/format1.c | 28 ++++++++++++++++++++++++++--
1 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index d6c462a..f5a9d12 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -118,6 +118,28 @@ static int _fix_partial_vg(struct volume_group *vg, struct dm_list *pvs)
struct disk_list *dl;
struct dm_list *pvh;
struct pv_list *pvl;
+ struct lv_list *ll;
+ struct lv_segment *seg;
+
+ /*
+ * FIXME: code should remap missing segments to error segment.
+ * Also current mapping code allocates 1 segment per missing extent.
+ * For now bail out completely - allocated structures are not complete
+ */
+ dm_list_iterate_items(ll, &vg->lvs)
+ dm_list_iterate_items(seg, &ll->lv->segments) {
+
+ /* area_count is always 1 here, s == 0 */
+ if (seg_type(seg, 0) != AREA_PV)
+ continue;
+
+ if (seg_pv(seg, 0))
+ continue;
+
+ log_error("Partial mode support for missing lvm1 PVs and "
+ "partially available LVs is currently not implemented.");
+ return 0;
+ }
dm_list_iterate(pvh, pvs) {
dl = dm_list_item(pvh, struct disk_list);
@@ -129,8 +151,10 @@ static int _fix_partial_vg(struct volume_group *vg, struct dm_list *pvs)
!(pvl->pv = dm_pool_zalloc(vg->vgmem, sizeof(*pvl->pv))))
return_0;
- if (!id_create(&pvl->pv->id))
- goto_out;
+ /* Use vg uuid with replaced first chars to "missing" as missing PV UUID */
+ memcpy(&pvl->pv->id.uuid, vg->id.uuid, sizeof(pvl->pv->id.uuid));
+ memcpy(&pvl->pv->id.uuid, "missing", 7);
+
if (!(pvl->pv->vg_name = dm_pool_strdup(vg->vgmem, vg->name)))
goto_out;
memcpy(&pvl->pv->vgid, &vg->id, sizeof(vg->id));
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] Restrict lvm1 partial mode.
2010-10-04 16:48 [PATCH] Restrict lvm1 partial mode Milan Broz
@ 2010-10-04 17:20 ` Petr Rockai
2010-10-04 17:47 ` Milan Broz
2010-10-04 18:54 ` Milan Broz
0 siblings, 2 replies; 4+ messages in thread
From: Petr Rockai @ 2010-10-04 17:20 UTC (permalink / raw)
To: lvm-devel
Milan Broz <mbroz@redhat.com> writes:
> diff --git a/lib/format1/format1.c b/lib/format1/format1.c
> index d6c462a..f5a9d12 100644
> --- a/lib/format1/format1.c
> +++ b/lib/format1/format1.c
> @@ -118,6 +118,28 @@ static int _fix_partial_vg(struct volume_group *vg, struct dm_list *pvs)
> struct disk_list *dl;
> struct dm_list *pvh;
> struct pv_list *pvl;
> + struct lv_list *ll;
> + struct lv_segment *seg;
> +
> + /*
> + * FIXME: code should remap missing segments to error segment.
> + * Also current mapping code allocates 1 segment per missing extent.
> + * For now bail out completely - allocated structures are not complete
> + */
> + dm_list_iterate_items(ll, &vg->lvs)
> + dm_list_iterate_items(seg, &ll->lv->segments) {
> +
> + /* area_count is always 1 here, s == 0 */
> + if (seg_type(seg, 0) != AREA_PV)
> + continue;
> +
> + if (seg_pv(seg, 0))
> + continue;
> +
> + log_error("Partial mode support for missing lvm1 PVs and "
> + "partially available LVs is currently not implemented.");
> + return 0;
> + }
OK.
> dm_list_iterate(pvh, pvs) {
> dl = dm_list_item(pvh, struct disk_list);
> @@ -129,8 +151,10 @@ static int _fix_partial_vg(struct volume_group *vg, struct dm_list *pvs)
> !(pvl->pv = dm_pool_zalloc(vg->vgmem, sizeof(*pvl->pv))))
> return_0;
>
> - if (!id_create(&pvl->pv->id))
> - goto_out;
> + /* Use vg uuid with replaced first chars to "missing" as missing PV UUID */
> + memcpy(&pvl->pv->id.uuid, vg->id.uuid, sizeof(pvl->pv->id.uuid));
> + memcpy(&pvl->pv->id.uuid, "missing", 7);
Does what the comment says... would the result be a bit less confusing
though if it said
memcpy(&pvl->pv->id.uuid, "missing_", 8);
instead? I know, a nitpick.
Other than that,
Reviewed-By: Petr Rockai <prockai@redhat.com>
Yours,
Petr.
PS: Would it be possible to have automated tests for LVM1 stuff as well?
The below seems to work (i.e. new LVM1 VGs can still be created), so we
could just add couple tests for missing PV behaviour with LVM1...
aux prepare_devs 4
pvcreate -M1 $devs
vgcreate -M1 $vg $devs
vgs -o +vg_fmt | grep lvm1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] Restrict lvm1 partial mode.
2010-10-04 17:20 ` Petr Rockai
@ 2010-10-04 17:47 ` Milan Broz
2010-10-04 18:54 ` Milan Broz
1 sibling, 0 replies; 4+ messages in thread
From: Milan Broz @ 2010-10-04 17:47 UTC (permalink / raw)
To: lvm-devel
On 10/04/2010 07:20 PM, Petr Rockai wrote:
> PS: Would it be possible to have automated tests for LVM1 stuff as well?
> The below seems to work (i.e. new LVM1 VGs can still be created), so we
> could just add couple tests for missing PV behaviour with LVM1...
It depends if we want to spend resources for supporting lvm1 format forever.
It is very rarely used today and I can remember only troubles with it:-)
Milan
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] Restrict lvm1 partial mode.
2010-10-04 17:20 ` Petr Rockai
2010-10-04 17:47 ` Milan Broz
@ 2010-10-04 18:54 ` Milan Broz
1 sibling, 0 replies; 4+ messages in thread
From: Milan Broz @ 2010-10-04 18:54 UTC (permalink / raw)
To: lvm-devel
On 10/04/2010 07:20 PM, Petr Rockai wrote:
> Does what the comment says... would the result be a bit less confusing
> though if it said
>
> memcpy(&pvl->pv->id.uuid, "missing_", 8);
>
> instead? I know, a nitpick.
negative. Because we do not allow "_" in UUID :-)
m.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-10-04 18:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-04 16:48 [PATCH] Restrict lvm1 partial mode Milan Broz
2010-10-04 17:20 ` Petr Rockai
2010-10-04 17:47 ` Milan Broz
2010-10-04 18:54 ` Milan Broz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.