From: Mark McLoughlin <markmc@redhat.com>
To: agk@redhat.com
Cc: Mark McLoughlin <markmc@redhat.com>, dm-devel@redhat.com
Subject: [PATCH 07/10] dm snapshot: Make origin_write() bio arg optional
Date: Tue, 1 Apr 2008 09:32:54 +0200 [thread overview]
Message-ID: <1207035177-7156-8-git-send-email-markmc@redhat.com> (raw)
In-Reply-To: <1207035177-7156-7-git-send-email-markmc@redhat.com>
Similar to the previous patch, change the arguments to
__origin_write() so that rather than requiring a bio structure, we
take a origin device sector index and optional bio structure.
Rationale is that the merged target will want to trigger an exception
in all associated snapshots before merging the chunk from the COW
to the origin and at this point we don't have a bio structure
corresponding to that copy.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
drivers/md/dm-snap.c | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index e64b9b4..e4ba02c 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -1103,7 +1103,8 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
/*-----------------------------------------------------------------
* Origin methods
*---------------------------------------------------------------*/
-static int __origin_write(struct list_head *snapshots, struct bio *bio)
+static int __origin_write(struct list_head *snapshots, sector_t sector,
+ struct bio *bio)
{
int r = DM_MAPIO_REMAPPED;
struct dm_snapshot *snap;
@@ -1123,14 +1124,14 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
goto next_snapshot;
/* Nothing to do if writing beyond end of snapshot */
- if (bio->bi_sector >= dm_table_get_size(snap->table))
+ if (sector >= dm_table_get_size(snap->table))
goto next_snapshot;
/*
* Remember, different snapshots can have
* different chunk sizes.
*/
- chunk = sector_to_chunk(snap, bio->bi_sector);
+ chunk = sector_to_chunk(snap, sector);
/*
* Check exception table to see if block
@@ -1166,7 +1167,8 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
*/
get_pending_exception(primary_pe);
- bio_list_add(&primary_pe->origin_bios, bio);
+ if (bio)
+ bio_list_add(&primary_pe->origin_bios, bio);
r = DM_MAPIO_SUBMITTED;
}
@@ -1212,7 +1214,8 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
/*
* Called on a write from the origin driver.
*/
-static int do_origin(struct dm_dev *origin, struct bio *bio)
+static int do_origin(struct dm_dev *origin, sector_t sector,
+ struct bio *bio)
{
struct origin *o;
int r = DM_MAPIO_REMAPPED;
@@ -1220,7 +1223,7 @@ static int do_origin(struct dm_dev *origin, struct bio *bio)
down_read(&_origins_lock);
o = __lookup_origin(origin->bdev);
if (o)
- r = __origin_write(&o->snapshots, bio);
+ r = __origin_write(&o->snapshots, sector, bio);
up_read(&_origins_lock);
return r;
@@ -1266,10 +1269,14 @@ static int origin_map(struct dm_target *ti, struct bio *bio,
union map_info *map_context)
{
struct dm_dev *dev = ti->private;
+
bio->bi_bdev = dev->bdev;
/* Only tell snapshots if this is a write */
- return (bio_rw(bio) == WRITE) ? do_origin(dev, bio) : DM_MAPIO_REMAPPED;
+ if (bio_rw(bio) != WRITE)
+ return DM_MAPIO_REMAPPED;
+
+ return do_origin(dev, bio->bi_sector, bio);
}
#define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r))
--
1.5.4.1
next prev parent 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 ` [PATCH 06/10] dm snapshot: Make find_pending_exception() not take a bio Mark McLoughlin
2008-04-01 7:32 ` Mark McLoughlin [this message]
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-8-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.