From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13789 invoked by alias); 1 Jun 2009 14:23:40 -0000 Received: (qmail 13773 invoked by uid 9664); 1 Jun 2009 14:23:39 -0000 Date: Mon, 01 Jun 2009 14:23:00 -0000 Message-ID: <20090601142339.13771.qmail@sourceware.org> From: mbroz@sourceware.org To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org Subject: LVM2/lib/metadata lv_manip.c Mailing-List: contact lvm2-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: lvm2-cvs-owner@sourceware.org X-SW-Source: 2009-06/txt/msg00001.txt.bz2 CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2009-06-01 14:23:38 Modified files: lib/metadata : lv_manip.c Log message: Fix log allocation segfault (fix previous commits). 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) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.178&r2=1.179 --- LVM2/lib/metadata/lv_manip.c 2009/05/30 00:09:27 1.178 +++ LVM2/lib/metadata/lv_manip.c 2009/06/01 14:23:38 1.179 @@ -1124,6 +1124,13 @@ 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 @@ * 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) {