public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: agk@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2 ./WHATS_NEW lib/metadata/lv_manip.c
Date: Tue, 23 Mar 2010 15:07:00 -0000	[thread overview]
Message-ID: <20100323150756.29815.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-03-23 15:07:56

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : lv_manip.c 

Log message:
	Allow dynamic extension of array of areas selected as allocation candidates.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1474&r2=1.1475
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.210&r2=1.211

--- LVM2/WHATS_NEW	2010/03/23 14:47:35	1.1474
+++ LVM2/WHATS_NEW	2010/03/23 15:07:55	1.1475
@@ -1,5 +1,6 @@
 Version 2.02.63 - 
 ================================
+  Allow dynamic extension of array of areas selected as allocation candidates.
   Export and use only valid cookie value in test suite.
   Remove const modifier for struct volume_group* from process_each_lv_in_vg().
   Don't allow resizing of internal logical volumes.
--- LVM2/lib/metadata/lv_manip.c	2010/03/01 20:00:21	1.210
+++ LVM2/lib/metadata/lv_manip.c	2010/03/23 15:07:55	1.211
@@ -989,8 +989,8 @@
  * Choose sets of parallel areas to use, respecting any constraints.
  */
 static int _find_parallel_space(struct alloc_handle *ah, alloc_policy_t alloc,
-				struct dm_list *pvms, struct pv_area **areas,
-				uint32_t areas_size, unsigned can_split,
+				struct dm_list *pvms, struct pv_area ***areas_ptr,
+				uint32_t *areas_size_ptr, unsigned can_split,
 				struct lv_segment *prev_lvseg,
 				uint32_t *allocated, uint32_t needed)
 {
@@ -1094,8 +1094,8 @@
 					if (prev_lvseg &&
 					    _check_contiguous(ah->cmd,
 							      prev_lvseg,
-							      pva, areas,
-							      areas_size)) {
+							      pva, *areas_ptr,
+							      *areas_size_ptr)) {
 						preferred_count++;
 						goto next_pv;
 					}
@@ -1106,8 +1106,8 @@
 					if (prev_lvseg &&
 					    _check_cling(ah->cmd,
 							   prev_lvseg,
-							   pva, areas,
-							   areas_size)) {
+							   pva, *areas_ptr,
+							   *areas_size_ptr)) {
 						preferred_count++;
 					}
 					goto next_pv;
@@ -1127,10 +1127,15 @@
 					already_found_one = 1;
 				}
 
-				areas[ix + ix_offset - 1] = pva;
+				/* Expand areas array if needed after an area was split. */
+				if (ix + ix_offset > *areas_size_ptr) {
+					*areas_size_ptr *= 2;
+					*areas_ptr = dm_realloc(*areas_ptr, sizeof(**areas_ptr) * (*areas_size_ptr));
+				}
+				(*areas_ptr)[ix + ix_offset - 1] = pva;
 			}
 		next_pv:
-			if (ix >= areas_size)
+			if (ix >= *areas_size_ptr)
 				break;
 		}
 
@@ -1146,7 +1151,7 @@
 
 		/* sort the areas so we allocate from the biggest */
 		if (ix > 1)
-			qsort(areas + ix_offset, ix, sizeof(*areas),
+			qsort((*areas_ptr) + ix_offset, ix, sizeof(**areas_ptr),
 			      _comp_area);
 
 		/*
@@ -1160,7 +1165,7 @@
 		if (log_needs_allocating) {
 			/* How many areas are too small for the log? */
 			while (too_small_for_log_count < ix_offset + ix &&
-			       (*(areas + ix_offset + ix - 1 -
+			       (*((*areas_ptr) + ix_offset + ix - 1 -
 				  too_small_for_log_count))->count < ah->log_len)
 				too_small_for_log_count++;
 			ix_log_offset = ix_offset + ix - too_small_for_log_count - ah->log_area_count;
@@ -1172,7 +1177,7 @@
 			/* FIXME With ALLOC_ANYWHERE, need to split areas */
 			break;
 
-		if (!_alloc_parallel_area(ah, max_parallel, areas, allocated,
+		if (!_alloc_parallel_area(ah, max_parallel, *areas_ptr, allocated,
 					  log_needs_allocating, ix_log_offset))
 			return_0;
 
@@ -1247,8 +1252,8 @@
 	/* Attempt each defined allocation policy in turn */
 	for (alloc = ALLOC_CONTIGUOUS; alloc < ALLOC_INHERIT; alloc++) {
 		old_allocated = allocated;
-		if (!_find_parallel_space(ah, alloc, pvms, areas,
-					  areas_size, can_split,
+		if (!_find_parallel_space(ah, alloc, pvms, &areas,
+					  &areas_size, can_split,
 					  prev_lvseg, &allocated, ah->new_extents))
 			goto_out;
 		if ((allocated == ah->new_extents) || (ah->alloc == alloc) ||


             reply	other threads:[~2010-03-23 15:07 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-23 15:07 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-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 23:40 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=20100323150756.29815.qmail@sourceware.org \
    --to=agk@sourceware.org \
    --cc=lvm-devel@redhat.com \
    --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: link
Be 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).