public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/lib/metadata lv_manip.c
@ 2011-09-16 18:39 jbrassow
0 siblings, 0 replies; 79+ messages in thread
From: jbrassow @ 2011-09-16 18:39 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: jbrassow@sourceware.org 2011-09-16 18:39:04
Modified files:
lib/metadata : lv_manip.c
Log message:
Fix Bug 738832 - core to disk log conversion fails with internal error
This bug showed up when trying to add a log to a mirror whose images are on
multiple devices. This is an intra-release regression and no WHATS_NEW
entry will be added. The error was introduce in the following commit:
2d8a2f35c77fdeef1dbe0ef791db8530d07826eb
The solution is to recognise in _alloc_init that if there are no mirrors
or stripes specified, then 'new_extents' should be zero.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.288&r2=1.289
--- LVM2/lib/metadata/lv_manip.c 2011/09/16 12:12:51 1.288
+++ LVM2/lib/metadata/lv_manip.c 2011/09/16 18:39:03 1.289
@@ -767,7 +767,10 @@
return NULL;
}
- ah->new_extents = new_extents;
+ if (mirrors || stripes)
+ ah->new_extents = new_extents;
+ else
+ ah->new_extents = 0;
ah->area_count = area_count;
ah->parity_count = segtype->parity_devs;
ah->region_size = region_size;
@@ -801,7 +804,7 @@
ah->log_area_count = metadata_area_count;
ah->log_len = !metadata_area_count ? 0 :
mirror_log_extents(ah->region_size, extent_size,
- ah->new_extents / ah->area_multiple);
+ new_extents / ah->area_multiple);
}
for (s = 0; s < alloc_count; s++)
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-05-11 15:32 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2012-05-11 15:32 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2012-05-11 15:32:19
Modified files:
lib/metadata : lv_manip.c
Log message:
Always include debug mesg when cling to allocated is set.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.376&r2=1.377
--- LVM2/lib/metadata/lv_manip.c 2012/05/11 15:26:30 1.376
+++ LVM2/lib/metadata/lv_manip.c 2012/05/11 15:32:19 1.377
@@ -1673,7 +1673,7 @@
if (alloc_parms->flags & A_CLING_TO_ALLOCED)
ix_offset = ah->area_count;
- if (alloc_parms->alloc == ALLOC_NORMAL)
+ if (alloc_parms->alloc == ALLOC_NORMAL || (alloc_parms->flags & A_CLING_TO_ALLOCED))
log_debug("Cling_to_allocated is %sset",
alloc_parms->flags & A_CLING_TO_ALLOCED ? "" : "not ");
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-05-11 15:26 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2012-05-11 15:26 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2012-05-11 15:26:30
Modified files:
lib/metadata : lv_manip.c
Log message:
Refactor _has_matching_pv_tag to provide a fn that takes PV structs.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.375&r2=1.376
--- LVM2/lib/metadata/lv_manip.c 2012/05/09 12:12:21 1.375
+++ LVM2/lib/metadata/lv_manip.c 2012/05/11 15:26:30 1.376
@@ -1248,13 +1248,13 @@
* Does PV area have a tag listed in allocation/cling_tag_list that
* matches a tag of the PV of the existing segment?
*/
-static int _has_matching_pv_tag(struct pv_match *pvmatch, struct pv_segment *pvseg, struct pv_area *pva)
+static int _pvs_have_matching_tag(const struct dm_config_node *cling_tag_list_cn, struct physical_volume *pv1, struct physical_volume *pv2)
{
const struct dm_config_value *cv;
const char *str;
const char *tag_matched;
- for (cv = pvmatch->cling_tag_list_cn->v; cv; cv = cv->next) {
+ for (cv = cling_tag_list_cn->v; cv; cv = cv->next) {
if (cv->type != DM_CFG_STRING) {
log_error("Ignoring invalid string in config file entry "
"allocation/cling_tag_list");
@@ -1283,21 +1283,21 @@
/* Wildcard matches any tag against any tag. */
if (!strcmp(str, "*")) {
- if (!str_list_match_list(&pvseg->pv->tags, &pva->map->pv->tags, &tag_matched))
+ if (!str_list_match_list(&pv1->tags, &pv2->tags, &tag_matched))
continue;
else {
log_debug("Matched allocation PV tag %s on existing %s with free space on %s.",
- tag_matched, pv_dev_name(pvseg->pv), pv_dev_name(pva->map->pv));
+ tag_matched, pv_dev_name(pv1), pv_dev_name(pv2));
return 1;
}
}
- if (!str_list_match_item(&pvseg->pv->tags, str) ||
- !str_list_match_item(&pva->map->pv->tags, str))
+ if (!str_list_match_item(&pv1->tags, str) ||
+ !str_list_match_item(&pv2->tags, str))
continue;
else {
log_debug("Matched allocation PV tag %s on existing %s with free space on %s.",
- str, pv_dev_name(pvseg->pv), pv_dev_name(pva->map->pv));
+ str, pv_dev_name(pv1), pv_dev_name(pv2));
return 1;
}
}
@@ -1305,6 +1305,11 @@
return 0;
}
+static int _has_matching_pv_tag(struct pv_match *pvmatch, struct pv_segment *pvseg, struct pv_area *pva)
+{
+ return _pvs_have_matching_tag(pvmatch->cling_tag_list_cn, pvseg->pv, pva->map->pv);
+}
+
/*
* Is PV area contiguous to PV segment?
*/
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-03-04 15:57 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2012-03-04 15:57 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2012-03-04 15:57:27
Modified files:
lib/metadata : lv_manip.c
Log message:
Just make error message more clear
Make more obvious, the origin LV for snapshot must be active.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.369&r2=1.370
--- LVM2/lib/metadata/lv_manip.c 2012/03/01 10:09:36 1.369
+++ LVM2/lib/metadata/lv_manip.c 2012/03/04 15:57:27 1.370
@@ -4218,7 +4218,7 @@
}
if (!lv_info(cmd, org, 0, &info, 0, 0)) {
- log_error("Check for existence of snapshot "
+ log_error("Check for existence of active snapshot "
"origin '%s' failed.", org->name);
return NULL;
}
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-03-01 10:09 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2012-03-01 10:09 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2012-03-01 10:09:37
Modified files:
lib/metadata : lv_manip.c
Log message:
Add stack trace for lv_reduce
Use common code call with stack trace.
TODO: maybe the release_lv_segment_area()
should be actually able to return error code to upper level.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.368&r2=1.369
--- LVM2/lib/metadata/lv_manip.c 2012/02/29 22:08:58 1.368
+++ LVM2/lib/metadata/lv_manip.c 2012/03/01 10:09:36 1.369
@@ -312,13 +312,10 @@
return;
}
- if (seg_lv(seg, s)->status & MIRROR_IMAGE) {
- lv_reduce(seg_lv(seg, s), area_reduction);
- return;
- }
-
- if (seg_lv(seg, s)->status & THIN_POOL_DATA) {
- lv_reduce(seg_lv(seg, s), area_reduction);
+ if ((seg_lv(seg, s)->status & MIRROR_IMAGE) ||
+ (seg_lv(seg, s)->status & THIN_POOL_DATA)) {
+ if (!lv_reduce(seg_lv(seg, s), area_reduction))
+ stack; /* FIXME: any upper level reporting */
return;
}
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-02-28 10:08 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2012-02-28 10:08 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2012-02-28 10:08:20
Modified files:
lib/metadata : lv_manip.c
Log message:
Explicitely check list size of segments
instead of checking for NULL from last_seg and first_seg.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.366&r2=1.367
--- LVM2/lib/metadata/lv_manip.c 2012/02/23 22:24:47 1.366
+++ LVM2/lib/metadata/lv_manip.c 2012/02/28 10:08:20 1.367
@@ -2093,7 +2093,8 @@
}
}
- if ((seg = last_seg(lv)) && (seg->segtype == segtype)) {
+ if (!dm_list_empty(&lv->segments) &&
+ (seg = last_seg(lv)) && (seg->segtype == segtype)) {
seg->area_len += extents;
seg->len += extents;
} else {
@@ -2411,7 +2412,7 @@
char img_name[len];
struct lv_segment *mapseg;
- if (lv->le_count || first_seg(lv)) {
+ if (lv->le_count || !dm_list_empty(&lv->segments)) {
log_error(INTERNAL_ERROR
"Non-empty LV passed to _lv_insert_empty_sublv");
return 0;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-02-12 21:37 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2012-02-12 21:37 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2012-02-12 21:37:03
Modified files:
lib/metadata : lv_manip.c
Log message:
missing error mesg
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.359&r2=1.360
--- LVM2/lib/metadata/lv_manip.c 2012/02/09 15:13:42 1.359
+++ LVM2/lib/metadata/lv_manip.c 2012/02/12 21:37:03 1.360
@@ -3316,8 +3316,11 @@
if (lv_is_merging_cow(lv) && !level) {
if (lv_info(lv->vg->cmd, lv, 0, &info, 1, 0) &&
info.exists && info.live_table) {
- if (!lv_snapshot_percent(lv, &snap_percent))
- return_0;
+ if (!lv_snapshot_percent(lv, &snap_percent)) {
+ log_error("Failed to obtain merging snapshot progress percentage for logical volume %s.",
+ lv->name);
+ return 0;
+ }
if ((snap_percent != PERCENT_INVALID) &&
(snap_percent != PERCENT_MERGE_FAILED)) {
log_error("Can't remove merging snapshot logical volume \"%s\"",
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-02-01 2:11 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2012-02-01 2:11 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2012-02-01 02:11:43
Modified files:
lib/metadata : lv_manip.c
Log message:
lost line
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.355&r2=1.356
--- LVM2/lib/metadata/lv_manip.c 2012/02/01 02:10:46 1.355
+++ LVM2/lib/metadata/lv_manip.c 2012/02/01 02:11:43 1.356
@@ -1458,6 +1458,8 @@
const struct alloc_parms *alloc_parms, struct alloc_state *alloc_state,
unsigned already_found_one, unsigned iteration_count, unsigned log_iteration_count)
{
+ unsigned s;
+
/* Skip fully-reserved areas (which are not currently removed from the list). */
if (!pva->unreserved)
return NEXT_AREA;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-01-26 21:39 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2012-01-26 21:39 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2012-01-26 21:39:33
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin for_each_sub_lv
Adapt to scan thin dependency LVs
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.353&r2=1.354
--- LVM2/lib/metadata/lv_manip.c 2012/01/25 11:27:42 1.353
+++ LVM2/lib/metadata/lv_manip.c 2012/01/26 21:39:32 1.354
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -2784,8 +2784,21 @@
if (!for_each_sub_lv(cmd, seg->log_lv, fn, data))
return_0;
}
- if (seg->metadata_lv && !fn(cmd, seg->metadata_lv, data))
- return_0;
+
+ if (seg->pool_lv) {
+ if (!fn(cmd, seg->pool_lv, data))
+ return_0;
+ if (!for_each_sub_lv(cmd, seg->pool_lv, fn, data))
+ return_0;
+ }
+
+ if (seg->metadata_lv) {
+ if (!fn(cmd, seg->metadata_lv, data))
+ return_0;
+ if (!for_each_sub_lv(cmd, seg->metadata_lv, fn, data))
+ return_0;
+ }
+
for (s = 0; s < seg->area_count; s++) {
if (seg_type(seg, s) != AREA_LV)
continue;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-01-25 11:27 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2012-01-25 11:27 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2012-01-25 11:27:42
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin clear stacked message for thin pool
Before removing thin pool LV always make sure, stacked message
for previous run are cleared - but allow to remove any
device that should have been created
(i.e. creation of snapshot failed - so the message for snapshot creation
may be replaced with delete message within unfinished transaction).
Also commit messages after lv remove - so free space is released in pool.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.352&r2=1.353
--- LVM2/lib/metadata/lv_manip.c 2012/01/25 09:15:44 1.352
+++ LVM2/lib/metadata/lv_manip.c 2012/01/25 11:27:42 1.353
@@ -527,10 +527,6 @@
return_0;
if (seg->pool_lv) {
- /* For now, clear stacked messages here */
- if (!update_pool_lv(seg->pool_lv, 1))
- return_0;
-
if (!detach_pool_lv(seg))
return_0;
}
@@ -3142,6 +3138,7 @@
struct logical_volume *format1_origin = NULL;
int format1_reload_required = 0;
int visible;
+ struct logical_volume *pool_lv = NULL;
vg = lv->vg;
@@ -3176,7 +3173,8 @@
log_error("Can't remove logical volume %s used by a thin pool.",
lv->name);
return 0;
- }
+ } else if (lv_is_thin_volume(lv))
+ pool_lv = first_seg(lv)->pool_lv;
if (lv->status & LOCKED) {
log_error("Can't remove locked LV %s", lv->name);
@@ -3222,6 +3220,13 @@
return 0;
}
+ /* Clear thin pool stacked messages */
+ if (pool_lv && !pool_has_message(first_seg(pool_lv), lv, 0) &&
+ !update_pool_lv(pool_lv, 1)) {
+ log_error("Failed to update thin pool %s.", pool_lv->name);
+ return 0;
+ }
+
visible = lv_is_visible(lv);
log_verbose("Releasing logical volume \"%s\"", lv->name);
@@ -3256,6 +3261,13 @@
return 0;
}
+ /* Release unneeded blocks in thin pool */
+ /* TODO: defer when multiple LVs relased at once */
+ if (pool_lv && !update_pool_lv(pool_lv, 1)) {
+ log_error("Failed to update thin pool %s.", pool_lv->name);
+ return 0;
+ }
+
backup(vg);
if (visible)
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-01-25 9:15 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2012-01-25 9:15 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2012-01-25 09:15:44
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin correct activation order
When the message is passed only in resume path the order needs
to be corrected.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.351&r2=1.352
--- LVM2/lib/metadata/lv_manip.c 2012/01/25 09:14:25 1.351
+++ LVM2/lib/metadata/lv_manip.c 2012/01/25 09:15:44 1.352
@@ -4373,18 +4373,17 @@
if (((lp->activate == CHANGE_AY) ||
(lp->activate == CHANGE_AE) ||
(lp->activate == CHANGE_ALY))) {
+ /* At this point send message to kernel thin mda */
+ pool_lv = lv_is_thin_pool(lv) ? lv : first_seg(lv)->pool_lv;
+ if (!update_pool_lv(pool_lv, 1)) {
+ stack;
+ goto deactivate_and_revert_new_lv;
+ }
if (!activate_lv_excl(cmd, lv)) {
log_error("Aborting. Failed to activate thin %s.",
lv->name);
goto deactivate_and_revert_new_lv;
}
-
- pool_lv = lv_is_thin_pool(lv) ? lv : first_seg(lv)->pool_lv;
- /* Drop any queued thin messages after activation */
- if (!update_pool_lv(pool_lv, 0)) {
- stack;
- goto deactivate_and_revert_new_lv;
- }
}
} else if (lp->snapshot) {
if (!activate_lv_excl(cmd, lv)) {
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-01-25 9:14 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2012-01-25 9:14 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2012-01-25 09:14:25
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin use suspend/resume_lv_origin
Use origin_only support for thin volume when thin snapshot is created.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.350&r2=1.351
--- LVM2/lib/metadata/lv_manip.c 2012/01/25 09:02:35 1.350
+++ LVM2/lib/metadata/lv_manip.c 2012/01/25 09:14:25 1.351
@@ -4354,16 +4354,17 @@
"the autoextend threshold (%d%%).", percent);
goto revert_new_lv;
}
- if (!suspend_lv(cmd, org)) {
- log_error("Failed to suspend thin origin %s.",
+ if (!suspend_lv_origin(cmd, org)) {
+ log_error("Failed to suspend thin snapshot origin %s.",
org->name);
goto revert_new_lv;
- } else if (!resume_lv(cmd, org)) {
- log_error("Failed to resume thin origin %s.",
+ }
+ if (!resume_lv_origin(cmd, org)) { /* deptree updates thin-pool */
+ log_error("Failed to resume thin snapshot origin %s.",
org->name);
goto revert_new_lv;
}
- /* At this point snapshot is active in kernel thin mda */
+ /* At this point remove pool messages, snapshot is active */
if (!update_pool_lv(first_seg(org)->pool_lv, 0)) {
stack;
goto deactivate_and_revert_new_lv;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-01-25 9:02 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2012-01-25 9:02 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2012-01-25 09:02:35
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin check for lv_thin_pool_percent error status
Check has been missing.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.349&r2=1.350
--- LVM2/lib/metadata/lv_manip.c 2012/01/25 08:57:25 1.349
+++ LVM2/lib/metadata/lv_manip.c 2012/01/25 09:02:35 1.350
@@ -4340,9 +4340,13 @@
init_dmeventd_monitor(lp->activation_monitoring);
if (seg_is_thin(lp)) {
- /* For thin snapshot suspend active thin origin first */
+ /* For snapshot, suspend active thin origin first */
if (org && lv_is_active(org)) {
- lv_thin_pool_percent(first_seg(org)->pool_lv, 0, &percent);
+ /* Check if the pool is bellow threshold (Works only for active thin) */
+ if (!lv_thin_pool_percent(first_seg(org)->pool_lv, 0, &percent)) {
+ stack;
+ goto revert_new_lv;
+ }
percent /= PERCENT_1;
if (percent >= (find_config_tree_int(cmd, "activation/thin_pool_autoextend_threshold",
DEFAULT_THIN_POOL_AUTOEXTEND_THRESHOLD))) {
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-01-25 8:57 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2012-01-25 8:57 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2012-01-25 08:57:25
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin prevent removal of its data and metadata LVs
LVs cannot be removed while there are linked to thin pool.
(Gives better error message, than validation).
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.348&r2=1.349
--- LVM2/lib/metadata/lv_manip.c 2012/01/24 14:53:59 1.348
+++ LVM2/lib/metadata/lv_manip.c 2012/01/25 08:57:25 1.349
@@ -3172,6 +3172,12 @@
return 0;
}
+ if (lv_is_thin_pool_data(lv) || lv_is_thin_pool_metadata(lv)) {
+ log_error("Can't remove logical volume %s used by a thin pool.",
+ lv->name);
+ return 0;
+ }
+
if (lv->status & LOCKED) {
log_error("Can't remove locked LV %s", lv->name);
return 0;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-01-24 14:54 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2012-01-24 14:54 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2012-01-24 14:53:59
Modified files:
lib/metadata : lv_manip.c
Log message:
Caller is still entitled to reference an LV that's unlinked, so don't
tamper with struct contents.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.347&r2=1.348
--- LVM2/lib/metadata/lv_manip.c 2012/01/24 14:15:52 1.347
+++ LVM2/lib/metadata/lv_manip.c 2012/01/24 14:53:59 1.348
@@ -3111,8 +3111,6 @@
dm_list_del(&lvl->list);
- lv->status = 0; /* Reset */
-
return 1;
}
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-01-24 14:15 mbroz
0 siblings, 0 replies; 79+ messages in thread
From: mbroz @ 2012-01-24 14:15 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mbroz@sourceware.org 2012-01-24 14:15:52
Modified files:
lib/metadata : lv_manip.c
Log message:
Properly show LV removal message.
(Fix regression in commit 6e181ba96dc1f806afc2d7fe825a8d3dd8093052)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.346&r2=1.347
--- LVM2/lib/metadata/lv_manip.c 2012/01/24 00:55:03 1.346
+++ LVM2/lib/metadata/lv_manip.c 2012/01/24 14:15:52 1.347
@@ -3143,6 +3143,7 @@
struct lvinfo info;
struct logical_volume *format1_origin = NULL;
int format1_reload_required = 0;
+ int visible;
vg = lv->vg;
@@ -3217,6 +3218,8 @@
return 0;
}
+ visible = lv_is_visible(lv);
+
log_verbose("Releasing logical volume \"%s\"", lv->name);
if (!lv_remove(lv)) {
log_error("Error releasing logical volume \"%s\"", lv->name);
@@ -3251,7 +3254,7 @@
backup(vg);
- if (lv_is_visible(lv))
+ if (visible)
log_print("Logical volume \"%s\" successfully removed", lv->name);
return 1;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2012-01-19 15:39 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2012-01-19 15:39 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2012-01-19 15:39:41
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin disable snapshot creation when pool is over the threshold.
Since snapshot needs to suspend origin - it might lead to pool userspace
deadlock (as the pool will wait for new space in case it would be overfilled,
but dmeventd would not be able to resize it, as the lvcreate operation would
have kept the VG lock.)
To minimize the risk of such scenario - we prevent to create new snapshot
in case we are over the threshold - but beware, there is still small timewindow,
so keep threshold at some reasonable level!
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.342&r2=1.343
--- LVM2/lib/metadata/lv_manip.c 2012/01/19 15:31:45 1.342
+++ LVM2/lib/metadata/lv_manip.c 2012/01/19 15:39:41 1.343
@@ -3996,6 +3996,7 @@
struct logical_volume *lv, *org = NULL;
struct logical_volume *pool_lv;
struct lv_list *lvl;
+ percent_t percent;
int origin_active = 0;
struct lvinfo info;
@@ -4315,6 +4316,14 @@
if (seg_is_thin(lp)) {
/* For thin snapshot suspend active thin origin first */
if (org && lv_is_active(org)) {
+ lv_thin_pool_percent(first_seg(org)->pool_lv, 0, &percent);
+ percent /= PERCENT_1;
+ if (percent >= (find_config_tree_int(cmd, "activation/thin_pool_autoextend_threshold",
+ DEFAULT_THIN_POOL_AUTOEXTEND_THRESHOLD))) {
+ log_error("Failed to create snapshot, pool is filled over "
+ "the autoextend threshold (%d%%).", percent);
+ goto revert_new_lv;
+ }
if (!suspend_lv(cmd, org)) {
log_error("Failed to suspend thin origin %s.",
org->name);
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-11-15 17:29 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-11-15 17:29 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-11-15 17:29:52
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin update prompt message
Enhance message with info about how many thin volumes are going to
be removed with thin pool removal.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.335&r2=1.336
--- LVM2/lib/metadata/lv_manip.c 2011/11/15 17:27:41 1.335
+++ LVM2/lib/metadata/lv_manip.c 2011/11/15 17:29:52 1.336
@@ -3257,10 +3257,12 @@
}
if (lv_is_used_thin_pool(lv)) {
- /* remove thin LVs first */
+ /* Remove thin LVs first */
if ((force == PROMPT) &&
- yes_no_prompt("Do you really want to remove all thin volumes when removing"
- " pool logical volume %s? [y/n]: ", lv->name) == 'n') {
+ yes_no_prompt("Removing pool %s will also remove %u "
+ "thin volume(s). OK? [y/n]: ", lv->name,
+ /* Note: Snaphosts not included */
+ dm_list_size(&lv->segs_using_this_lv)) == 'n') {
log_error("Logical volume %s not removed.", lv->name);
return 0;
}
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-11-15 17:23 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-11-15 17:23 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-11-15 17:23:51
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin supports only thin volumes as snapshot origins
It's currently of the scope to properly solve the snapshoting
of internal thin devs so prevent non-toplevel snapshots here.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.333&r2=1.334
--- LVM2/lib/metadata/lv_manip.c 2011/11/12 22:53:23 1.333
+++ LVM2/lib/metadata/lv_manip.c 2011/11/15 17:23:51 1.334
@@ -4071,6 +4071,16 @@
"merging snapshot is not supported");
return NULL;
}
+
+ if (lv_is_thin_type(org) && !lv_is_thin_volume(org)) {
+ log_error("Snapshots of thin pool %sdevices "
+ "are not supported.",
+ lv_is_thin_pool_data(org) ? "data " :
+ lv_is_thin_pool_metadata(org) ?
+ "metadata " : "");
+ return NULL;
+ }
+
if ((org->status & MIRROR_IMAGE) ||
(org->status & MIRROR_LOG)) {
log_error("Snapshots of mirror %ss "
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-11-12 22:53 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-11-12 22:53 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-11-12 22:53:23
Modified files:
lib/metadata : lv_manip.c
Log message:
Add missing stack reporting
also remove unneeded {}
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.332&r2=1.333
--- LVM2/lib/metadata/lv_manip.c 2011/11/12 22:52:18 1.332
+++ LVM2/lib/metadata/lv_manip.c 2011/11/12 22:53:23 1.333
@@ -3248,12 +3248,11 @@
if (lv_is_origin(lv)) {
/* remove snapshot LVs first */
- dm_list_iterate_safe(snh, snht, &lv->snapshot_segs) {
+ dm_list_iterate_safe(snh, snht, &lv->snapshot_segs)
if (!lv_remove_with_dependencies(cmd, dm_list_struct_base(snh, struct lv_segment,
origin_list)->cow,
force, level + 1))
- return 0;
- }
+ return_0;
}
if (lv_is_used_thin_pool(lv)) {
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-11-12 22:52 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-11-12 22:52 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-11-12 22:52:18
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin use items iterator and stack reporting
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.331&r2=1.332
--- LVM2/lib/metadata/lv_manip.c 2011/11/12 22:51:20 1.331
+++ LVM2/lib/metadata/lv_manip.c 2011/11/12 22:52:18 1.332
@@ -3235,6 +3235,7 @@
const force_t force, unsigned level)
{
struct dm_list *snh, *snht;
+ struct seg_list *sl, *tsl;
if (lv_is_cow(lv)) {
/* A merging snapshot cannot be removed directly */
@@ -3263,12 +3264,11 @@
log_error("Logical volume %s not removed.", lv->name);
return 0;
}
- dm_list_iterate_safe(snh, snht, &lv->segs_using_this_lv) {
- if (!lv_remove_with_dependencies(cmd,
- dm_list_item(snh, struct seg_list)->seg->lv,
+
+ dm_list_iterate_items_safe(sl, tsl, &lv->segs_using_this_lv)
+ if (!lv_remove_with_dependencies(cmd, sl->seg->lv,
force, level + 1))
- return 0;
- }
+ return_0;
}
return lv_remove_single(cmd, lv, force);
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-11-12 22:51 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-11-12 22:51 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-11-12 22:51:20
Modified files:
lib/metadata : lv_manip.c
Log message:
Missing stack printing
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.330&r2=1.331
--- LVM2/lib/metadata/lv_manip.c 2011/11/10 12:43:05 1.330
+++ LVM2/lib/metadata/lv_manip.c 2011/11/12 22:51:20 1.331
@@ -3142,7 +3142,7 @@
vg = lv->vg;
if (!vg_check_status(vg, LVM_WRITE))
- return 0;
+ return_0;
if (lv_is_origin(lv)) {
log_error("Can't remove logical volume \"%s\" under snapshot",
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-11-10 12:42 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-11-10 12:42 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-11-10 12:42:36
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin test min thin_pool size for at least 1 chunk
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.328&r2=1.329
--- LVM2/lib/metadata/lv_manip.c 2011/11/10 12:42:15 1.328
+++ LVM2/lib/metadata/lv_manip.c 2011/11/10 12:42:36 1.329
@@ -4102,6 +4102,12 @@
return NULL;
}
+ if (seg_is_thin_pool(lp) &&
+ (lp->extents * vg->extent_size < lp->chunk_size)) {
+ log_error("Unable to create thin pool smaller than 1 chunk.");
+ return NULL;
+ }
+
if (lp->snapshot && !lp->thin && (lp->extents * vg->extent_size < 2 * lp->chunk_size)) {
log_error("Unable to create a snapshot smaller than 2 chunks.");
return NULL;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-11-10 12:42 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-11-10 12:42 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-11-10 12:42:15
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin align volume size on chunk boundary size
If the extent_size is smaller then the chunk_size we may try
to find better aligment (wasting less space).
i.e. using 4KB extent_size and 64KB chunk size will
lead to creation of 64KB aligned thin volume.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.327&r2=1.328
--- LVM2/lib/metadata/lv_manip.c 2011/11/10 12:39:01 1.327
+++ LVM2/lib/metadata/lv_manip.c 2011/11/10 12:42:15 1.328
@@ -2051,6 +2051,7 @@
struct lv_segment *seg;
struct logical_volume *thin_pool_lv = NULL;
struct lv_list *lvl;
+ uint32_t size;
if (thin_pool_name) {
if (!(lvl = find_lv_in_vg(lv->vg, thin_pool_name))) {
@@ -2059,6 +2060,17 @@
return 0;
}
thin_pool_lv = lvl->lv;
+ size = first_seg(thin_pool_lv)->data_block_size;
+ if (lv->vg->extent_size < size) {
+ /* Align extents on chunk boundary size */
+ size = ((uint64_t)lv->vg->extent_size * extents + size - 1) /
+ size * size / lv->vg->extent_size;
+ if (size != extents) {
+ log_print("Rounding size (%d extents) up to chunk boundary "
+ "size (%d extents).", extents, size);
+ extents = size;
+ }
+ }
}
if ((seg = last_seg(lv)) && (seg->segtype == segtype)) {
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-11-10 12:39 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-11-10 12:39 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-11-10 12:39:01
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin disable pool create without activation
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.326&r2=1.327
--- LVM2/lib/metadata/lv_manip.c 2011/11/07 13:54:54 1.326
+++ LVM2/lib/metadata/lv_manip.c 2011/11/10 12:39:01 1.327
@@ -4110,13 +4110,21 @@
return NULL;
}
- if ((segtype_is_mirrored(lp->segtype) ||
- segtype_is_raid(lp->segtype) || seg_is_thin_volume(lp)) && !activation()) {
+ if (!activation() &&
+ (seg_is_mirrored(lp) ||
+ seg_is_raid(lp) ||
+ seg_is_thin_pool(lp))) {
+ /*
+ * FIXME: For thin pool add some code to allow delayed
+ * initialization of empty thin pool volume.
+ * i.e. using some LV flag, fake message,...
+ * and testing for metadata pool header signature?
+ */
log_error("Can't create %s without using "
"device-mapper kernel driver.",
segtype_is_raid(lp->segtype) ? lp->segtype->name :
segtype_is_mirrored(lp->segtype) ? "mirror" :
- "thin volume");
+ "thin pool volume");
return NULL;
}
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-11-07 13:54 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2011-11-07 13:54 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2011-11-07 13:54:55
Modified files:
lib/metadata : lv_manip.c
Log message:
Must not override alloc policy specified by user.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.325&r2=1.326
--- LVM2/lib/metadata/lv_manip.c 2011/11/07 11:03:47 1.325
+++ LVM2/lib/metadata/lv_manip.c 2011/11/07 13:54:54 1.326
@@ -2576,12 +2576,9 @@
return lv_add_virtual_segment(lv, 0u, extents, segtype, thin_pool_name);
if (!lv->le_count && segtype_is_thin_pool(segtype)) {
- if (stripes == 1 && (dm_list_size(allocatable_pvs) == 1)) {
- log_warn("WARNING: Only one PV available for thin pool data and metadata.");
- alloc = ALLOC_ANYWHERE;
- }
/* Thin pool allocation treats its metadata device like a mirror log. */
- /* TODO: add support for stripped metadata pool */
+ /* FIXME Allow pool and data on same device with NORMAL */
+ /* FIXME Support striped metadata pool */
log_count = 1;
} else if (segtype_is_raid(segtype) && !lv->le_count)
log_count = mirrors * stripes;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-11-04 22:45 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-11-04 22:45 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-11-04 22:45:52
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin pool allocation simplified
Support allocation of metadata from the same PV, if the VG
is build only from one PV.
As thinp is not mirror - we do not require 2 PVs
for basic thin usage as user is losing only perfomance.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.322&r2=1.323
--- LVM2/lib/metadata/lv_manip.c 2011/11/04 22:44:22 1.322
+++ LVM2/lib/metadata/lv_manip.c 2011/11/04 22:45:52 1.323
@@ -2568,10 +2568,15 @@
if (segtype_is_virtual(segtype))
return lv_add_virtual_segment(lv, 0u, extents, segtype, thin_pool_name);
- if (!lv->le_count && segtype_is_thin_pool(segtype))
+ if (!lv->le_count && segtype_is_thin_pool(segtype)) {
+ if (stripes == 1 && (dm_list_size(allocatable_pvs) == 1)) {
+ log_warn("WARNING: Only one PV available for thin pool data and metadata.");
+ alloc = ALLOC_ANYWHERE;
+ }
/* Thin pool allocation treats its metadata device like a mirror log. */
+ /* TODO: add support for stripped metadata pool */
log_count = 1;
- else if (segtype_is_raid(segtype) && !lv->le_count)
+ } else if (segtype_is_raid(segtype) && !lv->le_count)
log_count = mirrors * stripes;
if (!(ah = allocate_extents(lv->vg, lv, segtype, stripes, mirrors,
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-11-03 15:46 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-11-03 15:46 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-11-03 15:46:51
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin no device is created - so nothing to revert here
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.318&r2=1.319
--- LVM2/lib/metadata/lv_manip.c 2011/11/03 14:56:20 1.318
+++ LVM2/lib/metadata/lv_manip.c 2011/11/03 15:46:51 1.319
@@ -4114,10 +4114,8 @@
lp->pool, vg->name);
return 0;
}
- if (!update_pool_lv(lvl->lv, 1)) {
- stack;
- goto revert_new_lv;
- }
+ if (!update_pool_lv(lvl->lv, 1))
+ return_0;
}
if (segtype_is_mirrored(lp->segtype) || segtype_is_raid(lp->segtype)) {
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-11-03 14:56 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-11-03 14:56 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-11-03 14:56:20
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin using update_pool_lv
Replace detach_pool_messages with update_pool_lv.
Move creation code from to 'if' condition into 1.
Ensure creation has finished all previous message operations.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.317&r2=1.318
--- LVM2/lib/metadata/lv_manip.c 2011/11/03 14:36:40 1.317
+++ LVM2/lib/metadata/lv_manip.c 2011/11/03 14:56:20 1.318
@@ -519,8 +519,14 @@
if (seg->pool_metadata_lv && !lv_remove(seg->pool_metadata_lv))
return_0;
- if (seg->pool_lv && !detach_pool_lv(seg))
- return_0;
+ if (seg->pool_lv) {
+ /* For now, clear stacked messages here */
+ if (!update_pool_lv(seg->pool_lv, 1))
+ return_0;
+
+ if (!detach_pool_lv(seg))
+ return_0;
+ }
dm_list_del(&seg->list);
reduction = seg->len;
@@ -3917,6 +3923,7 @@
uint64_t status = UINT64_C(0);
struct logical_volume *lv, *org = NULL;
struct logical_volume *pool_lv;
+ struct lv_list *lvl;
int origin_active = 0;
struct lvinfo info;
@@ -4097,6 +4104,22 @@
}
}
+ if (seg_is_thin_volume(lp) &&
+ ((lp->activate == CHANGE_AY) ||
+ (lp->activate == CHANGE_AE) ||
+ (lp->activate == CHANGE_ALY))) {
+ /* Ensure all stacked messages are submitted */
+ if (!(lvl = find_lv_in_vg(vg, lp->pool))) {
+ log_error("Unable to find existing pool LV %s in VG %s.",
+ lp->pool, vg->name);
+ return 0;
+ }
+ if (!update_pool_lv(lvl->lv, 1)) {
+ stack;
+ goto revert_new_lv;
+ }
+ }
+
if (segtype_is_mirrored(lp->segtype) || segtype_is_raid(lp->segtype)) {
init_mirror_in_sync(lp->nosync);
@@ -4196,14 +4219,21 @@
init_dmeventd_monitor(lp->activation_monitoring);
if (seg_is_thin(lp)) {
- if ((lp->activate == CHANGE_AY) ||
- (lp->activate == CHANGE_ALY))
- lp->activate = CHANGE_AE;
- if ((lp->activate == CHANGE_AE) &&
- !activate_lv_excl(cmd, lv)) {
- log_error("Aborting. Failed to activate thin %s.",
- lv->name);
- goto deactivate_and_revert_new_lv;
+ if (((lp->activate == CHANGE_AY) ||
+ (lp->activate == CHANGE_AE) ||
+ (lp->activate == CHANGE_ALY))) {
+ if (!activate_lv_excl(cmd, lv)) {
+ log_error("Aborting. Failed to activate thin %s.",
+ lv->name);
+ goto deactivate_and_revert_new_lv;
+ }
+
+ pool_lv = lv_is_thin_pool(lv) ? lv : first_seg(lv)->pool_lv;
+ /* Drop any queued thin messages after activation */
+ if (!update_pool_lv(pool_lv, 0)) {
+ stack;
+ goto deactivate_and_revert_new_lv;
+ }
}
} else if (lp->snapshot) {
if (!activate_lv_excl(cmd, lv)) {
@@ -4227,13 +4257,6 @@
lp->snapshot ? "snapshot exception store" :
"start of new LV");
goto deactivate_and_revert_new_lv;
- } else if (seg_is_thin_volume(lp) && (lp->activate == CHANGE_AE)) {
- /* FIXME: for now we may drop any queued thin messages
- * since we are sure everything was activated already */
- if (!detach_pool_messages(first_seg(lv)->pool_lv)) {
- stack;
- goto deactivate_and_revert_new_lv;
- }
}
if (lp->snapshot) {
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-10-30 22:02 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-10-30 22:02 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-10-30 22:02:18
Modified files:
lib/metadata : lv_manip.c
Log message:
Cleanup unsuccessfully created thin LV
If something fails during creation of thin LV remove such LV
and deactivate in case it's been already tried to activate
(i.e. thin kernel driver fails for some reason.)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.314&r2=1.315
--- LVM2/lib/metadata/lv_manip.c 2011/10/30 22:01:39 1.314
+++ LVM2/lib/metadata/lv_manip.c 2011/10/30 22:02:18 1.315
@@ -4150,7 +4150,7 @@
!deactivate_lv(cmd, pool_lv)) {
log_error("Failed to deactivate unused pool %s.",
pool_lv->name);
- return NULL;
+ goto revert_new_lv;
}
/*
@@ -4159,12 +4159,16 @@
*/
if (!(first_seg(lv)->device_id =
- get_free_pool_device_id(first_seg(pool_lv))))
- return_NULL;
+ get_free_pool_device_id(first_seg(pool_lv)))) {
+ stack;
+ goto revert_new_lv;
+ }
if (!attach_pool_message(first_seg(pool_lv),
- DM_THIN_MESSAGE_CREATE_THIN, lv, 0, 0))
- return_NULL;
+ DM_THIN_MESSAGE_CREATE_THIN, lv, 0, 0)) {
+ stack;
+ goto revert_new_lv;
+ }
}
if (lp->log_count &&
@@ -4194,7 +4198,7 @@
if (!activate_lv_excl(cmd, lv)) {
log_error("Aborting. Failed to activate thin %s.",
lv->name);
- goto revert_new_lv;
+ goto deactivate_and_revert_new_lv;
}
} else if (lp->snapshot) {
if (!activate_lv_excl(cmd, lv)) {
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-10-28 20:29 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-10-28 20:29 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-10-28 20:29:32
Modified files:
lib/metadata : lv_manip.c
Log message:
Thin support for lvrename
Rename pool's metadata lv _tmeta together with pool and _tdata.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.309&r2=1.310
--- LVM2/lib/metadata/lv_manip.c 2011/10/28 20:28:01 1.309
+++ LVM2/lib/metadata/lv_manip.c 2011/10/28 20:29:32 1.310
@@ -2745,6 +2745,8 @@
dm_list_iterate_items(seg, &lv->segments) {
if (seg->log_lv && !fn(cmd, seg->log_lv, data))
return_0;
+ if (seg->pool_metadata_lv && !fn(cmd, seg->pool_metadata_lv, data))
+ return_0;
for (s = 0; s < seg->area_count; s++) {
if (seg_type(seg, s) != AREA_LV)
continue;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-10-28 20:18 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-10-28 20:18 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-10-28 20:18:32
Modified files:
lib/metadata : lv_manip.c
Log message:
Remove thin code from mirror/raid lv_extend
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.305&r2=1.306
--- LVM2/lib/metadata/lv_manip.c 2011/10/28 20:17:56 1.305
+++ LVM2/lib/metadata/lv_manip.c 2011/10/28 20:18:32 1.306
@@ -2596,13 +2596,6 @@
if (!(r = _lv_extend_layered_lv(ah, lv, extents, 0,
stripes, stripe_size)))
- goto out;
-
- if (segtype_is_thin_pool(segtype) &&
- !(r = lv_add_segment(ah, ah->area_count, 1,
- first_seg(lv)->pool_metadata_lv,
- get_segtype_from_string(lv->vg->cmd,
- "striped"), 0, 0, 0)))
goto_out;
/*
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-10-22 16:49 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-10-22 16:49 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-10-22 16:48:59
Modified files:
lib/metadata : lv_manip.c
Log message:
Remove old thin code from _lv_insert_empty_sublvs
Since thin is not able to use _lv_insert_empty_sublvs,
remove its appearence from this function.
Start to use extend_pool() function for desired functionality
and modify lv_extend() for this.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.302&r2=1.303
--- LVM2/lib/metadata/lv_manip.c 2011/10/22 16:46:34 1.302
+++ LVM2/lib/metadata/lv_manip.c 2011/10/22 16:48:59 1.303
@@ -2369,9 +2369,6 @@
lv->status |= MIRRORED;
sub_lv_status = MIRROR_IMAGE;
layer_name = "mimage";
- } else if (segtype_is_thin_pool(segtype)) {
- lv->status |= THIN_POOL;
- layer_name = "tpool";
} else
return_0;
@@ -2406,19 +2403,13 @@
lv->alloc, lv->vg)))
return_0;
- if (segtype_is_thin_pool(segtype)) {
- if (!attach_pool_data_lv(mapseg, sub_lv))
- return_0;
- } else if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, sub_lv_status))
+ if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, sub_lv_status))
return_0;
- /* Metadata LVs for raid or thin pool */
+ /* Metadata LVs for raid */
if (segtype_is_raid(segtype)) {
if (dm_snprintf(img_name, len, "%s_rmeta_%u", lv->name, i) < 0)
return_0;
- } else if (segtype_is_thin_pool(segtype)) {
- if (dm_snprintf(img_name, len, "%s_tmeta", lv->name) < 0)
- return_0;
} else
continue;
@@ -2428,12 +2419,10 @@
lv->alloc, lv->vg)))
return_0;
- if (segtype_is_thin_pool(segtype)) {
- if (!attach_pool_metadata_lv(mapseg, sub_lv))
- return_0;
- } else if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, RAID_META))
+ if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, RAID_META))
return_0;
}
+
dm_list_add(&lv->segments, &mapseg->list);
return 1;
@@ -2562,29 +2551,15 @@
struct alloc_handle *ah;
uint32_t sub_lv_count;
- /*
- * For RAID, all the devices are AREA_LV.
- * However, for 'mirror on stripe' using non-RAID targets,
- * the mirror legs are AREA_LV while the stripes underneath
- * are AREA_PV.
- */
- if (segtype_is_raid(segtype))
- sub_lv_count = mirrors * stripes + segtype->parity_devs;
- else if (segtype_is_thin_pool(segtype))
- sub_lv_count = 1;
- else
- sub_lv_count = mirrors;
-
log_very_verbose("Extending segment type, %s", segtype->name);
if (segtype_is_virtual(segtype))
return lv_add_virtual_segment(lv, 0u, extents, segtype, thin_pool_name);
- if (segtype_is_raid(segtype) && !lv->le_count)
- log_count = mirrors * stripes;
-
if (segtype_is_thin_pool(segtype))
log_count = 1;
+ else if (segtype_is_raid(segtype) && !lv->le_count)
+ log_count = mirrors * stripes;
/* Thin pool allocation treats its metadata device like a mirror log. */
if (!(ah = allocate_extents(lv->vg, lv, segtype, stripes, mirrors,
@@ -2592,10 +2567,24 @@
allocatable_pvs, alloc, NULL)))
return_0;
- if (!segtype_is_mirrored(segtype) && !segtype_is_raid(segtype) && !segtype_is_thin_pool(segtype))
+ if (segtype_is_thin_pool(segtype)) {
+ if (!(r = extend_pool(lv, segtype, ah)))
+ stack;
+ } else if (!segtype_is_mirrored(segtype) && !segtype_is_raid(segtype))
r = lv_add_segment(ah, 0, ah->area_count, lv, segtype,
stripe_size, 0u, 0);
else {
+ /*
+ * For RAID, all the devices are AREA_LV.
+ * However, for 'mirror on stripe' using non-RAID targets,
+ * the mirror legs are AREA_LV while the stripes underneath
+ * are AREA_PV.
+ */
+ if (segtype_is_raid(segtype))
+ sub_lv_count = mirrors * stripes + segtype->parity_devs;
+ else
+ sub_lv_count = mirrors;
+
if (!lv->le_count &&
!_lv_insert_empty_sublvs(lv, segtype, stripe_size,
region_size, sub_lv_count)) {
@@ -4202,34 +4191,12 @@
init_dmeventd_monitor(lp->activation_monitoring);
- if (seg_is_thin_pool(lp)) {
- /* FIXME: skipping in test mode is not going work */
- if (!activate_lv_excl(cmd, first_seg(lv)->pool_metadata_lv) ||
- /* Clear 4KB of metadata device for new thin-pool. */
- // FIXME: maybe -zero n should allow to recreate same thin pool
- // and different option should be used for zero_new_blocks
- !set_lv(cmd, first_seg(lv)->pool_metadata_lv, UINT64_C(0), 0)) {
- log_error("Aborting. Failed to wipe pool metadata %s.",
- lv->name);
- goto revert_new_lv;
- }
- /* FIXME: we may postpone finish of the pool creation to the
- * moment of the first activation - but this needs more changes
- * so we would update metadata with vgchange -ay
- *
- * For now always activate.
- */
+ if (seg_is_thin_pool(lp) || seg_is_thin(lp)) {
if (!activate_lv_excl(cmd, lv)) {
- log_error("Aborting. Could not to activate thin pool %s.",
+ log_error("Aborting. Failed to activate thin %s.",
lv->name);
goto revert_new_lv;
}
- } else if (seg_is_thin(lp)) {
- /* FIXME: same as with thin pool - add lazy creation support */
- if (!activate_lv_excl(cmd, lv)) {
- log_error("Aborting. Failed to activate thin %s.", lv->name);
- goto revert_new_lv;
- }
} else if (lp->snapshot) {
if (!activate_lv_excl(cmd, lv)) {
log_error("Aborting. Failed to activate snapshot "
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-10-22 16:46 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-10-22 16:46 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-10-22 16:46:34
Modified files:
lib/metadata : lv_manip.c
Log message:
Remove extra empty check
dm_list_splice handles empty list itself, no need to duplicate code.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.301&r2=1.302
--- LVM2/lib/metadata/lv_manip.c 2011/10/22 16:42:11 1.301
+++ LVM2/lib/metadata/lv_manip.c 2011/10/22 16:46:34 1.302
@@ -4139,8 +4139,7 @@
lv->minor);
}
- if (!dm_list_empty(&lp->tags))
- dm_list_splice(&lv->tags, &lp->tags);
+ dm_list_splice(&lv->tags, &lp->tags);
lp->region_size = adjusted_mirror_region_size(vg->extent_size,
lp->extents,
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-10-21 9:55 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-10-21 9:55 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-10-21 09:55:50
Modified files:
lib/metadata : lv_manip.c
Log message:
Remove double-hack for setting metadata size
Drop the second lv_extend and set 128MB directly in the first hack place.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.298&r2=1.299
--- LVM2/lib/metadata/lv_manip.c 2011/10/21 09:55:07 1.298
+++ LVM2/lib/metadata/lv_manip.c 2011/10/21 09:55:50 1.299
@@ -800,8 +800,8 @@
}
} else if (segtype_is_thin_pool(segtype)) {
ah->log_area_count = metadata_area_count;
-// FIXME Calculate thin metadata area size
- ah->log_len = 1;
+// FIXME Calculate thin metadata area size (--metadatasize, or reuse --regionsize??)
+ ah->log_len = 128 * 1024 * 1024 / (512 * extent_size); /* Fixed 128MB */
} else {
ah->log_area_count = metadata_area_count;
ah->log_len = !metadata_area_count ? 0 :
@@ -2605,17 +2605,12 @@
stripes, stripe_size)))
goto out;
- if (segtype_is_thin_pool(segtype)) {
- /* FIXME: resize metadata size here for now */
- struct logical_volume *tmeta = first_seg(lv)->pool_metadata_lv;
- if ((r = lv_add_segment(ah, ah->area_count, 1, tmeta,
- get_segtype_from_string(lv->vg->cmd, "striped"), 0, 0, 0))) {
- if (!(r = lv_extend(tmeta, first_seg(tmeta)->segtype,
- 1, 0, 1, 0, 10, NULL, allocatable_pvs, ALLOC_INHERIT)))
- stack;
- } else
- stack;
- }
+ if (segtype_is_thin_pool(segtype) &&
+ !(r = lv_add_segment(ah, ah->area_count, 1,
+ first_seg(lv)->pool_metadata_lv,
+ get_segtype_from_string(lv->vg->cmd,
+ "striped"), 0, 0, 0)))
+ goto_out;
/*
* If we are expanding an existing mirror, we can skip the
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-10-20 10:35 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-10-20 10:35 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-10-20 10:35:14
Modified files:
lib/metadata : lv_manip.c
Log message:
Ensure right activation order
Couple FIXMEs put into the code for parts of the code which may be
improved later, since we might be able to add 'lazy' device creation later.
For now require exclusive activation.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.296&r2=1.297
--- LVM2/lib/metadata/lv_manip.c 2011/10/19 16:36:39 1.296
+++ LVM2/lib/metadata/lv_manip.c 2011/10/20 10:35:14 1.297
@@ -4214,7 +4214,33 @@
init_dmeventd_monitor(lp->activation_monitoring);
- if (lp->snapshot) {
+ if (seg_is_thin_pool(lp)) {
+ /* FIXME: skipping in test mode is not going work */
+ if (!activate_lv_excl(cmd, first_seg(lv)->pool_metadata_lv) ||
+ /* First 4KB of metadata device must be cleared. */
+ !set_lv(cmd, first_seg(lv)->pool_metadata_lv, UINT64_C(0), 0)) {
+ log_error("Aborting. Failed to wipe pool metadata %s.",
+ lv->name);
+ goto revert_new_lv;
+ }
+ /* FIXME: we may postpone finish of the pool creation to the
+ * moment of the first activation - but this needs more changes
+ * so we would update metadata with vgchange -ay
+ *
+ * For now always activate.
+ */
+ if (!activate_lv_excl(cmd, lv)) {
+ log_error("Aborting. Could not to activate thin pool %s.",
+ lv->name);
+ goto revert_new_lv;
+ }
+ } else if (seg_is_thin(lp)) {
+ /* FIXME: same as with thin pool - add lazy creation support */
+ if (!activate_lv_excl(cmd, lv)) {
+ log_error("Aborting. Failed to activate thin %s.", lv->name);
+ goto revert_new_lv;
+ }
+ } else if (lp->snapshot) {
if (!activate_lv_excl(cmd, lv)) {
log_error("Aborting. Failed to activate snapshot "
"exception store.");
@@ -4236,12 +4262,9 @@
lp->snapshot ? "snapshot exception store" :
"start of new LV");
goto deactivate_and_revert_new_lv;
- } else if (seg_is_thin_pool(lp)) {
- if (!set_lv(cmd, first_seg(lv)->pool_metadata_lv, UINT64_C(0), 0))
- log_error("Aborting. Failed to wipe pool metadata %s.",
- lv->name);
} else if (seg_is_thin_volume(lp)) {
- /* since we've got here, we may drop any queued thin messages */
+ /* FIXME: for now we may drop any queued thin messages
+ * since we are sure everything was activated already */
if (!detach_pool_messages(first_seg(first_seg(lv)->pool_lv)))
goto deactivate_and_revert_new_lv;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-10-03 18:43 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-10-03 18:43 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-10-03 18:43:39
Modified files:
lib/metadata : lv_manip.c
Log message:
Add code to activate thin target
Code to zero pool metadata lv when pool is created.
Add code to create thin target via message sending.
(Revert is missing)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.292&r2=1.293
--- LVM2/lib/metadata/lv_manip.c 2011/09/29 08:56:38 1.292
+++ LVM2/lib/metadata/lv_manip.c 2011/10/03 18:43:39 1.293
@@ -3889,6 +3889,7 @@
uint32_t size_rest;
uint64_t status = UINT64_C(0);
struct logical_volume *lv, *org = NULL;
+ struct logical_volume *pool_lv;
int origin_active = 0;
struct lvinfo info;
@@ -4113,6 +4114,27 @@
if (seg_is_thin_pool(lp) && lp->zero)
first_seg(lv)->zero_new_blocks = 1;
+ else if (seg_is_thin_volume(lp)) {
+ pool_lv = first_seg(lv)->pool_lv;
+
+ if (!(first_seg(lv)->device_id =
+ get_free_pool_device_id(first_seg(pool_lv))))
+ return_NULL;
+
+ if (!activate_lv(pool_lv->vg->cmd, pool_lv)) {
+ log_error("Failed to activate %s/%s to send message.",
+ pool_lv->vg->name, pool_lv->name);
+ return NULL;
+ }
+
+ if (!lv_send_message(pool_lv, "create_thin %u", first_seg(lv)->device_id))
+ return_NULL;
+
+ /*
+ * FIXME: Skipping deactivate_lv(pool_lv) as it is going to be needed anyway
+ * but revert_new_lv should revert to deactivated state.
+ */
+ }
if (seg_is_thin_pool(lp)) {
/* FIXME: add lvcreate params - maybe -c/--chunksize?,
@@ -4166,6 +4188,10 @@
lp->snapshot ? "snapshot exception store" :
"start of new LV");
goto deactivate_and_revert_new_lv;
+ } else if (seg_is_thin_pool(lp)) {
+ if (!set_lv(cmd, first_seg(lv)->pool_metadata_lv, UINT64_C(0), 0))
+ log_error("Aborting. Failed to wipe pool metadata %s.",
+ lv->name);
}
if (lp->snapshot) {
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-09-16 12:12 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-09-16 12:12 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-09-16 12:12:54
Modified files:
lib/metadata : lv_manip.c
Log message:
Remove thin volumes before thin pools
When user wants to remove thin pool - check if there are no thin volumes using it.
If so - query before removal (or -ff for no question) and remove them first.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.287&r2=1.288
--- LVM2/lib/metadata/lv_manip.c 2011/09/16 11:59:22 1.287
+++ LVM2/lib/metadata/lv_manip.c 2011/09/16 12:12:51 1.288
@@ -3178,6 +3178,22 @@
}
}
+ if (lv_is_thin_pool(lv) && dm_list_size(&lv->segs_using_this_lv)) {
+ /* remove thin LVs first */
+ if ((force == PROMPT) &&
+ yes_no_prompt("Do you really want to remove all thin volumes when removing "
+ "pool logical volume %s? [y/n]: ", lv->name) == 'n') {
+ log_error("Logical volume %s not removed", lv->name);
+ return 0;
+ }
+ dm_list_iterate_safe(snh, snht, &lv->segs_using_this_lv) {
+ if (!lv_remove_with_dependencies(cmd,
+ dm_list_item(snh, struct seg_list)->seg->lv,
+ force, level + 1))
+ return 0;
+ }
+ }
+
return lv_remove_single(cmd, lv, force);
}
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-09-16 11:59 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2011-09-16 11:59 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-09-16 11:59:22
Modified files:
lib/metadata : lv_manip.c
Log message:
Reset LV status when unlinking LV from VG
When LV is unlinked, we want to catch problem in vg_validate,
that LV has changed.
i.e. catch LV has been removed and is no long thin_pool while still
being referenced by some thin volume.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.286&r2=1.287
--- LVM2/lib/metadata/lv_manip.c 2011/09/16 09:59:42 1.286
+++ LVM2/lib/metadata/lv_manip.c 2011/09/16 11:59:22 1.287
@@ -3028,6 +3028,8 @@
dm_list_del(&lvl->list);
+ lv->status = 0; /* Reset */
+
return 1;
}
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-09-06 15:39 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2011-09-06 15:39 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2011-09-06 15:39:47
Modified files:
lib/metadata : lv_manip.c
Log message:
else
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.278&r2=1.279
--- LVM2/lib/metadata/lv_manip.c 2011/09/06 00:26:43 1.278
+++ LVM2/lib/metadata/lv_manip.c 2011/09/06 15:39:46 1.279
@@ -2354,7 +2354,7 @@
// lv->status |= THIN_POOL;
// status = THIN_IMAGE;
layer_name = "tdata";
- }
+ } else
return_0;
/*
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-08-19 22:55 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2011-08-19 22:55 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2011-08-19 22:55:07
Modified files:
lib/metadata : lv_manip.c
Log message:
Remove incorrect error message added in 2.02.87.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.275&r2=1.276
--- LVM2/lib/metadata/lv_manip.c 2011/08/19 16:41:26 1.275
+++ LVM2/lib/metadata/lv_manip.c 2011/08/19 22:55:07 1.276
@@ -1706,10 +1706,8 @@
if ((alloc_parms->alloc == ALLOC_ANYWHERE &&
ix + ix_offset >= devices_needed + alloc_state->log_area_count_still_needed) ||
(preferred_count == ix_offset &&
- (ix_offset == devices_needed + alloc_state->log_area_count_still_needed))) {
- log_error("Breaking: preferred_count = %d, ix_offset = %d, devices_needed = %d", preferred_count, ix_offset, devices_needed);
+ (ix_offset == devices_needed + alloc_state->log_area_count_still_needed)))
break;
- }
}
} while ((alloc_parms->alloc == ALLOC_ANYWHERE && last_ix != ix && ix < devices_needed + alloc_state->log_area_count_still_needed) ||
/* With cling_to_alloced, if there were gaps in the preferred areas, have a second iteration */
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-08-19 16:41 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2011-08-19 16:41 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2011-08-19 16:41:27
Modified files:
lib/metadata : lv_manip.c
Log message:
avoid multi-line calc with incorrect intermediate var contents
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.274&r2=1.275
--- LVM2/lib/metadata/lv_manip.c 2011/08/18 19:41:21 1.274
+++ LVM2/lib/metadata/lv_manip.c 2011/08/19 16:41:26 1.275
@@ -1541,28 +1541,28 @@
struct alloc_state *alloc_state)
{
const char *metadata_type;
- uint32_t p_areas_count, p_area_size;
+ uint32_t parallel_areas_count, parallel_area_size;
uint32_t metadata_count, metadata_size;
- p_area_size = (ah->new_extents - alloc_state->allocated);
- p_area_size /= ah->area_multiple;
- p_area_size -= (ah->alloc_and_split_meta) ? ah->log_len : 0;
- p_areas_count = ah->area_count + ah->parity_count;
+ parallel_area_size = (ah->new_extents - alloc_state->allocated) / ah->area_multiple -
+ ((ah->alloc_and_split_meta) ? ah->log_len : 0);
+
+ parallel_areas_count = ah->area_count + ah->parity_count;
metadata_size = ah->log_len;
if (ah->alloc_and_split_meta) {
metadata_type = "RAID metadata area";
- metadata_count = p_areas_count;
+ metadata_count = parallel_areas_count;
} else {
metadata_type = "mirror log";
metadata_count = alloc_state->log_area_count_still_needed;
}
log_debug("Still need %" PRIu32 " total extents:",
- p_area_size * p_areas_count + metadata_size * metadata_count);
+ parallel_area_size * parallel_areas_count + metadata_size * metadata_count);
log_debug(" %" PRIu32 " (%" PRIu32 " data/%" PRIu32
" parity) parallel areas of %" PRIu32 " extents each",
- p_areas_count, ah->area_count, ah->parity_count, p_area_size);
+ parallel_areas_count, ah->area_count, ah->parity_count, parallel_area_size);
log_debug(" %" PRIu32 " %ss of %" PRIu32 " extents each",
metadata_count, metadata_type, metadata_size);
}
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-08-10 16:44 jbrassow
0 siblings, 0 replies; 79+ messages in thread
From: jbrassow @ 2011-08-10 16:44 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: jbrassow@sourceware.org 2011-08-10 16:44:18
Modified files:
lib/metadata : lv_manip.c
Log message:
Fix compiler warning.
Compiler complaining that meta_lv could be used uninitialized. (Not true
because it is protected by 'clear_metadata'.) I switched to using 'lv->vg',
as it makes no difference to vg_[write|commit].
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.270&r2=1.271
--- LVM2/lib/metadata/lv_manip.c 2011/08/05 09:21:13 1.270
+++ LVM2/lib/metadata/lv_manip.c 2011/08/10 16:44:17 1.271
@@ -2389,7 +2389,7 @@
/*
* We must clear the metadata areas upon creation.
*/
- if (!vg_write(meta_lv->vg) || !vg_commit(meta_lv->vg))
+ if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
for (s = 0; s < seg->area_count; s++) {
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-08-05 9:21 prajnoha
0 siblings, 0 replies; 79+ messages in thread
From: prajnoha @ 2011-08-05 9:21 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha@sourceware.org 2011-08-05 09:21:13
Modified files:
lib/metadata : lv_manip.c
Log message:
Remove unused 'origin' variable in lv_remove_single function.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.269&r2=1.270
--- LVM2/lib/metadata/lv_manip.c 2011/08/02 22:07:22 1.269
+++ LVM2/lib/metadata/lv_manip.c 2011/08/05 09:21:13 1.270
@@ -2923,7 +2923,6 @@
{
struct volume_group *vg;
struct lvinfo info;
- struct logical_volume *origin = NULL;
vg = lv->vg;
@@ -2983,7 +2982,6 @@
return 0;
if (lv_is_cow(lv)) {
- origin = origin_from_cow(lv);
log_verbose("Removing snapshot %s", lv->name);
/* vg_remove_snapshot() will preload origin/former snapshots */
if (!vg_remove_snapshot(lv))
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-06-06 12:08 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2011-06-06 12:08 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2011-06-06 12:08:42
Modified files:
lib/metadata : lv_manip.c
Log message:
missing space in mesg
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.259&r2=1.260
--- LVM2/lib/metadata/lv_manip.c 2011/06/01 19:21:04 1.259
+++ LVM2/lib/metadata/lv_manip.c 2011/06/06 12:08:42 1.260
@@ -418,7 +418,7 @@
if (seg_is_striped(seg)) {
if (reduction % seg->area_count) {
log_error("Segment extent reduction %" PRIu32
- "not divisible by #stripes %" PRIu32,
+ " not divisible by #stripes %" PRIu32,
reduction, seg->area_count);
return 0;
}
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2011-03-25 22:02 jbrassow
0 siblings, 0 replies; 79+ messages in thread
From: jbrassow @ 2011-03-25 22:02 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: jbrassow@sourceware.org 2011-03-25 22:02:27
Modified files:
lib/metadata : lv_manip.c
Log message:
Fix unhandled condition in _move_lv_segments
If _move_lv_segments is passed a 'lv_from' that does not yet
have any segments, it will screw things up because the code
that does the segment copy assumes there is at least one
segment. See copy code here:
lv_to->segments = lv_from->segments;
lv_to->segments.n->p = &lv_to->segments;
lv_to->segments.p->n = &lv_to->segments;
If 'segments' is an empty list, the first statement copies over
the values, but the next two reset those values to point to the
other LV's list structure. 'lv_to' now appears to have one
segment, but it is really an ill-set pointer.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.251&r2=1.252
--- LVM2/lib/metadata/lv_manip.c 2011/02/28 19:53:03 1.251
+++ LVM2/lib/metadata/lv_manip.c 2011/03/25 22:02:27 1.252
@@ -2950,7 +2950,8 @@
}
}
- lv_to->segments = lv_from->segments;
+ if (!dm_list_empty(&lv_from->segments))
+ lv_to->segments = lv_from->segments;
lv_to->segments.n->p = &lv_to->segments;
lv_to->segments.p->n = &lv_to->segments;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2010-04-08 0:56 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2010-04-08 0:56 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2010-04-08 00:56:26
Modified files:
lib/metadata : lv_manip.c
Log message:
missing ?:
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.226&r2=1.227
--- LVM2/lib/metadata/lv_manip.c 2010/04/08 00:52:41 1.226
+++ LVM2/lib/metadata/lv_manip.c 2010/04/08 00:56:26 1.227
@@ -2096,7 +2096,7 @@
if (!_for_each_pv(cmd, use_pvmove_parent_lv ? seg->pvmove_source_seg->lv : lv,
use_pvmove_parent_lv ? seg->pvmove_source_seg->le : current_le,
use_pvmove_parent_lv ? spvs->len * calc_area_multiple(seg->pvmove_source_seg->segtype, seg->pvmove_source_seg->area_count) : spvs->len,
- seg->pvmove_source_seg,
+ use_pvmove_parent_lv ? seg->pvmove_source_seg : NULL,
&spvs->len,
0, 0, -1, 0, _add_pvs, (void *) spvs))
return_NULL;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2010-04-08 0:52 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2010-04-08 0:52 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2010-04-08 00:52:41
Modified files:
lib/metadata : lv_manip.c
Log message:
suppress bogus compiler warning
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.225&r2=1.226
--- LVM2/lib/metadata/lv_manip.c 2010/04/08 00:28:58 1.225
+++ LVM2/lib/metadata/lv_manip.c 2010/04/08 00:52:41 1.226
@@ -2063,7 +2063,7 @@
struct dm_list *parallel_areas;
struct seg_pvs *spvs;
uint32_t current_le = 0;
- struct lv_segment *seg;
+ struct lv_segment * uninitialized_var(seg);
if (!(parallel_areas = dm_pool_alloc(cmd->mem, sizeof(*parallel_areas)))) {
log_error("parallel_areas allocation failed");
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2010-04-02 1:35 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2010-04-02 1:35 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2010-04-02 01:35:35
Modified files:
lib/metadata : lv_manip.c
Log message:
remove compiler warning
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.223&r2=1.224
--- LVM2/lib/metadata/lv_manip.c 2010/04/01 13:58:13 1.223
+++ LVM2/lib/metadata/lv_manip.c 2010/04/02 01:35:34 1.224
@@ -1269,7 +1269,6 @@
struct dm_list *pvms;
uint32_t areas_size;
alloc_policy_t alloc;
- struct alloced_area *aa;
unsigned log_needs_allocating = 0;
if (allocated >= ah->new_extents && !ah->log_area_count) {
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2010-04-01 13:58 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2010-04-01 13:58 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2010-04-01 13:58:13
Modified files:
lib/metadata : lv_manip.c
Log message:
Try to fix tracking of whether or not log extents need allocating.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.222&r2=1.223
--- LVM2/lib/metadata/lv_manip.c 2010/04/01 12:29:07 1.222
+++ LVM2/lib/metadata/lv_manip.c 2010/04/01 13:58:13 1.223
@@ -1011,7 +1011,7 @@
struct dm_list *pvms, struct pv_area_used **areas_ptr,
uint32_t *areas_size_ptr, unsigned can_split,
struct lv_segment *prev_lvseg,
- uint32_t *allocated, uint32_t needed)
+ uint32_t *allocated, uint32_t *log_needs_allocating, uint32_t needed)
{
struct pv_map *pvm;
struct pv_area *pva;
@@ -1028,7 +1028,6 @@
struct seg_pvs *spvs;
struct dm_list *parallel_pvs;
uint32_t free_pes;
- unsigned log_needs_allocating;
struct alloced_area *aa;
uint32_t s;
@@ -1082,9 +1081,6 @@
}
}
- log_needs_allocating = (ah->log_area_count &&
- dm_list_empty(&ah->alloced_areas[ah->area_count])) ? 1 : 0;
-
do {
/*
* Provide for escape from the loop if no progress is made.
@@ -1183,8 +1179,12 @@
pva->unreserved -= required;
reinsert_reduced_pv_area(pva);
}
- } else if (required > pva->count)
- required = pva->count;
+ } else {
+ if (required < ah->log_len)
+ required = ah->log_len;
+ if (required > pva->count)
+ required = pva->count;
+ }
/* Expand areas array if needed after an area was split. */
if (ix + ix_offset > *areas_size_ptr) {
@@ -1200,16 +1200,16 @@
}
next_pv:
if (alloc == ALLOC_ANYWHERE &&
- ix + ix_offset >= ah->area_count + (log_needs_allocating ? ah->log_area_count : 0))
+ ix + ix_offset >= ah->area_count + (*log_needs_allocating ? ah->log_area_count : 0))
break;
}
- } while (alloc == ALLOC_ANYWHERE && last_ix != ix && ix < ah->area_count + (log_needs_allocating ? ah->log_area_count : 0));
+ } while (alloc == ALLOC_ANYWHERE && last_ix != ix && ix < ah->area_count + (*log_needs_allocating ? ah->log_area_count : 0));
if ((contiguous || cling) && (preferred_count < ix_offset))
break;
if (ix + ix_offset < ah->area_count +
- (log_needs_allocating ? ah->log_area_count : 0))
+ (*log_needs_allocating ? ah->log_area_count : 0))
break;
/* sort the areas so we allocate from the biggest */
@@ -1225,7 +1225,7 @@
ix_log_offset = 0;
/* FIXME This logic is due to its heritage and can be simplified! */
- if (log_needs_allocating) {
+ if (*log_needs_allocating) {
/* How many areas are too small for the log? */
while (too_small_for_log_count < ix_offset + ix &&
(*((*areas_ptr) + ix_offset + ix - 1 -
@@ -1235,14 +1235,16 @@
}
if (ix + ix_offset < ah->area_count +
- (log_needs_allocating ? ah->log_area_count +
+ (*log_needs_allocating ? ah->log_area_count +
too_small_for_log_count : 0))
break;
if (!_alloc_parallel_area(ah, max_parallel, *areas_ptr, allocated,
- log_needs_allocating, ix_log_offset))
+ *log_needs_allocating, ix_log_offset))
return_0;
+ *log_needs_allocating = 0;
+
} while ((alloc != ALLOC_CONTIGUOUS) && *allocated != needed && can_split);
return 1;
@@ -1268,15 +1270,15 @@
uint32_t areas_size;
alloc_policy_t alloc;
struct alloced_area *aa;
- unsigned log_allocated = 0;
+ unsigned log_needs_allocating = 0;
if (allocated >= ah->new_extents && !ah->log_area_count) {
log_error("_allocate called with no work to do!");
return 1;
}
- if (!ah->log_area_count)
- log_allocated = 1;
+ if (ah->log_area_count)
+ log_needs_allocating = 1;
if (ah->alloc == ALLOC_CONTIGUOUS)
can_split = 0;
@@ -1322,17 +1324,14 @@
"Need %" PRIu32 " extents for %" PRIu32 " parallel areas and %" PRIu32 " log extents.",
get_alloc_string(alloc),
(ah->new_extents - allocated) / ah->area_multiple,
- ah->area_count, log_allocated ? 0 : ah->log_area_count);
+ ah->area_count, log_needs_allocating ? ah->log_area_count : 0);
if (!_find_parallel_space(ah, alloc, pvms, &areas,
&areas_size, can_split,
- prev_lvseg, &allocated, ah->new_extents))
+ prev_lvseg, &allocated, &log_needs_allocating, ah->new_extents))
goto_out;
- if ((allocated == ah->new_extents) || (ah->alloc == alloc) ||
+ if ((allocated == ah->new_extents && !log_needs_allocating) || (ah->alloc == alloc) ||
(!can_split && (allocated != old_allocated)))
break;
- /* Log is always allocated the first time anything is allocated. */
- if (old_allocated != allocated)
- log_allocated = 1;
}
if (allocated != ah->new_extents) {
@@ -1345,14 +1344,12 @@
goto out;
}
- if (ah->log_area_count)
- dm_list_iterate_items(aa, &ah->alloced_areas[ah->area_count])
- if (!aa[0].pv) {
- log_error("Insufficient extents for log allocation "
- "for logical volume %s.",
- lv ? lv->name : "");
- goto out;
- }
+ if (log_needs_allocating) {
+ log_error("Insufficient extents for log allocation "
+ "for logical volume %s.",
+ lv ? lv->name : "");
+ goto out;
+ }
r = 1;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2010-04-01 12:29 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2010-04-01 12:29 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2010-04-01 12:29:08
Modified files:
lib/metadata : lv_manip.c
Log message:
initialise log_allocated to 0
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.221&r2=1.222
--- LVM2/lib/metadata/lv_manip.c 2010/04/01 10:34:10 1.221
+++ LVM2/lib/metadata/lv_manip.c 2010/04/01 12:29:07 1.222
@@ -1268,7 +1268,7 @@
uint32_t areas_size;
alloc_policy_t alloc;
struct alloced_area *aa;
- unsigned log_allocated;
+ unsigned log_allocated = 0;
if (allocated >= ah->new_extents && !ah->log_area_count) {
log_error("_allocate called with no work to do!");
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2010-03-31 20:26 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2010-03-31 20:26 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2010-03-31 20:26:04
Modified files:
lib/metadata : lv_manip.c
Log message:
Attempt to fix non-ALLOC_ANYWHERE allocation code after recent changes broke
The preference given to the PVs with the largest free areas.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.219&r2=1.220
--- LVM2/lib/metadata/lv_manip.c 2010/03/31 17:23:19 1.219
+++ LVM2/lib/metadata/lv_manip.c 2010/03/31 20:26:04 1.220
@@ -877,8 +877,8 @@
static int _comp_area(const void *l, const void *r)
{
- const struct pv_area_used *lhs = *((const struct pv_area_used * const *) l);
- const struct pv_area_used *rhs = *((const struct pv_area_used * const *) r);
+ const struct pv_area_used *lhs = (const struct pv_area_used *) l;
+ const struct pv_area_used *rhs = (const struct pv_area_used *) r;
if (lhs->used < rhs->used)
return 1;
@@ -1166,10 +1166,7 @@
already_found_one = 1;
}
- if (ix + ix_offset - 1 < ah->area_count)
- required = (max_parallel - *allocated) / ah->area_multiple;
- else
- required = ah->log_len;
+ required = (max_parallel - *allocated) / ah->area_multiple;
if (alloc == ALLOC_ANYWHERE) {
/*
@@ -1177,6 +1174,8 @@
* into two or more parts. If the whole stripe doesn't fit,
* reduce amount we're looking for.
*/
+ if (ix + ix_offset - 1 >= ah->area_count)
+ required = ah->log_len;
if (required >= pva->unreserved) {
required = pva->unreserved;
pva->unreserved = 0;
@@ -1200,7 +1199,8 @@
(alloc == ALLOC_ANYWHERE) ? pva->unreserved : pva->count - required);
}
next_pv:
- if (ix + ix_offset >= ah->area_count + (log_needs_allocating ? ah->log_area_count : 0))
+ if (alloc == ALLOC_ANYWHERE &&
+ ix + ix_offset >= ah->area_count + (log_needs_allocating ? ah->log_area_count : 0))
break;
}
} while (alloc == ALLOC_ANYWHERE && last_ix != ix && ix < ah->area_count + (log_needs_allocating ? ah->log_area_count : 0));
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2010-02-17 23:36 snitzer
0 siblings, 0 replies; 79+ messages in thread
From: snitzer @ 2010-02-17 23:36 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: snitzer@sourceware.org 2010-02-17 23:36:45
Modified files:
lib/metadata : lv_manip.c
Log message:
Do not reload origin again in lv_remove_single() if it had a merging
snapshot. vg_remove_snapshot() will have already performed the required
reload.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.208&r2=1.209
--- LVM2/lib/metadata/lv_manip.c 2010/02/17 22:59:46 1.208
+++ LVM2/lib/metadata/lv_manip.c 2010/02/17 23:36:45 1.209
@@ -2064,6 +2064,7 @@
struct volume_group *vg;
struct lvinfo info;
struct logical_volume *origin = NULL;
+ int was_merging = 0;
vg = lv->vg;
@@ -2118,6 +2119,7 @@
if (lv_is_cow(lv)) {
origin = origin_from_cow(lv);
+ was_merging = lv_is_merging_origin(origin);
log_verbose("Removing snapshot %s", lv->name);
/* vg_remove_snapshot() will preload origin if it was merging */
if (!vg_remove_snapshot(lv))
@@ -2140,8 +2142,8 @@
if (!vg_write(vg) || !vg_commit(vg))
return_0;
- /* If no snapshots left, reload without -real. */
- if (origin && (!lv_is_origin(origin))) {
+ /* If no snapshots left, and was not merging, reload without -real. */
+ if (origin && (!lv_is_origin(origin) && !was_merging)) {
if (!suspend_lv(cmd, origin)) {
log_error("Failed to refresh %s without snapshot.", origin->name);
return 0;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2010-01-20 21:53 snitzer
0 siblings, 0 replies; 79+ messages in thread
From: snitzer @ 2010-01-20 21:53 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: snitzer@sourceware.org 2010-01-20 21:53:10
Modified files:
lib/metadata : lv_manip.c
Log message:
Preload the origin prior to suspend IFF snapshot(s) still exist after a
merge completes. This narrows the scope of this "hack" (which still
needs a proper fix within the deptree).
This stops dmeventd from trying to access snapshot devices that were
already removed.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.206&r2=1.207
--- LVM2/lib/metadata/lv_manip.c 2010/01/14 14:39:57 1.206
+++ LVM2/lib/metadata/lv_manip.c 2010/01/20 21:53:10 1.207
@@ -2064,7 +2064,7 @@
struct volume_group *vg;
struct lvinfo info;
struct logical_volume *origin = NULL;
- int was_merging = 0;
+ int was_merging = 0, preload_origin = 0;
vg = lv->vg;
@@ -2130,6 +2130,11 @@
log_verbose("Removing snapshot %s", lv->name);
if (!vg_remove_snapshot(lv))
return_0;
+ if (was_merging && lv_is_origin(origin)) {
+ /* snapshot(s) still exist. preload new origin prior to suspend. */
+ /* FIXME Seek a simpler way of dealing with this within the tree. */
+ preload_origin = 1;
+ }
}
log_verbose("Releasing logical volume \"%s\"", lv->name);
@@ -2142,22 +2147,21 @@
if (!vg_write(vg))
return_0;
- /* FIXME Seek a simpler way of dealing with this within the tree. */
+ if (!preload_origin && !vg_commit(vg))
+ return_0;
+
/* If no snapshots left or if we stopped merging, reload */
if (origin && (!lv_is_origin(origin) || was_merging)) {
if (!suspend_lv(cmd, origin)) {
log_error("Failed to refresh %s without snapshot.", origin->name);
return 0;
}
- if (!vg_commit(vg))
+ if (preload_origin && !vg_commit(vg))
return_0;
if (!resume_lv(cmd, origin)) {
log_error("Failed to resume %s.", origin->name);
return 0;
}
- } else {
- if (!vg_commit(vg))
- return_0;
}
backup(vg);
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2010-01-14 10:17 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2010-01-14 10:17 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2010-01-14 10:17:13
Modified files:
lib/metadata : lv_manip.c
Log message:
Cleanup const compiler warning
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.204&r2=1.205
--- LVM2/lib/metadata/lv_manip.c 2010/01/14 10:09:42 1.204
+++ LVM2/lib/metadata/lv_manip.c 2010/01/14 10:17:12 1.205
@@ -852,8 +852,8 @@
static int _comp_area(const void *l, const void *r)
{
- const struct pv_area *lhs = *((const struct pv_area **) l);
- const struct pv_area *rhs = *((const struct pv_area **) r);
+ const struct pv_area *lhs = *((const struct pv_area * const *) l);
+ const struct pv_area *rhs = *((const struct pv_area * const *) r);
if (lhs->count < rhs->count)
return 1;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2010-01-14 10:09 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2010-01-14 10:09 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2010-01-14 10:09:42
Modified files:
lib/metadata : lv_manip.c
Log message:
Move initialization of the 'cmd' member of the struct alloc_handle
before the first potentional return.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.203&r2=1.204
--- LVM2/lib/metadata/lv_manip.c 2010/01/14 10:08:03 1.203
+++ LVM2/lib/metadata/lv_manip.c 2010/01/14 10:09:42 1.204
@@ -566,11 +566,11 @@
return NULL;
}
+ ah->cmd = cmd;
+
if (segtype_is_virtual(segtype))
return ah;
- ah->cmd = cmd;
-
if (!(ah->mem = dm_pool_create("allocation", 1024))) {
log_error("allocation pool creation failed");
return NULL;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2010-01-14 10:08 zkabelac
0 siblings, 0 replies; 79+ messages in thread
From: zkabelac @ 2010-01-14 10:08 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2010-01-14 10:08:03
Modified files:
lib/metadata : lv_manip.c
Log message:
lvol%d is generated for NULL name in lv_create_empty().
So just avoid code duplication.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.202&r2=1.203
--- LVM2/lib/metadata/lv_manip.c 2010/01/13 01:56:18 1.202
+++ LVM2/lib/metadata/lv_manip.c 2010/01/14 10:08:03 1.203
@@ -2852,8 +2852,6 @@
uint64_t status = UINT64_C(0);
struct logical_volume *lv, *org = NULL;
int origin_active = 0;
- char lv_name_buf[128];
- const char *lv_name;
struct lvinfo info;
if (lp->lv_name && find_lv_in_vg(vg, lp->lv_name)) {
@@ -3008,16 +3006,6 @@
if (!archive(vg))
return 0;
- if (lp->lv_name)
- lv_name = lp->lv_name;
- else {
- if (!generate_lv_name(vg, "lvol%d", lv_name_buf, sizeof(lv_name_buf))) {
- log_error("Failed to generate LV name.");
- return 0;
- }
- lv_name = &lv_name_buf[0];
- }
-
if (lp->tag) {
if (!(vg->fid->fmt->features & FMT_TAGS)) {
log_error("Volume group %s does not support tags",
@@ -3036,7 +3024,7 @@
}
}
- if (!(lv = lv_create_empty(lv_name ? lv_name : "lvol%d", NULL,
+ if (!(lv = lv_create_empty(lp->lv_name ? lp->lv_name : "lvol%d", NULL,
status, lp->alloc, vg)))
return_0;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2010-01-13 1:52 snitzer
0 siblings, 0 replies; 79+ messages in thread
From: snitzer @ 2010-01-13 1:52 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: snitzer@sourceware.org 2010-01-13 01:52:58
Modified files:
lib/metadata : lv_manip.c
Log message:
When turning merging origin into non-merging origin, there is bad sequence:
snapshots are suspended, new origin is created, snapshots are resumed, new
origin is resumed. So it allocates memory while suspended.
To fix it, move vg_commit after suspend_lv, so that the suspend code will
treat it as precommitted vg and will preload new origin prior to suspend.
NOTE: agk doesn't like this "hack"; need to revisit and fix
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.199&r2=1.200
--- LVM2/lib/metadata/lv_manip.c 2010/01/13 01:51:45 1.199
+++ LVM2/lib/metadata/lv_manip.c 2010/01/13 01:52:58 1.200
@@ -2140,19 +2140,28 @@
}
/* store it on disks */
- if (!vg_write(vg) || !vg_commit(vg))
+ if (!vg_write(vg))
return_0;
- backup(vg);
-
/* If no snapshots left or if we stopped merging, reload */
if (origin && (!lv_is_origin(origin) || was_merging)) {
- if (!suspend_lv(cmd, origin))
+ if (!suspend_lv(cmd, origin)) {
log_error("Failed to refresh %s without snapshot.", origin->name);
- else if (!resume_lv(cmd, origin))
+ return 0;
+ }
+ if (!vg_commit(vg))
+ return_0;
+ if (!resume_lv(cmd, origin)) {
log_error("Failed to resume %s.", origin->name);
+ return 0;
+ }
+ } else {
+ if (!vg_commit(vg))
+ return_0;
}
+ backup(vg);
+
if (lv_is_visible(lv))
log_print("Logical volume \"%s\" successfully removed", lv->name);
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2010-01-13 1:51 snitzer
0 siblings, 0 replies; 79+ messages in thread
From: snitzer @ 2010-01-13 1:51 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: snitzer@sourceware.org 2010-01-13 01:51:45
Modified files:
lib/metadata : lv_manip.c
Log message:
Reload origin if merging has stopped.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.198&r2=1.199
--- LVM2/lib/metadata/lv_manip.c 2010/01/13 01:35:49 1.198
+++ LVM2/lib/metadata/lv_manip.c 2010/01/13 01:51:45 1.199
@@ -2065,6 +2065,7 @@
struct volume_group *vg;
struct lvinfo info;
struct logical_volume *origin = NULL;
+ int was_merging = 0;
vg = lv->vg;
@@ -2126,6 +2127,7 @@
if (lv_is_cow(lv)) {
origin = origin_from_cow(lv);
+ was_merging = !!origin->merging_snapshot;
log_verbose("Removing snapshot %s", lv->name);
if (!vg_remove_snapshot(lv))
return_0;
@@ -2143,8 +2145,8 @@
backup(vg);
- /* If no snapshots left, reload without -real. */
- if (origin && !lv_is_origin(origin)) {
+ /* If no snapshots left or if we stopped merging, reload */
+ if (origin && (!lv_is_origin(origin) || was_merging)) {
if (!suspend_lv(cmd, origin))
log_error("Failed to refresh %s without snapshot.", origin->name);
else if (!resume_lv(cmd, origin))
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2010-01-10 20:44 snitzer
0 siblings, 0 replies; 79+ messages in thread
From: snitzer @ 2010-01-10 20:44 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: snitzer@sourceware.org 2010-01-10 20:44:09
Modified files:
lib/metadata : lv_manip.c
Log message:
remove unused variable 'i' that was recently introduced in lv_add_segment
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.193&r2=1.194
--- LVM2/lib/metadata/lv_manip.c 2010/01/08 23:06:36 1.193
+++ LVM2/lib/metadata/lv_manip.c 2010/01/10 20:44:09 1.194
@@ -1390,7 +1390,6 @@
uint32_t region_size,
struct logical_volume *log_lv)
{
- int i;
struct dm_list *aa_list;
/*
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2010-01-08 23:06 jbrassow
0 siblings, 0 replies; 79+ messages in thread
From: jbrassow @ 2010-01-08 23:06 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: jbrassow@sourceware.org 2010-01-08 23:06:36
Modified files:
lib/metadata : lv_manip.c
Log message:
update comment
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.192&r2=1.193
--- LVM2/lib/metadata/lv_manip.c 2010/01/08 22:32:35 1.192
+++ LVM2/lib/metadata/lv_manip.c 2010/01/08 23:06:36 1.193
@@ -1396,8 +1396,6 @@
/*
* We don't actually use the 'log_lv' parameter for anything more
* than just figuring out that this allocation is for a log device
- * It'd be nice to change the arguments type, but the function is
- * exported.
*/
aa_list = (log_lv) ? &ah->log_areas :
&ah->alloced_areas[first_area];
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2009-06-06 16:37 mbroz
0 siblings, 0 replies; 79+ messages in thread
From: mbroz @ 2009-06-06 16:37 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mbroz@sourceware.org 2009-06-06 16:37:15
Modified files:
lib/metadata : lv_manip.c
Log message:
Suspend virtual origin before real snapshot.
Because preload of table for snapshot can produce snapshot
metadata (in kernel cow header) read.
Code should suspend origin first to avoid possible deadlock
when preloading (thus calling snapshot in-kernel constructor)
for origin with suspended cow device.
(fixes previous commit)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.180&r2=1.181
--- LVM2/lib/metadata/lv_manip.c 2009/06/01 15:55:07 1.180
+++ LVM2/lib/metadata/lv_manip.c 2009/06/06 16:37:15 1.181
@@ -1806,7 +1806,7 @@
/* rename active virtual origin too */
if (lv_is_cow(lv) && lv_is_virtual_origin(lvl2.lv = origin_from_cow(lv)))
- dm_list_add(&lvs_changed, &lvl2.list);
+ dm_list_add_h(&lvs_changed, &lvl2.list);
log_verbose("Writing out updated volume group");
if (!vg_write(vg))
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2009-06-01 14:23 mbroz
0 siblings, 0 replies; 79+ messages in thread
From: mbroz @ 2009-06-01 14:23 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mbroz@sourceware.org 2009-06-01 14:23:38
Modified files:
lib/metadata : lv_manip.c
Log message:
Fix log allocation segfault (fix previous commits).
If there is no free area for log, code should break the loop.
(Otherwise it uses uninitializes areas later.)
Easily reproducible using lvconvert --repair
- kill device with log
- run lvconvert --repair vg/lv (with no PV usable for log)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.178&r2=1.179
--- LVM2/lib/metadata/lv_manip.c 2009/05/30 00:09:27 1.178
+++ LVM2/lib/metadata/lv_manip.c 2009/06/01 14:23:38 1.179
@@ -1124,6 +1124,13 @@
if ((contiguous || cling) && (preferred_count < ix_offset))
break;
+ log_needs_allocating = (ah->log_count && !ah->log_area.len) ?
+ 1 : 0;
+
+ if (ix + ix_offset < ah->area_count +
+ (log_needs_allocating ? ah->log_count : 0))
+ break;
+
/* sort the areas so we allocate from the biggest */
if (ix > 1)
qsort(areas + ix_offset, ix, sizeof(*areas),
@@ -1136,9 +1143,6 @@
* FIXME decide which PV to use at top of function instead
*/
- log_needs_allocating = (ah->log_count && !ah->log_area.len) ?
- 1 : 0;
-
too_small_for_log_count = 0;
if (!log_needs_allocating) {
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2009-01-06 17:24 mbroz
0 siblings, 0 replies; 79+ messages in thread
From: mbroz @ 2009-01-06 17:24 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mbroz@sourceware.org 2009-01-06 17:24:21
Modified files:
lib/metadata : lv_manip.c
Log message:
Fix "Calculate mirror log size" commit, the le_count should be always set.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.162&r2=1.163
--- LVM2/lib/metadata/lv_manip.c 2008/12/19 15:26:02 1.162
+++ LVM2/lib/metadata/lv_manip.c 2009/01/06 17:24:21 1.163
@@ -844,7 +844,7 @@
/* FIXME only_single_area_segments used as workaround to skip log LV - needs new param? */
if (!only_single_area_segments && seg_is_mirrored(seg) && seg->log_lv) {
- if (!(r = _for_each_pv(cmd, seg->log_lv, 0, seg->log_lv->le_count?:1,
+ if (!(r = _for_each_pv(cmd, seg->log_lv, 0, seg->log_lv->le_count,
NULL, 0, 0, 0, only_single_area_segments,
fn, data)))
stack;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2008-01-16 20:00 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2008-01-16 20:00 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2008-01-16 20:00:01
Modified files:
lib/metadata : lv_manip.c
Log message:
additional safety check on new segment list
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.141&r2=1.142
--- LVM2/lib/metadata/lv_manip.c 2008/01/16 19:00:59 1.141
+++ LVM2/lib/metadata/lv_manip.c 2008/01/16 20:00:01 1.142
@@ -91,6 +91,13 @@
sl = list_item(list_first(&lv->segs_using_this_lv), struct seg_list);
+ if (sl->count != 1) {
+ log_error("%s is expected to have only one segment using it, "
+ "while %s:%" PRIu32 " uses it %d times",
+ lv->name, sl->seg->lv->name, sl->seg->le, sl->count);
+ return NULL;
+ }
+
return sl->seg;
}
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2007-11-04 16:28 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2007-11-04 16:28 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2007-11-04 16:28:57
Modified files:
lib/metadata : lv_manip.c
Log message:
fix new lvremove checks - mustn't fail when activation is disabled
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.131&r2=1.132
--- LVM2/lib/metadata/lv_manip.c 2007/10/12 14:29:32 1.131
+++ LVM2/lib/metadata/lv_manip.c 2007/11/04 16:28:57 1.132
@@ -1839,45 +1839,37 @@
/* FIXME Ensure not referred to by another existing LVs */
- /*
- * If we can't get information about the LV from the kernel, or
- * someone has the LV device open, fail.
- */
- if (!lv_info(cmd, lv, &info, 1)) {
- log_error("Unable to obtain status for logical volume \"%s\"",
- lv->name);
- return 0;
- }
- if (info.open_count) {
- log_error("Can't remove open logical volume \"%s\"",
- lv->name);
- return 0;
- }
-
- /*
- * Check for confirmation prompts in the following cases:
- * 1) Clustered VG, and some remote nodes have the LV active
- * 2) Non-clustered VG, but LV active locally
- */
- if ((vg_status(vg) & CLUSTERED) && !activate_lv_excl(cmd, lv) &&
- (force == PROMPT)) {
- if (yes_no_prompt("Logical volume \"%s\" is active on other "
- "cluster nodes. Really remove? [y/n]: ",
- lv->name) == 'n') {
- log_print("Logical volume \"%s\" not removed",
+ if (lv_info(cmd, lv, &info, 1)) {
+ if (info.open_count) {
+ log_error("Can't remove open logical volume \"%s\"",
lv->name);
return 0;
}
- } else if (info.exists && (force == PROMPT)) {
- if (yes_no_prompt("Do you really want to remove active "
- "logical volume \"%s\"? [y/n]: ",
- lv->name) == 'n') {
- log_print("Logical volume \"%s\" not removed",
- lv->name);
- return 0;
- }
- }
+ /*
+ * Check for confirmation prompts in the following cases:
+ * 1) Clustered VG, and some remote nodes have the LV active
+ * 2) Non-clustered VG, but LV active locally
+ */
+ if ((vg_status(vg) & CLUSTERED) && !activate_lv_excl(cmd, lv) &&
+ (force == PROMPT)) {
+ if (yes_no_prompt("Logical volume \"%s\" is active on other "
+ "cluster nodes. Really remove? [y/n]: ",
+ lv->name) == 'n') {
+ log_print("Logical volume \"%s\" not removed",
+ lv->name);
+ return 0;
+ }
+ } else if (info.exists && (force == PROMPT)) {
+ if (yes_no_prompt("Do you really want to remove active "
+ "logical volume \"%s\"? [y/n]: ",
+ lv->name) == 'n') {
+ log_print("Logical volume \"%s\" not removed",
+ lv->name);
+ return 0;
+ }
+ }
+ }
if (!archive(vg))
return 0;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2007-08-08 18:00 wysochanski
0 siblings, 0 replies; 79+ messages in thread
From: wysochanski @ 2007-08-08 18:00 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2007-08-08 18:00:37
Modified files:
lib/metadata : lv_manip.c
Log message:
Remove extra checks for sub LV renaming.
Patch by Jun'ichi Nomura <j-nomura@ce.jp.nec.com>.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.121&r2=1.122
--- LVM2/lib/metadata/lv_manip.c 2007/08/07 18:55:38 1.121
+++ LVM2/lib/metadata/lv_manip.c 2007/08/08 18:00:36 1.122
@@ -1491,25 +1491,7 @@
}
/*
- * Returns a pointer to LV name suffix.
- * Returns NULL if the LV doesn't have suffix.
- */
-static char *_sub_lv_name_suffix(const char *lvname)
-{
- char *s;
-
- if ((s = strstr(lvname, "_mimage")))
- return s;
-
- if ((s = strstr(lvname, "_mlog")))
- return s;
-
- return NULL;
-}
-
-/*
* Rename sub LV.
- * If a new name for the sub LV cannot be determined, 1 is returned.
* 'lv_name_old' and 'lv_name_new' are old and new names of the main LV.
*/
static int _rename_sub_lv(struct cmd_context *cmd,
@@ -1519,14 +1501,18 @@
char *suffix, *new_name;
size_t len;
- /* Rename only if the lv has known suffix */
- if (!(suffix = _sub_lv_name_suffix(lv->name)))
- return 1;
-
- /* Make sure that lv->name is exactly a lv_name_old + suffix */
- len = suffix - lv->name;
- if (strlen(lv_name_old) != len || strncmp(lv->name, lv_name_old, len))
- return 1;
+ /*
+ * A sub LV name starts with lv_name_old + '_'.
+ * The suffix follows lv_name_old and includes '_'.
+ */
+ len = strlen(lv_name_old);
+ if (strncmp(lv->name, lv_name_old, len) || lv->name[len] != '_') {
+ log_error("Cannot rename \"%s\": name format not recognized "
+ "for internal LV \"%s\"",
+ lv_name_old, lv->name);
+ return 0;
+ }
+ suffix = lv->name + len;
/*
* Compose a new name for sub lv:
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2007-08-07 18:55 wysochanski
0 siblings, 0 replies; 79+ messages in thread
From: wysochanski @ 2007-08-07 18:55 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2007-08-07 18:55:38
Modified files:
lib/metadata : lv_manip.c
Log message:
A few more cleanups for lvrename of mirrors checkin:
* add struct lv_names for old/new names
* replace lv->status & MIRROR checks with lv_is_visible()
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.120&r2=1.121
--- LVM2/lib/metadata/lv_manip.c 2007/08/07 16:57:09 1.120
+++ LVM2/lib/metadata/lv_manip.c 2007/08/07 18:55:38 1.121
@@ -25,6 +25,11 @@
#include "segtype.h"
#include "archiver.h"
+struct lv_names {
+ const char *old;
+ const char *new;
+};
+
/*
* PVs used by a segment of an LV
*/
@@ -1548,9 +1553,9 @@
static int _rename_cb(struct cmd_context *cmd, struct logical_volume *lv,
void *data)
{
- char **names = (char **) data;
+ struct lv_names *lv_names = (struct lv_names *) data;
- return _rename_sub_lv(cmd, lv, names[0], names[1]);
+ return _rename_sub_lv(cmd, lv, lv_names->old, lv_names->new);
}
/*
@@ -1588,10 +1593,10 @@
const char *new_name)
{
struct volume_group *vg = lv->vg;
- const char *names[2];
+ struct lv_names lv_names;
/* rename is not allowed on sub LVs */
- if ((lv->status & MIRROR_LOG) || (lv->status & MIRROR_IMAGE)) {
+ if (!lv_is_visible(lv)) {
log_error("Cannot rename internal LV \"%s\".", lv->name);
return 0;
}
@@ -1611,9 +1616,9 @@
return 0;
/* rename sub LVs */
- names[0] = lv->name;
- names[1] = new_name;
- if (!_for_each_sub_lv(cmd, lv, _rename_cb, (void *) names))
+ lv_names.old = lv->name;
+ lv_names.new = new_name;
+ if (!_for_each_sub_lv(cmd, lv, _rename_cb, (void *) &lv_names))
return 0;
/* rename main LV */
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2007-08-07 16:57 wysochanski
0 siblings, 0 replies; 79+ messages in thread
From: wysochanski @ 2007-08-07 16:57 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2007-08-07 16:57:09
Modified files:
lib/metadata : lv_manip.c
Log message:
Some simple fixups for last checkin:
* remove "_" from "return_0"
* improve some naming and terminology
* add 'const'
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.119&r2=1.120
--- LVM2/lib/metadata/lv_manip.c 2007/08/06 20:35:48 1.119
+++ LVM2/lib/metadata/lv_manip.c 2007/08/07 16:57:09 1.120
@@ -1472,12 +1472,12 @@
if (find_lv_in_vg(vg, new_name)) {
log_error("Logical volume \"%s\" already exists in "
"volume group \"%s\"", new_name, vg->name);
- return_0;
+ return 0;
}
if (lv->status & LOCKED) {
log_error("Cannot rename locked LV %s", lv->name);
- return_0;
+ return 0;
}
lv->name = new_name;
@@ -1489,7 +1489,7 @@
* Returns a pointer to LV name suffix.
* Returns NULL if the LV doesn't have suffix.
*/
-static char * sub_lv_name_suffix(const char *lvname)
+static char *_sub_lv_name_suffix(const char *lvname)
{
char *s;
@@ -1504,24 +1504,23 @@
/*
* Rename sub LV.
- * Returns 0 on failure, 1 on success.
* If a new name for the sub LV cannot be determined, 1 is returned.
- * 'lv_main_old' and 'lv_main_new' are old and new names of the main LV.
+ * 'lv_name_old' and 'lv_name_new' are old and new names of the main LV.
*/
static int _rename_sub_lv(struct cmd_context *cmd,
struct logical_volume *lv,
- char *lv_main_old, char *lv_main_new)
+ const char *lv_name_old, const char *lv_name_new)
{
char *suffix, *new_name;
- size_t l;
+ size_t len;
/* Rename only if the lv has known suffix */
- if (!(suffix = sub_lv_name_suffix(lv->name)))
+ if (!(suffix = _sub_lv_name_suffix(lv->name)))
return 1;
- /* Make sure that lv->name is exactly a lv_main_old + suffix */
- l = suffix - lv->name;
- if (strlen(lv_main_old) != l || strncmp(lv->name, lv_main_old, l))
+ /* Make sure that lv->name is exactly a lv_name_old + suffix */
+ len = suffix - lv->name;
+ if (strlen(lv_name_old) != len || strncmp(lv->name, lv_name_old, len))
return 1;
/*
@@ -1530,15 +1529,15 @@
* if the sub LV is "lvol0_mlog" and
* a new name for main LV is "lvol1"
*/
- l = strlen(lv_main_new) + strlen(suffix) + 1;
- new_name = dm_pool_alloc(cmd->mem, l);
+ len = strlen(lv_name_new) + strlen(suffix) + 1;
+ new_name = dm_pool_alloc(cmd->mem, len);
if (!new_name) {
log_error("Failed to allocate space for new name");
- return_0;
+ return 0;
}
- if (!dm_snprintf(new_name, l, "%s%s", lv_main_new, suffix)) {
+ if (!dm_snprintf(new_name, len, "%s%s", lv_name_new, suffix)) {
log_error("Failed to create new name");
- return_0;
+ return 0;
}
/* Rename it */
@@ -1569,11 +1568,11 @@
list_iterate_items(seg, &lv->segments) {
if (seg->log_lv && !func(cmd, seg->log_lv, data))
- return_0;
+ return 0;
for (s = 0; s < seg->area_count; s++)
if (seg_type(seg, s) == AREA_LV &&
!func(cmd, seg_lv(seg, s), data))
- return_0;
+ return 0;
}
return 1;
@@ -1593,7 +1592,7 @@
/* rename is not allowed on sub LVs */
if ((lv->status & MIRROR_LOG) || (lv->status & MIRROR_IMAGE)) {
- log_error("Cannot rename hidden LV \"%s\".", lv->name);
+ log_error("Cannot rename internal LV \"%s\".", lv->name);
return 0;
}
@@ -1609,7 +1608,7 @@
}
if (!archive(vg))
- return_0;
+ return 0;
/* rename sub LVs */
names[0] = lv->name;
@@ -1625,7 +1624,7 @@
log_verbose("Writing out updated volume group");
if (!vg_write(vg))
- return_0;
+ return 0;
backup(vg);
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2007-08-06 20:35 wysochanski
0 siblings, 0 replies; 79+ messages in thread
From: wysochanski @ 2007-08-06 20:35 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2007-08-06 20:35:48
Modified files:
lib/metadata : lv_manip.c
Log message:
Add support for renaming mirrored LVs.
Patch by Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.118&r2=1.119
--- LVM2/lib/metadata/lv_manip.c 2007/08/06 14:57:48 1.118
+++ LVM2/lib/metadata/lv_manip.c 2007/08/06 20:35:48 1.119
@@ -1461,6 +1461,126 @@
}
/*
+ * Minimal LV renaming function.
+ * Metadata transaction should be made by caller.
+ * Assumes new_name is allocated from cmd->mem pool.
+ */
+static int _rename_single_lv(struct logical_volume *lv, char *new_name)
+{
+ struct volume_group *vg = lv->vg;
+
+ if (find_lv_in_vg(vg, new_name)) {
+ log_error("Logical volume \"%s\" already exists in "
+ "volume group \"%s\"", new_name, vg->name);
+ return_0;
+ }
+
+ if (lv->status & LOCKED) {
+ log_error("Cannot rename locked LV %s", lv->name);
+ return_0;
+ }
+
+ lv->name = new_name;
+
+ return 1;
+}
+
+/*
+ * Returns a pointer to LV name suffix.
+ * Returns NULL if the LV doesn't have suffix.
+ */
+static char * sub_lv_name_suffix(const char *lvname)
+{
+ char *s;
+
+ if ((s = strstr(lvname, "_mimage")))
+ return s;
+
+ if ((s = strstr(lvname, "_mlog")))
+ return s;
+
+ return NULL;
+}
+
+/*
+ * Rename sub LV.
+ * Returns 0 on failure, 1 on success.
+ * If a new name for the sub LV cannot be determined, 1 is returned.
+ * 'lv_main_old' and 'lv_main_new' are old and new names of the main LV.
+ */
+static int _rename_sub_lv(struct cmd_context *cmd,
+ struct logical_volume *lv,
+ char *lv_main_old, char *lv_main_new)
+{
+ char *suffix, *new_name;
+ size_t l;
+
+ /* Rename only if the lv has known suffix */
+ if (!(suffix = sub_lv_name_suffix(lv->name)))
+ return 1;
+
+ /* Make sure that lv->name is exactly a lv_main_old + suffix */
+ l = suffix - lv->name;
+ if (strlen(lv_main_old) != l || strncmp(lv->name, lv_main_old, l))
+ return 1;
+
+ /*
+ * Compose a new name for sub lv:
+ * e.g. new name is "lvol1_mlog"
+ * if the sub LV is "lvol0_mlog" and
+ * a new name for main LV is "lvol1"
+ */
+ l = strlen(lv_main_new) + strlen(suffix) + 1;
+ new_name = dm_pool_alloc(cmd->mem, l);
+ if (!new_name) {
+ log_error("Failed to allocate space for new name");
+ return_0;
+ }
+ if (!dm_snprintf(new_name, l, "%s%s", lv_main_new, suffix)) {
+ log_error("Failed to create new name");
+ return_0;
+ }
+
+ /* Rename it */
+ return _rename_single_lv(lv, new_name);
+}
+
+/* Callback for _for_each_sub_lv */
+static int _rename_cb(struct cmd_context *cmd, struct logical_volume *lv,
+ void *data)
+{
+ char **names = (char **) data;
+
+ return _rename_sub_lv(cmd, lv, names[0], names[1]);
+}
+
+/*
+ * Loop down sub LVs and call "func" for each.
+ * "func" is responsible to log necessary information on failure.
+ */
+static int _for_each_sub_lv(struct cmd_context *cmd, struct logical_volume *lv,
+ int (*func)(struct cmd_context *cmd,
+ struct logical_volume *lv,
+ void *data),
+ void *data)
+{
+ struct lv_segment *seg;
+ int s;
+
+ list_iterate_items(seg, &lv->segments) {
+ if (seg->log_lv && !func(cmd, seg->log_lv, data))
+ return_0;
+ for (s = 0; s < seg->area_count; s++)
+ if (seg_type(seg, s) == AREA_LV &&
+ !func(cmd, seg_lv(seg, s), data))
+ return_0;
+ }
+
+ return 1;
+}
+
+
+/*
* Core of LV renaming routine.
* VG must be locked by caller.
* Returns 0 on failure, 1 on success.
@@ -1469,6 +1589,13 @@
const char *new_name)
{
struct volume_group *vg = lv->vg;
+ const char *names[2];
+
+ /* rename is not allowed on sub LVs */
+ if ((lv->status & MIRROR_LOG) || (lv->status & MIRROR_IMAGE)) {
+ log_error("Cannot rename hidden LV \"%s\".", lv->name);
+ return 0;
+ }
if (find_lv_in_vg(vg, new_name)) {
log_error("Logical volume \"%s\" already exists in "
@@ -1481,17 +1608,16 @@
return 0;
}
- if ((lv->status & MIRRORED) ||
- (lv->status & MIRROR_LOG) ||
- (lv->status & MIRROR_IMAGE)) {
- log_error("Mirrored LV, \"%s\" cannot be renamed: %s",
- lv->name, strerror(ENOSYS));
- return 0;
- }
-
if (!archive(vg))
return_0;
+ /* rename sub LVs */
+ names[0] = lv->name;
+ names[1] = new_name;
+ if (!_for_each_sub_lv(cmd, lv, _rename_cb, (void *) names))
+ return 0;
+
+ /* rename main LV */
if (!(lv->name = dm_pool_strdup(cmd->mem, new_name))) {
log_error("Failed to allocate space for new name");
return 0;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2006-10-07 16:00 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2006-10-07 16:00 UTC (permalink / raw)
To: lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2006-10-07 16:00:29
Modified files:
lib/metadata : lv_manip.c
Log message:
more refactoring
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.107&r2=1.108
--- LVM2/lib/metadata/lv_manip.c 2006/10/07 12:41:06 1.107
+++ LVM2/lib/metadata/lv_manip.c 2006/10/07 16:00:28 1.108
@@ -681,7 +681,7 @@
struct lv_segment *seg;
uint32_t s;
uint32_t remaining_seg_len, area_len, area_multiple;
- int r;
+ int r = 1;
if (!(seg = find_seg_by_le(lv, le))) {
log_error("Failed to find segment for %s extent %" PRIu32,
@@ -712,7 +712,6 @@
} else if (seg_type(seg, s) == AREA_PV)
if (!(r = fn(cmd, seg_pvseg(seg, s), data)))
stack;
-
if (r != 1)
return r;
}
@@ -758,36 +757,50 @@
return 1;
}
+static int _check_pv_contiguous(struct logical_volume *prev_lv, uint32_t prev_le, struct pv_area *pva,
+ struct pv_area **areas, uint32_t areas_size)
+{
+ struct lv_segment *seg;
+ uint32_t s;
+ int r;
+
+ if (!(seg = find_seg_by_le(prev_lv, prev_le))) {
+ log_error("Failed to find segment for %s extent %" PRIu32,
+ prev_lv->name, prev_le);
+ return 0;
+ }
+
+ for (s = 0; s < seg->area_count && s < areas_size; s++) {
+ if (seg_type(seg, s) == AREA_LV) {
+ /* FIXME For more areas supply flattened seg to ensure consistency */
+ if (seg->area_count == 1) {
+ if (!(r = _check_pv_contiguous(seg->lv, seg->le + seg->len - 1, pva, &areas[s], 1)))
+ stack;
+ if (r != 1)
+ return r;
+ }
+ } else if (seg_type(seg, s) == AREA_PV)
+ if (_is_contiguous(seg_pvseg(seg, s), pva)) {
+ areas[s] = pva;
+ return 2; /* Finished */
+ }
+ }
+
+ return 1; /* Continue search */
+}
+
/*
* Is pva contiguous to any existing areas or on the same PV?
*/
static int _check_contiguous(struct lv_segment *prev_lvseg, struct pv_area *pva,
struct pv_area **areas, uint32_t areas_size)
{
- struct pv_segment *prev_pvseg;
- struct lv_segment *lastseg;
- uint32_t s;
-
- for (s = 0; s < prev_lvseg->area_count && s < areas_size; s++) {
- if (seg_type(prev_lvseg, s) == AREA_LV) {
- lastseg = list_item(list_last(&seg_lv(prev_lvseg, s)->segments), struct lv_segment);
- /* FIXME For more areas supply flattened prev_lvseg to ensure consistency */
- if (lastseg->area_count == 1 &&
- _check_contiguous(lastseg, pva, &areas[s], 1))
- return 1;
- continue;
- }
-
- if (!(prev_pvseg = seg_pvseg(prev_lvseg, s)))
- continue; /* FIXME Broken */
+ int r;
- if (_is_contiguous(prev_pvseg, pva)) {
- areas[s] = pva;
- return 1;
- }
- }
+ if (!(r = _check_pv_contiguous(prev_lvseg->lv, prev_lvseg->le + prev_lvseg->len - 1, pva, areas, areas_size)))
+ stack;
- return 0;
+ return r ? 1 : 0;
}
/*
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2006-10-07 11:34 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2006-10-07 11:34 UTC (permalink / raw)
To: lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2006-10-07 11:34:54
Modified files:
lib/metadata : lv_manip.c
Log message:
abstract _is_contiguous()
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.105&r2=1.106
--- LVM2/lib/metadata/lv_manip.c 2006/10/07 11:23:22 1.105
+++ LVM2/lib/metadata/lv_manip.c 2006/10/07 11:34:53 1.106
@@ -733,6 +733,20 @@
}
/*
+ * Is PV area contiguous to PV segment?
+ */
+static int _is_contiguous(struct pv_segment *pvseg, struct pv_area *pva)
+{
+ if (pvseg->pv != pva->map->pv)
+ return 0;
+
+ if (pvseg->pe + pvseg->len != pva->start)
+ return 0;
+
+ return 1;
+}
+
+/*
* Is pva contiguous to any existing areas or on the same PV?
*/
static int _check_contiguous(struct lv_segment *prev_lvseg, struct pv_area *pva,
@@ -755,10 +769,7 @@
if (!(prev_pvseg = seg_pvseg(prev_lvseg, s)))
continue; /* FIXME Broken */
- if ((prev_pvseg->pv != pva->map->pv))
- continue;
-
- if (prev_pvseg->pe + prev_pvseg->len == pva->start) {
+ if (_is_contiguous(prev_pvseg, pva)) {
areas[s] = pva;
return 1;
}
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2006-10-07 11:23 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2006-10-07 11:23 UTC (permalink / raw)
To: lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2006-10-07 11:23:23
Modified files:
lib/metadata : lv_manip.c
Log message:
move _for_each_pv()
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.104&r2=1.105
--- LVM2/lib/metadata/lv_manip.c 2006/10/07 11:00:09 1.104
+++ LVM2/lib/metadata/lv_manip.c 2006/10/07 11:23:22 1.105
@@ -666,6 +666,58 @@
return 1;
}
+/*
+ * Call fn for each AREA_PV used by the LV segment at lv:le of length *max_seg_len.
+ * If any constituent area contains more than one segment, max_seg_len is
+ * reduced to cover only the first.
+ */
+static int _for_each_pv(struct cmd_context *cmd, struct logical_volume *lv,
+ uint32_t le, uint32_t len, uint32_t *max_seg_len,
+ int (*fn)(struct cmd_context *cmd, struct pv_segment *peg, void *data),
+ void *data)
+{
+ struct lv_segment *seg;
+ uint32_t s;
+ uint32_t remaining_seg_len, area_len, area_multiple;
+
+ if (!(seg = find_seg_by_le(lv, le))) {
+ log_error("Failed to find segment for %s extent %" PRIu32,
+ lv->name, le);
+ return 0;
+ }
+
+ /* Remaining logical length of segment */
+ remaining_seg_len = seg->len - (le - seg->le);
+
+ if (remaining_seg_len > len)
+ remaining_seg_len = len;
+
+ if (max_seg_len && *max_seg_len > remaining_seg_len)
+ *max_seg_len = remaining_seg_len;
+
+ area_multiple = segtype_is_striped(seg->segtype) ? seg->area_count : 1;
+ area_len = remaining_seg_len / area_multiple ? : 1;
+
+ for (s = 0; s < seg->area_count; s++)
+ if (seg_type(seg, s) == AREA_LV) {
+ if (!_for_each_pv(cmd, seg_lv(seg, s),
+ seg_le(seg, s) + (le - seg->le) / area_multiple,
+ area_len, max_seg_len, fn, data))
+ return_0;
+ } else if ((seg_type(seg, s) == AREA_PV) &&
+ !fn(cmd, seg_pvseg(seg, s), data))
+ return_0;
+
+ if (seg_is_mirrored(seg) && seg->log_lv &&
+ !_for_each_pv(cmd, seg->log_lv, 0, MIRROR_LOG_SIZE,
+ NULL, fn, data))
+ return_0;
+
+ /* FIXME Add snapshot cow LVs etc. */
+
+ return 1;
+}
+
static int _comp_area(const void *l, const void *r)
{
const struct pv_area *lhs = *((const struct pv_area **) l);
@@ -1380,58 +1432,6 @@
return lv;
}
-/*
- * Call fn for each AREA_PV used by the LV segment at lv:le of length *max_seg_len.
- * If any constituent area contains more than one segment, max_seg_len is
- * reduced to cover only the first.
- */
-static int _for_each_pv(struct cmd_context *cmd, struct logical_volume *lv,
- uint32_t le, uint32_t len, uint32_t *max_seg_len,
- int (*fn)(struct cmd_context *cmd, struct pv_segment *peg, void *data),
- void *data)
-{
- struct lv_segment *seg;
- uint32_t s;
- uint32_t remaining_seg_len, area_len, area_multiple;
-
- if (!(seg = find_seg_by_le(lv, le))) {
- log_error("Failed to find segment for %s extent %" PRIu32,
- lv->name, le);
- return 0;
- }
-
- /* Remaining logical length of segment */
- remaining_seg_len = seg->len - (le - seg->le);
-
- if (remaining_seg_len > len)
- remaining_seg_len = len;
-
- if (max_seg_len && *max_seg_len > remaining_seg_len)
- *max_seg_len = remaining_seg_len;
-
- area_multiple = segtype_is_striped(seg->segtype) ? seg->area_count : 1;
- area_len = remaining_seg_len / area_multiple ? : 1;
-
- for (s = 0; s < seg->area_count; s++)
- if (seg_type(seg, s) == AREA_LV) {
- if (!_for_each_pv(cmd, seg_lv(seg, s),
- seg_le(seg, s) + (le - seg->le) / area_multiple,
- area_len, max_seg_len, fn, data))
- return_0;
- } else if ((seg_type(seg, s) == AREA_PV) &&
- !fn(cmd, seg_pvseg(seg, s), data))
- return_0;
-
- if (seg_is_mirrored(seg) && seg->log_lv &&
- !_for_each_pv(cmd, seg->log_lv, 0, MIRROR_LOG_SIZE,
- NULL, fn, data))
- return_0;
-
- /* FIXME Add snapshot cow LVs etc. */
-
- return 1;
-}
-
static int _add_pvs(struct cmd_context *cmd, struct pv_segment *peg, void *data)
{
struct seg_pvs *spvs = (struct seg_pvs *) data;
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2006-04-27 17:58 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2006-04-27 17:58 UTC (permalink / raw)
To: lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2006-04-27 17:58:48
Modified files:
lib/metadata : lv_manip.c
Log message:
remove redundant list_init
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2005-11-24 21:23 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2005-11-24 21:23 UTC (permalink / raw)
To: lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2005-11-24 21:23:56
Modified files:
lib/metadata : lv_manip.c
Log message:
alloc avoids parallel pvs when supplied
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.92&r2=1.93
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2005-11-24 18:00 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2005-11-24 18:00 UTC (permalink / raw)
To: lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2005-11-24 18:00:47
Modified files:
lib/metadata : lv_manip.c
Log message:
_find_parallel_space -> _find_segment_space
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.89&r2=1.90
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2005-10-27 22:20 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2005-10-27 22:20 UTC (permalink / raw)
To: lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2005-10-27 22:20:33
Modified files:
lib/metadata : lv_manip.c
Log message:
Fix contiguous allocation without preceding segments.
Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.86&r2=1.87
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2005-06-03 15:44 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2005-06-03 15:44 UTC (permalink / raw)
To: lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2005-06-03 15:44:12
Modified files:
lib/metadata : lv_manip.c
Log message:
lvremove mirror images
Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.75&r2=1.76
^ permalink raw reply [flat|nested] 79+ messages in thread
* LVM2/lib/metadata lv_manip.c
@ 2004-03-19 16:19 agk
0 siblings, 0 replies; 79+ messages in thread
From: agk @ 2004-03-19 16:19 UTC (permalink / raw)
To: lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2004-03-19 16:19:42
Modified files:
lib/metadata : lv_manip.c
Log message:
Fix lvreduce pv extents calculations.
Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.51&r2=1.52
^ permalink raw reply [flat|nested] 79+ messages in thread
end of thread, other threads:[~2012-05-11 15:32 UTC | newest]
Thread overview: 79+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-16 18:39 LVM2/lib/metadata lv_manip.c jbrassow
-- strict thread matches above, loose matches on Subject: below --
2012-05-11 15:32 agk
2012-05-11 15:26 agk
2012-03-04 15:57 zkabelac
2012-03-01 10:09 zkabelac
2012-02-28 10:08 zkabelac
2012-02-12 21:37 agk
2012-02-01 2:11 agk
2012-01-26 21:39 zkabelac
2012-01-25 11:27 zkabelac
2012-01-25 9:15 zkabelac
2012-01-25 9:14 zkabelac
2012-01-25 9:02 zkabelac
2012-01-25 8:57 zkabelac
2012-01-24 14:54 agk
2012-01-24 14:15 mbroz
2012-01-19 15:39 zkabelac
2011-11-15 17:29 zkabelac
2011-11-15 17:23 zkabelac
2011-11-12 22:53 zkabelac
2011-11-12 22:52 zkabelac
2011-11-12 22:51 zkabelac
2011-11-10 12:42 zkabelac
2011-11-10 12:42 zkabelac
2011-11-10 12:39 zkabelac
2011-11-07 13:54 agk
2011-11-04 22:45 zkabelac
2011-11-03 15:46 zkabelac
2011-11-03 14:56 zkabelac
2011-10-30 22:02 zkabelac
2011-10-28 20:29 zkabelac
2011-10-28 20:18 zkabelac
2011-10-22 16:49 zkabelac
2011-10-22 16:46 zkabelac
2011-10-21 9:55 zkabelac
2011-10-20 10:35 zkabelac
2011-10-03 18:43 zkabelac
2011-09-16 12:12 zkabelac
2011-09-16 11:59 zkabelac
2011-09-06 15:39 agk
2011-08-19 22:55 agk
2011-08-19 16:41 agk
2011-08-10 16:44 jbrassow
2011-08-05 9:21 prajnoha
2011-06-06 12:08 agk
2011-03-25 22:02 jbrassow
2010-04-08 0:56 agk
2010-04-08 0:52 agk
2010-04-02 1:35 agk
2010-04-01 13:58 agk
2010-04-01 12:29 agk
2010-03-31 20:26 agk
2010-02-17 23:36 snitzer
2010-01-20 21:53 snitzer
2010-01-14 10:17 zkabelac
2010-01-14 10:09 zkabelac
2010-01-14 10:08 zkabelac
2010-01-13 1:52 snitzer
2010-01-13 1:51 snitzer
2010-01-10 20:44 snitzer
2010-01-08 23:06 jbrassow
2009-06-06 16:37 mbroz
2009-06-01 14:23 mbroz
2009-01-06 17:24 mbroz
2008-01-16 20:00 agk
2007-11-04 16:28 agk
2007-08-08 18:00 wysochanski
2007-08-07 18:55 wysochanski
2007-08-07 16:57 wysochanski
2007-08-06 20:35 wysochanski
2006-10-07 16:00 agk
2006-10-07 11:34 agk
2006-10-07 11:23 agk
2006-04-27 17:58 agk
2005-11-24 21:23 agk
2005-11-24 18:00 agk
2005-10-27 22:20 agk
2005-06-03 15:44 agk
2004-03-19 16:19 agk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).