Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 91732
b: refs/heads/master
c: afdc1a7
h: refs/heads/master
v: v3
  • Loading branch information
FUJITA Tomonori authored and Jens Axboe committed Apr 21, 2008
1 parent 10ace2a commit cd4c607
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c5dec1c3034f1ae3503efbf641ff3b0273b64797
refs/heads/master: afdc1a780ef84a54b613dae6f971407748aab61c
22 changes: 17 additions & 5 deletions trunk/block/blk-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <linux/module.h>
#include <linux/bio.h>
#include <linux/blkdev.h>
#include <scsi/sg.h> /* for struct sg_iovec */

#include "blk.h"

Expand Down Expand Up @@ -194,15 +195,26 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
struct sg_iovec *iov, int iov_count, unsigned int len)
{
struct bio *bio;
int i, read = rq_data_dir(rq) == READ;
int unaligned = 0;

if (!iov || iov_count <= 0)
return -EINVAL;

/* we don't allow misaligned data like bio_map_user() does. If the
* user is using sg, they're expected to know the alignment constraints
* and respect them accordingly */
bio = bio_map_user_iov(q, NULL, iov, iov_count,
rq_data_dir(rq) == READ);
for (i = 0; i < iov_count; i++) {
unsigned long uaddr = (unsigned long)iov[i].iov_base;

if (uaddr & queue_dma_alignment(q)) {
unaligned = 1;
break;
}
}

if (unaligned || (q->dma_pad_mask & len))
bio = bio_copy_user_iov(q, iov, iov_count, read);
else
bio = bio_map_user_iov(q, NULL, iov, iov_count, read);

if (IS_ERR(bio))
return PTR_ERR(bio);

Expand Down

0 comments on commit cd4c607

Please sign in to comment.