Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753523AbYJXEnr (ORCPT ); Fri, 24 Oct 2008 00:43:47 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752692AbYJXEjU (ORCPT ); Fri, 24 Oct 2008 00:39:20 -0400 Received: from kroah.org ([198.145.64.141]:51755 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751854AbYJXEjQ (ORCPT ); Fri, 24 Oct 2008 00:39:16 -0400 Date: Thu, 23 Oct 2008 21:34:27 -0700 From: Greg KH To: linux-kernel@vger.kernel.org, stable@kernel.org, jejb@kernel.org Cc: Justin Forbes , Zwane Mwaikambo , "Theodore Ts'o" , Randy Dunlap , Dave Jones , Chuck Wolber , Chris Wedgwood , Michael Krufky , Chuck Ebbert , Domenico Andreoli , Willy Tarreau , Rodrigo Rubira Branco , Jake Edge , Eugene Teo , torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Mikulas Patocka , Alasdair G Kergon Subject: [patch 12/27] dm exception store: fix misordered writes Message-ID: <20081024043427.GM30828@kroah.com> References: <20081024042023.054190751@mini.kroah.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="dm-exception-store-fix-misordered-writes.patch" In-Reply-To: <20081024043303.GA30828@kroah.com> User-Agent: Mutt/1.5.16 (2007-06-09) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1657 Lines: 55 2.6.27-stable review patch. If anyone has any objections, please let us know. ------------------ From: Mikulas Patocka commit 7acedc5b98a2fcff64f00c21110aae7d3ac2f7df upstream We must zero the next chunk on disk *before* writing out the current chunk, not after. Otherwise if the machine crashes at the wrong time, the "end of metadata" marker may be missing. Signed-off-by: Mikulas Patocka Signed-off-by: Alasdair G Kergon Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-exception-store.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) --- a/drivers/md/dm-exception-store.c +++ b/drivers/md/dm-exception-store.c @@ -603,17 +603,22 @@ static void persistent_commit(struct exc return; /* + * If we completely filled the current area, then wipe the next one. + */ + if ((ps->current_committed == ps->exceptions_per_area) && + zero_disk_area(ps, ps->current_area + 1)) + ps->valid = 0; + + /* * Commit exceptions to disk. */ - if (area_io(ps, WRITE)) + if (ps->valid && area_io(ps, WRITE)) ps->valid = 0; /* * Advance to the next area if this one is full. */ if (ps->current_committed == ps->exceptions_per_area) { - if (zero_disk_area(ps, ps->current_area + 1)) - ps->valid = 0; ps->current_committed = 0; ps->current_area++; zero_memory_area(ps); -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/