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 lib/m ...
- From: agk at sourceware dot org
- To: lvm2-cvs at sourceware dot org
- Date: 8 Oct 2006 12:01:13 -0000
- Subject: LVM2 ./WHATS_NEW lib/metadata/lv_manip.c lib/m ...
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: