From: "Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>
To: linux-lvm@redhat.com, Alasdair Kergon <agk@redhat.com>,
Jonathan Brassow <jbrassow@redhat.com>
Subject: [linux-lvm] [PATCH LVM2] Fix max_parallel calculation
Date: Tue, 29 Aug 2006 13:12:25 -0400 [thread overview]
Message-ID: <44F47579.1040307@ce.jp.nec.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 828 bytes --]
Hi,
In _find_parallel_space(), there is 2 mistakes in calculation of
max_parallel (and *allocated).
1. max_parallel and *allocated are number of extents multiplied by
ah->area_multiple.
So it needs to be divided by ah->area_multiple when it's used for
stripe length calculation
2. max_parallel specifies the total number of extents, not the newly
allocated one.
So it doesn't need to be offset by starting le.
As a result, allocation fails unexpectedly.
Typical failure cases:
1) lvcreate --alloc contiguous fails for striped LV
if requested LV size is larger than a PV size
2) lvconvert -m to add mirror to existing LV fails
if the existing LV has more than one segments
Attached patch fixes them.
Applicable to 2.02.09.
Thanks,
--
Jun'ichi Nomura, NEC Corporation of America
[-- Attachment #2: 02-fix-max_parallel-calculation.patch --]
[-- Type: text/x-patch, Size: 2479 bytes --]
In _find_parallel_space(), there is 2 mistakes in calculation of
max_parallel (and *allocated).
1. max_parallel and *allocated are number of extents multiplied by
ah->area_multiple.
So it needs to be divided by ah->area_multiple when it's used for
stripe length calculation
2. max_parallel specifies the total number of extents, not the newly
allocated one.
So it doesn't need to be offset by starting le.
Attached patch fixes them.
Otherwise, allocation fails unexpectedly.
Typical failure cases:
1) lvcreate --alloc contiguous fails for striped LV
if requested LV size is larger than a PV size
2) lvconvert -m to add mirror to existing LV fails
if the existing LV has more than one segments
diff -urp LVM2.01/lib/metadata/lv_manip.c LVM2.02/lib/metadata/lv_manip.c
--- LVM2.01/lib/metadata/lv_manip.c 2006-08-26 00:06:29.000000000 -0400
+++ LVM2.02/lib/metadata/lv_manip.c 2006-08-29 03:14:57.000000000 -0400
@@ -715,6 +715,12 @@ static int _find_parallel_space(struct a
do {
ix = 0;
+ /*
+ * max_parallel and *allocated are number of extents
+ * multiplied by ah->area_multiple.
+ * So they should be divided by ah->area_multiple before
+ * using for calcualtion of a stripe length.
+ */
parallel_pvs = NULL;
max_parallel = needed;
@@ -723,11 +729,12 @@ static int _find_parallel_space(struct a
* the maximum we can allocate in one go accordingly.
*/
if (ah->parallel_areas) {
+ next_le = (prev_lvseg ? prev_lvseg->le + prev_lvseg->len : 0) + (*allocated / ah->area_multiple);
list_iterate_items(spvs, ah->parallel_areas) {
- next_le = (prev_lvseg ? prev_lvseg->le + prev_lvseg->len : 0) + *allocated;
- if (next_le >= spvs->le) {
- if (next_le + max_parallel > spvs->le + spvs->len)
- max_parallel = (spvs->le + spvs->len - next_le) * ah->area_multiple;
+ if (next_le >= spvs->le &&
+ next_le < spvs->le + spvs->len) {
+ if (max_parallel / ah->area_multiple > spvs->le + spvs->len)
+ max_parallel = (spvs->le + spvs->len) * ah->area_multiple;
parallel_pvs = &spvs->pvs;
break;
}
@@ -773,7 +780,7 @@ static int _find_parallel_space(struct a
}
/* Is it big enough on its own? */
- if ((pva->count < max_parallel - *allocated) &&
+ if ((pva->count < (max_parallel - *allocated) / ah->area_multiple) &&
((!can_split && !ah->log_count) ||
(already_found_one &&
!(alloc == ALLOC_ANYWHERE))))
reply other threads:[~2006-08-29 17:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=44F47579.1040307@ce.jp.nec.com \
--to=j-nomura@ce.jp.nec.com \
--cc=agk@redhat.com \
--cc=jbrassow@redhat.com \
--cc=linux-lvm@redhat.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.