]> sourceware.org Git - lvm2.git/commitdiff
Fix log allocation segfault (fix previous commits).
authorMilan Broz <mbroz@redhat.com>
Mon, 1 Jun 2009 14:23:38 +0000 (14:23 +0000)
committerMilan Broz <mbroz@redhat.com>
Mon, 1 Jun 2009 14:23:38 +0000 (14:23 +0000)
If there is no free area for log, code should break the loop.
(Otherwise it uses uninitializes areas later.)

Easily reproducible using lvconvert --repair
 - kill device with log
 - run lvconvert --repair vg/lv (with no PV usable for log)

lib/metadata/lv_manip.c

index 68092a813dc45be0d10e00783a9d4de7c67cea80..fcfd30d1586a3cee721481ced986c93d82add994 100644 (file)
@@ -1124,6 +1124,13 @@ static int _find_parallel_space(struct alloc_handle *ah, alloc_policy_t alloc,
                if ((contiguous || cling) && (preferred_count < ix_offset))
                        break;
 
+               log_needs_allocating = (ah->log_count && !ah->log_area.len) ?
+                                      1 : 0;
+
+               if (ix + ix_offset < ah->area_count +
+                  (log_needs_allocating ? ah->log_count : 0))
+                       break;
+
                /* sort the areas so we allocate from the biggest */
                if (ix > 1)
                        qsort(areas + ix_offset, ix, sizeof(*areas),
@@ -1136,9 +1143,6 @@ static int _find_parallel_space(struct alloc_handle *ah, alloc_policy_t alloc,
                 * FIXME decide which PV to use at top of function instead
                 */
 
-               log_needs_allocating = (ah->log_count && !ah->log_area.len) ?
-                                      1 : 0;
-
                too_small_for_log_count = 0;
 
                if (!log_needs_allocating) {
This page took 0.040046 seconds and 5 git commands to generate.