All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark McLoughlin <markmc@redhat.com>
To: agk@redhat.com
Cc: Mark McLoughlin <markmc@redhat.com>, dm-devel@redhat.com
Subject: [PATCH 06/10] dm snapshot: Make find_pending_exception() not take a bio
Date: Tue,  1 Apr 2008 09:32:53 +0200	[thread overview]
Message-ID: <1207035177-7156-7-git-send-email-markmc@redhat.com> (raw)
In-Reply-To: <1207035177-7156-6-git-send-email-markmc@redhat.com>

Change __find_pending_exception() so that it takes an old chunk index
and "prepare" flag rather than a bio structure.

Rationale is that the merged target will use the pending exception
table for tracking writes which have been mapped to the COW device. In
such cases, we won't want a new exception to be prepared in the
exception store.

Also, the merged target will want to trigger an exception in all
associated snapshots without a corresponding bio structure. We'll need
to do this when initiating a copy from the COW device to the origin
device.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
 drivers/md/dm-snap.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 7684f8f..e64b9b4 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -881,11 +881,10 @@ static void start_copy(struct dm_snap_pending_exception *pe)
  * this.
  */
 static struct dm_snap_pending_exception *
-__find_pending_exception(struct dm_snapshot *s, struct bio *bio)
+__find_pending_exception(struct dm_snapshot *s, chunk_t chunk, int prepare)
 {
 	struct dm_snap_exception *e;
 	struct dm_snap_pending_exception *pe;
-	chunk_t chunk = sector_to_chunk(s, bio->bi_sector);
 	unsigned long flags;
 
 	spin_lock_irqsave(&s->pe_lock, flags);
@@ -934,7 +933,7 @@ __find_pending_exception(struct dm_snapshot *s, struct bio *bio)
 	insert_exception(&s->pending, &pe->e);
 
  ref_and_out:
-	if (bio_rw(bio) != WRITE)
+	if (!prepare)
 		get_pending_exception(pe);
 	else if (!pe->started) {
 		if (s->store.prepare_exception(&s->store, &pe->e)) {
@@ -992,7 +991,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
 		goto out_unlock;
 	}
 
-	pe = __find_pending_exception(s, bio);
+	pe = __find_pending_exception(s, chunk, bio_rw(bio) == WRITE);
 	if (!pe) {
 		__invalidate_snapshot(s, -ENOMEM);
 		r = -EIO;
@@ -1142,7 +1141,7 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
 		if (e)
 			goto next_snapshot;
 
-		pe = __find_pending_exception(snap, bio);
+		pe = __find_pending_exception(snap, chunk, 1);
 		if (!pe) {
 			__invalidate_snapshot(snap, -ENOMEM);
 			goto next_snapshot;
-- 
1.5.4.1

  reply	other threads:[~2008-04-01  7:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-01  7:32 [PATCH 0/10] Snapshot merging back from the dead? Mark McLoughlin
2008-04-01  7:32 ` [PATCH 01/10] dm snapshot: Fix the fraction full percentage Mark McLoughlin
2008-04-01  7:32   ` [PATCH 02/10] dm snapshot: Track snapshot reads Mark McLoughlin
2008-04-01  7:32     ` [PATCH 03/10] dm snapshot: Add exception store methods for merging Mark McLoughlin
2008-04-01  7:32       ` [PATCH 04/10] dm snapshot: Split snapshot constructor Mark McLoughlin
2008-04-01  7:32         ` [PATCH 05/10] dm snapshot: Split up origin_resume() Mark McLoughlin
2008-04-01  7:32           ` Mark McLoughlin [this message]
2008-04-01  7:32             ` [PATCH 07/10] dm snapshot: Make origin_write() bio arg optional Mark McLoughlin
2008-04-01  7:32               ` [PATCH 08/10] dm snapshot: Add basic version of snapshot-merged target Mark McLoughlin
2008-04-01  7:32                 ` [PATCH 09/10] dm snapshot: Track snapshot-merged writes Mark McLoughlin
2008-04-01  7:32                   ` [PATCH 10/10] dm snapshot: Add snapshot merging code Mark McLoughlin
2008-04-14  8:41 ` [PATCH 0/10] Snapshot merging back from the dead? Mark McLoughlin

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=1207035177-7156-7-git-send-email-markmc@redhat.com \
    --to=markmc@redhat.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.