mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
block: add gfp_mask argument to blk_rq_map_user and blk_rq_map_user_iov
Currently, blk_rq_map_user and blk_rq_map_user_iov always do GFP_KERNEL allocation. This adds gfp_mask argument to blk_rq_map_user and blk_rq_map_user_iov so sg can use it (sg always does GFP_ATOMIC allocation). Signed-off-by: FUJITA Tomonori <[email protected]> Signed-off-by: Douglas Gilbert <[email protected]> Cc: Mike Christie <[email protected]> Cc: James Bottomley <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
parent
45333d5a31
commit
a3bce90edd
8 changed files with 47 additions and 34 deletions
|
|
@ -41,7 +41,8 @@ static int __blk_rq_unmap_user(struct bio *bio)
|
|||
}
|
||||
|
||||
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,
|
||||
gfp_t gfp_mask)
|
||||
{
|
||||
unsigned long uaddr;
|
||||
unsigned int alignment;
|
||||
|
|
@ -57,9 +58,9 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
|
|||
uaddr = (unsigned long) ubuf;
|
||||
alignment = queue_dma_alignment(q) | q->dma_pad_mask;
|
||||
if (!(uaddr & alignment) && !(len & alignment))
|
||||
bio = bio_map_user(q, NULL, uaddr, len, reading);
|
||||
bio = bio_map_user(q, NULL, uaddr, len, reading, gfp_mask);
|
||||
else
|
||||
bio = bio_copy_user(q, uaddr, len, reading);
|
||||
bio = bio_copy_user(q, uaddr, len, reading, gfp_mask);
|
||||
|
||||
if (IS_ERR(bio))
|
||||
return PTR_ERR(bio);
|
||||
|
|
@ -90,6 +91,7 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
|
|||
* @rq: request structure to fill
|
||||
* @ubuf: the user buffer
|
||||
* @len: length of user data
|
||||
* @gfp_mask: memory allocation flags
|
||||
*
|
||||
* Description:
|
||||
* Data will be mapped directly for zero copy I/O, if possible. Otherwise
|
||||
|
|
@ -105,7 +107,7 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
|
|||
* unmapping.
|
||||
*/
|
||||
int blk_rq_map_user(struct request_queue *q, struct request *rq,
|
||||
void __user *ubuf, unsigned long len)
|
||||
void __user *ubuf, unsigned long len, gfp_t gfp_mask)
|
||||
{
|
||||
unsigned long bytes_read = 0;
|
||||
struct bio *bio = NULL;
|
||||
|
|
@ -132,7 +134,7 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq,
|
|||
if (end - start > BIO_MAX_PAGES)
|
||||
map_len -= PAGE_SIZE;
|
||||
|
||||
ret = __blk_rq_map_user(q, rq, ubuf, map_len);
|
||||
ret = __blk_rq_map_user(q, rq, ubuf, map_len, gfp_mask);
|
||||
if (ret < 0)
|
||||
goto unmap_rq;
|
||||
if (!bio)
|
||||
|
|
@ -160,6 +162,7 @@ EXPORT_SYMBOL(blk_rq_map_user);
|
|||
* @iov: pointer to the iovec
|
||||
* @iov_count: number of elements in the iovec
|
||||
* @len: I/O byte count
|
||||
* @gfp_mask: memory allocation flags
|
||||
*
|
||||
* Description:
|
||||
* Data will be mapped directly for zero copy I/O, if possible. Otherwise
|
||||
|
|
@ -175,7 +178,8 @@ EXPORT_SYMBOL(blk_rq_map_user);
|
|||
* unmapping.
|
||||
*/
|
||||
int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
|
||||
struct sg_iovec *iov, int iov_count, unsigned int len)
|
||||
struct sg_iovec *iov, int iov_count, unsigned int len,
|
||||
gfp_t gfp_mask)
|
||||
{
|
||||
struct bio *bio;
|
||||
int i, read = rq_data_dir(rq) == READ;
|
||||
|
|
@ -194,9 +198,9 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
|
|||
}
|
||||
|
||||
if (unaligned || (q->dma_pad_mask & len))
|
||||
bio = bio_copy_user_iov(q, iov, iov_count, read);
|
||||
bio = bio_copy_user_iov(q, iov, iov_count, read, gfp_mask);
|
||||
else
|
||||
bio = bio_map_user_iov(q, NULL, iov, iov_count, read);
|
||||
bio = bio_map_user_iov(q, NULL, iov, iov_count, read, gfp_mask);
|
||||
|
||||
if (IS_ERR(bio))
|
||||
return PTR_ERR(bio);
|
||||
|
|
|
|||
|
|
@ -283,7 +283,8 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, int has_write_perm)
|
|||
next_rq->cmd_type = rq->cmd_type;
|
||||
|
||||
dxferp = (void*)(unsigned long)hdr->din_xferp;
|
||||
ret = blk_rq_map_user(q, next_rq, dxferp, hdr->din_xfer_len);
|
||||
ret = blk_rq_map_user(q, next_rq, dxferp, hdr->din_xfer_len,
|
||||
GFP_KERNEL);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -298,7 +299,7 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, int has_write_perm)
|
|||
dxfer_len = 0;
|
||||
|
||||
if (dxfer_len) {
|
||||
ret = blk_rq_map_user(q, rq, dxferp, dxfer_len);
|
||||
ret = blk_rq_map_user(q, rq, dxferp, dxfer_len, GFP_KERNEL);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -315,10 +315,11 @@ static int sg_io(struct file *file, struct request_queue *q,
|
|||
}
|
||||
|
||||
ret = blk_rq_map_user_iov(q, rq, iov, hdr->iovec_count,
|
||||
hdr->dxfer_len);
|
||||
hdr->dxfer_len, GFP_KERNEL);
|
||||
kfree(iov);
|
||||
} else if (hdr->dxfer_len)
|
||||
ret = blk_rq_map_user(q, rq, hdr->dxferp, hdr->dxfer_len);
|
||||
ret = blk_rq_map_user(q, rq, hdr->dxferp, hdr->dxfer_len,
|
||||
GFP_KERNEL);
|
||||
|
||||
if (ret)
|
||||
goto out;
|
||||
|
|
|
|||
Loading…
Reference in a new issue