All of lore.kernel.org
 help / color / mirror / Atom feed
From: agk@sourceware.org <agk@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2/lib/metadata lv_manip.c
Date: 1 Apr 2010 13:58:13 -0000	[thread overview]
Message-ID: <20100401135813.22411.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk at sourceware.org	2010-04-01 13:58:13

Modified files:
	lib/metadata   : lv_manip.c 

Log message:
	Try to fix tracking of whether or not log extents need allocating.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.222&r2=1.223

--- LVM2/lib/metadata/lv_manip.c	2010/04/01 12:29:07	1.222
+++ LVM2/lib/metadata/lv_manip.c	2010/04/01 13:58:13	1.223
@@ -1011,7 +1011,7 @@
 				struct dm_list *pvms, struct pv_area_used **areas_ptr,
 				uint32_t *areas_size_ptr, unsigned can_split,
 				struct lv_segment *prev_lvseg,
-				uint32_t *allocated, uint32_t needed)
+				uint32_t *allocated, uint32_t *log_needs_allocating, uint32_t needed)
 {
 	struct pv_map *pvm;
 	struct pv_area *pva;
@@ -1028,7 +1028,6 @@
 	struct seg_pvs *spvs;
 	struct dm_list *parallel_pvs;
 	uint32_t free_pes;
-	unsigned log_needs_allocating;
 	struct alloced_area *aa;
 	uint32_t s;
 
@@ -1082,9 +1081,6 @@
 			}
 		}
 
-		log_needs_allocating = (ah->log_area_count &&
-					dm_list_empty(&ah->alloced_areas[ah->area_count])) ?  1 : 0;
-
 		do {
 			/*
 			 * Provide for escape from the loop if no progress is made.
@@ -1183,8 +1179,12 @@
 							pva->unreserved -= required;
 							reinsert_reduced_pv_area(pva);
 						}
-					} else if (required > pva->count)
-						required = pva->count;
+					} else {
+						if (required < ah->log_len)
+							required = ah->log_len;
+						if (required > pva->count)
+							required = pva->count;
+					}
 
 					/* Expand areas array if needed after an area was split. */
 					if (ix + ix_offset > *areas_size_ptr) {
@@ -1200,16 +1200,16 @@
 				}
 			next_pv:
 				if (alloc == ALLOC_ANYWHERE &&
-				    ix + ix_offset >= ah->area_count + (log_needs_allocating ? ah->log_area_count : 0))
+				    ix + ix_offset >= ah->area_count + (*log_needs_allocating ? ah->log_area_count : 0))
 					break;
 			}
-		} while (alloc == ALLOC_ANYWHERE && last_ix != ix && ix < ah->area_count + (log_needs_allocating ? ah->log_area_count : 0));
+		} while (alloc == ALLOC_ANYWHERE && last_ix != ix && ix < ah->area_count + (*log_needs_allocating ? ah->log_area_count : 0));
 
 		if ((contiguous || cling) && (preferred_count < ix_offset))
 			break;
 
 		if (ix + ix_offset < ah->area_count +
-		   (log_needs_allocating ? ah->log_area_count : 0))
+		   (*log_needs_allocating ? ah->log_area_count : 0))
 			break;
 
 		/* sort the areas so we allocate from the biggest */
@@ -1225,7 +1225,7 @@
 		ix_log_offset = 0;
 
 		/* FIXME This logic is due to its heritage and can be simplified! */
-		if (log_needs_allocating) {
+		if (*log_needs_allocating) {
 			/* How many areas are too small for the log? */
 			while (too_small_for_log_count < ix_offset + ix &&
 			       (*((*areas_ptr) + ix_offset + ix - 1 -
@@ -1235,14 +1235,16 @@
 		}
 
 		if (ix + ix_offset < ah->area_count +
-		    (log_needs_allocating ? ah->log_area_count +
+		    (*log_needs_allocating ? ah->log_area_count +
 					    too_small_for_log_count : 0))
 			break;
 
 		if (!_alloc_parallel_area(ah, max_parallel, *areas_ptr, allocated,
-					  log_needs_allocating, ix_log_offset))
+					  *log_needs_allocating, ix_log_offset))
 			return_0;
 
+		*log_needs_allocating = 0;
+
 	} while ((alloc != ALLOC_CONTIGUOUS) && *allocated != needed && can_split);
 
 	return 1;
@@ -1268,15 +1270,15 @@
 	uint32_t areas_size;
 	alloc_policy_t alloc;
 	struct alloced_area *aa;
-	unsigned log_allocated = 0;
+	unsigned log_needs_allocating = 0;
 
 	if (allocated >= ah->new_extents && !ah->log_area_count) {
 		log_error("_allocate called with no work to do!");
 		return 1;
 	}
 
-	if (!ah->log_area_count)
-		log_allocated = 1;
+	if (ah->log_area_count)
+		log_needs_allocating = 1;
 
 	if (ah->alloc == ALLOC_CONTIGUOUS)
 		can_split = 0;
@@ -1322,17 +1324,14 @@
 			  "Need %" PRIu32 " extents for %" PRIu32 " parallel areas and %" PRIu32 " log extents.",
 			  get_alloc_string(alloc),
 			  (ah->new_extents - allocated) / ah->area_multiple,
-			  ah->area_count, log_allocated ? 0 : ah->log_area_count);
+			  ah->area_count, log_needs_allocating ? ah->log_area_count : 0);
 		if (!_find_parallel_space(ah, alloc, pvms, &areas,
 					  &areas_size, can_split,
-					  prev_lvseg, &allocated, ah->new_extents))
+					  prev_lvseg, &allocated, &log_needs_allocating, ah->new_extents))
 			goto_out;
