aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2008-03-04 05:17:11 -0500
committerJens Axboe <axboe@carl.home.kernel.dk>2008-03-04 05:17:11 -0500
commit7a85f8896f4b4a4a0249563b92af9e3161a6b467 (patch)
tree616c62e3c96237e874fc0f47133fbca2160913b5 /block
parent89b6e743788516491846724d7ef89bcac7ac9c99 (diff)
block: restore the meaning of rq->data_len to the true data length
The meaning of rq->data_len was changed to the length of an allocated buffer from the true data length. It breaks SG_IO friends and bsg. This patch restores the meaning of rq->data_len to the true data length and adds rq->extra_len to store an extended length (due to drain buffer and padding). This patch also removes the code to update bio in blk_rq_map_user introduced by the commit 40b01b9bbdf51ae543a04744283bf2d56c4a6afa. The commit adjusts bio according to memory alignment (queue_dma_alignment). However, memory alignment is NOT padding alignment. This adjustment also breaks SG_IO friends and bsg. Padding alignment needs to be fixed in a proper way (by a separate patch). Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Jens Axboe <axboe@carl.home.kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/blk-core.c3
-rw-r--r--block/blk-map.c6
-rw-r--r--block/blk-merge.c2
-rw-r--r--block/bsg.c8
-rw-r--r--block/scsi_ioctl.c4
5 files changed, 9 insertions, 14 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 2d7e3a2f56c..a248cf1c98d 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -127,7 +127,6 @@ void rq_init(struct request_queue *q, struct request *rq)
127 rq->nr_hw_segments = 0; 127 rq->nr_hw_segments = 0;
128 rq->ioprio = 0; 128 rq->ioprio = 0;
129 rq->special = NULL; 129 rq->special = NULL;
130 rq->raw_data_len = 0;
131 rq->buffer = NULL; 130 rq->buffer = NULL;
132 rq->tag = -1; 131 rq->tag = -1;
133 rq->errors = 0; 132 rq->errors = 0;
@@ -135,6 +134,7 @@ void rq_init(struct request_queue *q, struct request *rq)
135 rq->cmd_len = 0; 134 rq->cmd_len = 0;
136 memset(rq->cmd, 0, sizeof(rq->cmd)); 135 memset(rq->cmd, 0, sizeof(rq->cmd));
137 rq->data_len = 0; 136 rq->data_len = 0;
137 rq->extra_len = 0;
138 rq->sense_len = 0; 138 rq->sense_len = 0;
139 rq->data = NULL; 139 rq->data = NULL;
140 rq->sense = NULL; 140 rq->sense = NULL;
@@ -2018,7 +2018,6 @@ void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
2018 rq->hard_cur_sectors = rq->current_nr_sectors; 2018 rq->hard_cur_sectors = rq->current_nr_sectors;
2019 rq->hard_nr_sectors = rq->nr_sectors = bio_sectors(bio); 2019 rq->hard_nr_sectors = rq->nr_sectors = bio_sectors(bio);
2020 rq->buffer = bio_data(bio); 2020 rq->buffer = bio_data(bio);
2021 rq->raw_data_len = bio->bi_size;
2022 rq->data_len = bio->bi_size; 2021 rq->data_len = bio->bi_size;
2023 2022
2024 rq->bio = rq->biotail = bio; 2023 rq->bio = rq->biotail = bio;
diff --git a/block/blk-map.c b/block/blk-map.c
index 09f7fd0bcb7..f5598322954 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -19,7 +19,6 @@ int blk_rq_append_bio(struct request_queue *q, struct request *rq,
19 rq->biotail->bi_next = bio; 19 rq->biotail->bi_next = bio;
20 rq->biotail = bio; 20 rq->biotail = bio;
21 21
22 rq->raw_data_len += bio->bi_size;
23 rq->data_len += bio->bi_size; 22 rq->data_len += bio->bi_size;
24 } 23 }
25 return 0; 24 return 0;
@@ -151,11 +150,8 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq,
151 */ 150 */
152 if (len & queue_dma_alignment(q)) { 151 if (len & queue_dma_alignment(q)) {
153 unsigned int pad_len = (queue_dma_alignment(q) & ~len) + 1; 152 unsigned int pad_len = (queue_dma_alignment(q) & ~len) + 1;
154 struct bio *bio = rq->biotail;
155 153
156 bio->bi_io_vec[bio->bi_vcnt - 1].bv_len += pad_len; 154 rq->extra_len += pad_len;
157 bio->bi_size += pad_len;
158 rq->data_len += pad_len;
159 } 155 }
160 156
161 rq->buffer = rq->data = NULL; 157 rq->buffer = rq->data = NULL;
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 7506c4fe026..0f58616bcd7 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -231,7 +231,7 @@ new_segment:
231 ((unsigned long)q->dma_drain_buffer) & 231 ((unsigned long)q->dma_drain_buffer) &
232 (PAGE_SIZE - 1)); 232 (PAGE_SIZE - 1));
233 nsegs++; 233 nsegs++;
234 rq->data_len += q->dma_drain_size; 234 rq->extra_len += q->dma_drain_size;
235 } 235 }
236 236
237 if (sg) 237 if (sg)
diff --git a/block/bsg.c b/block/bsg.c
index 7f3c09549e4..8917c5174dc 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -437,14 +437,14 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr,
437 } 437 }
438 438
439 if (rq->next_rq) { 439 if (rq->next_rq) {
440 hdr->dout_resid = rq->raw_data_len; 440 hdr->dout_resid = rq->data_len;
441 hdr->din_resid = rq->next_rq->raw_data_len; 441 hdr->din_resid = rq->next_rq->data_len;
442 blk_rq_unmap_user(bidi_bio); 442 blk_rq_unmap_user(bidi_bio);
443 blk_put_request(rq->next_rq); 443 blk_put_request(rq->next_rq);
444 } else if (rq_data_dir(rq) == READ) 444 } else if (rq_data_dir(rq) == READ)
445 hdr->din_resid = rq->raw_data_len; 445 hdr->din_resid = rq->data_len;
446 else 446 else
447 hdr->dout_resid = rq->raw_data_len; 447 hdr->dout_resid = rq->data_len;
448 448
449 /* 449 /*
450 * If the request generated a negative error number, return it 450 * If the request generated a negative error number, return it
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index e993cac4911..a2c3a936ebf 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -266,7 +266,7 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
266 hdr->info = 0; 266 hdr->info = 0;
267 if (hdr->masked_status || hdr->host_status || hdr->driver_status) 267 if (hdr->masked_status || hdr->host_status || hdr->driver_status)
268 hdr->info |= SG_INFO_CHECK; 268 hdr->info |= SG_INFO_CHECK;
269 hdr->resid = rq->raw_data_len; 269 hdr->resid = rq->data_len;
270 hdr->sb_len_wr = 0; 270 hdr->sb_len_wr = 0;
271 271
272 if (rq->sense_len && hdr->sbp) { 272 if (rq->sense_len && hdr->sbp) {
@@ -528,8 +528,8 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk,
528 rq = blk_get_request(q, WRITE, __GFP_WAIT); 528 rq = blk_get_request(q, WRITE, __GFP_WAIT);
529 rq->cmd_type = REQ_TYPE_BLOCK_PC; 529 rq->cmd_type = REQ_TYPE_BLOCK_PC;
530 rq->data = NULL; 530 rq->data = NULL;
531 rq->raw_data_len = 0;
532 rq->data_len = 0; 531 rq->data_len = 0;
532 rq->extra_len = 0;
533 rq->timeout = BLK_DEFAULT_SG_TIMEOUT; 533 rq->timeout = BLK_DEFAULT_SG_TIMEOUT;
534 memset(rq->cmd, 0, sizeof(rq->cmd)); 534 memset(rq->cmd, 0, sizeof(rq->cmd));
535 rq->cmd[0] = cmd; 535 rq->cmd[0] = cmd;