From patchwork Mon Oct 5 19:02:40 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 51778 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 n95J2vYC016157 for ; Mon, 5 Oct 2009 19:02:57 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 490B08E08A5; Mon, 5 Oct 2009 15:02:57 -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 n95J2pB8009975 for ; Mon, 5 Oct 2009 15:02:51 -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 n95J2oNc005962; Mon, 5 Oct 2009 15:02:51 -0400 From: Mike Snitzer To: dm-devel@redhat.com Date: Mon, 5 Oct 2009 15:02:40 -0400 Message-Id: <1254769367-12111-6-git-send-email-snitzer@redhat.com> In-Reply-To: <1254769367-12111-1-git-send-email-snitzer@redhat.com> References: <1254769367-12111-1-git-send-email-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: Mikulas Patocka Subject: [dm-devel] [PATCH 05/12] dm-snapshot-no-more-merging-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 31040f9..2cb0636 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c @@ -285,6 +285,22 @@ static void __insert_origin(struct origin *o) list_add_tail(&o->hash_list, sl); } +static struct dm_snapshot *__find_merging_snapshot(struct block_device *origin) +{ + struct origin *o; + struct dm_snapshot *snap; + + o = __lookup_origin(origin); + if (!o) + return NULL; + + list_for_each_entry(snap, &o->snapshots, list) + if (is_merge(snap->ti)) + return snap; + + return NULL; +} + /* * Make a note of the snapshot and its origin so we can look it * up when the origin has a write on it. @@ -299,6 +315,13 @@ static int register_snapshot(struct dm_snapshot *snap) return -ENOMEM; down_write(&_origins_lock); + + /* Do not allow more than one merging snapshot */ + if (is_merge(snap->ti) && __find_merging_snapshot(bdev)) { + up_write(&_origins_lock); + return -EINVAL; + } + o = __lookup_origin(bdev); if (o)