diff options
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/floppy.c | 81 | ||||
-rw-r--r-- | drivers/block/lguest_blk.c | 10 | ||||
-rw-r--r-- | drivers/block/nbd.c | 22 | ||||
-rw-r--r-- | drivers/block/ps3disk.c | 31 | ||||
-rw-r--r-- | drivers/block/xen-blkfront.c | 7 |
5 files changed, 69 insertions, 82 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 085b7794fb3e..f0a86e201b44 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -2437,22 +2437,19 @@ static void rw_interrupt(void) | |||
2437 | /* Compute maximal contiguous buffer size. */ | 2437 | /* Compute maximal contiguous buffer size. */ |
2438 | static int buffer_chain_size(void) | 2438 | static int buffer_chain_size(void) |
2439 | { | 2439 | { |
2440 | struct bio *bio; | ||
2441 | struct bio_vec *bv; | 2440 | struct bio_vec *bv; |
2442 | int size, i; | 2441 | int size; |
2442 | struct req_iterator iter; | ||
2443 | char *base; | 2443 | char *base; |
2444 | 2444 | ||
2445 | base = bio_data(current_req->bio); | 2445 | base = bio_data(current_req->bio); |
2446 | size = 0; | 2446 | size = 0; |
2447 | 2447 | ||
2448 | rq_for_each_bio(bio, current_req) { | 2448 | rq_for_each_segment(bv, current_req, iter) { |
2449 | bio_for_each_segment(bv, bio, i) { | 2449 | if (page_address(bv->bv_page) + bv->bv_offset != base + size) |
2450 | if (page_address(bv->bv_page) + bv->bv_offset != | 2450 | break; |
2451 | base + size) | ||
2452 | break; | ||
2453 | 2451 | ||
2454 | size += bv->bv_len; | 2452 | size += bv->bv_len; |
2455 | } | ||
2456 | } | 2453 | } |
2457 | 2454 | ||
2458 | return size >> 9; | 2455 | return size >> 9; |
@@ -2479,9 +2476,9 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2) | |||
2479 | { | 2476 | { |
2480 | int remaining; /* number of transferred 512-byte sectors */ | 2477 | int remaining; /* number of transferred 512-byte sectors */ |
2481 | struct bio_vec *bv; | 2478 | struct bio_vec *bv; |
2482 | struct bio *bio; | ||
2483 | char *buffer, *dma_buffer; | 2479 | char *buffer, *dma_buffer; |
2484 | int size, i; | 2480 | int size; |
2481 | struct req_iterator iter; | ||
2485 | 2482 | ||
2486 | max_sector = transfer_size(ssize, | 2483 | max_sector = transfer_size(ssize, |
2487 | min(max_sector, max_sector_2), | 2484 | min(max_sector, max_sector_2), |
@@ -2514,43 +2511,41 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2) | |||
2514 | 2511 | ||
2515 | size = current_req->current_nr_sectors << 9; | 2512 | size = current_req->current_nr_sectors << 9; |
2516 | 2513 | ||
2517 | rq_for_each_bio(bio, current_req) { | 2514 | rq_for_each_segment(bv, current_req, iter) { |
2518 | bio_for_each_segment(bv, bio, i) { | 2515 | if (!remaining) |
2519 | if (!remaining) | 2516 | break; |
2520 | break; | ||
2521 | 2517 | ||
2522 | size = bv->bv_len; | 2518 | size = bv->bv_len; |
2523 | SUPBOUND(size, remaining); | 2519 | SUPBOUND(size, remaining); |
2524 | 2520 | ||
2525 | buffer = page_address(bv->bv_page) + bv->bv_offset; | 2521 | buffer = page_address(bv->bv_page) + bv->bv_offset; |
2526 | #ifdef FLOPPY_SANITY_CHECK | 2522 | #ifdef FLOPPY_SANITY_CHECK |
2527 | if (dma_buffer + size > | 2523 | if (dma_buffer + size > |
2528 | floppy_track_buffer + (max_buffer_sectors << 10) || | 2524 | floppy_track_buffer + (max_buffer_sectors << 10) || |
2529 | dma_buffer < floppy_track_buffer) { | 2525 | dma_buffer < floppy_track_buffer) { |
2530 | DPRINT("buffer overrun in copy buffer %d\n", | 2526 | DPRINT("buffer overrun in copy buffer %d\n", |
2531 | (int)((floppy_track_buffer - | 2527 | (int)((floppy_track_buffer - |
2532 | dma_buffer) >> 9)); | 2528 | dma_buffer) >> 9)); |
2533 | printk("fsector_t=%d buffer_min=%d\n", | 2529 | printk("fsector_t=%d buffer_min=%d\n", |
2534 | fsector_t, buffer_min); | 2530 | fsector_t, buffer_min); |
2535 | printk("current_count_sectors=%ld\n", | 2531 | printk("current_count_sectors=%ld\n", |
2536 | current_count_sectors); | 2532 | current_count_sectors); |
2537 | if (CT(COMMAND) == FD_READ) | ||
2538 | printk("read\n"); | ||
2539 | if (CT(COMMAND) == FD_WRITE) | ||
2540 | printk("write\n"); | ||
2541 | break; | ||
2542 | } | ||
2543 | if (((unsigned long)buffer) % 512) | ||
2544 | DPRINT("%p buffer not aligned\n", buffer); | ||
2545 | #endif | ||
2546 | if (CT(COMMAND) == FD_READ) | 2533 | if (CT(COMMAND) == FD_READ) |
2547 | memcpy(buffer, dma_buffer, size); | 2534 | printk("read\n"); |
2548 | else | 2535 | if (CT(COMMAND) == FD_WRITE) |
2549 | memcpy(dma_buffer, buffer, size); | 2536 | printk("write\n"); |
2550 | 2537 | break; | |
2551 | remaining -= size; | ||
2552 | dma_buffer += size; | ||
2553 | } | 2538 | } |
2539 | if (((unsigned long)buffer) % 512) | ||
2540 | DPRINT("%p buffer not aligned\n", buffer); | ||
2541 | #endif | ||
2542 | if (CT(COMMAND) == FD_READ) | ||
2543 | memcpy(buffer, dma_buffer, size); | ||
2544 | else | ||
2545 | memcpy(dma_buffer, buffer, size); | ||
2546 | |||
2547 | remaining -= size; | ||
2548 | dma_buffer += size; | ||
2554 | } | 2549 | } |
2555 | #ifdef FLOPPY_SANITY_CHECK | 2550 | #ifdef FLOPPY_SANITY_CHECK |
2556 | if (remaining) { | 2551 | if (remaining) { |
diff --git a/drivers/block/lguest_blk.c b/drivers/block/lguest_blk.c index 160cf14431ac..1e838ae60a60 100644 --- a/drivers/block/lguest_blk.c +++ b/drivers/block/lguest_blk.c | |||
@@ -142,12 +142,11 @@ static irqreturn_t lgb_irq(int irq, void *_bd) | |||
142 | * return the total length. */ | 142 | * return the total length. */ |
143 | static unsigned int req_to_dma(struct request *req, struct lguest_dma *dma) | 143 | static unsigned int req_to_dma(struct request *req, struct lguest_dma *dma) |
144 | { | 144 | { |
145 | unsigned int i = 0, idx, len = 0; | 145 | unsigned int i = 0, len = 0; |
146 | struct bio *bio; | 146 | struct req_iterator iter; |
147 | struct bio_vec *bvec; | ||
147 | 148 | ||
148 | rq_for_each_bio(bio, req) { | 149 | rq_for_each_segment(bvec, req, iter) { |
149 | struct bio_vec *bvec; | ||
150 | bio_for_each_segment(bvec, bio, idx) { | ||
151 | /* We told the block layer not to give us too many. */ | 150 | /* We told the block layer not to give us too many. */ |
152 | BUG_ON(i == LGUEST_MAX_DMA_SECTIONS); | 151 | BUG_ON(i == LGUEST_MAX_DMA_SECTIONS); |
153 | /* If we had a zero-length segment, it would look like | 152 | /* If we had a zero-length segment, it would look like |
@@ -160,7 +159,6 @@ static unsigned int req_to_dma(struct request *req, struct lguest_dma *dma) | |||
160 | dma->len[i] = bvec->bv_len; | 159 | dma->len[i] = bvec->bv_len; |
161 | len += bvec->bv_len; | 160 | len += bvec->bv_len; |
162 | i++; | 161 | i++; |
163 | } | ||
164 | } | 162 | } |
165 | /* If the array isn't full, we mark the end with a 0 length */ | 163 | /* If the array isn't full, we mark the end with a 0 length */ |
166 | if (i < LGUEST_MAX_DMA_SECTIONS) | 164 | if (i < LGUEST_MAX_DMA_SECTIONS) |
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index be92c658f06e..228b2ff577aa 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -180,7 +180,7 @@ static inline int sock_send_bvec(struct socket *sock, struct bio_vec *bvec, | |||
180 | 180 | ||
181 | static int nbd_send_req(struct nbd_device *lo, struct request *req) | 181 | static int nbd_send_req(struct nbd_device *lo, struct request *req) |
182 | { | 182 | { |
183 | int result, i, flags; | 183 | int result, flags; |
184 | struct nbd_request request; | 184 | struct nbd_request request; |
185 | unsigned long size = req->nr_sectors << 9; | 185 | unsigned long size = req->nr_sectors << 9; |
186 | struct socket *sock = lo->sock; | 186 | struct socket *sock = lo->sock; |
@@ -205,16 +205,15 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req) | |||
205 | } | 205 | } |
206 | 206 | ||
207 | if (nbd_cmd(req) == NBD_CMD_WRITE) { | 207 | if (nbd_cmd(req) == NBD_CMD_WRITE) { |
208 | struct bio *bio; | 208 | struct req_iterator iter; |
209 | struct bio_vec *bvec; | ||
209 | /* | 210 | /* |
210 | * we are really probing at internals to determine | 211 | * we are really probing at internals to determine |
211 | * whether to set MSG_MORE or not... | 212 | * whether to set MSG_MORE or not... |
212 | */ | 213 | */ |
213 | rq_for_each_bio(bio, req) { | 214 | rq_for_each_segment(bvec, req, iter) { |
214 | struct bio_vec *bvec; | ||
215 | bio_for_each_segment(bvec, bio, i) { | ||
216 | flags = 0; | 215 | flags = 0; |
217 | if ((i < (bio->bi_vcnt - 1)) || bio->bi_next) | 216 | if (!rq_iter_last(req, iter)) |
218 | flags = MSG_MORE; | 217 | flags = MSG_MORE; |
219 | dprintk(DBG_TX, "%s: request %p: sending %d bytes data\n", | 218 | dprintk(DBG_TX, "%s: request %p: sending %d bytes data\n", |
220 | lo->disk->disk_name, req, | 219 | lo->disk->disk_name, req, |
@@ -226,7 +225,6 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req) | |||
226 | result); | 225 | result); |
227 | goto error_out; | 226 | goto error_out; |
228 | } | 227 | } |
229 | } | ||
230 | } | 228 | } |
231 | } | 229 | } |
232 | return 0; | 230 | return 0; |
@@ -321,11 +319,10 @@ static struct request *nbd_read_stat(struct nbd_device *lo) | |||
321 | dprintk(DBG_RX, "%s: request %p: got reply\n", | 319 | dprintk(DBG_RX, "%s: request %p: got reply\n", |
322 | lo->disk->disk_name, req); | 320 | lo->disk->disk_name, req); |
323 | if (nbd_cmd(req) == NBD_CMD_READ) { | 321 | if (nbd_cmd(req) == NBD_CMD_READ) { |
324 | int i; | 322 | struct req_iterator iter; |
325 | struct bio *bio; | 323 | struct bio_vec *bvec; |
326 | rq_for_each_bio(bio, req) { | 324 | |
327 | struct bio_vec *bvec; | 325 | rq_for_each_segment(bvec, req, iter) { |
328 | bio_for_each_segment(bvec, bio, i) { | ||
329 | result = sock_recv_bvec(sock, bvec); | 326 | result = sock_recv_bvec(sock, bvec); |
330 | if (result <= 0) { | 327 | if (result <= 0) { |
331 | printk(KERN_ERR "%s: Receive data failed (result %d)\n", | 328 | printk(KERN_ERR "%s: Receive data failed (result %d)\n", |
@@ -336,7 +333,6 @@ static struct request *nbd_read_stat(struct nbd_device *lo) | |||
336 | } | 333 | } |
337 | dprintk(DBG_RX, "%s: request %p: got %d bytes data\n", | 334 | dprintk(DBG_RX, "%s: request %p: got %d bytes data\n", |
338 | lo->disk->disk_name, req, bvec->bv_len); | 335 | lo->disk->disk_name, req, bvec->bv_len); |
339 | } | ||
340 | } | 336 | } |
341 | } | 337 | } |
342 | return req; | 338 | return req; |
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c index aa8b890c80d7..8953e7ce0016 100644 --- a/drivers/block/ps3disk.c +++ b/drivers/block/ps3disk.c | |||
@@ -91,30 +91,30 @@ static void ps3disk_scatter_gather(struct ps3_storage_device *dev, | |||
91 | struct request *req, int gather) | 91 | struct request *req, int gather) |
92 | { | 92 | { |
93 | unsigned int offset = 0; | 93 | unsigned int offset = 0; |
94 | struct bio *bio; | 94 | struct req_iterator iter; |
95 | sector_t sector; | ||
96 | struct bio_vec *bvec; | 95 | struct bio_vec *bvec; |
97 | unsigned int i = 0, j; | 96 | unsigned int i = 0; |
98 | size_t size; | 97 | size_t size; |
99 | void *buf; | 98 | void *buf; |
100 | 99 | ||
101 | rq_for_each_bio(bio, req) { | 100 | rq_for_each_segment(bvec, req, iter) { |
102 | sector = bio->bi_sector; | 101 | unsigned long flags; |
103 | dev_dbg(&dev->sbd.core, | 102 | dev_dbg(&dev->sbd.core, |
104 | "%s:%u: bio %u: %u segs %u sectors from %lu\n", | 103 | "%s:%u: bio %u: %u segs %u sectors from %lu\n", |
105 | __func__, __LINE__, i, bio_segments(bio), | 104 | __func__, __LINE__, i, bio_segments(iter.bio), |
106 | bio_sectors(bio), sector); | 105 | bio_sectors(iter.bio), |
107 | bio_for_each_segment(bvec, bio, j) { | 106 | (unsigned long)iter.bio->bi_sector); |
107 | |||
108 | size = bvec->bv_len; | 108 | size = bvec->bv_len; |
109 | buf = __bio_kmap_atomic(bio, j, KM_IRQ0); | 109 | buf = bvec_kmap_irq(bvec, &flags); |
110 | if (gather) | 110 | if (gather) |
111 | memcpy(dev->bounce_buf+offset, buf, size); | 111 | memcpy(dev->bounce_buf+offset, buf, size); |
112 | else | 112 | else |
113 | memcpy(buf, dev->bounce_buf+offset, size); | 113 | memcpy(buf, dev->bounce_buf+offset, size); |
114 | offset += size; | 114 | offset += size; |
115 | flush_kernel_dcache_page(bio_iovec_idx(bio, j)->bv_page); | 115 | flush_kernel_dcache_page(bvec->bv_page); |
116 | __bio_kunmap_atomic(bio, KM_IRQ0); | 116 | bvec_kunmap_irq(bvec, &flags); |
117 | } | 117 | |
118 | i++; | 118 | i++; |
119 | } | 119 | } |
120 | } | 120 | } |
@@ -130,12 +130,13 @@ static int ps3disk_submit_request_sg(struct ps3_storage_device *dev, | |||
130 | 130 | ||
131 | #ifdef DEBUG | 131 | #ifdef DEBUG |
132 | unsigned int n = 0; | 132 | unsigned int n = 0; |
133 | struct bio *bio; | 133 | struct bio_vec *bv; |
134 | struct req_iterator iter; | ||
134 | 135 | ||
135 | rq_for_each_bio(bio, req) | 136 | rq_for_each_segment(bv, req, iter) |
136 | n++; | 137 | n++; |
137 | dev_dbg(&dev->sbd.core, | 138 | dev_dbg(&dev->sbd.core, |
138 | "%s:%u: %s req has %u bios for %lu sectors %lu hard sectors\n", | 139 | "%s:%u: %s req has %u bvecs for %lu sectors %lu hard sectors\n", |
139 | __func__, __LINE__, op, n, req->nr_sectors, | 140 | __func__, __LINE__, op, n, req->nr_sectors, |
140 | req->hard_nr_sectors); | 141 | req->hard_nr_sectors); |
141 | #endif | 142 | #endif |
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 964e51634f2d..6af250113c2a 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -150,9 +150,8 @@ static int blkif_queue_request(struct request *req) | |||
150 | struct blkfront_info *info = req->rq_disk->private_data; | 150 | struct blkfront_info *info = req->rq_disk->private_data; |
151 | unsigned long buffer_mfn; | 151 | unsigned long buffer_mfn; |
152 | struct blkif_request *ring_req; | 152 | struct blkif_request *ring_req; |
153 | struct bio *bio; | 153 | struct req_iterator iter; |
154 | struct bio_vec *bvec; | 154 | struct bio_vec *bvec; |
155 | int idx; | ||
156 | unsigned long id; | 155 | unsigned long id; |
157 | unsigned int fsect, lsect; | 156 | unsigned int fsect, lsect; |
158 | int ref; | 157 | int ref; |
@@ -186,8 +185,7 @@ static int blkif_queue_request(struct request *req) | |||
186 | ring_req->operation = BLKIF_OP_WRITE_BARRIER; | 185 | ring_req->operation = BLKIF_OP_WRITE_BARRIER; |
187 | 186 | ||
188 | ring_req->nr_segments = 0; | 187 | ring_req->nr_segments = 0; |
189 | rq_for_each_bio (bio, req) { | 188 | rq_for_each_segment(bvec, req, iter) { |
190 | bio_for_each_segment (bvec, bio, idx) { | ||
191 | BUG_ON(ring_req->nr_segments | 189 | BUG_ON(ring_req->nr_segments |
192 | == BLKIF_MAX_SEGMENTS_PER_REQUEST); | 190 | == BLKIF_MAX_SEGMENTS_PER_REQUEST); |
193 | buffer_mfn = pfn_to_mfn(page_to_pfn(bvec->bv_page)); | 191 | buffer_mfn = pfn_to_mfn(page_to_pfn(bvec->bv_page)); |
@@ -213,7 +211,6 @@ static int blkif_queue_request(struct request *req) | |||
213 | .last_sect = lsect }; | 211 | .last_sect = lsect }; |
214 | 212 | ||
215 | ring_req->nr_segments++; | 213 | ring_req->nr_segments++; |
216 | } | ||
217 | } | 214 | } |
218 | 215 | ||
219 | info->ring.req_prod_pvt++; | 216 | info->ring.req_prod_pvt++; |