-		if ((allocated == ah->new_extents) || (ah->alloc == alloc) ||
+		if ((allocated == ah->new_extents && !log_needs_allocating) || (ah->alloc == alloc) ||
 		    (!can_split && (allocated != old_allocated)))
 			break;
-		/* Log is always allocated the first time anything is allocated. */
-		if (old_allocated != allocated)
-			log_allocated = 1;
 	}
 
 	if (allocated != ah->new_extents) {
@@ -1345,14 +1344,12 @@
 		goto out;
 	}
 
-	if (ah->log_area_count)
-		dm_list_iterate_items(aa, &ah->alloced_areas[ah->area_count])
-			if (!aa[0].pv) {
-				log_error("Insufficient extents for log allocation "
-					  "for logical volume %s.",
-					  lv ? lv->name : "");
-				goto out;
-			}
+	if (log_needs_allocating) {
+		log_error("Insufficient extents for log allocation "
+			  "for logical volume %s.",
+			  lv ? lv->name : "");
+		goto out;
+	}
 
 	r = 1;
 



             reply	other threads:[~2010-04-01 13:58 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-01 13:58 agk [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-05-11 15:32 LVM2/lib/metadata lv_manip.c agk
2012-05-11 15:26 agk
2012-03-04 15:57 zkabelac
2012-03-01 10:09 zkabelac
2012-02-28 10:08 zkabelac
2012-02-12 21:37 agk
2012-02-01  2:11 agk
2012-01-26 21:39 zkabelac
2012-01-25 11:27 zkabelac
2012-01-25  9:15 zkabelac
2012-01-25  9:14 zkabelac
2012-01-25  9:02 zkabelac
2012-01-25  8:57 zkabelac
2012-01-24 14:54 agk
2012-01-24 14:15 mbroz
2012-01-19 15:39 zkabelac
2011-11-15 17:29 zkabelac
2011-11-15 17:23 zkabelac
2011-11-12 22:53 zkabelac
2011-11-12 22:52 zkabelac
2011-11-12 22:51 zkabelac
2011-11-10 12:42 zkabelac
2011-11-10 12:42 zkabelac
2011-11-10 12:39 zkabelac
2011-11-07 13:54 agk
2011-11-04 22:45 zkabelac
2011-11-03 15:46 zkabelac
2011-11-03 14:56 zkabelac
2011-10-30 22:02 zkabelac
2011-10-28 20:29 zkabelac
2011-10-28 20:18 zkabelac
2011-10-22 16:48 zkabelac
2011-10-22 16:46 zkabelac
2011-10-21  9:55 zkabelac
2011-10-20 10:35 zkabelac
2011-10-03 18:43 zkabelac
2011-09-16 18:39 jbrassow
2011-09-16 12:12 zkabelac
2011-09-16 11:59 zkabelac
2011-09-06 15:39 agk
2011-08-19 22:55 agk
2011-08-19 16:41 agk
2011-08-10 16:44 jbrassow
2011-08-05  9:21 prajnoha
2011-06-06 12:08 agk
2011-03-25 22:02 jbrassow
2011-03-25 22:10 ` Zdenek Kabelac
2010-04-08  0:56 agk
2010-04-08  0:52 agk
2010-04-02  1:35 agk
2010-04-01 12:29 agk
2010-03-31 20:26 agk
2010-02-17 23:36 snitzer
2010-01-20 21:53 snitzer
2010-01-14 10:17 zkabelac
2010-01-14 10:09 zkabelac
2010-01-14 10:08 zkabelac
2010-01-13  1:52 snitzer
2010-01-13  1:51 snitzer
2010-01-10 20:44 snitzer
2010-01-08 23:06 jbrassow
2009-06-06 16:37 mbroz
2009-06-01 14:23 mbroz
2009-01-06 17:24 mbroz
2008-01-16 20:00 agk
2007-11-04 16:28 agk
2007-08-08 18:00 wysochanski
2007-08-09  2:46 ` jorge alberto garcia gonzalez
2007-08-09  2:52 ` jorge alberto garcia gonzalez
2007-08-07 18:55 wysochanski
2007-08-07 16:57 wysochanski
2007-08-06 20:35 wysochanski
2007-08-07 12:52 ` Alasdair G Kergon
2007-08-07 12:56   ` Alasdair G Kergon
2007-08-07 21:15   ` Jun'ichi Nomura

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=20100401135813.22411.qmail@sourceware.org \
    --to=agk@sourceware.org \
    --cc=lvm-devel@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.