From patchwork Mon Oct 5 13:38:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 51736 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n95DciuT002334 for ; Mon, 5 Oct 2009 13:38:45 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 84019619F12; Mon, 5 Oct 2009 09:38:43 -0400 (EDT) Received: from int-mx03.intmail.prod.int.phx2.redhat.com (nat-pool.util.phx.redhat.com [10.8.5.200]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n95Dcgla030323 for ; Mon, 5 Oct 2009 09:38:42 -0400 Received: from localhost (dhcp-100-18-171.bos.redhat.com [10.16.18.171]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n95Dcfbj014936; Mon, 5 Oct 2009 09:38:42 -0400 Date: Mon, 5 Oct 2009 09:38:41 -0400 From: Mike Snitzer To: Mikulas Patocka Message-ID: <20091005133841.GA30122@redhat.com> References: <20091002172656.GA13491@redhat.com> <20091004034843.GC25374@redhat.com> <20091005043334.GA27758@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20091005043334.GA27758@redhat.com> User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Alasdair G Kergon Subject: [dm-devel] Re: clustered snapshots X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index bcfbe85..b271f56 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c @@ -790,17 +790,25 @@ static void merge_callback(int read_err, unsigned long write_err, void *context) * so that dm_consecutive_chunk_count_dec() accounting works */ for (i = s->merge_write_interlock_n - 1; i >= 0; i--) { - e = lookup_exception(&s->complete, - s->merge_write_interlock + i); + chunk_t old_chunk = s->merge_write_interlock + i; + e = lookup_exception(&s->complete, old_chunk); if (!e) { DMERR("exception for block %llu is on " "disk but not in memory", - (unsigned long long) - s->merge_write_interlock + i); + (unsigned long long)old_chunk); up_write(&s->lock); goto shut; } if (dm_consecutive_chunk_count(e)) { + if (old_chunk == e->old_chunk) { + e->old_chunk++; + e->new_chunk++; + } else if (old_chunk != e->old_chunk + + dm_consecutive_chunk_count(e)) { + DMERR("merge from the middle of a chunk range"); + up_write(&s->lock); + goto shut; + } dm_consecutive_chunk_count_dec(e); } else { remove_exception(e);