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 /block/ll_rw_blk.c | |
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>
Diffstat (limited to 'block/ll_rw_blk.c')
-rw-r--r-- | block/ll_rw_blk.c | 38 |
1 files changed, 22 insertions, 16 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); |