diff options
author | Jens Axboe <axboe@kernel.dk> | 2013-03-24 23:38:59 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2013-03-24 23:38:59 -0400 |
commit | 705cd0ea1cde2ce9225f1485c5a32c5841cacc5f (patch) | |
tree | 72bc2c5eded0e04fc5e70ca2bd6df93a2e264112 /block | |
parent | c8158819d506a8aedeca53c52dfb709a0aabe011 (diff) | |
parent | 29ed7813ce5c4661261aeebddb1b8660e0860223 (diff) |
Merge branch 'for-jens' of http://evilpiepirate.org/git/linux-bcache into for-3.10/core
This contains Kents prep work for the immutable bio_vecs.
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-core.c | 82 | ||||
-rw-r--r-- | block/cfq-iosched.c | 7 | ||||
-rw-r--r-- | block/deadline-iosched.c | 2 |
3 files changed, 16 insertions, 75 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 441f3488a766..f224d1793ee5 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -159,20 +159,10 @@ static void req_bio_endio(struct request *rq, struct bio *bio, | |||
159 | else if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) | 159 | else if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) |
160 | error = -EIO; | 160 | error = -EIO; |
161 | 161 | ||
162 | if (unlikely(nbytes > bio->bi_size)) { | ||
163 | printk(KERN_ERR "%s: want %u bytes done, %u left\n", | ||
164 | __func__, nbytes, bio->bi_size); | ||
165 | nbytes = bio->bi_size; | ||
166 | } | ||
167 | |||
168 | if (unlikely(rq->cmd_flags & REQ_QUIET)) | 162 | if (unlikely(rq->cmd_flags & REQ_QUIET)) |
169 | set_bit(BIO_QUIET, &bio->bi_flags); | 163 | set_bit(BIO_QUIET, &bio->bi_flags); |
170 | 164 | ||
171 | bio->bi_size -= nbytes; | 165 | bio_advance(bio, nbytes); |
172 | bio->bi_sector += (nbytes >> 9); | ||
173 | |||
174 | if (bio_integrity(bio)) | ||
175 | bio_integrity_advance(bio, nbytes); | ||
176 | 166 | ||
177 | /* don't actually finish bio if it's part of flush sequence */ | 167 | /* don't actually finish bio if it's part of flush sequence */ |
178 | if (bio->bi_size == 0 && !(rq->cmd_flags & REQ_FLUSH_SEQ)) | 168 | if (bio->bi_size == 0 && !(rq->cmd_flags & REQ_FLUSH_SEQ)) |
@@ -1609,7 +1599,7 @@ static void handle_bad_sector(struct bio *bio) | |||
1609 | printk(KERN_INFO "%s: rw=%ld, want=%Lu, limit=%Lu\n", | 1599 | printk(KERN_INFO "%s: rw=%ld, want=%Lu, limit=%Lu\n", |
1610 | bdevname(bio->bi_bdev, b), | 1600 | bdevname(bio->bi_bdev, b), |
1611 | bio->bi_rw, | 1601 | bio->bi_rw, |
1612 | (unsigned long long)bio->bi_sector + bio_sectors(bio), | 1602 | (unsigned long long)bio_end_sector(bio), |
1613 | (long long)(i_size_read(bio->bi_bdev->bd_inode) >> 9)); | 1603 | (long long)(i_size_read(bio->bi_bdev->bd_inode) >> 9)); |
1614 | 1604 | ||
1615 | set_bit(BIO_EOF, &bio->bi_flags); | 1605 | set_bit(BIO_EOF, &bio->bi_flags); |
@@ -2292,8 +2282,7 @@ EXPORT_SYMBOL(blk_fetch_request); | |||
2292 | **/ | 2282 | **/ |
2293 | bool blk_update_request(struct request *req, int error, unsigned int nr_bytes) | 2283 | bool blk_update_request(struct request *req, int error, unsigned int nr_bytes) |
2294 | { | 2284 | { |
2295 | int total_bytes, bio_nbytes, next_idx = 0; | 2285 | int total_bytes; |
2296 | struct bio *bio; | ||
2297 | 2286 | ||
2298 | if (!req->bio) | 2287 | if (!req->bio) |
2299 | return false; | 2288 | return false; |
@@ -2339,56 +2328,21 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes) | |||
2339 | 2328 | ||
2340 | blk_account_io_completion(req, nr_bytes); | 2329 | blk_account_io_completion(req, nr_bytes); |
2341 | 2330 | ||
2342 | total_bytes = bio_nbytes = 0; | 2331 | total_bytes = 0; |
2343 | while ((bio = req->bio) != NULL) { | 2332 | while (req->bio) { |
2344 | int nbytes; | 2333 | struct bio *bio = req->bio; |
2334 | unsigned bio_bytes = min(bio->bi_size, nr_bytes); | ||
2345 | 2335 | ||
2346 | if (nr_bytes >= bio->bi_size) { | 2336 | if (bio_bytes == bio->bi_size) |
2347 | req->bio = bio->bi_next; | 2337 | req->bio = bio->bi_next; |
2348 | nbytes = bio->bi_size; | ||
2349 | req_bio_endio(req, bio, nbytes, error); | ||
2350 | next_idx = 0; | ||
2351 | bio_nbytes = 0; | ||
2352 | } else { | ||
2353 | int idx = bio->bi_idx + next_idx; | ||
2354 | |||
2355 | if (unlikely(idx >= bio->bi_vcnt)) { | ||
2356 | blk_dump_rq_flags(req, "__end_that"); | ||
2357 | printk(KERN_ERR "%s: bio idx %d >= vcnt %d\n", | ||
2358 | __func__, idx, bio->bi_vcnt); | ||
2359 | break; | ||
2360 | } | ||
2361 | |||
2362 | nbytes = bio_iovec_idx(bio, idx)->bv_len; | ||
2363 | BIO_BUG_ON(nbytes > bio->bi_size); | ||
2364 | |||
2365 | /* | ||
2366 | * not a complete bvec done | ||
2367 | */ | ||
2368 | if (unlikely(nbytes > nr_bytes)) { | ||
2369 | bio_nbytes += nr_bytes; | ||
2370 | total_bytes += nr_bytes; | ||
2371 | break; | ||
2372 | } | ||
2373 | 2338 | ||
2374 | /* | 2339 | req_bio_endio(req, bio, bio_bytes, error); |
2375 | * advance to the next vector | ||
2376 | */ | ||
2377 | next_idx++; | ||
2378 | bio_nbytes += nbytes; | ||
2379 | } | ||
2380 | 2340 | ||
2381 | total_bytes += nbytes; | 2341 | total_bytes += bio_bytes; |
2382 | nr_bytes -= nbytes; | 2342 | nr_bytes -= bio_bytes; |
2383 | 2343 | ||
2384 | bio = req->bio; | 2344 | if (!nr_bytes) |
2385 | if (bio) { | 2345 | break; |
2386 | /* | ||
2387 | * end more in this run, or just return 'not-done' | ||
2388 | */ | ||
2389 | if (unlikely(nr_bytes <= 0)) | ||
2390 | break; | ||
2391 | } | ||
2392 | } | 2346 | } |
2393 | 2347 | ||
2394 | /* | 2348 | /* |
@@ -2404,16 +2358,6 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes) | |||
2404 | return false; | 2358 | return false; |
2405 | } | 2359 | } |
2406 | 2360 | ||
2407 | /* | ||
2408 | * if the request wasn't completed, update state | ||
2409 | */ | ||
2410 | if (bio_nbytes) { | ||
2411 | req_bio_endio(req, bio, bio_nbytes, error); | ||
2412 | bio->bi_idx += next_idx; | ||
2413 | bio_iovec(bio)->bv_offset += nr_bytes; | ||
2414 | bio_iovec(bio)->bv_len -= nr_bytes; | ||
2415 | } | ||
2416 | |||
2417 | req->__data_len -= total_bytes; | 2361 | req->__data_len -= total_bytes; |
2418 | req->buffer = bio_data(req->bio); | 2362 | req->buffer = bio_data(req->bio); |
2419 | 2363 | ||
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index 4f0ade74cfd0..d5cd3131c57a 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c | |||
@@ -2270,11 +2270,8 @@ cfq_find_rq_fmerge(struct cfq_data *cfqd, struct bio *bio) | |||
2270 | return NULL; | 2270 | return NULL; |
2271 | 2271 | ||
2272 | cfqq = cic_to_cfqq(cic, cfq_bio_sync(bio)); | 2272 | cfqq = cic_to_cfqq(cic, cfq_bio_sync(bio)); |
2273 | if (cfqq) { | 2273 | if (cfqq) |
2274 | sector_t sector = bio->bi_sector + bio_sectors(bio); | 2274 | return elv_rb_find(&cfqq->sort_list, bio_end_sector(bio)); |
2275 | |||
2276 | return elv_rb_find(&cfqq->sort_list, sector); | ||
2277 | } | ||
2278 | 2275 | ||
2279 | return NULL; | 2276 | return NULL; |
2280 | } | 2277 | } |
diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c index 90037b5eb17f..ba19a3afab79 100644 --- a/block/deadline-iosched.c +++ b/block/deadline-iosched.c | |||
@@ -132,7 +132,7 @@ deadline_merge(struct request_queue *q, struct request **req, struct bio *bio) | |||
132 | * check for front merge | 132 | * check for front merge |
133 | */ | 133 | */ |
134 | if (dd->front_merges) { | 134 | if (dd->front_merges) { |
135 | sector_t sector = bio->bi_sector + bio_sectors(bio); | 135 | sector_t sector = bio_end_sector(bio); |
136 | 136 | ||
137 | __rq = elv_rb_find(&dd->sort_list[bio_data_dir(bio)], sector); | 137 | __rq = elv_rb_find(&dd->sort_list[bio_data_dir(bio)], sector); |
138 | if (__rq) { | 138 | if (__rq) { |