Skip to content

Commit

Permalink
block: merge __bio_map_user_iov into bio_map_user_iov
Browse files Browse the repository at this point in the history
And also remove the unused bdev argument.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Ming Lei <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Feb 5, 2015
1 parent 75c72b8 commit 37f19e5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 38 deletions.
56 changes: 20 additions & 36 deletions block/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,10 +1244,18 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
return ERR_PTR(ret);
}

static struct bio *__bio_map_user_iov(struct request_queue *q,
struct block_device *bdev,
const struct iov_iter *iter,
gfp_t gfp_mask)
/**
* bio_map_user_iov - map user iovec into bio
* @q: the struct request_queue for the bio
* @iter: iovec iterator
* @gfp_mask: memory allocation flags
*
* Map the user space address into a bio suitable for io to a block
* device. Returns an error pointer in case of error.
*/
struct bio *bio_map_user_iov(struct request_queue *q,
const struct iov_iter *iter,
gfp_t gfp_mask)
{
int j;
int nr_pages = 0;
Expand Down Expand Up @@ -1343,8 +1351,15 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
if (iter->type & WRITE)
bio->bi_rw |= REQ_WRITE;

bio->bi_bdev = bdev;
bio->bi_flags |= (1 << BIO_USER_MAPPED);

/*
* subtle -- if __bio_map_user() ended up bouncing a bio,
* it would normally disappear when its bi_end_io is run.
* however, we need it for the unmap, so grab an extra
* reference to it
*/
bio_get(bio);
return bio;

out_unmap:
Expand All @@ -1359,37 +1374,6 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
return ERR_PTR(ret);
}

/**
* bio_map_user_iov - map user iovec into bio
* @q: the struct request_queue for the bio
* @bdev: destination block device
* @iter: iovec iterator
* @gfp_mask: memory allocation flags
*
* Map the user space address into a bio suitable for io to a block
* device. Returns an error pointer in case of error.
*/
struct bio *bio_map_user_iov(struct request_queue *q, struct block_device *bdev,
const struct iov_iter *iter,
gfp_t gfp_mask)
{
struct bio *bio;

bio = __bio_map_user_iov(q, bdev, iter, gfp_mask);
if (IS_ERR(bio))
return bio;

/*
* subtle -- if __bio_map_user() ended up bouncing a bio,
* it would normally disappear when its bi_end_io is run.
* however, we need it for the unmap, so grab an extra
* reference to it
*/
bio_get(bio);

return bio;
}

static void __bio_unmap_user(struct bio *bio)
{
struct bio_vec *bvec;
Expand Down
2 changes: 1 addition & 1 deletion block/blk-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
if (unaligned || (q->dma_pad_mask & iter->count) || map_data)
bio = bio_copy_user_iov(q, map_data, iter, gfp_mask);
else
bio = bio_map_user_iov(q, NULL, iter, gfp_mask);
bio = bio_map_user_iov(q, iter, gfp_mask);

if (IS_ERR(bio))
return PTR_ERR(bio);
Expand Down
1 change: 0 additions & 1 deletion include/linux/bio.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *,
extern int bio_get_nr_vecs(struct block_device *);
struct rq_map_data;
extern struct bio *bio_map_user_iov(struct request_queue *,
struct block_device *,
const struct iov_iter *, gfp_t);
extern void bio_unmap_user(struct bio *);
extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int,
Expand Down

0 comments on commit 37f19e5

Please sign in to comment.