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 lib/m ... Date: Sun, 08 Oct 2006 12:01:00 -0000 [thread overview] Message-ID: <20061008120113.16755.qmail@sourceware.org> (raw) CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2006-10-08 12:01:13 Modified files: . : WHATS_NEW lib/metadata : lv_manip.c metadata.h man : lvm.8 lib/display : display.c lib/report : report.c Log message: add cling allocation policy Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.462&r2=1.463 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.109&r2=1.110 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.149&r2=1.150 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvm.8.diff?cvsroot=lvm2&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.49&r2=1.50 --- LVM2/WHATS_NEW 2006/10/07 23:42:03 1.462 +++ LVM2/WHATS_NEW 2006/10/08 12:01:12 1.463 @@ -1,5 +1,6 @@ Version 2.02.11 - ===================================== + Add cling allocation policy. Change _check_contiguous() to use _for_each_pv(). Extend _for_each_pv() to allow termination without error. Abstract _is_contiguous(). --- LVM2/lib/metadata/lv_manip.c 2006/10/07 23:40:36 1.109 +++ LVM2/lib/metadata/lv_manip.c 2006/10/08 12:01:12 1.110 @@ -773,6 +773,17 @@ }; /* + * Is PV area on the same PV? + */ +static int _is_same_pv(struct pv_segment *pvseg, struct pv_area *pva) +{ + if (pvseg->pv != pva->map->pv) + return 0; + + return 1; +} + +/* * Is PV area contiguous to PV segment? */ static int _is_contiguous(struct pv_segment *pvseg, struct pv_area *pva) @@ -786,9 +797,9 @@ return 1; } -static int _is_contiguous_condition(struct cmd_context *cmd, - struct pv_segment *pvseg, uint32_t s, - void *data) +static int _is_condition(struct cmd_context *cmd, + struct pv_segment *pvseg, uint32_t s, + void *data) { struct pv_match *pvmatch = data; @@ -804,6 +815,34 @@ } /* + * Is pva on same PV as any existing areas? + */ +static int _check_cling(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; + + pvmatch.condition = _is_same_pv; + 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_condition, &pvmatch))) + stack; + + if (r != 2) + return 0; + + return 1; +} + +/* * Is pva contiguous to any existing areas or on the same PV? */ static int _check_contiguous(struct cmd_context *cmd, @@ -822,7 +861,7 @@ 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))) + _is_condition, &pvmatch))) stack; if (r != 2) @@ -844,9 +883,9 @@ struct pv_area *pva; struct pv_list *pvl; unsigned already_found_one = 0; - unsigned contiguous = 0, contiguous_count = 0; + unsigned contiguous = 0, cling = 0, preferred_count = 0; unsigned ix; - unsigned ix_offset = 0; /* Offset for non-contiguous allocations */ + unsigned ix_offset = 0; /* Offset for non-preferred allocations */ uint32_t max_parallel; /* Maximum extents to allocate */ uint32_t next_le; struct seg_pvs *spvs; @@ -856,9 +895,14 @@ /* FIXME Select log PV appropriately if there isn't one yet */ /* Are there any preceding segments we must follow on from? */ - if ((alloc == ALLOC_CONTIGUOUS) && prev_lvseg) { - contiguous = 1; + if (prev_lvseg) { ix_offset = prev_lvseg->area_count; + if ((alloc == ALLOC_CONTIGUOUS)) + contiguous = 1; + else if ((alloc == ALLOC_CLING)) + cling = 1; + else + ix_offset = 0; } /* FIXME This algorithm needs a lot of cleaning up! */ @@ -867,6 +911,7 @@ /* ix holds the number of areas found on other PVs */ do { ix = 0; + preferred_count = 0; parallel_pvs = NULL; max_parallel = needed; @@ -920,12 +965,23 @@ prev_lvseg, pva, areas, areas_size)) { - contiguous_count++; + preferred_count++; goto next_pv; } continue; } + if (cling) { + if (prev_lvseg && + _check_cling(ah->cmd, + prev_lvseg, + pva, areas, + areas_size)) { + preferred_count++; + } + goto next_pv; + } + /* Is it big enough on its own? */ if (pva->count * ah->area_multiple < max_parallel - *allocated && @@ -949,7 +1005,7 @@ break; } - if (contiguous && (contiguous_count < ix_offset)) + if ((contiguous || cling) && (preferred_count < ix_offset)) break; /* Only allocate log_area the first time around */ @@ -1059,6 +1115,18 @@ goto finished; old_allocated = allocated; + if (!_find_parallel_space(ah, ALLOC_CLING, pvms, areas, + areas_size, can_split, + prev_lvseg, &allocated, new_extents)) { + stack; + goto out; + } + + if ((allocated == new_extents) || (ah->alloc == ALLOC_CLING) || + (!can_split && (allocated != old_allocated))) + goto finished; + + old_allocated = allocated; if (!_find_parallel_space(ah, ALLOC_NORMAL, pvms, areas, areas_size, can_split, prev_lvseg, &allocated, new_extents)) { --- LVM2/lib/metadata/metadata.h 2006/09/11 21:14:56 1.149 +++ LVM2/lib/metadata/metadata.h 2006/10/08 12:01:12 1.150 @@ -82,6 +82,7 @@ ALLOC_INVALID = 0, ALLOC_INHERIT, ALLOC_CONTIGUOUS, + ALLOC_CLING, ALLOC_NORMAL, ALLOC_ANYWHERE } alloc_policy_t; --- LVM2/man/lvm.8 2006/08/18 22:35:59 1.8 +++ LVM2/man/lvm.8 2006/10/08 12:01:12 1.9 @@ -136,7 +136,7 @@ Delete the tag \fBtag\fP from a PV, VG or LV, if it's present. .TP \fB--alloc AllocationPolicy\fP -The allocation policy to use: \fBcontiguous\fP, \fBnormal\fP, \fBanywhere\fP or \fBinherit\fP. +The allocation policy to use: \fBcontiguous\fP, \fBcling\fP, \fBnormal\fP, \fBanywhere\fP or \fBinherit\fP. When a command needs to allocate physical extents from the volume group, the allocation policy controls how they are chosen. Each volume group and logical volume has an allocation policy. @@ -146,15 +146,18 @@ which applies the same policy as for the volume group. These policies can be changed using \fBlvchange\fP (8) and \fBvgchange\fP (8) or over-ridden on the command line of any command that performs allocation. -The \fBcontiguous\fP policy requires that new extents are adjacent to -existing extents. If there are sufficient free extents to satisfy +The \fBcontiguous\fP policy requires that new extents be placed adjacent +to existing extents. +The \fBcling\fP policy places new extents on the same physical +volume as existing extents in the same stripe of the Logical Volume. +If there are sufficient free extents to satisfy an allocation request but \fBnormal\fP doesn't use them, \fBanywhere\fP will - even if that reduces performance by placing two stripes on the same physical volume. .IP N.B. The policies described above are not implemented fully yet. -In particular, \fBcontiguous\fP does not place new extents adjacent to existing -extents and \fBanywhere\fP is not implemented at all. +In particular, contiguous free space cannot be broken up to +satisfy allocation attempts. .SH ENVIRONMENT VARIABLES .TP \fBLVM_SYSTEM_DIR\fP --- LVM2/lib/display/display.c 2006/05/09 21:23:50 1.67 +++ LVM2/lib/display/display.c 2006/10/08 12:01:12 1.68 @@ -30,6 +30,7 @@ } _policies[] = { { ALLOC_CONTIGUOUS, "contiguous"}, { + ALLOC_CLING, "cling"}, { ALLOC_NORMAL, "normal"}, { ALLOC_ANYWHERE, "anywhere"}, { ALLOC_INHERIT, "inherit"} --- LVM2/lib/report/report.c 2006/10/03 17:55:20 1.49 +++ LVM2/lib/report/report.c 2006/10/08 12:01:13 1.50 @@ -104,6 +104,8 @@ switch (alloc) { case ALLOC_CONTIGUOUS: return 'c'; + case ALLOC_CLING: + return 'C'; case ALLOC_NORMAL: return 'n'; case ALLOC_ANYWHERE:
next reply other threads:[~2006-10-08 12:01 UTC|newest] Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top 2006-10-08 12:01 agk [this message] -- strict thread matches above, loose matches on Subject: below -- 2012-02-23 17:36 jbrassow 2012-02-23 3:57 jbrassow 2012-02-15 15:18 zkabelac 2012-02-08 13:05 zkabelac 2012-02-01 2:10 agk 2011-10-22 16:42 zkabelac 2011-09-06 18:49 agk 2011-08-18 19:41 jbrassow 2011-08-11 3:29 jbrassow 2011-06-23 14:01 jbrassow 2011-04-09 19:05 zkabelac 2011-01-24 14:19 agk 2011-01-11 17:05 jbrassow 2010-10-14 20:03 jbrassow 2010-04-23 19:27 snitzer 2010-04-09 1:00 agk 2010-03-25 21:19 agk 2010-03-25 2:31 agk 2010-01-08 22:32 jbrassow 2009-05-13 21:29 mbroz 2009-05-13 21:28 mbroz 2009-04-21 14:32 mbroz 2009-04-07 10:20 mbroz 2008-03-28 19:08 wysochanski 2008-01-26 0:25 agk 2008-01-18 22:01 agk 2007-12-20 18:55 agk 2007-08-28 16:14 wysochanski 2007-08-03 21:22 wysochanski 2006-12-13 3:40 agk 2006-10-23 15:54 agk 2006-09-11 21:14 agk 2005-11-10 14:45 agk 2005-10-18 13:43 agk 2004-05-05 18:49 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=20061008120113.16755.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).