From: NeilBrown <neilb@suse.de>
To: Jens Axboe <jens.axboe@oracle.com>
Cc: linux-kernel@vger.kernel.org, Tejun Heo <htejun@gmail.com>
Subject: [PATCH 004 of 6] New function blk_req_append_bio
Date: Thu, 16 Aug 2007 21:21:15 +1000 [thread overview]
Message-ID: <1070816112115.12215@suse.de> (raw)
In-Reply-To: 20070816211551.11839.patches@notabene
ll_back_merge_fn is currently exported to SCSI where is it used,
together with blk_rq_bio_prep, in exactly the same way these
functions are used in __blk_rq_map_user.
So move the common code into a new function (blk_rq_append_bio), and
don't export ll_back_merge_fn any longer.
Signed-off-by: Neil Brown <neilb@suse.de>
### Diffstat output
./block/ll_rw_blk.c | 38 ++++++++++++++++++++++----------------
./drivers/scsi/scsi_lib.c | 11 +----------
./include/linux/blkdev.h | 4 ++--
3 files changed, 25 insertions(+), 28 deletions(-)
diff .prev/block/ll_rw_blk.c ./block/ll_rw_blk.c
--- .prev/block/ll_rw_blk.c 2007-08-16 21:10:01.000000000 +1000
+++ ./block/ll_rw_blk.c 2007-08-16 21:10:16.000000000 +1000
@@ -1430,7 +1430,8 @@ static inline int ll_new_hw_segment(stru
return 1;
}
-int ll_back_merge_fn(struct request_queue *q, struct request *req, struct bio *bio)
+static int ll_back_merge_fn(struct request_queue *q, struct request *req,
+ struct bio *bio)
{
unsigned short max_sectors;
int len;
@@ -1466,7 +1467,6 @@ int ll_back_merge_fn(struct request_queu
return ll_new_hw_segment(q, req, bio);
}
-EXPORT_SYMBOL(ll_back_merge_fn);
static int ll_front_merge_fn(struct request_queue *q, struct request *req,
struct bio *bio)
@@ -2358,6 +2358,23 @@ static int __blk_rq_unmap_user(struct bi
return ret;
}
+int blk_rq_append_bio(struct request_queue *q, struct request *rq,
+ struct bio *bio)
+{
+ if (!rq->bio)
+ blk_rq_bio_prep(q, rq, bio);
+ else if (!ll_back_merge_fn(q, rq, bio))
+ return -EINVAL;
+ else {
+ rq->biotail->bi_next = bio;
+ rq->biotail = bio;
+
+ rq->data_len += bio->bi_size;
+ }
+ return 0;
+}
+EXPORT_SYMBOL(blk_rq_append_bio);
+
static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
void __user *ubuf, unsigned int len)
{
@@ -2389,21 +2406,10 @@ static int __blk_rq_map_user(struct requ
*/
bio_get(bio);
- if (!rq->bio)
- blk_rq_bio_prep(q, rq, bio);
- else if (!ll_back_merge_fn(q, rq, bio)) {
- ret = -EINVAL;
- goto unmap_bio;
- } else {
- rq->biotail->bi_next = bio;
- rq->biotail = bio;
-
- rq->data_len += bio->bi_size;
- }
-
- return bio->bi_size;
+ ret = blk_rq_append_bio(q, rq, bio);
+ if (!ret)
+ return bio->bi_size;
-unmap_bio:
/* if it was boucned we must call the end io function */
bio_endio(bio, bio->bi_size, 0);
__blk_rq_unmap_user(orig_bio);
diff .prev/drivers/scsi/scsi_lib.c ./drivers/scsi/scsi_lib.c
--- .prev/drivers/scsi/scsi_lib.c 2007-08-16 21:10:00.000000000 +1000
+++ ./drivers/scsi/scsi_lib.c 2007-08-16 21:10:16.000000000 +1000
@@ -268,16 +268,7 @@ static int scsi_merge_bio(struct request
bio->bi_rw |= (1 << BIO_RW);
blk_queue_bounce(q, &bio);
- if (!rq->bio)
- blk_rq_bio_prep(q, rq, bio);
- else if (!ll_back_merge_fn(q, rq, bio))
- return -EINVAL;
- else {
- rq->biotail->bi_next = bio;
- rq->biotail = bio;
- }
-
- return 0;
+ return blk_rq_append_bio(q, rq, bio);
}
static int scsi_bi_endio(struct bio *bio, unsigned int bytes_done, int error)
diff .prev/include/linux/blkdev.h ./include/linux/blkdev.h
--- .prev/include/linux/blkdev.h 2007-08-16 21:10:00.000000000 +1000
+++ ./include/linux/blkdev.h 2007-08-16 21:10:16.000000000 +1000
@@ -675,8 +675,8 @@ extern int sg_scsi_ioctl(struct file *,
/*
* Temporary export, until SCSI gets fixed up.
*/
-extern int ll_back_merge_fn(struct request_queue *, struct request *,
- struct bio *);
+extern int blk_rq_append_bio(struct request_queue *q, struct request *rq,
+ struct bio *bio);
/*
* A queue has just exitted congestion. Note this in the global counter of
next prev parent reply other threads:[~2007-08-16 11:22 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-16 11:20 [PATCH 000 of 6] A few block-layer tidy-up patches NeilBrown
2007-08-16 11:20 ` [PATCH 001 of 6] Merge blk_recount_segments into blk_recalc_rq_segments NeilBrown
2007-08-16 11:21 ` [PATCH 002 of 6] Introduce rq_for_each_segment replacing rq_for_each_bio NeilBrown
2007-08-17 7:13 ` Geert Uytterhoeven
2007-08-18 14:37 ` Satyam Sharma
2007-08-18 14:30 ` Jan Engelhardt
2007-08-18 14:48 ` Satyam Sharma
2007-08-20 11:21 ` Geert Uytterhoeven
2007-08-20 12:46 ` Jan Engelhardt
2007-08-21 1:38 ` Satyam Sharma
2007-08-21 7:09 ` Geert Uytterhoeven
2007-08-21 9:46 ` Satyam Sharma
2007-08-21 9:52 ` Geert Uytterhoeven
2007-08-21 10:41 ` [PATCH] PS3: Update MAINTAINERS Satyam Sharma
2007-08-21 19:01 ` Geoff Levand
2007-08-21 20:01 ` Joe Perches
2007-08-21 20:06 ` Rene Herman
2007-08-21 20:17 ` Geoff Levand
2007-08-21 20:33 ` Rene Herman
2007-08-21 20:48 ` Satyam Sharma
2007-08-21 20:41 ` Rene Herman
2007-08-21 20:47 ` Joe Perches
2007-08-21 21:58 ` Hugh Blemings
2007-08-23 18:14 ` Matt Mackall
2007-08-24 5:52 ` Hugh Blemings
2007-08-21 20:10 ` Geoff Levand
2007-08-24 6:25 ` [Cbe-oss-dev] " Hugh Blemings
2007-08-24 6:47 ` Satyam Sharma
2007-08-24 6:48 ` Hugh Blemings
2007-08-16 11:21 ` [PATCH 003 of 6] Fix various abuse of bio fields in umem.c NeilBrown
2007-08-16 11:21 ` NeilBrown [this message]
2007-08-16 11:21 ` [PATCH 005 of 6] Stop exporting blk_rq_bio_prep NeilBrown
2007-08-16 11:21 ` [PATCH 006 of 6] Share code between init_request_from_bio and blk_rq_bio_prep NeilBrown
2007-08-16 11:36 ` [PATCH 000 of 6] A few block-layer tidy-up patches Jens Axboe
2007-08-17 0:40 ` Neil Brown
2007-08-17 6:17 ` Jens Axboe
2007-08-17 7:21 ` Neil Brown
2007-08-17 12:37 ` Jens Axboe
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=1070816112115.12215@suse.de \
--to=neilb@suse.de \
--cc=htejun@gmail.com \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.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