mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: dm-devel@redhat.com
Cc: linux-kernel@vger.kernel.org, Mikulas Patocka <mpatocka@redhat.com>
Subject: [PATCH v4 11/13] dm snapshot: make exceptions in other snapshots when merging
Date: Fri, 20 Nov 2009 15:27:51 -0500	[thread overview]
Message-ID: <1258748873-24185-12-git-send-email-snitzer@redhat.com> (raw)
In-Reply-To: <1258748873-24185-1-git-send-email-snitzer@redhat.com>

From: Mikulas Patocka <mpatocka@redhat.com>

When there is one merging snapshot and other non-merging snapshots,
snapshot_merge_process() must make exceptions in the non-merging
snapshots.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
 drivers/md/dm-snap.c |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index e41be70..2b5b083 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -255,6 +255,8 @@ struct origin {
 static struct list_head *_origins;
 static struct rw_semaphore _origins_lock;
 
+static DECLARE_WAIT_QUEUE_HEAD(_pending_exception_done);
+
 static int init_origin_hash(void)
 {
 	int i;
@@ -742,13 +744,18 @@ static int init_hash_tables(struct dm_snapshot *s)
 static void flush_bios(struct bio *bio);
 static void error_bios(struct bio *bio);
 
+static int __origin_write(struct list_head *snapshots,
+			  sector_t sector, struct bio *bio);
+
 static void merge_callback(int read_err, unsigned long write_err,
 			   void *context);
 
 static void snapshot_merge_process(struct dm_snapshot *s)
 {
 	int r;
-	chunk_t old_chunk, new_chunk;
+	chunk_t old_chunk, new_chunk, n;
+	struct origin *o;
+	int must_wait;
 	struct dm_io_region src, dest;
 
 	BUG_ON(!s->merge_running);
@@ -779,6 +786,27 @@ static void snapshot_merge_process(struct dm_snapshot *s)
 	src.sector = chunk_to_sector(s->store, new_chunk);
 	src.count = dest.count;
 
+test_again:
+	/* Reallocate other snapshots */
+	must_wait = 0;
+	/*
+	 * Merging snapshot already has the origin's __minimum_chunk_size()
+	 * stored in split_io (see: snapshot_merge_resume); avoid rediscovery
+	 */
+	BUG_ON(!s->ti->split_io);
+	down_read(&_origins_lock);
+	o = __lookup_origin(s->origin->bdev);
+	for (n = 0; n < s->store->chunk_size; n += s->ti->split_io) {
+		r = __origin_write(&o->snapshots, dest.sector + n, NULL);
+		if (r == DM_MAPIO_SUBMITTED)
+			must_wait = 1;
+	}
+	up_read(&_origins_lock);
+	if (must_wait) {
+		sleep_on_timeout(&_pending_exception_done, HZ / 100 + 1);
+		goto test_again;
+	}
+
 	down_write(&s->lock);
 	s->merge_write_interlock = old_chunk;
 	s->merge_write_interlock_n = 1;
@@ -1301,6 +1329,8 @@ static void pending_complete(struct dm_snap_pending_exception *pe, int success)
 	origin_bios = bio_list_get(&pe->origin_bios);
 	free_pending_exception(pe);
 
+	wake_up_all(&_pending_exception_done);
+
 	up_write(&s->lock);
 
 	/* Submit any pending write bios */
-- 
1.6.5.2


  parent reply	other threads:[~2009-11-20 20:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-20 20:27 [PATCH v4 00/13] snapshot-merge target Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 01/13] dm snapshot: allow live exception store handover between tables Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 02/13] dm snapshot: rework writing to snapshot origin Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 03/13] dm exception store: add snapshot-merge specific methods Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 04/13] dm exception store: snapshot-merge usage accounting Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 05/13] dm snapshot: add snapshot-merge target Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 06/13] dm snapshot: merge target should not allocate new exceptions Mike Snitzer
2009-11-20 20:54   ` Mike Snitzer
2009-11-20 21:02   ` Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 07/13] dm snapshot: do not allow more than one merging snapshot Mike Snitzer
2009-11-20 21:04   ` Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 08/13] dm snapshot: the merge procedure Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 09/13] dm snapshot: queue writes to an area that is actively being merged Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 10/13] dm snapshot: do not merge a chunk until active writes to it finish Mike Snitzer
2009-11-20 20:27 ` Mike Snitzer [this message]
2009-11-20 20:27 ` [PATCH v4 12/13] dm snapshot: redirect accesses to origin if merging snap invalidated Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 13/13] dm snapshot: merge a linear region of chunks using one large IO Mike Snitzer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1258748873-24185-12-git-send-email-snitzer@redhat.com \
    --to=snitzer@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®