Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 155244
b: refs/heads/master
c: ecb554a
h: refs/heads/master
v: v3
  • Loading branch information
FUJITA Tomonori authored and Jens Axboe committed Jul 10, 2009
1 parent eddb7bf commit d02d2f3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 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: 76da03467a1a78811777561bbb1fa56175ee4778
refs/heads/master: ecb554a846f8e9d2a58f6d6c118168a63ac065aa
4 changes: 4 additions & 0 deletions trunk/drivers/scsi/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,10 @@ static int sg_start_req(Sg_request *srp, unsigned char *cmd)
md->nr_entries = req_schp->k_use_sg;
md->offset = 0;
md->null_mapped = hp->dxferp ? 0 : 1;
if (dxfer_dir == SG_DXFER_TO_FROM_DEV)
md->from_user = 1;
else
md->from_user = 0;
}

if (iov_count) {
Expand Down
22 changes: 12 additions & 10 deletions trunk/fs/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,14 +705,13 @@ static struct bio_map_data *bio_alloc_map_data(int nr_segs, int iov_count,
}

static int __bio_copy_iov(struct bio *bio, struct bio_vec *iovecs,
struct sg_iovec *iov, int iov_count, int uncopy,
int do_free_page)
struct sg_iovec *iov, int iov_count,
int to_user, int from_user, int do_free_page)
{
int ret = 0, i;
struct bio_vec *bvec;
int iov_idx = 0;
unsigned int iov_off = 0;
int read = bio_data_dir(bio) == READ;

__bio_for_each_segment(bvec, bio, i, 0) {
char *bv_addr = page_address(bvec->bv_page);
Expand All @@ -727,13 +726,14 @@ static int __bio_copy_iov(struct bio *bio, struct bio_vec *iovecs,
iov_addr = iov[iov_idx].iov_base + iov_off;

if (!ret) {
if (!read && !uncopy)
ret = copy_from_user(bv_addr, iov_addr,
bytes);
if (read && uncopy)
if (to_user)
ret = copy_to_user(iov_addr, bv_addr,
bytes);

if (from_user)
ret = copy_from_user(bv_addr, iov_addr,
bytes);

if (ret)
ret = -EFAULT;
}
Expand Down Expand Up @@ -770,7 +770,8 @@ int bio_uncopy_user(struct bio *bio)

if (!bio_flagged(bio, BIO_NULL_MAPPED))
ret = __bio_copy_iov(bio, bmd->iovecs, bmd->sgvecs,
bmd->nr_sgvecs, 1, bmd->is_our_pages);
bmd->nr_sgvecs, bio_data_dir(bio) == READ,
0, bmd->is_our_pages);
bio_free_map_data(bmd);
bio_put(bio);
return ret;
Expand Down Expand Up @@ -875,8 +876,9 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
/*
* success
*/
if (!write_to_vm && (!map_data || !map_data->null_mapped)) {
ret = __bio_copy_iov(bio, bio->bi_io_vec, iov, iov_count, 0, 0);
if ((!write_to_vm && (!map_data || !map_data->null_mapped)) ||
(map_data && map_data->from_user)) {
ret = __bio_copy_iov(bio, bio->bi_io_vec, iov, iov_count, 0, 1, 0);
if (ret)
goto cleanup;
}
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ struct rq_map_data {
int nr_entries;
unsigned long offset;
int null_mapped;
int from_user;
};

struct req_iterator {
Expand Down

0 comments on commit d02d2f3

Please sign in to comment.