aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
Diffstat (limited to 'block')
-rw-r--r--block/blk-map.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/block/blk-map.c b/block/blk-map.c
index dad6a2907835..572140cda5ff 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -45,7 +45,6 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
45 unsigned int len, gfp_t gfp_mask) 45 unsigned int len, gfp_t gfp_mask)
46{ 46{
47 unsigned long uaddr; 47 unsigned long uaddr;
48 unsigned int alignment;
49 struct bio *bio, *orig_bio; 48 struct bio *bio, *orig_bio;
50 int reading, ret; 49 int reading, ret;
51 50
@@ -56,8 +55,7 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
56 * direct dma. else, set up kernel bounce buffers 55 * direct dma. else, set up kernel bounce buffers
57 */ 56 */
58 uaddr = (unsigned long) ubuf; 57 uaddr = (unsigned long) ubuf;
59 alignment = queue_dma_alignment(q) | q->dma_pad_mask; 58 if (blk_rq_aligned(q, ubuf, len) && !map_data)
60 if (!(uaddr & alignment) && !(len & alignment) && !map_data)
61 bio = bio_map_user(q, NULL, uaddr, len, reading, gfp_mask); 59 bio = bio_map_user(q, NULL, uaddr, len, reading, gfp_mask);
62 else 60 else
63 bio = bio_copy_user(q, map_data, uaddr, len, reading, gfp_mask); 61 bio = bio_copy_user(q, map_data, uaddr, len, reading, gfp_mask);
@@ -274,8 +272,6 @@ EXPORT_SYMBOL(blk_rq_unmap_user);
274int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf, 272int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
275 unsigned int len, gfp_t gfp_mask) 273 unsigned int len, gfp_t gfp_mask)
276{ 274{
277 unsigned long kaddr;
278 unsigned int alignment;
279 int reading = rq_data_dir(rq) == READ; 275 int reading = rq_data_dir(rq) == READ;
280 int do_copy = 0; 276 int do_copy = 0;
281 struct bio *bio; 277 struct bio *bio;
@@ -285,11 +281,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
285 if (!len || !kbuf) 281 if (!len || !kbuf)
286 return -EINVAL; 282 return -EINVAL;
287 283
288 kaddr = (unsigned long)kbuf; 284 do_copy = !blk_rq_aligned(q, kbuf, len) || object_is_on_stack(kbuf);
289 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
290 do_copy = ((kaddr & alignment) || (len & alignment) ||
291 object_is_on_stack(kbuf));
292
293 if (do_copy) 285 if (do_copy)
294 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading); 286 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
295 else 287 else