Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 91733
b: refs/heads/master
c: f18573a
h: refs/heads/master
i:
  91731: 10ace2a
v: v3
  • Loading branch information
FUJITA Tomonori authored and Jens Axboe committed Apr 21, 2008
1 parent cd4c607 commit c8d4eff
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 21 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: afdc1a780ef84a54b613dae6f971407748aab61c
refs/heads/master: f18573abcc57844a7c3c12699d40eead8728cd8a
24 changes: 5 additions & 19 deletions trunk/block/blk-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,25 +141,8 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq,
ubuf += ret;
}

/*
* __blk_rq_map_user() copies the buffers if starting address
* or length isn't aligned to dma_pad_mask. As the copied
* buffer is always page aligned, we know that there's enough
* room for padding. Extend the last bio and update
* rq->data_len accordingly.
*
* On unmap, bio_uncopy_user() will use unmodified
* bio_map_data pointed to by bio->bi_private.
*/
if (len & q->dma_pad_mask) {
unsigned int pad_len = (q->dma_pad_mask & ~len) + 1;
struct bio *tail = rq->biotail;

tail->bi_io_vec[tail->bi_vcnt - 1].bv_len += pad_len;
tail->bi_size += pad_len;

rq->extra_len += pad_len;
}
if (!bio_flagged(bio, BIO_USER_MAPPED))
rq->cmd_flags |= REQ_COPY_USER;

rq->buffer = rq->data = NULL;
return 0;
Expand Down Expand Up @@ -224,6 +207,9 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
return -EINVAL;
}

if (!bio_flagged(bio, BIO_USER_MAPPED))
rq->cmd_flags |= REQ_COPY_USER;

bio_get(bio);
blk_rq_bio_prep(q, rq, bio);
rq->buffer = rq->data = NULL;
Expand Down
9 changes: 9 additions & 0 deletions trunk/block/blk-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,15 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq,
bvprv = bvec;
} /* segments in rq */


if (unlikely(rq->cmd_flags & REQ_COPY_USER) &&
(rq->data_len & q->dma_pad_mask)) {
unsigned int pad_len = (q->dma_pad_mask & ~rq->data_len) + 1;

sg->length += pad_len;
rq->extra_len += pad_len;
}

if (q->dma_drain_size && q->dma_drain_needed(rq)) {
if (rq->cmd_flags & REQ_RW)
memset(q->dma_drain_buffer, 0, q->dma_drain_size);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/scsi/scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
"Notifying upper driver of completion "
"(result %x)\n", cmd->result));

good_bytes = scsi_bufflen(cmd) + cmd->request->extra_len;
good_bytes = scsi_bufflen(cmd);
if (cmd->request->cmd_type != REQ_TYPE_BLOCK_PC) {
drv = scsi_cmd_to_driver(cmd);
if (drv->done)
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ enum rq_flag_bits {
__REQ_RW_SYNC, /* request is sync (O_DIRECT) */
__REQ_ALLOCED, /* request came from our alloc pool */
__REQ_RW_META, /* metadata io request */
__REQ_COPY_USER, /* contains copies of user pages */
__REQ_NR_BITS, /* stops here */
};

Expand All @@ -133,6 +134,7 @@ enum rq_flag_bits {
#define REQ_RW_SYNC (1 << __REQ_RW_SYNC)
#define REQ_ALLOCED (1 << __REQ_ALLOCED)
#define REQ_RW_META (1 << __REQ_RW_META)
#define REQ_COPY_USER (1 << __REQ_COPY_USER)

#define BLK_MAX_CDB 16

Expand Down

0 comments on commit c8d4eff

Please sign in to comment.