This is the mail archive of the
lvm2-cvs@sourceware.org
mailing list for the LVM2 project.
LVM2 ./WHATS_NEW lib/metadata/lv_manip.c
- From: agk at sourceware dot org
- To: lvm2-cvs at sourceware dot org
- Date: 7 Oct 2006 12:41:07 -0000
- Subject: LVM2 ./WHATS_NEW lib/metadata/lv_manip.c
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2006-10-07 12:41:06
Modified files:
. : WHATS_NEW
lib/metadata : lv_manip.c
Log message:
Extend _for_each_pv() to allow termination without error.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.459&r2=1.460
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.106&r2=1.107
--- LVM2/WHATS_NEW 2006/10/07 11:00:09 1.459
+++ LVM2/WHATS_NEW 2006/10/07 12:41:06 1.460
@@ -1,5 +1,7 @@
Version 2.02.11 -
=====================================
+ Extend _for_each_pv() to allow termination without error.
+ Abstract _is_contiguous().
Remove duplicated pv arg from _check_contiguous().
Accept regionsize with lvconvert.
Add report columns with underscore before field names ending 'size'.
--- LVM2/lib/metadata/lv_manip.c 2006/10/07 11:34:53 1.106
+++ LVM2/lib/metadata/lv_manip.c 2006/10/07 12:41:06 1.107
@@ -670,6 +670,8 @@
* 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.
+ * fn should return 0 on error, 1 to continue scanning or >1 to terminate without error.
+ * In the last case, this function passes on the return code.
*/
static int _for_each_pv(struct cmd_context *cmd, struct logical_volume *lv,
uint32_t le, uint32_t len, uint32_t *max_seg_len,
@@ -679,6 +681,7 @@
struct lv_segment *seg;
uint32_t s;
uint32_t remaining_seg_len, area_len, area_multiple;
+ int r;
if (!(seg = find_seg_by_le(lv, le))) {
log_error("Failed to find segment for %s extent %" PRIu32,
@@ -698,20 +701,29 @@
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++)
+ 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;
+ if (!(r = _for_each_pv(cmd, seg_lv(seg, s),
+ seg_le(seg, s) +
+ (le - seg->le) / area_multiple,
+ area_len, max_seg_len, fn,
+ data)))
+ stack;
+ } else if (seg_type(seg, s) == AREA_PV)
+ if (!(r = fn(cmd, seg_pvseg(seg, s), data)))
+ stack;
+
+ if (r != 1)
+ return r;
+ }
+
+ if (seg_is_mirrored(seg) && seg->log_lv) {
+ if (!(r = _for_each_pv(cmd, seg->log_lv, 0, MIRROR_LOG_SIZE,
+ NULL, fn, data)))
+ stack;
+ if (r != 1)
+ return r;
+ }
/* FIXME Add snapshot cow LVs etc. */