提交 3001ca77 编写于 作者: N NeilBrown 提交者: Jens Axboe

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: NNeil Brown <neilb@suse.de>

diff .prev/block/ll_rw_blk.c ./block/ll_rw_blk.c
Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
上级 eea9befa
...@@ -1441,7 +1441,8 @@ static inline int ll_new_hw_segment(struct request_queue *q, ...@@ -1441,7 +1441,8 @@ static inline int ll_new_hw_segment(struct request_queue *q,
return 1; 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; unsigned short max_sectors;
int len; int len;
...@@ -1477,7 +1478,6 @@ int ll_back_merge_fn(struct request_queue *q, struct request *req, struct bio *b ...@@ -1477,7 +1478,6 @@ int ll_back_merge_fn(struct request_queue *q, struct request *req, struct bio *b
return ll_new_hw_segment(q, req, bio); 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, static int ll_front_merge_fn(struct request_queue *q, struct request *req,
struct bio *bio) struct bio *bio)
...@@ -2367,6 +2367,23 @@ static int __blk_rq_unmap_user(struct bio *bio) ...@@ -2367,6 +2367,23 @@ static int __blk_rq_unmap_user(struct bio *bio)
return ret; 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, static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
void __user *ubuf, unsigned int len) void __user *ubuf, unsigned int len)
{ {
...@@ -2398,21 +2415,10 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq, ...@@ -2398,21 +2415,10 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
*/ */
bio_get(bio); bio_get(bio);
if (!rq->bio) ret = blk_rq_append_bio(q, rq, bio);
blk_rq_bio_prep(q, rq, bio); if (!ret)
else if (!ll_back_merge_fn(q, rq, bio)) { return bio->bi_size;
ret = -EINVAL;
goto unmap_bio;
} else {
rq->biotail->bi_next = bio;
rq->biotail = bio;
rq->data_len += bio->bi_size;
}
return bio->bi_size;
unmap_bio:
/* if it was boucned we must call the end io function */ /* if it was boucned we must call the end io function */
bio_endio(bio, bio->bi_size, 0); bio_endio(bio, bio->bi_size, 0);
__blk_rq_unmap_user(orig_bio); __blk_rq_unmap_user(orig_bio);
......
...@@ -263,16 +263,7 @@ static int scsi_merge_bio(struct request *rq, struct bio *bio) ...@@ -263,16 +263,7 @@ static int scsi_merge_bio(struct request *rq, struct bio *bio)
bio->bi_rw |= (1 << BIO_RW); bio->bi_rw |= (1 << BIO_RW);
blk_queue_bounce(q, &bio); blk_queue_bounce(q, &bio);
if (!rq->bio) return blk_rq_append_bio(q, 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;
} }
static int scsi_bi_endio(struct bio *bio, unsigned int bytes_done, int error) static int scsi_bi_endio(struct bio *bio, unsigned int bytes_done, int error)
......
...@@ -675,8 +675,8 @@ extern int sg_scsi_ioctl(struct file *, struct request_queue *, ...@@ -675,8 +675,8 @@ extern int sg_scsi_ioctl(struct file *, struct request_queue *,
/* /*
* Temporary export, until SCSI gets fixed up. * Temporary export, until SCSI gets fixed up.
*/ */
extern int ll_back_merge_fn(struct request_queue *, struct request *, extern int blk_rq_append_bio(struct request_queue *q, struct request *rq,
struct bio *); struct bio *bio);
/* /*
* A queue has just exitted congestion. Note this in the global counter of * A queue has just exitted congestion. Note this in the global counter of
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册