public inbox for lvm2-cvs@sourceware.org help / color / mirror / Atom feed
From: agk@sourceware.org To: lvm2-cvs@sourceware.org Subject: LVM2 ./WHATS_NEW lib/metadata/lv_manip.c Date: Sat, 07 Oct 2006 23:40:00 -0000 [thread overview] Message-ID: <20061007234036.20621.qmail@sourceware.org> (raw) CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2006-10-07 23:40:36 Modified files: . : WHATS_NEW lib/metadata : lv_manip.c Log message: check_contiguous to use for_each_pv Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.460&r2=1.461 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.108&r2=1.109 --- LVM2/WHATS_NEW 2006/10/07 12:41:06 1.460 +++ LVM2/WHATS_NEW 2006/10/07 23:40:36 1.461 @@ -7,6 +7,7 @@ Add report columns with underscore before field names ending 'size'. Correct regionsize default on lvcreate man page (MB). Fix clvmd bug that could cause it to die when a node with a long name crashed. + Add device size to text metadata. Fix format_text mda_setup pv->size and pv_setup pe_count calculations. Fix _for_each_pv() for mirror with core log. Add lvm_dump.sh script to create a tarball of debugging info from a system. --- LVM2/lib/metadata/lv_manip.c 2006/10/07 16:00:28 1.108 +++ LVM2/lib/metadata/lv_manip.c 2006/10/07 23:40:36 1.109 @@ -398,6 +398,7 @@ * Details of an allocation attempt */ struct alloc_handle { + struct cmd_context *cmd; struct dm_pool *mem; alloc_policy_t alloc; /* Overall policy */ @@ -417,7 +418,8 @@ /* * Preparation for a specific allocation attempt */ -static struct alloc_handle *_alloc_init(struct dm_pool *mem, +static struct alloc_handle *_alloc_init(struct cmd_context *cmd, + struct dm_pool *mem, const struct segment_type *segtype, alloc_policy_t alloc, uint32_t mirrors, @@ -464,6 +466,8 @@ 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; @@ -675,7 +679,12 @@ */ 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), + uint32_t first_area, uint32_t max_areas, + int top_level_area_index, + int only_single_area_segments, + int (*fn)(struct cmd_context *cmd, + struct pv_segment *peg, uint32_t s, + void *data), void *data) { struct lv_segment *seg; @@ -701,24 +710,32 @@ 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 = first_area; + s < seg->area_count && (!max_areas || s <= max_areas); + s++) { if (seg_type(seg, s) == AREA_LV) { 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, + area_len, max_seg_len, + only_single_area_segments ? 0 : 0, + only_single_area_segments ? 1 : 0, + top_level_area_index != -1 ? top_level_area_index : s, + only_single_area_segments, fn, data))) stack; } else if (seg_type(seg, s) == AREA_PV) - if (!(r = fn(cmd, seg_pvseg(seg, s), data))) + if (!(r = fn(cmd, seg_pvseg(seg, s), top_level_area_index != -1 ? top_level_area_index : s, data))) stack; if (r != 1) return r; } - if (seg_is_mirrored(seg) && seg->log_lv) { + /* 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, MIRROR_LOG_SIZE, - NULL, fn, data))) + NULL, 0, 0, 0, only_single_area_segments, + fn, data))) stack; if (r != 1) return r; @@ -744,6 +761,18 @@ } /* + * Search for pvseg that matches condition + */ +struct pv_match { + int (*condition)(struct pv_segment *pvseg, struct pv_area *pva); + + struct pv_area **areas; + struct pv_area *pva; + uint32_t areas_size; + int s; /* Area index of match */ +}; + +/* * Is PV area contiguous to PV segment? */ static int _is_contiguous(struct pv_segment *pvseg, struct pv_area *pva) @@ -757,50 +786,49 @@ 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) +static int _is_contiguous_condition(struct cmd_context *cmd, + struct pv_segment *pvseg, uint32_t s, + void *data) { - struct lv_segment *seg; - uint32_t s; - int r; + struct pv_match *pvmatch = data; - 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; - } + if (!pvmatch->condition(pvseg, pvmatch->pva)) + return 1; /* Continue */ - 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 */ - } - } + if (s >= pvmatch->areas_size) + return 1; + + pvmatch->areas[s] = pvmatch->pva; - return 1; /* Continue search */ + return 2; /* Finished */ } /* * 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, +static int _check_contiguous(struct cmd_context *cmd, + struct lv_segment *prev_lvseg, struct pv_area *pva, struct pv_area **areas, uint32_t areas_size) { + struct pv_match pvmatch; int r; - if (!(r = _check_pv_contiguous(prev_lvseg->lv, prev_lvseg->le + prev_lvseg->len - 1, pva, areas, areas_size))) + pvmatch.condition = _is_contiguous; + pvmatch.areas = areas; + pvmatch.areas_size = areas_size; + pvmatch.pva = pva; + + /* FIXME Cope with stacks by flattening */ + if (!(r = _for_each_pv(cmd, prev_lvseg->lv, + prev_lvseg->le + prev_lvseg->len - 1, 1, NULL, + 0, 0, -1, 1, + _is_contiguous_condition, &pvmatch))) stack; - return r ? 1 : 0; + if (r != 2) + return 0; + + return 1; } /* @@ -888,7 +916,8 @@ list_iterate_items(pva, &pvm->areas) { if (contiguous) { if (prev_lvseg && - _check_contiguous(prev_lvseg, + _check_contiguous(ah->cmd, + prev_lvseg, pva, areas, areas_size)) { contiguous_count++; @@ -1124,7 +1153,7 @@ if (alloc == ALLOC_INHERIT) alloc = vg->alloc; - if (!(ah = _alloc_init(vg->cmd->mem, segtype, alloc, mirrors, + if (!(ah = _alloc_init(vg->cmd, vg->cmd->mem, segtype, alloc, mirrors, stripes, log_count, mirrored_pv, mirrored_pe, parallel_areas))) { stack; @@ -1468,7 +1497,8 @@ return lv; } -static int _add_pvs(struct cmd_context *cmd, struct pv_segment *peg, void *data) +static int _add_pvs(struct cmd_context *cmd, struct pv_segment *peg, + uint32_t s __attribute((unused)), void *data) { struct seg_pvs *spvs = (struct seg_pvs *) data; struct pv_list *pvl; @@ -1522,7 +1552,8 @@ /* Find next segment end */ /* FIXME Unnecessary nesting! */ - if (!_for_each_pv(cmd, lv, current_le, spvs->len, &spvs->len, _add_pvs, (void *) spvs)) { + if (!_for_each_pv(cmd, lv, current_le, spvs->len, &spvs->len, + 0, 0, -1, 0, _add_pvs, (void *) spvs)) { stack; return NULL; }
next reply other threads:[~2006-10-07 23:40 UTC|newest] Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top 2006-10-07 23:40 agk [this message] -- strict thread matches above, loose matches on Subject: below -- 2012-05-11 22:19 agk 2012-05-11 18:59 agk 2012-05-09 12:12 zkabelac 2012-03-05 14:13 zkabelac 2012-02-29 22:09 zkabelac 2012-02-22 17:14 jbrassow 2012-02-09 15:13 prajnoha 2012-02-08 13:02 zkabelac 2012-01-20 22:04 snitzer 2011-11-15 17:32 zkabelac 2011-11-15 17:28 zkabelac 2011-10-28 20:23 zkabelac 2011-10-28 20:17 zkabelac 2011-09-14 14:20 mbroz 2011-09-13 18:43 jbrassow 2011-06-29 17:05 agk 2011-04-07 21:49 jbrassow 2011-02-27 1:16 agk 2011-01-28 2:58 snitzer 2010-12-20 14:38 zkabelac 2010-12-01 12:56 zkabelac 2010-03-29 17:59 agk 2010-03-25 18:16 agk 2010-03-23 15:07 agk 2010-01-12 20:53 agk 2010-01-05 15:58 mbroz 2009-05-30 0:09 agk 2009-05-28 1:59 agk 2009-05-28 0:29 agk 2008-12-19 15:26 mbroz 2008-10-23 11:21 agk 2008-10-17 10:57 agk 2008-09-29 9:59 mbroz 2008-02-22 13:22 agk 2007-01-05 15:53 mbroz 2006-12-12 19:30 agk 2006-10-30 16:10 agk 2006-10-07 12:41 agk 2006-10-07 11:00 agk 2006-10-05 21:24 agk 2005-11-28 20:01 agk 2005-11-24 18:46 agk 2005-07-12 14:50 agk 2005-06-03 18:07 agk
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20061007234036.20621.qmail@sourceware.org \ --to=agk@sourceware.org \ --cc=lvm2-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).