diff options
author | NeilBrown <neilb@suse.de> | 2007-08-16 07:31:27 -0400 |
---|---|---|
committer | Jens Axboe <axboe@carl.home.kernel.dk> | 2007-10-10 03:25:56 -0400 |
commit | 3001ca77128273cc5634d79f5306ce2e5a14ec41 (patch) | |
tree | 0e5904fc170afb6c01f8f0930e3c4a4ae20b19b2 | |
parent | eea9befaccb8d43ce89585d612159761c978f056 (diff) |
New function blk_req_append_bio
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>
diff .prev/block/ll_rw_blk.c ./block/ll_rw_blk.c
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r-- | block/ll_rw_blk.c | 38 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 11 | ||||
-rw-r--r-- | include/linux/blkdev.h | 4 |
3 files changed, 25 insertions, 28 deletions
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 094c0fa5c405..2de9bad1d042 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c | |||
@@ -1441,7 +1441,8 @@ static inline int ll_new_hw_segment(struct request_queue *q, | |||
1441 | return 1; | 1441 | return 1; |
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | int ll_back_merge_fn(struct request_queue *q, struct request *req, struct bio *bio) | 1444 | static int ll_back_merge_fn(struct request_queue *q, struct request *req, |
1445 | struct bio *bio) | ||
1445 | { | 1446 | { |
1446 | unsigned short max_sectors; | 1447 | unsigned short max_sectors; |
1447 | int len; | 1448 | int len; |
@@ -1477,7 +1478,6 @@ int ll_back_merge_fn(struct request_queue *q, struct request *req, struct bio *b | |||
1477 | 1478 | ||
1478 | return ll_new_hw_segment(q, req, bio); | 1479 | return ll_new_hw_segment(q, req, bio); |
1479 | } | 1480 | } |
1480 | EXPORT_SYMBOL(ll_back_merge_fn); | ||
1481 | 1481 | ||
1482 | static int ll_front_merge_fn(struct request_queue *q, struct request *req, | 1482 | static int ll_front_merge_fn(struct request_queue *q, struct request *req, |
1483 | struct bio *bio) | 1483 | struct bio *bio) |
@@ -2367,6 +2367,23 @@ static int __blk_rq_unmap_user(struct bio *bio) | |||
2367 | return ret; | 2367 | return ret; |
2368 | } | 2368 | } |
2369 | 2369 | ||
2370 | int blk_rq_append_bio(struct request_queue *q, struct request *rq, | ||
2371 | struct bio *bio) | ||
2372 | { | ||
2373 | if (!rq->bio) | ||
2374 | blk_rq_bio_prep(q, rq, bio); | ||
2375 | else if (!ll_back_merge_fn(q, rq, bio)) | ||
2376 | return -EINVAL; | ||
2377 | else { | ||
2378 | rq->biotail->bi_next = bio; | ||
2379 | rq->biotail = bio; | ||
2380 | |||
2381 | rq->data_len += bio->bi_size; | ||
2382 | } | ||
2383 | return 0; | ||
2384 | } | ||
2385 | EXPORT_SYMBOL(blk_rq_append_bio); | ||
2386 | |||
2370 | static int __blk_rq_map_user(struct request_queue *q, struct request *rq, | 2387 | static int __blk_rq_map_user(struct request_queue *q, struct request *rq, |
2371 | void __user *ubuf, unsigned int len) | 2388 | void __user *ubuf, unsigned int len) |
2372 | { | 2389 | { |
@@ -2398,21 +2415,10 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq, | |||
2398 | */ | 2415 | */ |
2399 | bio_get(bio); | 2416 | bio_get(bio); |
2400 | 2417 | ||
2401 | if (!rq->bio) | 2418 | ret = blk_rq_append_bio(q, rq, bio); |
2402 | blk_rq_bio_prep(q, rq, bio); | 2419 | if (!ret) |
2403 | else if (!ll_back_merge_fn(q, rq, bio)) { | 2420 | return bio->bi_size; |
2404 | ret = -EINVAL; | ||
2405 | goto unmap_bio; | ||
2406 | } else { | ||
2407 | rq->biotail->bi_next = bio; | ||
2408 | rq->biotail = bio; | ||
2409 | |||
2410 | rq->data_len += bio->bi_size; | ||
2411 | } | ||
2412 | |||
2413 | return bio->bi_size; | ||
2414 | 2421 | ||
2415 | unmap_bio: | ||
2416 | /* if it was boucned we must call the end io function */ | 2422 | /* if it was boucned we must call the end io function */ |
2417 | bio_endio(bio, bio->bi_size, 0); | 2423 | bio_endio(bio, bio->bi_size, 0); |
2418 | __blk_rq_unmap_user(orig_bio); | 2424 | __blk_rq_unmap_user(orig_bio); |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index a417a6ff9f97..59b398530295 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -263,16 +263,7 @@ static int scsi_merge_bio(struct request *rq, struct bio *bio) | |||
263 | bio->bi_rw |= (1 << BIO_RW); | 263 | bio->bi_rw |= (1 << BIO_RW); |
264 | blk_queue_bounce(q, &bio); | 264 | blk_queue_bounce(q, &bio); |
265 | 265 | ||
266 | if (!rq->bio) | 266 | return blk_rq_append_bio(q, rq, bio); |
267 | blk_rq_bio_prep(q, rq, bio); | ||
268 | else if (!ll_back_merge_fn(q, rq, bio)) | ||
269 | return -EINVAL; | ||
270 | else { | ||
271 | rq->biotail->bi_next = bio; | ||
272 | rq->biotail = bio; | ||
273 | } | ||
274 | |||
275 | return 0; | ||
276 | } | 267 | } |
277 | 268 | ||
278 | static int scsi_bi_endio(struct bio *bio, unsigned int bytes_done, int error) | 269 | static int scsi_bi_endio(struct bio *bio, unsigned int bytes_done, int error) |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index a4b13b8a9d09..3021a5b1d392 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -675,8 +675,8 @@ extern int sg_scsi_ioctl(struct file *, struct request_queue *, | |||
675 | /* | 675 | /* |
676 | * Temporary export, until SCSI gets fixed up. | 676 | * Temporary export, until SCSI gets fixed up. |
677 | */ | 677 | */ |
678 | extern int ll_back_merge_fn(struct request_queue *, struct request *, | 678 | extern int blk_rq_append_bio(struct request_queue *q, struct request *rq, |
679 | struct bio *); | 679 | struct bio *bio); |
680 | 680 | ||
681 | /* | 681 | /* |
682 | * A queue has just exitted congestion. Note this in the global counter of | 682 | * A queue has just exitted congestion. Note this in the global counter of |