From: Boaz Harrosh <bharrosh@panasas.com>
To: Jens Axboe <Jens.Axboe@oracle.com>,
James Bottomley <James.Bottomley@hansenpartnership.com>,
FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
Jeff Garzik <jeff@garzik.org>,
Tejun
Cc: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Subject: [RFC 3/4] New blk_make_request(), takes bio, returns a request
Date: Thu, 07 May 2009 19:16:28 +0300 [thread overview]
Message-ID: <4A03095C.7030008@panasas.com> (raw)
In-Reply-To: <4A0307F4.50205@panasas.com>
New block API:
given a struct bio allocates a new request. This is the parallel of
generic_make_request for BLOCK_PC commands users.
The passed bio may be a chained-bio. The bio is bounced if needed
inside the call to this member.
This is in the effort of un-exporting blk_rq_append_bio().
Requested-comments-by: Boaz Harrosh <bharrosh@panasas.com>
TO: Jens Axboe <Jens.Axboe@oracle.com>
CC: Tejun Heo <tj@kernel.org>
CC: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
CC: James Bottomley <James.Bottomley@hansenpartnership.com>
CC: Jeff Garzik <jeff@garzik.org>
---
block/blk-core.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
include/linux/blkdev.h | 2 ++
2 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 2998fe3..d79c6e8 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -902,6 +902,52 @@ struct request *blk_get_request(struct request_queue *q, int rw, gfp_t gfp_mask)
EXPORT_SYMBOL(blk_get_request);
/**
+ * blk_make_request - given a bio, allocate a corresponding struct request.
+ *
+ * @bio: The bio describing the memory mappings that will be submitted for IO.
+ * It may be a chained-bio properly constructed by block/bio layer.
+ *
+ * blk_make_request is the parallel of generic_make_request for BLOCK_PC
+ * type commands. Where the struct request needs to be farther initialized by
+ * the caller. It is passed a &struct bio, which describes the memory info to
+ * be read/written to/from.
+ *
+ * The caller of blk_make_request must make sure that bi_io_vec
+ * are set to describe the memory buffers. That bio_data_dir() will return
+ * the needed direction of the request. (And all bio's in the passed bio-chain
+ * are properly set accordingly), the passed total_bytes may be shorter then
+ * the passed total_bytes(bio-chain).
+ *
+ * If called under none-sleepable conditions, mapped bio buffers must not
+ * need bouncing, by calling the appropriate masked or flagged allocator,
+ * suitable for the target device. Otherwise the call to blk_queue_bounce will
+ * BUG.
+ */
+struct request *blk_make_request(struct request_queue *q, struct bio *bio,
+ gfp_t gfp_mask)
+{
+ struct request *rq = blk_get_request(q, bio_data_dir(bio), gfp_mask);
+
+ if (unlikely(!rq))
+ return ERR_PTR(-ENOMEM);
+
+ for_each_bio(bio) {
+ struct bio *bounce_bio = bio;
+ int ret;
+
+ blk_queue_bounce(q, &bounce_bio);
+ ret = blk_rq_append_bio(q, rq, bounce_bio);
+ if (unlikely(ret)) {
+ blk_put_request(rq);
+ return ERR_PTR(ret);
+ }
+ }
+
+ return rq;
+}
+EXPORT_SYMBOL(blk_make_request);
+
+/**
* blk_start_queueing - initiate dispatch of requests to device
* @q: request queue to kick into gear
*
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index b4f71f1..19728b0 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -752,6 +752,8 @@ extern void blk_rq_init(struct request_queue *q, struct request *rq);
extern void blk_put_request(struct request *);
extern void __blk_put_request(struct request_queue *, struct request *);
extern struct request *blk_get_request(struct request_queue *, int, gfp_t);
+extern struct request *blk_make_request(struct request_queue *, struct bio *,
+ gfp_t);
extern void blk_insert_request(struct request_queue *, struct request *, int, void *);
extern void blk_requeue_request(struct request_queue *, struct request *);
extern int blk_rq_check_limits(struct request_queue *q, struct request *rq);
--
1.6.2.1
next prev parent reply other threads:[~2009-05-07 16:16 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-07 16:10 [patchset 0/4] osd: Stop usage of blk_rq_append_bio Boaz Harrosh
2009-05-07 16:12 ` [PATCH 1/4] allow blk_rq_map_kern to append to requests Boaz Harrosh
2009-05-07 16:14 ` [PATCH 2/4] libosd: Use new blk_rq_map_kern Boaz Harrosh
2009-05-07 16:16 ` Boaz Harrosh [this message]
2009-05-07 16:18 ` [RFC 4/4] libosd: Use of new blk_make_request Boaz Harrosh
2009-05-09 7:36 ` [patchset 0/4] osd: Stop usage of blk_rq_append_bio Jeff Garzik
2009-05-09 8:12 ` Tejun Heo
2009-05-12 11:25 ` Jens Axboe
2009-05-13 14:28 ` Boaz Harrosh
2009-05-13 14:36 ` Boaz Harrosh
2009-05-13 14:47 ` James Bottomley
2009-05-14 14:53 ` Boaz Harrosh
2009-05-14 15:35 ` James Bottomley
2009-05-14 16:11 ` Boaz Harrosh
2009-05-14 16:39 ` Boaz Harrosh
2009-05-17 8:24 ` Boaz Harrosh
2009-05-14 16:46 ` James Bottomley
2009-05-13 14:52 ` Stephen Rothwell
2009-05-13 15:01 ` Boaz Harrosh
2009-05-13 15:13 ` Stephen Rothwell
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=4A03095C.7030008@panasas.com \
--to=bharrosh@panasas.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=Jens.Axboe@oracle.com \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=jeff@garzik.org \
--cc=nab@linux-iscsi.org \
/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).