From: Robin Dong <robin.k.dong@gmail.com>
To: linux-kernel@vger.kernel.org, dm-devel@redhat.com
Cc: Robin Dong <sanbai@taobao.com>
Subject: [PATCH 2/2] md: modify dm_io() so it could return bios instead of submitting it
Date: Thu, 20 Sep 2012 11:18:42 +0800 [thread overview]
Message-ID: <1348111122-27400-2-git-send-email-robin.k.dong@gmail.com> (raw)
In-Reply-To: <1348111122-27400-1-git-send-email-robin.k.dong@gmail.com>
From: Robin Dong <sanbai@taobao.com>
When trying to modify flashcache to request based (current it's bio based), we need
to make request from bios by ourselves, but dm_io() will submit these bios directly,
so we propose to modify the dm_io() to return bios instead of submiting it.
This could also improve the flexibility of dm_io().
Signed-off-by: Robin Dong <sanbai@taobao.com>
---
drivers/md/dm.c | 11 +++++++++++
include/linux/device-mapper.h | 3 +++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 4e09b6f..bf6e3bb 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1459,11 +1459,22 @@ static int dm_request_based(struct mapped_device *md)
static void dm_request(struct request_queue *q, struct bio *bio)
{
struct mapped_device *md = q->queuedata;
+ struct dm_table *map = dm_get_live_table(md);
+ struct dm_target *ti = dm_table_find_target(map, bio->bi_sector);
+
+ if (ti->type->mk_rq) {
+ ti->type->mk_rq(ti, q, bio);
+ goto out;
+ }
if (dm_request_based(md))
blk_queue_bio(q, bio);
else
_dm_request(q, bio);
+
+out:
+ dm_table_put(map);
+ return;
}
void dm_dispatch_request(struct request *rq)
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 38d27a1..2386389 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -50,6 +50,8 @@ typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio,
union map_info *map_context);
typedef int (*dm_map_request_fn) (struct dm_target *ti, struct request *clone,
union map_info *map_context);
+typedef int (*dm_make_request_fn) (struct dm_target *ti,
+ struct request_queue *q, struct bio *bio);
/*
* Returns:
@@ -136,6 +138,7 @@ struct target_type {
dm_dtr_fn dtr;
dm_map_fn map;
dm_map_request_fn map_rq;
+ dm_make_request_fn mk_rq;
dm_endio_fn end_io;
dm_request_endio_fn rq_end_io;
dm_presuspend_fn presuspend;
--
1.7.1
next prev parent reply other threads:[~2012-09-20 3:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-20 3:18 [PATCH 1/2] md: add new interface 'mk_rq' in target_type Robin Dong
2012-09-20 3:18 ` Robin Dong [this message]
2012-11-14 3:08 ` [PATCH 2/2] md: modify dm_io() so it could return bios instead of submitting it Robin Dong
2012-11-14 3:08 ` [PATCH 1/2] md: add new interface 'mk_rq' in target_type Robin Dong
-- strict thread matches above, loose matches on Subject: below --
2012-09-03 2:12 Robin Dong
2012-09-03 2:12 ` [PATCH 2/2] md: modify dm_io() so it could return bios instead of submitting it Robin Dong
2012-09-03 2:07 [PATCH 1/2] md: add new interface 'mk_rq' in target_type Robin Dong
2012-09-03 2:07 ` [PATCH 2/2] md: modify dm_io() so it could return bios instead of submitting it Robin Dong
2012-08-20 7:04 [PATCH 1/2] md: add new interface 'mk_rq' in target_type Robin Dong
2012-08-20 7:04 ` [PATCH 2/2] md: modify dm_io() so it could return bios instead of submitting it Robin Dong
2012-08-20 6:22 [PATCH 1/2] md: add new interface 'mk_rq' in target_type Robin Dong
2012-08-20 6:22 ` [PATCH 2/2] md: modify dm_io() so it could return bios instead of submitting it Robin Dong
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=1348111122-27400-2-git-send-email-robin.k.dong@gmail.com \
--to=robin.k.dong@gmail.com \
--cc=dm-devel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sanbai@taobao.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;
as well as URLs for NNTP newsgroup(s).