Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'post-2.6.15' of git://brick.kernel.dk/data/git/linux-2.6-block

Manual fixup for merge with Jens' "Suspend support for libata", commit
ID 9b847548663ef1039dd49f0eb4463d001e596bc3.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>

+707 -656
+2 -8
Documentation/block/biodoc.txt
··· 263 263 The generic i/o scheduler would make sure that it places the barrier request and 264 264 all other requests coming after it after all the previous requests in the 265 265 queue. Barriers may be implemented in different ways depending on the 266 - driver. A SCSI driver for example could make use of ordered tags to 267 - preserve the necessary ordering with a lower impact on throughput. For IDE 268 - this might be two sync cache flush: a pre and post flush when encountering 269 - a barrier write. 270 - 271 - There is a provision for queues to indicate what kind of barriers they 272 - can provide. This is as of yet unmerged, details will be added here once it 273 - is in the kernel. 266 + driver. For more details regarding I/O barriers, please read barrier.txt 267 + in this directory. 274 268 275 269 1.2.2 Request Priority/Latency 276 270
+25 -119
block/as-iosched.c
··· 182 182 183 183 static kmem_cache_t *arq_pool; 184 184 185 + static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq); 186 + static void as_antic_stop(struct as_data *ad); 187 + 185 188 /* 186 189 * IO Context helper functions 187 190 */ ··· 373 370 * existing request against the same sector), which can happen when using 374 371 * direct IO, then return the alias. 375 372 */ 376 - static struct as_rq *as_add_arq_rb(struct as_data *ad, struct as_rq *arq) 373 + static struct as_rq *__as_add_arq_rb(struct as_data *ad, struct as_rq *arq) 377 374 { 378 375 struct rb_node **p = &ARQ_RB_ROOT(ad, arq)->rb_node; 379 376 struct rb_node *parent = NULL; ··· 398 395 rb_insert_color(&arq->rb_node, ARQ_RB_ROOT(ad, arq)); 399 396 400 397 return NULL; 398 + } 399 + 400 + static void as_add_arq_rb(struct as_data *ad, struct as_rq *arq) 401 + { 402 + struct as_rq *alias; 403 + 404 + while ((unlikely(alias = __as_add_arq_rb(ad, arq)))) { 405 + as_move_to_dispatch(ad, alias); 406 + as_antic_stop(ad); 407 + } 401 408 } 402 409 403 410 static inline void as_del_arq_rb(struct as_data *ad, struct as_rq *arq) ··· 1146 1133 /* 1147 1134 * take it off the sort and fifo list, add to dispatch queue 1148 1135 */ 1149 - while (!list_empty(&rq->queuelist)) { 1150 - struct request *__rq = list_entry_rq(rq->queuelist.next); 1151 - struct as_rq *__arq = RQ_DATA(__rq); 1152 - 1153 - list_del(&__rq->queuelist); 1154 - 1155 - elv_dispatch_add_tail(ad->q, __rq); 1156 - 1157 - if (__arq->io_context && __arq->io_context->aic) 1158 - atomic_inc(&__arq->io_context->aic->nr_dispatched); 1159 - 1160 - WARN_ON(__arq->state != AS_RQ_QUEUED); 1161 - __arq->state = AS_RQ_DISPATCHED; 1162 - 1163 - ad->nr_dispatched++; 1164 - } 1165 - 1166 1136 as_remove_queued_request(ad->q, rq); 1167 1137 WARN_ON(arq->state != AS_RQ_QUEUED); 1168 1138 ··· 1322 1326 } 1323 1327 1324 1328 /* 1325 - * Add arq to a list behind alias 1326 - */ 1327 - static inline void 1328 - as_add_aliased_request(struct as_data *ad, struct as_rq *arq, 1329 - struct as_rq *alias) 1330 - { 1331 - struct request *req = arq->request; 1332 - struct list_head *insert = alias->request->queuelist.prev; 1333 - 1334 - /* 1335 - * Transfer list of aliases 1336 - */ 1337 - while (!list_empty(&req->queuelist)) { 1338 - struct request *__rq = list_entry_rq(req->queuelist.next); 1339 - struct as_rq *__arq = RQ_DATA(__rq); 1340 - 1341 - list_move_tail(&__rq->queuelist, &alias->request->queuelist); 1342 - 1343 - WARN_ON(__arq->state != AS_RQ_QUEUED); 1344 - } 1345 - 1346 - /* 1347 - * Another request with the same start sector on the rbtree. 1348 - * Link this request to that sector. They are untangled in 1349 - * as_move_to_dispatch 1350 - */ 1351 - list_add(&arq->request->queuelist, insert); 1352 - 1353 - /* 1354 - * Don't want to have to handle merges. 1355 - */ 1356 - as_del_arq_hash(arq); 1357 - arq->request->flags |= REQ_NOMERGE; 1358 - } 1359 - 1360 - /* 1361 1329 * add arq to rbtree and fifo 1362 1330 */ 1363 1331 static void as_add_request(request_queue_t *q, struct request *rq) 1364 1332 { 1365 1333 struct as_data *ad = q->elevator->elevator_data; 1366 1334 struct as_rq *arq = RQ_DATA(rq); 1367 - struct as_rq *alias; 1368 1335 int data_dir; 1369 1336 1370 1337 arq->state = AS_RQ_NEW; ··· 1346 1387 atomic_inc(&arq->io_context->aic->nr_queued); 1347 1388 } 1348 1389 1349 - alias = as_add_arq_rb(ad, arq); 1350 - if (!alias) { 1351 - /* 1352 - * set expire time (only used for reads) and add to fifo list 1353 - */ 1354 - arq->expires = jiffies + ad->fifo_expire[data_dir]; 1355 - list_add_tail(&arq->fifo, &ad->fifo_list[data_dir]); 1390 + as_add_arq_rb(ad, arq); 1391 + if (rq_mergeable(arq->request)) 1392 + as_add_arq_hash(ad, arq); 1356 1393 1357 - if (rq_mergeable(arq->request)) 1358 - as_add_arq_hash(ad, arq); 1359 - as_update_arq(ad, arq); /* keep state machine up to date */ 1394 + /* 1395 + * set expire time (only used for reads) and add to fifo list 1396 + */ 1397 + arq->expires = jiffies + ad->fifo_expire[data_dir]; 1398 + list_add_tail(&arq->fifo, &ad->fifo_list[data_dir]); 1360 1399 1361 - } else { 1362 - as_add_aliased_request(ad, arq, alias); 1363 - 1364 - /* 1365 - * have we been anticipating this request? 1366 - * or does it come from the same process as the one we are 1367 - * anticipating for? 1368 - */ 1369 - if (ad->antic_status == ANTIC_WAIT_REQ 1370 - || ad->antic_status == ANTIC_WAIT_NEXT) { 1371 - if (as_can_break_anticipation(ad, arq)) 1372 - as_antic_stop(ad); 1373 - } 1374 - } 1375 - 1400 + as_update_arq(ad, arq); /* keep state machine up to date */ 1376 1401 arq->state = AS_RQ_QUEUED; 1377 1402 } 1378 1403 ··· 1479 1536 * if the merge was a front merge, we need to reposition request 1480 1537 */ 1481 1538 if (rq_rb_key(req) != arq->rb_key) { 1482 - struct as_rq *alias, *next_arq = NULL; 1483 - 1484 - if (ad->next_arq[arq->is_sync] == arq) 1485 - next_arq = as_find_next_arq(ad, arq); 1486 - 1487 - /* 1488 - * Note! We should really be moving any old aliased requests 1489 - * off this request and try to insert them into the rbtree. We 1490 - * currently don't bother. Ditto the next function. 1491 - */ 1492 1539 as_del_arq_rb(ad, arq); 1493 - if ((alias = as_add_arq_rb(ad, arq))) { 1494 - list_del_init(&arq->fifo); 1495 - as_add_aliased_request(ad, arq, alias); 1496 - if (next_arq) 1497 - ad->next_arq[arq->is_sync] = next_arq; 1498 - } 1540 + as_add_arq_rb(ad, arq); 1499 1541 /* 1500 1542 * Note! At this stage of this and the next function, our next 1501 1543 * request may not be optimal - eg the request may have "grown" ··· 1507 1579 as_add_arq_hash(ad, arq); 1508 1580 1509 1581 if (rq_rb_key(req) != arq->rb_key) { 1510 - struct as_rq *alias, *next_arq = NULL; 1511 - 1512 - if (ad->next_arq[arq->is_sync] == arq) 1513 - next_arq = as_find_next_arq(ad, arq); 1514 - 1515 1582 as_del_arq_rb(ad, arq); 1516 - if ((alias = as_add_arq_rb(ad, arq))) { 1517 - list_del_init(&arq->fifo); 1518 - as_add_aliased_request(ad, arq, alias); 1519 - if (next_arq) 1520 - ad->next_arq[arq->is_sync] = next_arq; 1521 - } 1583 + as_add_arq_rb(ad, arq); 1522 1584 } 1523 1585 1524 1586 /* ··· 1525 1607 */ 1526 1608 swap_io_context(&arq->io_context, &anext->io_context); 1527 1609 } 1528 - } 1529 - 1530 - /* 1531 - * Transfer list of aliases 1532 - */ 1533 - while (!list_empty(&next->queuelist)) { 1534 - struct request *__rq = list_entry_rq(next->queuelist.next); 1535 - struct as_rq *__arq = RQ_DATA(__rq); 1536 - 1537 - list_move_tail(&__rq->queuelist, &req->queuelist); 1538 - 1539 - WARN_ON(__arq->state != AS_RQ_QUEUED); 1540 1610 } 1541 1611 1542 1612 /*
+8 -8
block/cfq-iosched.c
··· 25 25 /* 26 26 * tunables 27 27 */ 28 - static int cfq_quantum = 4; /* max queue in one round of service */ 29 - static int cfq_queued = 8; /* minimum rq allocate limit per-queue*/ 30 - static int cfq_fifo_expire[2] = { HZ / 4, HZ / 8 }; 31 - static int cfq_back_max = 16 * 1024; /* maximum backwards seek, in KiB */ 32 - static int cfq_back_penalty = 2; /* penalty of a backwards seek */ 28 + static const int cfq_quantum = 4; /* max queue in one round of service */ 29 + static const int cfq_queued = 8; /* minimum rq allocate limit per-queue*/ 30 + static const int cfq_fifo_expire[2] = { HZ / 4, HZ / 8 }; 31 + static const int cfq_back_max = 16 * 1024; /* maximum backwards seek, in KiB */ 32 + static const int cfq_back_penalty = 2; /* penalty of a backwards seek */ 33 33 34 - static int cfq_slice_sync = HZ / 10; 34 + static const int cfq_slice_sync = HZ / 10; 35 35 static int cfq_slice_async = HZ / 25; 36 - static int cfq_slice_async_rq = 2; 36 + static const int cfq_slice_async_rq = 2; 37 37 static int cfq_slice_idle = HZ / 100; 38 38 39 39 #define CFQ_IDLE_GRACE (HZ / 10) ··· 45 45 /* 46 46 * disable queueing at the driver/hardware level 47 47 */ 48 - static int cfq_max_depth = 2; 48 + static const int cfq_max_depth = 2; 49 49 50 50 /* 51 51 * for the hash of cfqq inside the cfqd
+4 -4
block/deadline-iosched.c
··· 19 19 /* 20 20 * See Documentation/block/deadline-iosched.txt 21 21 */ 22 - static int read_expire = HZ / 2; /* max time before a read is submitted. */ 23 - static int write_expire = 5 * HZ; /* ditto for writes, these limits are SOFT! */ 24 - static int writes_starved = 2; /* max times reads can starve a write */ 25 - static int fifo_batch = 16; /* # of sequential requests treated as one 22 + static const int read_expire = HZ / 2; /* max time before a read is submitted. */ 23 + static const int write_expire = 5 * HZ; /* ditto for writes, these limits are SOFT! */ 24 + static const int writes_starved = 2; /* max times reads can starve a write */ 25 + static const int fifo_batch = 16; /* # of sequential requests treated as one 26 26 by the above parameters. For throughput. */ 27 27 28 28 static const int deadline_hash_shift = 5;
+59 -27
block/elevator.c
··· 304 304 305 305 rq->flags &= ~REQ_STARTED; 306 306 307 - /* 308 - * if this is the flush, requeue the original instead and drop the flush 309 - */ 310 - if (rq->flags & REQ_BAR_FLUSH) { 311 - clear_bit(QUEUE_FLAG_FLUSH, &q->queue_flags); 312 - rq = rq->end_io_data; 313 - } 314 - 315 - __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0); 307 + __elv_add_request(q, rq, ELEVATOR_INSERT_REQUEUE, 0); 316 308 } 317 309 318 310 static void elv_drain_elevator(request_queue_t *q) ··· 324 332 void __elv_add_request(request_queue_t *q, struct request *rq, int where, 325 333 int plug) 326 334 { 335 + struct list_head *pos; 336 + unsigned ordseq; 337 + 338 + if (q->ordcolor) 339 + rq->flags |= REQ_ORDERED_COLOR; 340 + 327 341 if (rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER)) { 342 + /* 343 + * toggle ordered color 344 + */ 345 + q->ordcolor ^= 1; 346 + 328 347 /* 329 348 * barriers implicitly indicate back insertion 330 349 */ ··· 396 393 q->elevator->ops->elevator_add_req_fn(q, rq); 397 394 break; 398 395 396 + case ELEVATOR_INSERT_REQUEUE: 397 + /* 398 + * If ordered flush isn't in progress, we do front 399 + * insertion; otherwise, requests should be requeued 400 + * in ordseq order. 401 + */ 402 + rq->flags |= REQ_SOFTBARRIER; 403 + 404 + if (q->ordseq == 0) { 405 + list_add(&rq->queuelist, &q->queue_head); 406 + break; 407 + } 408 + 409 + ordseq = blk_ordered_req_seq(rq); 410 + 411 + list_for_each(pos, &q->queue_head) { 412 + struct request *pos_rq = list_entry_rq(pos); 413 + if (ordseq <= blk_ordered_req_seq(pos_rq)) 414 + break; 415 + } 416 + 417 + list_add_tail(&rq->queuelist, pos); 418 + break; 419 + 399 420 default: 400 421 printk(KERN_ERR "%s: bad insertion point %d\n", 401 422 __FUNCTION__, where); ··· 449 422 { 450 423 struct request *rq; 451 424 452 - if (unlikely(list_empty(&q->queue_head) && 453 - !q->elevator->ops->elevator_dispatch_fn(q, 0))) 454 - return NULL; 425 + while (1) { 426 + while (!list_empty(&q->queue_head)) { 427 + rq = list_entry_rq(q->queue_head.next); 428 + if (blk_do_ordered(q, &rq)) 429 + return rq; 430 + } 455 431 456 - rq = list_entry_rq(q->queue_head.next); 457 - 458 - /* 459 - * if this is a barrier write and the device has to issue a 460 - * flush sequence to support it, check how far we are 461 - */ 462 - if (blk_fs_request(rq) && blk_barrier_rq(rq)) { 463 - BUG_ON(q->ordered == QUEUE_ORDERED_NONE); 464 - 465 - if (q->ordered == QUEUE_ORDERED_FLUSH && 466 - !blk_barrier_preflush(rq)) 467 - rq = blk_start_pre_flush(q, rq); 432 + if (!q->elevator->ops->elevator_dispatch_fn(q, 0)) 433 + return NULL; 468 434 } 469 - 470 - return rq; 471 435 } 472 436 473 437 struct request *elv_next_request(request_queue_t *q) ··· 516 498 blkdev_dequeue_request(rq); 517 499 rq->flags |= REQ_QUIET; 518 500 end_that_request_chunk(rq, 0, nr_bytes); 519 - end_that_request_last(rq); 501 + end_that_request_last(rq, 0); 520 502 } else { 521 503 printk(KERN_ERR "%s: bad return=%d\n", __FUNCTION__, 522 504 ret); ··· 611 593 * request is released from the driver, io must be done 612 594 */ 613 595 if (blk_account_rq(rq)) { 596 + struct request *first_rq = list_entry_rq(q->queue_head.next); 597 + 614 598 q->in_flight--; 599 + 600 + /* 601 + * Check if the queue is waiting for fs requests to be 602 + * drained for flush sequence. 603 + */ 604 + if (q->ordseq && q->in_flight == 0 && 605 + blk_ordered_cur_seq(q) == QUEUE_ORDSEQ_DRAIN && 606 + blk_ordered_req_seq(first_rq) > QUEUE_ORDSEQ_DRAIN) { 607 + blk_ordered_complete_seq(q, QUEUE_ORDSEQ_DRAIN, 0); 608 + q->request_fn(q); 609 + } 610 + 615 611 if (blk_sorted_rq(rq) && e->ops->elevator_completed_req_fn) 616 612 e->ops->elevator_completed_req_fn(q, rq); 617 613 }
+339 -221
block/ll_rw_blk.c
··· 36 36 static void blk_unplug_work(void *data); 37 37 static void blk_unplug_timeout(unsigned long data); 38 38 static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io); 39 + static void init_request_from_bio(struct request *req, struct bio *bio); 40 + static int __make_request(request_queue_t *q, struct bio *bio); 39 41 40 42 /* 41 43 * For the allocated request tables ··· 290 288 291 289 /** 292 290 * blk_queue_ordered - does this queue support ordered writes 293 - * @q: the request queue 294 - * @flag: see below 291 + * @q: the request queue 292 + * @ordered: one of QUEUE_ORDERED_* 295 293 * 296 294 * Description: 297 295 * For journalled file systems, doing ordered writes on a commit ··· 300 298 * feature should call this function and indicate so. 301 299 * 302 300 **/ 303 - void blk_queue_ordered(request_queue_t *q, int flag) 301 + int blk_queue_ordered(request_queue_t *q, unsigned ordered, 302 + prepare_flush_fn *prepare_flush_fn) 304 303 { 305 - switch (flag) { 306 - case QUEUE_ORDERED_NONE: 307 - if (q->flush_rq) 308 - kmem_cache_free(request_cachep, q->flush_rq); 309 - q->flush_rq = NULL; 310 - q->ordered = flag; 311 - break; 312 - case QUEUE_ORDERED_TAG: 313 - q->ordered = flag; 314 - break; 315 - case QUEUE_ORDERED_FLUSH: 316 - q->ordered = flag; 317 - if (!q->flush_rq) 318 - q->flush_rq = kmem_cache_alloc(request_cachep, 319 - GFP_KERNEL); 320 - break; 321 - default: 322 - printk("blk_queue_ordered: bad value %d\n", flag); 323 - break; 304 + if (ordered & (QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH) && 305 + prepare_flush_fn == NULL) { 306 + printk(KERN_ERR "blk_queue_ordered: prepare_flush_fn required\n"); 307 + return -EINVAL; 324 308 } 309 + 310 + if (ordered != QUEUE_ORDERED_NONE && 311 + ordered != QUEUE_ORDERED_DRAIN && 312 + ordered != QUEUE_ORDERED_DRAIN_FLUSH && 313 + ordered != QUEUE_ORDERED_DRAIN_FUA && 314 + ordered != QUEUE_ORDERED_TAG && 315 + ordered != QUEUE_ORDERED_TAG_FLUSH && 316 + ordered != QUEUE_ORDERED_TAG_FUA) { 317 + printk(KERN_ERR "blk_queue_ordered: bad value %d\n", ordered); 318 + return -EINVAL; 319 + } 320 + 321 + q->next_ordered = ordered; 322 + q->prepare_flush_fn = prepare_flush_fn; 323 + 324 + return 0; 325 325 } 326 326 327 327 EXPORT_SYMBOL(blk_queue_ordered); ··· 348 344 /* 349 345 * Cache flushing for ordered writes handling 350 346 */ 351 - static void blk_pre_flush_end_io(struct request *flush_rq) 347 + inline unsigned blk_ordered_cur_seq(request_queue_t *q) 352 348 { 353 - struct request *rq = flush_rq->end_io_data; 349 + if (!q->ordseq) 350 + return 0; 351 + return 1 << ffz(q->ordseq); 352 + } 353 + 354 + unsigned blk_ordered_req_seq(struct request *rq) 355 + { 354 356 request_queue_t *q = rq->q; 355 357 356 - elv_completed_request(q, flush_rq); 358 + BUG_ON(q->ordseq == 0); 357 359 358 - rq->flags |= REQ_BAR_PREFLUSH; 360 + if (rq == &q->pre_flush_rq) 361 + return QUEUE_ORDSEQ_PREFLUSH; 362 + if (rq == &q->bar_rq) 363 + return QUEUE_ORDSEQ_BAR; 364 + if (rq == &q->post_flush_rq) 365 + return QUEUE_ORDSEQ_POSTFLUSH; 359 366 360 - if (!flush_rq->errors) 361 - elv_requeue_request(q, rq); 362 - else { 363 - q->end_flush_fn(q, flush_rq); 364 - clear_bit(QUEUE_FLAG_FLUSH, &q->queue_flags); 365 - q->request_fn(q); 366 - } 367 + if ((rq->flags & REQ_ORDERED_COLOR) == 368 + (q->orig_bar_rq->flags & REQ_ORDERED_COLOR)) 369 + return QUEUE_ORDSEQ_DRAIN; 370 + else 371 + return QUEUE_ORDSEQ_DONE; 367 372 } 368 373 369 - static void blk_post_flush_end_io(struct request *flush_rq) 374 + void blk_ordered_complete_seq(request_queue_t *q, unsigned seq, int error) 370 375 { 371 - struct request *rq = flush_rq->end_io_data; 372 - request_queue_t *q = rq->q; 376 + struct request *rq; 377 + int uptodate; 373 378 374 - elv_completed_request(q, flush_rq); 379 + if (error && !q->orderr) 380 + q->orderr = error; 375 381 376 - rq->flags |= REQ_BAR_POSTFLUSH; 382 + BUG_ON(q->ordseq & seq); 383 + q->ordseq |= seq; 377 384 378 - q->end_flush_fn(q, flush_rq); 379 - clear_bit(QUEUE_FLAG_FLUSH, &q->queue_flags); 380 - q->request_fn(q); 381 - } 382 - 383 - struct request *blk_start_pre_flush(request_queue_t *q, struct request *rq) 384 - { 385 - struct request *flush_rq = q->flush_rq; 386 - 387 - BUG_ON(!blk_barrier_rq(rq)); 388 - 389 - if (test_and_set_bit(QUEUE_FLAG_FLUSH, &q->queue_flags)) 390 - return NULL; 391 - 392 - rq_init(q, flush_rq); 393 - flush_rq->elevator_private = NULL; 394 - flush_rq->flags = REQ_BAR_FLUSH; 395 - flush_rq->rq_disk = rq->rq_disk; 396 - flush_rq->rl = NULL; 385 + if (blk_ordered_cur_seq(q) != QUEUE_ORDSEQ_DONE) 386 + return; 397 387 398 388 /* 399 - * prepare_flush returns 0 if no flush is needed, just mark both 400 - * pre and post flush as done in that case 389 + * Okay, sequence complete. 401 390 */ 402 - if (!q->prepare_flush_fn(q, flush_rq)) { 403 - rq->flags |= REQ_BAR_PREFLUSH | REQ_BAR_POSTFLUSH; 404 - clear_bit(QUEUE_FLAG_FLUSH, &q->queue_flags); 405 - return rq; 391 + rq = q->orig_bar_rq; 392 + uptodate = q->orderr ? q->orderr : 1; 393 + 394 + q->ordseq = 0; 395 + 396 + end_that_request_first(rq, uptodate, rq->hard_nr_sectors); 397 + end_that_request_last(rq, uptodate); 398 + } 399 + 400 + static void pre_flush_end_io(struct request *rq, int error) 401 + { 402 + elv_completed_request(rq->q, rq); 403 + blk_ordered_complete_seq(rq->q, QUEUE_ORDSEQ_PREFLUSH, error); 404 + } 405 + 406 + static void bar_end_io(struct request *rq, int error) 407 + { 408 + elv_completed_request(rq->q, rq); 409 + blk_ordered_complete_seq(rq->q, QUEUE_ORDSEQ_BAR, error); 410 + } 411 + 412 + static void post_flush_end_io(struct request *rq, int error) 413 + { 414 + elv_completed_request(rq->q, rq); 415 + blk_ordered_complete_seq(rq->q, QUEUE_ORDSEQ_POSTFLUSH, error); 416 + } 417 + 418 + static void queue_flush(request_queue_t *q, unsigned which) 419 + { 420 + struct request *rq; 421 + rq_end_io_fn *end_io; 422 + 423 + if (which == QUEUE_ORDERED_PREFLUSH) { 424 + rq = &q->pre_flush_rq; 425 + end_io = pre_flush_end_io; 426 + } else { 427 + rq = &q->post_flush_rq; 428 + end_io = post_flush_end_io; 406 429 } 430 + 431 + rq_init(q, rq); 432 + rq->flags = REQ_HARDBARRIER; 433 + rq->elevator_private = NULL; 434 + rq->rq_disk = q->bar_rq.rq_disk; 435 + rq->rl = NULL; 436 + rq->end_io = end_io; 437 + q->prepare_flush_fn(q, rq); 438 + 439 + __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0); 440 + } 441 + 442 + static inline struct request *start_ordered(request_queue_t *q, 443 + struct request *rq) 444 + { 445 + q->bi_size = 0; 446 + q->orderr = 0; 447 + q->ordered = q->next_ordered; 448 + q->ordseq |= QUEUE_ORDSEQ_STARTED; 407 449 408 450 /* 409 - * some drivers dequeue requests right away, some only after io 410 - * completion. make sure the request is dequeued. 451 + * Prep proxy barrier request. 411 452 */ 412 - if (!list_empty(&rq->queuelist)) 413 - blkdev_dequeue_request(rq); 453 + blkdev_dequeue_request(rq); 454 + q->orig_bar_rq = rq; 455 + rq = &q->bar_rq; 456 + rq_init(q, rq); 457 + rq->flags = bio_data_dir(q->orig_bar_rq->bio); 458 + rq->flags |= q->ordered & QUEUE_ORDERED_FUA ? REQ_FUA : 0; 459 + rq->elevator_private = NULL; 460 + rq->rl = NULL; 461 + init_request_from_bio(rq, q->orig_bar_rq->bio); 462 + rq->end_io = bar_end_io; 414 463 415 - flush_rq->end_io_data = rq; 416 - flush_rq->end_io = blk_pre_flush_end_io; 464 + /* 465 + * Queue ordered sequence. As we stack them at the head, we 466 + * need to queue in reverse order. Note that we rely on that 467 + * no fs request uses ELEVATOR_INSERT_FRONT and thus no fs 468 + * request gets inbetween ordered sequence. 469 + */ 470 + if (q->ordered & QUEUE_ORDERED_POSTFLUSH) 471 + queue_flush(q, QUEUE_ORDERED_POSTFLUSH); 472 + else 473 + q->ordseq |= QUEUE_ORDSEQ_POSTFLUSH; 417 474 418 - __elv_add_request(q, flush_rq, ELEVATOR_INSERT_FRONT, 0); 419 - return flush_rq; 475 + __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0); 476 + 477 + if (q->ordered & QUEUE_ORDERED_PREFLUSH) { 478 + queue_flush(q, QUEUE_ORDERED_PREFLUSH); 479 + rq = &q->pre_flush_rq; 480 + } else 481 + q->ordseq |= QUEUE_ORDSEQ_PREFLUSH; 482 + 483 + if ((q->ordered & QUEUE_ORDERED_TAG) || q->in_flight == 0) 484 + q->ordseq |= QUEUE_ORDSEQ_DRAIN; 485 + else 486 + rq = NULL; 487 + 488 + return rq; 420 489 } 421 490 422 - static void blk_start_post_flush(request_queue_t *q, struct request *rq) 491 + int blk_do_ordered(request_queue_t *q, struct request **rqp) 423 492 { 424 - struct request *flush_rq = q->flush_rq; 493 + struct request *rq = *rqp, *allowed_rq; 494 + int is_barrier = blk_fs_request(rq) && blk_barrier_rq(rq); 425 495 426 - BUG_ON(!blk_barrier_rq(rq)); 496 + if (!q->ordseq) { 497 + if (!is_barrier) 498 + return 1; 427 499 428 - rq_init(q, flush_rq); 429 - flush_rq->elevator_private = NULL; 430 - flush_rq->flags = REQ_BAR_FLUSH; 431 - flush_rq->rq_disk = rq->rq_disk; 432 - flush_rq->rl = NULL; 433 - 434 - if (q->prepare_flush_fn(q, flush_rq)) { 435 - flush_rq->end_io_data = rq; 436 - flush_rq->end_io = blk_post_flush_end_io; 437 - 438 - __elv_add_request(q, flush_rq, ELEVATOR_INSERT_FRONT, 0); 439 - q->request_fn(q); 500 + if (q->next_ordered != QUEUE_ORDERED_NONE) { 501 + *rqp = start_ordered(q, rq); 502 + return 1; 503 + } else { 504 + /* 505 + * This can happen when the queue switches to 506 + * ORDERED_NONE while this request is on it. 507 + */ 508 + blkdev_dequeue_request(rq); 509 + end_that_request_first(rq, -EOPNOTSUPP, 510 + rq->hard_nr_sectors); 511 + end_that_request_last(rq, -EOPNOTSUPP); 512 + *rqp = NULL; 513 + return 0; 514 + } 440 515 } 441 - } 442 516 443 - static inline int blk_check_end_barrier(request_queue_t *q, struct request *rq, 444 - int sectors) 445 - { 446 - if (sectors > rq->nr_sectors) 447 - sectors = rq->nr_sectors; 448 - 449 - rq->nr_sectors -= sectors; 450 - return rq->nr_sectors; 451 - } 452 - 453 - static int __blk_complete_barrier_rq(request_queue_t *q, struct request *rq, 454 - int sectors, int queue_locked) 455 - { 456 - if (q->ordered != QUEUE_ORDERED_FLUSH) 457 - return 0; 458 - if (!blk_fs_request(rq) || !blk_barrier_rq(rq)) 459 - return 0; 460 - if (blk_barrier_postflush(rq)) 461 - return 0; 462 - 463 - if (!blk_check_end_barrier(q, rq, sectors)) { 464 - unsigned long flags = 0; 465 - 466 - if (!queue_locked) 467 - spin_lock_irqsave(q->queue_lock, flags); 468 - 469 - blk_start_post_flush(q, rq); 470 - 471 - if (!queue_locked) 472 - spin_unlock_irqrestore(q->queue_lock, flags); 517 + if (q->ordered & QUEUE_ORDERED_TAG) { 518 + if (is_barrier && rq != &q->bar_rq) 519 + *rqp = NULL; 520 + return 1; 473 521 } 522 + 523 + switch (blk_ordered_cur_seq(q)) { 524 + case QUEUE_ORDSEQ_PREFLUSH: 525 + allowed_rq = &q->pre_flush_rq; 526 + break; 527 + case QUEUE_ORDSEQ_BAR: 528 + allowed_rq = &q->bar_rq; 529 + break; 530 + case QUEUE_ORDSEQ_POSTFLUSH: 531 + allowed_rq = &q->post_flush_rq; 532 + break; 533 + default: 534 + allowed_rq = NULL; 535 + break; 536 + } 537 + 538 + if (rq != allowed_rq && 539 + (blk_fs_request(rq) || rq == &q->pre_flush_rq || 540 + rq == &q->post_flush_rq)) 541 + *rqp = NULL; 474 542 475 543 return 1; 476 544 } 477 545 478 - /** 479 - * blk_complete_barrier_rq - complete possible barrier request 480 - * @q: the request queue for the device 481 - * @rq: the request 482 - * @sectors: number of sectors to complete 483 - * 484 - * Description: 485 - * Used in driver end_io handling to determine whether to postpone 486 - * completion of a barrier request until a post flush has been done. This 487 - * is the unlocked variant, used if the caller doesn't already hold the 488 - * queue lock. 489 - **/ 490 - int blk_complete_barrier_rq(request_queue_t *q, struct request *rq, int sectors) 546 + static int flush_dry_bio_endio(struct bio *bio, unsigned int bytes, int error) 491 547 { 492 - return __blk_complete_barrier_rq(q, rq, sectors, 0); 493 - } 494 - EXPORT_SYMBOL(blk_complete_barrier_rq); 548 + request_queue_t *q = bio->bi_private; 549 + struct bio_vec *bvec; 550 + int i; 495 551 496 - /** 497 - * blk_complete_barrier_rq_locked - complete possible barrier request 498 - * @q: the request queue for the device 499 - * @rq: the request 500 - * @sectors: number of sectors to complete 501 - * 502 - * Description: 503 - * See blk_complete_barrier_rq(). This variant must be used if the caller 504 - * holds the queue lock. 505 - **/ 506 - int blk_complete_barrier_rq_locked(request_queue_t *q, struct request *rq, 507 - int sectors) 508 - { 509 - return __blk_complete_barrier_rq(q, rq, sectors, 1); 552 + /* 553 + * This is dry run, restore bio_sector and size. We'll finish 554 + * this request again with the original bi_end_io after an 555 + * error occurs or post flush is complete. 556 + */ 557 + q->bi_size += bytes; 558 + 559 + if (bio->bi_size) 560 + return 1; 561 + 562 + /* Rewind bvec's */ 563 + bio->bi_idx = 0; 564 + bio_for_each_segment(bvec, bio, i) { 565 + bvec->bv_len += bvec->bv_offset; 566 + bvec->bv_offset = 0; 567 + } 568 + 569 + /* Reset bio */ 570 + set_bit(BIO_UPTODATE, &bio->bi_flags); 571 + bio->bi_size = q->bi_size; 572 + bio->bi_sector -= (q->bi_size >> 9); 573 + q->bi_size = 0; 574 + 575 + return 0; 510 576 } 511 - EXPORT_SYMBOL(blk_complete_barrier_rq_locked); 577 + 578 + static inline int ordered_bio_endio(struct request *rq, struct bio *bio, 579 + unsigned int nbytes, int error) 580 + { 581 + request_queue_t *q = rq->q; 582 + bio_end_io_t *endio; 583 + void *private; 584 + 585 + if (&q->bar_rq != rq) 586 + return 0; 587 + 588 + /* 589 + * Okay, this is the barrier request in progress, dry finish it. 590 + */ 591 + if (error && !q->orderr) 592 + q->orderr = error; 593 + 594 + endio = bio->bi_end_io; 595 + private = bio->bi_private; 596 + bio->bi_end_io = flush_dry_bio_endio; 597 + bio->bi_private = q; 598 + 599 + bio_endio(bio, nbytes, error); 600 + 601 + bio->bi_end_io = endio; 602 + bio->bi_private = private; 603 + 604 + return 1; 605 + } 512 606 513 607 /** 514 608 * blk_queue_bounce_limit - set bounce buffer limit for queue ··· 1141 1039 1142 1040 EXPORT_SYMBOL(blk_queue_invalidate_tags); 1143 1041 1144 - static char *rq_flags[] = { 1042 + static const char * const rq_flags[] = { 1145 1043 "REQ_RW", 1146 1044 "REQ_FAILFAST", 1147 1045 "REQ_SORTED", 1148 1046 "REQ_SOFTBARRIER", 1149 1047 "REQ_HARDBARRIER", 1048 + "REQ_FUA", 1150 1049 "REQ_CMD", 1151 1050 "REQ_NOMERGE", 1152 1051 "REQ_STARTED", ··· 1167 1064 "REQ_PM_SUSPEND", 1168 1065 "REQ_PM_RESUME", 1169 1066 "REQ_PM_SHUTDOWN", 1067 + "REQ_ORDERED_COLOR", 1170 1068 }; 1171 1069 1172 1070 void blk_dump_rq_flags(struct request *rq, char *msg) ··· 1745 1641 if (q->queue_tags) 1746 1642 __blk_queue_free_tags(q); 1747 1643 1748 - blk_queue_ordered(q, QUEUE_ORDERED_NONE); 1749 - 1750 1644 kmem_cache_free(requestq_cachep, q); 1751 1645 } 1752 1646 ··· 1768 1666 1769 1667 return 0; 1770 1668 } 1771 - 1772 - static int __make_request(request_queue_t *, struct bio *); 1773 1669 1774 1670 request_queue_t *blk_alloc_queue(gfp_t gfp_mask) 1775 1671 { ··· 2008 1908 { 2009 1909 struct request *rq = NULL; 2010 1910 struct request_list *rl = &q->rq; 2011 - struct io_context *ioc = current_io_context(GFP_ATOMIC); 2012 - int priv; 1911 + struct io_context *ioc = NULL; 1912 + int may_queue, priv; 2013 1913 2014 - if (rl->count[rw]+1 >= q->nr_requests) { 2015 - /* 2016 - * The queue will fill after this allocation, so set it as 2017 - * full, and mark this process as "batching". This process 2018 - * will be allowed to complete a batch of requests, others 2019 - * will be blocked. 2020 - */ 2021 - if (!blk_queue_full(q, rw)) { 2022 - ioc_set_batching(q, ioc); 2023 - blk_set_queue_full(q, rw); 1914 + may_queue = elv_may_queue(q, rw, bio); 1915 + if (may_queue == ELV_MQUEUE_NO) 1916 + goto rq_starved; 1917 + 1918 + if (rl->count[rw]+1 >= queue_congestion_on_threshold(q)) { 1919 + if (rl->count[rw]+1 >= q->nr_requests) { 1920 + ioc = current_io_context(GFP_ATOMIC); 1921 + /* 1922 + * The queue will fill after this allocation, so set 1923 + * it as full, and mark this process as "batching". 1924 + * This process will be allowed to complete a batch of 1925 + * requests, others will be blocked. 1926 + */ 1927 + if (!blk_queue_full(q, rw)) { 1928 + ioc_set_batching(q, ioc); 1929 + blk_set_queue_full(q, rw); 1930 + } else { 1931 + if (may_queue != ELV_MQUEUE_MUST 1932 + && !ioc_batching(q, ioc)) { 1933 + /* 1934 + * The queue is full and the allocating 1935 + * process is not a "batcher", and not 1936 + * exempted by the IO scheduler 1937 + */ 1938 + goto out; 1939 + } 1940 + } 2024 1941 } 1942 + set_queue_congested(q, rw); 2025 1943 } 2026 1944 2027 - switch (elv_may_queue(q, rw, bio)) { 2028 - case ELV_MQUEUE_NO: 2029 - goto rq_starved; 2030 - case ELV_MQUEUE_MAY: 2031 - break; 2032 - case ELV_MQUEUE_MUST: 2033 - goto get_rq; 2034 - } 2035 - 2036 - if (blk_queue_full(q, rw) && !ioc_batching(q, ioc)) { 2037 - /* 2038 - * The queue is full and the allocating process is not a 2039 - * "batcher", and not exempted by the IO scheduler 2040 - */ 2041 - goto out; 2042 - } 2043 - 2044 - get_rq: 2045 1945 /* 2046 1946 * Only allow batching queuers to allocate up to 50% over the defined 2047 1947 * limit of requests, otherwise we could have thousands of requests ··· 2052 1952 2053 1953 rl->count[rw]++; 2054 1954 rl->starved[rw] = 0; 2055 - if (rl->count[rw] >= queue_congestion_on_threshold(q)) 2056 - set_queue_congested(q, rw); 2057 1955 2058 1956 priv = !test_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags); 2059 1957 if (priv) ··· 2060 1962 spin_unlock_irq(q->queue_lock); 2061 1963 2062 1964 rq = blk_alloc_request(q, rw, bio, priv, gfp_mask); 2063 - if (!rq) { 1965 + if (unlikely(!rq)) { 2064 1966 /* 2065 1967 * Allocation failed presumably due to memory. Undo anything 2066 1968 * we might have messed up. ··· 2085 1987 goto out; 2086 1988 } 2087 1989 1990 + /* 1991 + * ioc may be NULL here, and ioc_batching will be false. That's 1992 + * OK, if the queue is under the request limit then requests need 1993 + * not count toward the nr_batch_requests limit. There will always 1994 + * be some limit enforced by BLK_BATCH_TIME. 1995 + */ 2088 1996 if (ioc_batching(q, ioc)) 2089 1997 ioc->nr_batch_requests--; 2090 1998 ··· 2417 2313 */ 2418 2314 void blk_execute_rq_nowait(request_queue_t *q, struct gendisk *bd_disk, 2419 2315 struct request *rq, int at_head, 2420 - void (*done)(struct request *)) 2316 + rq_end_io_fn *done) 2421 2317 { 2422 2318 int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK; 2423 2319 ··· 2621 2517 * blk_end_sync_rq - executes a completion event on a request 2622 2518 * @rq: request to complete 2623 2519 */ 2624 - void blk_end_sync_rq(struct request *rq) 2520 + void blk_end_sync_rq(struct request *rq, int error) 2625 2521 { 2626 2522 struct completion *waiting = rq->waiting; 2627 2523 ··· 2759 2655 2760 2656 EXPORT_SYMBOL(blk_attempt_remerge); 2761 2657 2658 + static void init_request_from_bio(struct request *req, struct bio *bio) 2659 + { 2660 + req->flags |= REQ_CMD; 2661 + 2662 + /* 2663 + * inherit FAILFAST from bio (for read-ahead, and explicit FAILFAST) 2664 + */ 2665 + if (bio_rw_ahead(bio) || bio_failfast(bio)) 2666 + req->flags |= REQ_FAILFAST; 2667 + 2668 + /* 2669 + * REQ_BARRIER implies no merging, but lets make it explicit 2670 + */ 2671 + if (unlikely(bio_barrier(bio))) 2672 + req->flags |= (REQ_HARDBARRIER | REQ_NOMERGE); 2673 + 2674 + req->errors = 0; 2675 + req->hard_sector = req->sector = bio->bi_sector; 2676 + req->hard_nr_sectors = req->nr_sectors = bio_sectors(bio); 2677 + req->current_nr_sectors = req->hard_cur_sectors = bio_cur_sectors(bio); 2678 + req->nr_phys_segments = bio_phys_segments(req->q, bio); 2679 + req->nr_hw_segments = bio_hw_segments(req->q, bio); 2680 + req->buffer = bio_data(bio); /* see ->buffer comment above */ 2681 + req->waiting = NULL; 2682 + req->bio = req->biotail = bio; 2683 + req->ioprio = bio_prio(bio); 2684 + req->rq_disk = bio->bi_bdev->bd_disk; 2685 + req->start_time = jiffies; 2686 + } 2687 + 2762 2688 static int __make_request(request_queue_t *q, struct bio *bio) 2763 2689 { 2764 2690 struct request *req; ··· 2814 2680 spin_lock_prefetch(q->queue_lock); 2815 2681 2816 2682 barrier = bio_barrier(bio); 2817 - if (unlikely(barrier) && (q->ordered == QUEUE_ORDERED_NONE)) { 2683 + if (unlikely(barrier) && (q->next_ordered == QUEUE_ORDERED_NONE)) { 2818 2684 err = -EOPNOTSUPP; 2819 2685 goto end_io; 2820 2686 } ··· 2884 2750 * We don't worry about that case for efficiency. It won't happen 2885 2751 * often, and the elevators are able to handle it. 2886 2752 */ 2887 - 2888 - req->flags |= REQ_CMD; 2889 - 2890 - /* 2891 - * inherit FAILFAST from bio (for read-ahead, and explicit FAILFAST) 2892 - */ 2893 - if (bio_rw_ahead(bio) || bio_failfast(bio)) 2894 - req->flags |= REQ_FAILFAST; 2895 - 2896 - /* 2897 - * REQ_BARRIER implies no merging, but lets make it explicit 2898 - */ 2899 - if (unlikely(barrier)) 2900 - req->flags |= (REQ_HARDBARRIER | REQ_NOMERGE); 2901 - 2902 - req->errors = 0; 2903 - req->hard_sector = req->sector = sector; 2904 - req->hard_nr_sectors = req->nr_sectors = nr_sectors; 2905 - req->current_nr_sectors = req->hard_cur_sectors = cur_nr_sectors; 2906 - req->nr_phys_segments = bio_phys_segments(q, bio); 2907 - req->nr_hw_segments = bio_hw_segments(q, bio); 2908 - req->buffer = bio_data(bio); /* see ->buffer comment above */ 2909 - req->waiting = NULL; 2910 - req->bio = req->biotail = bio; 2911 - req->ioprio = prio; 2912 - req->rq_disk = bio->bi_bdev->bd_disk; 2913 - req->start_time = jiffies; 2753 + init_request_from_bio(req, bio); 2914 2754 2915 2755 spin_lock_irq(q->queue_lock); 2916 2756 if (elv_queue_empty(q)) ··· 3175 3067 if (nr_bytes >= bio->bi_size) { 3176 3068 req->bio = bio->bi_next; 3177 3069 nbytes = bio->bi_size; 3178 - bio_endio(bio, nbytes, error); 3070 + if (!ordered_bio_endio(req, bio, nbytes, error)) 3071 + bio_endio(bio, nbytes, error); 3179 3072 next_idx = 0; 3180 3073 bio_nbytes = 0; 3181 3074 } else { ··· 3231 3122 * if the request wasn't completed, update state 3232 3123 */ 3233 3124 if (bio_nbytes) { 3234 - bio_endio(bio, bio_nbytes, error); 3125 + if (!ordered_bio_endio(req, bio, bio_nbytes, error)) 3126 + bio_endio(bio, bio_nbytes, error); 3235 3127 bio->bi_idx += next_idx; 3236 3128 bio_iovec(bio)->bv_offset += nr_bytes; 3237 3129 bio_iovec(bio)->bv_len -= nr_bytes; ··· 3289 3179 /* 3290 3180 * queue lock must be held 3291 3181 */ 3292 - void end_that_request_last(struct request *req) 3182 + void end_that_request_last(struct request *req, int uptodate) 3293 3183 { 3294 3184 struct gendisk *disk = req->rq_disk; 3185 + int error; 3186 + 3187 + /* 3188 + * extend uptodate bool to allow < 0 value to be direct io error 3189 + */ 3190 + error = 0; 3191 + if (end_io_error(uptodate)) 3192 + error = !uptodate ? -EIO : uptodate; 3295 3193 3296 3194 if (unlikely(laptop_mode) && blk_fs_request(req)) 3297 3195 laptop_io_completion(); ··· 3314 3196 disk->in_flight--; 3315 3197 } 3316 3198 if (req->end_io) 3317 - req->end_io(req); 3199 + req->end_io(req, error); 3318 3200 else 3319 3201 __blk_put_request(req->q, req); 3320 3202 } ··· 3326 3208 if (!end_that_request_first(req, uptodate, req->hard_cur_sectors)) { 3327 3209 add_disk_randomness(req->rq_disk); 3328 3210 blkdev_dequeue_request(req); 3329 - end_that_request_last(req); 3211 + end_that_request_last(req, uptodate); 3330 3212 } 3331 3213 } 3332 3214
+1 -1
block/scsi_ioctl.c
··· 46 46 47 47 static int sg_get_version(int __user *p) 48 48 { 49 - static int sg_version_num = 30527; 49 + static const int sg_version_num = 30527; 50 50 return put_user(sg_version_num, p); 51 51 } 52 52
+1 -1
drivers/block/DAC960.c
··· 3471 3471 3472 3472 if (!end_that_request_first(Request, UpToDate, Command->BlockCount)) { 3473 3473 3474 - end_that_request_last(Request); 3474 + end_that_request_last(Request, UpToDate); 3475 3475 3476 3476 if (Command->Completion) { 3477 3477 complete(Command->Completion);
+1 -1
drivers/block/cciss.c
··· 2310 2310 printk("Done with %p\n", cmd->rq); 2311 2311 #endif /* CCISS_DEBUG */ 2312 2312 2313 - end_that_request_last(cmd->rq); 2313 + end_that_request_last(cmd->rq, status ? 1 : -EIO); 2314 2314 cmd_free(h,cmd,1); 2315 2315 } 2316 2316
+1 -1
drivers/block/cpqarray.c
··· 1036 1036 complete_buffers(cmd->rq->bio, ok); 1037 1037 1038 1038 DBGPX(printk("Done with %p\n", cmd->rq);); 1039 - end_that_request_last(cmd->rq); 1039 + end_that_request_last(cmd->rq, ok ? 1 : -EIO); 1040 1040 } 1041 1041 1042 1042 /*
+1 -1
drivers/block/floppy.c
··· 2301 2301 add_disk_randomness(req->rq_disk); 2302 2302 floppy_off((long)req->rq_disk->private_data); 2303 2303 blkdev_dequeue_request(req); 2304 - end_that_request_last(req); 2304 + end_that_request_last(req, uptodate); 2305 2305 2306 2306 /* We're done with the request */ 2307 2307 current_req = NULL;
+1 -1
drivers/block/nbd.c
··· 140 140 141 141 spin_lock_irqsave(q->queue_lock, flags); 142 142 if (!end_that_request_first(req, uptodate, req->nr_sectors)) { 143 - end_that_request_last(req); 143 + end_that_request_last(req, uptodate); 144 144 } 145 145 spin_unlock_irqrestore(q->queue_lock, flags); 146 146 }
+1 -1
drivers/block/sx8.c
··· 770 770 rc = end_that_request_first(req, uptodate, req->hard_nr_sectors); 771 771 assert(rc == 0); 772 772 773 - end_that_request_last(req); 773 + end_that_request_last(req, uptodate); 774 774 775 775 rc = carm_put_request(host, crq); 776 776 assert(rc == 0);
+1 -1
drivers/block/ub.c
··· 951 951 static void ub_end_rq(struct request *rq, int uptodate) 952 952 { 953 953 end_that_request_first(rq, uptodate, rq->hard_nr_sectors); 954 - end_that_request_last(rq); 954 + end_that_request_last(rq, uptodate); 955 955 } 956 956 957 957 static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
+1 -1
drivers/block/viodasd.c
··· 305 305 if (end_that_request_first(req, uptodate, num_sectors)) 306 306 return; 307 307 add_disk_randomness(req->rq_disk); 308 - end_that_request_last(req); 308 + end_that_request_last(req, uptodate); 309 309 } 310 310 311 311 /*
+1 -1
drivers/cdrom/cdu31a.c
··· 1402 1402 if (!end_that_request_first(req, 1, nblock)) { 1403 1403 spin_lock_irq(q->queue_lock); 1404 1404 blkdev_dequeue_request(req); 1405 - end_that_request_last(req); 1405 + end_that_request_last(req, 1); 1406 1406 spin_unlock_irq(q->queue_lock); 1407 1407 } 1408 1408 continue;
+2 -2
drivers/ide/ide-cd.c
··· 614 614 */ 615 615 spin_lock_irqsave(&ide_lock, flags); 616 616 end_that_request_chunk(failed, 0, failed->data_len); 617 - end_that_request_last(failed); 617 + end_that_request_last(failed, 0); 618 618 spin_unlock_irqrestore(&ide_lock, flags); 619 619 } 620 620 ··· 1735 1735 1736 1736 spin_lock_irqsave(&ide_lock, flags); 1737 1737 blkdev_dequeue_request(rq); 1738 - end_that_request_last(rq); 1738 + end_that_request_last(rq, 1); 1739 1739 HWGROUP(drive)->rq = NULL; 1740 1740 spin_unlock_irqrestore(&ide_lock, flags); 1741 1741 return ide_stopped;
+53 -84
drivers/ide/ide-disk.c
··· 681 681 682 682 #endif /* CONFIG_PROC_FS */ 683 683 684 - static void idedisk_end_flush(request_queue_t *q, struct request *flush_rq) 684 + static void idedisk_prepare_flush(request_queue_t *q, struct request *rq) 685 685 { 686 686 ide_drive_t *drive = q->queuedata; 687 - struct request *rq = flush_rq->end_io_data; 688 - int good_sectors = rq->hard_nr_sectors; 689 - int bad_sectors; 690 - sector_t sector; 691 - 692 - if (flush_rq->errors & ABRT_ERR) { 693 - printk(KERN_ERR "%s: barrier support doesn't work\n", drive->name); 694 - blk_queue_ordered(drive->queue, QUEUE_ORDERED_NONE); 695 - blk_queue_issue_flush_fn(drive->queue, NULL); 696 - good_sectors = 0; 697 - } else if (flush_rq->errors) { 698 - good_sectors = 0; 699 - if (blk_barrier_preflush(rq)) { 700 - sector = ide_get_error_location(drive,flush_rq->buffer); 701 - if ((sector >= rq->hard_sector) && 702 - (sector < rq->hard_sector + rq->hard_nr_sectors)) 703 - good_sectors = sector - rq->hard_sector; 704 - } 705 - } 706 - 707 - if (flush_rq->errors) 708 - printk(KERN_ERR "%s: failed barrier write: " 709 - "sector=%Lx(good=%d/bad=%d)\n", 710 - drive->name, (unsigned long long)rq->sector, 711 - good_sectors, 712 - (int) (rq->hard_nr_sectors-good_sectors)); 713 - 714 - bad_sectors = rq->hard_nr_sectors - good_sectors; 715 - 716 - if (good_sectors) 717 - __ide_end_request(drive, rq, 1, good_sectors); 718 - if (bad_sectors) 719 - __ide_end_request(drive, rq, 0, bad_sectors); 720 - } 721 - 722 - static int idedisk_prepare_flush(request_queue_t *q, struct request *rq) 723 - { 724 - ide_drive_t *drive = q->queuedata; 725 - 726 - if (!drive->wcache) 727 - return 0; 728 687 729 688 memset(rq->cmd, 0, sizeof(rq->cmd)); 730 689 ··· 694 735 rq->cmd[0] = WIN_FLUSH_CACHE; 695 736 696 737 697 - rq->flags |= REQ_DRIVE_TASK | REQ_SOFTBARRIER; 738 + rq->flags |= REQ_DRIVE_TASK; 698 739 rq->buffer = rq->cmd; 699 - return 1; 700 740 } 701 741 702 742 static int idedisk_issue_flush(request_queue_t *q, struct gendisk *disk, ··· 752 794 return 0; 753 795 } 754 796 797 + static void update_ordered(ide_drive_t *drive) 798 + { 799 + struct hd_driveid *id = drive->id; 800 + unsigned ordered = QUEUE_ORDERED_NONE; 801 + prepare_flush_fn *prep_fn = NULL; 802 + issue_flush_fn *issue_fn = NULL; 803 + 804 + if (drive->wcache) { 805 + unsigned long long capacity; 806 + int barrier; 807 + /* 808 + * We must avoid issuing commands a drive does not 809 + * understand or we may crash it. We check flush cache 810 + * is supported. We also check we have the LBA48 flush 811 + * cache if the drive capacity is too large. By this 812 + * time we have trimmed the drive capacity if LBA48 is 813 + * not available so we don't need to recheck that. 814 + */ 815 + capacity = idedisk_capacity(drive); 816 + barrier = ide_id_has_flush_cache(id) && 817 + (drive->addressing == 0 || capacity <= (1ULL << 28) || 818 + ide_id_has_flush_cache_ext(id)); 819 + 820 + printk(KERN_INFO "%s: cache flushes %ssupported\n", 821 + drive->name, barrier ? "" : "not"); 822 + 823 + if (barrier) { 824 + ordered = QUEUE_ORDERED_DRAIN_FLUSH; 825 + prep_fn = idedisk_prepare_flush; 826 + issue_fn = idedisk_issue_flush; 827 + } 828 + } else 829 + ordered = QUEUE_ORDERED_DRAIN; 830 + 831 + blk_queue_ordered(drive->queue, ordered, prep_fn); 832 + blk_queue_issue_flush_fn(drive->queue, issue_fn); 833 + } 834 + 755 835 static int write_cache(ide_drive_t *drive, int arg) 756 836 { 757 837 ide_task_t args; 758 - int err; 838 + int err = 1; 759 839 760 - if (!ide_id_has_flush_cache(drive->id)) 761 - return 1; 762 - 763 - memset(&args, 0, sizeof(ide_task_t)); 764 - args.tfRegister[IDE_FEATURE_OFFSET] = (arg) ? 840 + if (ide_id_has_flush_cache(drive->id)) { 841 + memset(&args, 0, sizeof(ide_task_t)); 842 + args.tfRegister[IDE_FEATURE_OFFSET] = (arg) ? 765 843 SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE; 766 - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES; 767 - args.command_type = IDE_DRIVE_TASK_NO_DATA; 768 - args.handler = &task_no_data_intr; 844 + args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES; 845 + args.command_type = IDE_DRIVE_TASK_NO_DATA; 846 + args.handler = &task_no_data_intr; 847 + err = ide_raw_taskfile(drive, &args, NULL); 848 + if (err == 0) 849 + drive->wcache = arg; 850 + } 769 851 770 - err = ide_raw_taskfile(drive, &args, NULL); 771 - if (err) 772 - return err; 852 + update_ordered(drive); 773 853 774 - drive->wcache = arg; 775 - return 0; 854 + return err; 776 855 } 777 856 778 857 static int do_idedisk_flushcache (ide_drive_t *drive) ··· 883 888 { 884 889 struct hd_driveid *id = drive->id; 885 890 unsigned long long capacity; 886 - int barrier; 887 891 888 892 idedisk_add_settings(drive); 889 893 ··· 986 992 drive->wcache = 1; 987 993 988 994 write_cache(drive, 1); 989 - 990 - /* 991 - * We must avoid issuing commands a drive does not understand 992 - * or we may crash it. We check flush cache is supported. We also 993 - * check we have the LBA48 flush cache if the drive capacity is 994 - * too large. By this time we have trimmed the drive capacity if 995 - * LBA48 is not available so we don't need to recheck that. 996 - */ 997 - barrier = 0; 998 - if (ide_id_has_flush_cache(id)) 999 - barrier = 1; 1000 - if (drive->addressing == 1) { 1001 - /* Can't issue the correct flush ? */ 1002 - if (capacity > (1ULL << 28) && !ide_id_has_flush_cache_ext(id)) 1003 - barrier = 0; 1004 - } 1005 - 1006 - printk(KERN_INFO "%s: cache flushes %ssupported\n", 1007 - drive->name, barrier ? "" : "not "); 1008 - if (barrier) { 1009 - blk_queue_ordered(drive->queue, QUEUE_ORDERED_FLUSH); 1010 - drive->queue->prepare_flush_fn = idedisk_prepare_flush; 1011 - drive->queue->end_flush_fn = idedisk_end_flush; 1012 - blk_queue_issue_flush_fn(drive->queue, idedisk_issue_flush); 1013 - } 1014 995 } 1015 996 1016 997 static void ide_cacheflush_p(ide_drive_t *drive)
+4 -7
drivers/ide/ide-io.c
··· 89 89 90 90 blkdev_dequeue_request(rq); 91 91 HWGROUP(drive)->rq = NULL; 92 - end_that_request_last(rq); 92 + end_that_request_last(rq, uptodate); 93 93 ret = 0; 94 94 } 95 95 return ret; ··· 119 119 if (!nr_sectors) 120 120 nr_sectors = rq->hard_cur_sectors; 121 121 122 - if (blk_complete_barrier_rq_locked(drive->queue, rq, nr_sectors)) 123 - ret = rq->nr_sectors != 0; 124 - else 125 - ret = __ide_end_request(drive, rq, uptodate, nr_sectors); 122 + ret = __ide_end_request(drive, rq, uptodate, nr_sectors); 126 123 127 124 spin_unlock_irqrestore(&ide_lock, flags); 128 125 return ret; ··· 244 247 } 245 248 blkdev_dequeue_request(rq); 246 249 HWGROUP(drive)->rq = NULL; 247 - end_that_request_last(rq); 250 + end_that_request_last(rq, 1); 248 251 spin_unlock_irqrestore(&ide_lock, flags); 249 252 } 250 253 ··· 376 379 blkdev_dequeue_request(rq); 377 380 HWGROUP(drive)->rq = NULL; 378 381 rq->errors = err; 379 - end_that_request_last(rq); 382 + end_that_request_last(rq, !rq->errors); 380 383 spin_unlock_irqrestore(&ide_lock, flags); 381 384 } 382 385
+1 -1
drivers/message/i2o/i2o_block.c
··· 468 468 469 469 spin_lock_irqsave(q->queue_lock, flags); 470 470 471 - end_that_request_last(req); 471 + end_that_request_last(req, uptodate); 472 472 473 473 if (likely(dev)) { 474 474 dev->open_queue_depth--;
+2 -2
drivers/mmc/mmc_block.c
··· 263 263 */ 264 264 add_disk_randomness(req->rq_disk); 265 265 blkdev_dequeue_request(req); 266 - end_that_request_last(req); 266 + end_that_request_last(req, 1); 267 267 } 268 268 spin_unlock_irq(&md->lock); 269 269 } while (ret); ··· 289 289 290 290 add_disk_randomness(req->rq_disk); 291 291 blkdev_dequeue_request(req); 292 - end_that_request_last(req); 292 + end_that_request_last(req, 0); 293 293 spin_unlock_irq(&md->lock); 294 294 295 295 return 0;
+1 -1
drivers/s390/block/dasd.c
··· 1035 1035 if (end_that_request_first(req, uptodate, req->hard_nr_sectors)) 1036 1036 BUG(); 1037 1037 add_disk_randomness(req->rq_disk); 1038 - end_that_request_last(req); 1038 + end_that_request_last(req, uptodate); 1039 1039 } 1040 1040 1041 1041 /*
+1 -1
drivers/s390/char/tape_block.c
··· 78 78 { 79 79 if (end_that_request_first(req, uptodate, req->hard_nr_sectors)) 80 80 BUG(); 81 - end_that_request_last(req); 81 + end_that_request_last(req, uptodate); 82 82 } 83 83 84 84 static void
-1
drivers/scsi/ahci.c
··· 214 214 .dma_boundary = AHCI_DMA_BOUNDARY, 215 215 .slave_configure = ata_scsi_slave_config, 216 216 .bios_param = ata_std_bios_param, 217 - .ordered_flush = 1, 218 217 }; 219 218 220 219 static const struct ata_port_operations ahci_ops = {
-1
drivers/scsi/ata_piix.c
··· 187 187 .dma_boundary = ATA_DMA_BOUNDARY, 188 188 .slave_configure = ata_scsi_slave_config, 189 189 .bios_param = ata_std_bios_param, 190 - .ordered_flush = 1, 191 190 .resume = ata_scsi_device_resume, 192 191 .suspend = ata_scsi_device_suspend, 193 192 };
-9
drivers/scsi/hosts.c
··· 347 347 shost->cmd_per_lun = sht->cmd_per_lun; 348 348 shost->unchecked_isa_dma = sht->unchecked_isa_dma; 349 349 shost->use_clustering = sht->use_clustering; 350 - shost->ordered_flush = sht->ordered_flush; 351 350 shost->ordered_tag = sht->ordered_tag; 352 - 353 - /* 354 - * hosts/devices that do queueing must support ordered tags 355 - */ 356 - if (shost->can_queue > 1 && shost->ordered_flush) { 357 - printk(KERN_ERR "scsi: ordered flushes don't support queueing\n"); 358 - shost->ordered_flush = 0; 359 - } 360 351 361 352 if (sht->max_host_blocked) 362 353 shost->max_host_blocked = sht->max_host_blocked;
+2 -2
drivers/scsi/ide-scsi.c
··· 1046 1046 1047 1047 /* kill current request */ 1048 1048 blkdev_dequeue_request(req); 1049 - end_that_request_last(req); 1049 + end_that_request_last(req, 0); 1050 1050 if (req->flags & REQ_SENSE) 1051 1051 kfree(scsi->pc->buffer); 1052 1052 kfree(scsi->pc); ··· 1056 1056 /* now nuke the drive queue */ 1057 1057 while ((req = elv_next_request(drive->queue))) { 1058 1058 blkdev_dequeue_request(req); 1059 - end_that_request_last(req); 1059 + end_that_request_last(req, 0); 1060 1060 } 1061 1061 1062 1062 HWGROUP(drive)->rq = NULL;
+25 -6
drivers/scsi/libata-core.c
··· 562 562 ATA_CMD_WRITE_MULTI, 563 563 ATA_CMD_READ_MULTI_EXT, 564 564 ATA_CMD_WRITE_MULTI_EXT, 565 + 0, 566 + 0, 567 + 0, 568 + ATA_CMD_WRITE_MULTI_FUA_EXT, 565 569 /* pio */ 566 570 ATA_CMD_PIO_READ, 567 571 ATA_CMD_PIO_WRITE, 568 572 ATA_CMD_PIO_READ_EXT, 569 573 ATA_CMD_PIO_WRITE_EXT, 574 + 0, 575 + 0, 576 + 0, 577 + 0, 570 578 /* dma */ 571 579 ATA_CMD_READ, 572 580 ATA_CMD_WRITE, 573 581 ATA_CMD_READ_EXT, 574 - ATA_CMD_WRITE_EXT 582 + ATA_CMD_WRITE_EXT, 583 + 0, 584 + 0, 585 + 0, 586 + ATA_CMD_WRITE_FUA_EXT 575 587 }; 576 588 577 589 /** ··· 596 584 * LOCKING: 597 585 * caller. 598 586 */ 599 - void ata_rwcmd_protocol(struct ata_queued_cmd *qc) 587 + int ata_rwcmd_protocol(struct ata_queued_cmd *qc) 600 588 { 601 589 struct ata_taskfile *tf = &qc->tf; 602 590 struct ata_device *dev = qc->dev; 591 + u8 cmd; 603 592 604 - int index, lba48, write; 593 + int index, fua, lba48, write; 605 594 595 + fua = (tf->flags & ATA_TFLAG_FUA) ? 4 : 0; 606 596 lba48 = (tf->flags & ATA_TFLAG_LBA48) ? 2 : 0; 607 597 write = (tf->flags & ATA_TFLAG_WRITE) ? 1 : 0; 608 598 609 599 if (dev->flags & ATA_DFLAG_PIO) { 610 600 tf->protocol = ATA_PROT_PIO; 611 - index = dev->multi_count ? 0 : 4; 601 + index = dev->multi_count ? 0 : 8; 612 602 } else { 613 603 tf->protocol = ATA_PROT_DMA; 614 - index = 8; 604 + index = 16; 615 605 } 616 606 617 - tf->command = ata_rw_cmds[index + lba48 + write]; 607 + cmd = ata_rw_cmds[index + fua + lba48 + write]; 608 + if (cmd) { 609 + tf->command = cmd; 610 + return 0; 611 + } 612 + return -1; 618 613 } 619 614 620 615 static const char * const xfer_mode_str[] = {
+26 -6
drivers/scsi/libata-scsi.c
··· 1096 1096 scsicmd[0] == WRITE_16) 1097 1097 tf->flags |= ATA_TFLAG_WRITE; 1098 1098 1099 - /* Calculate the SCSI LBA and transfer length. */ 1099 + /* Calculate the SCSI LBA, transfer length and FUA. */ 1100 1100 switch (scsicmd[0]) { 1101 1101 case READ_10: 1102 1102 case WRITE_10: 1103 1103 scsi_10_lba_len(scsicmd, &block, &n_block); 1104 + if (unlikely(scsicmd[1] & (1 << 3))) 1105 + tf->flags |= ATA_TFLAG_FUA; 1104 1106 break; 1105 1107 case READ_6: 1106 1108 case WRITE_6: ··· 1117 1115 case READ_16: 1118 1116 case WRITE_16: 1119 1117 scsi_16_lba_len(scsicmd, &block, &n_block); 1118 + if (unlikely(scsicmd[1] & (1 << 3))) 1119 + tf->flags |= ATA_TFLAG_FUA; 1120 1120 break; 1121 1121 default: 1122 1122 DPRINTK("no-byte command\n"); ··· 1162 1158 tf->device |= (block >> 24) & 0xf; 1163 1159 } 1164 1160 1165 - ata_rwcmd_protocol(qc); 1161 + if (unlikely(ata_rwcmd_protocol(qc) < 0)) 1162 + goto invalid_fld; 1166 1163 1167 1164 qc->nsect = n_block; 1168 1165 tf->nsect = n_block & 0xff; ··· 1181 1176 if ((block >> 28) || (n_block > 256)) 1182 1177 goto out_of_range; 1183 1178 1184 - ata_rwcmd_protocol(qc); 1179 + if (unlikely(ata_rwcmd_protocol(qc) < 0)) 1180 + goto invalid_fld; 1185 1181 1186 1182 /* Convert LBA to CHS */ 1187 1183 track = (u32)block / dev->sectors; ··· 1717 1711 unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, 1718 1712 unsigned int buflen) 1719 1713 { 1714 + struct ata_device *dev = args->dev; 1720 1715 u8 *scsicmd = args->cmd->cmnd, *p, *last; 1721 1716 const u8 sat_blk_desc[] = { 1722 1717 0, 0, 0, 0, /* number of blocks: sat unspecified */ ··· 1726 1719 }; 1727 1720 u8 pg, spg; 1728 1721 unsigned int ebd, page_control, six_byte, output_len, alloc_len, minlen; 1722 + u8 dpofua; 1729 1723 1730 1724 VPRINTK("ENTER\n"); 1731 1725 ··· 1795 1787 1796 1788 if (minlen < 1) 1797 1789 return 0; 1790 + 1791 + dpofua = 0; 1792 + if (ata_id_has_fua(args->id) && dev->flags & ATA_DFLAG_LBA48 && 1793 + (!(dev->flags & ATA_DFLAG_PIO) || dev->multi_count)) 1794 + dpofua = 1 << 4; 1795 + 1798 1796 if (six_byte) { 1799 1797 output_len--; 1800 1798 rbuf[0] = output_len; 1799 + if (minlen > 2) 1800 + rbuf[2] |= dpofua; 1801 1801 if (ebd) { 1802 1802 if (minlen > 3) 1803 1803 rbuf[3] = sizeof(sat_blk_desc); ··· 1818 1802 rbuf[0] = output_len >> 8; 1819 1803 if (minlen > 1) 1820 1804 rbuf[1] = output_len; 1805 + if (minlen > 3) 1806 + rbuf[3] |= dpofua; 1821 1807 if (ebd) { 1822 1808 if (minlen > 7) 1823 1809 rbuf[7] = sizeof(sat_blk_desc); ··· 2480 2462 if (xlat_func) 2481 2463 ata_scsi_translate(ap, dev, cmd, done, xlat_func); 2482 2464 else 2483 - ata_scsi_simulate(dev->id, cmd, done); 2465 + ata_scsi_simulate(ap, dev, cmd, done); 2484 2466 } else 2485 2467 ata_scsi_translate(ap, dev, cmd, done, atapi_xlat); 2486 2468 ··· 2503 2485 * spin_lock_irqsave(host_set lock) 2504 2486 */ 2505 2487 2506 - void ata_scsi_simulate(u16 *id, 2488 + void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, 2507 2489 struct scsi_cmnd *cmd, 2508 2490 void (*done)(struct scsi_cmnd *)) 2509 2491 { 2510 2492 struct ata_scsi_args args; 2511 2493 const u8 *scsicmd = cmd->cmnd; 2512 2494 2513 - args.id = id; 2495 + args.ap = ap; 2496 + args.dev = dev; 2497 + args.id = dev->id; 2514 2498 args.cmd = cmd; 2515 2499 args.done = done; 2516 2500
+3 -1
drivers/scsi/libata.h
··· 32 32 #define DRV_VERSION "1.20" /* must be exactly four chars */ 33 33 34 34 struct ata_scsi_args { 35 + struct ata_port *ap; 36 + struct ata_device *dev; 35 37 u16 *id; 36 38 struct scsi_cmnd *cmd; 37 39 void (*done)(struct scsi_cmnd *); ··· 43 41 extern int atapi_enabled; 44 42 extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, 45 43 struct ata_device *dev); 46 - extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc); 44 + extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc); 47 45 extern void ata_qc_free(struct ata_queued_cmd *qc); 48 46 extern int ata_qc_issue(struct ata_queued_cmd *qc); 49 47 extern int ata_check_atapi_dma(struct ata_queued_cmd *qc);
-1
drivers/scsi/sata_mv.c
··· 374 374 .dma_boundary = MV_DMA_BOUNDARY, 375 375 .slave_configure = ata_scsi_slave_config, 376 376 .bios_param = ata_std_bios_param, 377 - .ordered_flush = 1, 378 377 }; 379 378 380 379 static const struct ata_port_operations mv5_ops = {
-1
drivers/scsi/sata_nv.c
··· 235 235 .dma_boundary = ATA_DMA_BOUNDARY, 236 236 .slave_configure = ata_scsi_slave_config, 237 237 .bios_param = ata_std_bios_param, 238 - .ordered_flush = 1, 239 238 }; 240 239 241 240 static const struct ata_port_operations nv_ops = {
-1
drivers/scsi/sata_promise.c
··· 114 114 .dma_boundary = ATA_DMA_BOUNDARY, 115 115 .slave_configure = ata_scsi_slave_config, 116 116 .bios_param = ata_std_bios_param, 117 - .ordered_flush = 1, 118 117 }; 119 118 120 119 static const struct ata_port_operations pdc_sata_ops = {
-1
drivers/scsi/sata_sil.c
··· 147 147 .dma_boundary = ATA_DMA_BOUNDARY, 148 148 .slave_configure = ata_scsi_slave_config, 149 149 .bios_param = ata_std_bios_param, 150 - .ordered_flush = 1, 151 150 }; 152 151 153 152 static const struct ata_port_operations sil_ops = {
-1
drivers/scsi/sata_sil24.c
··· 292 292 .dma_boundary = ATA_DMA_BOUNDARY, 293 293 .slave_configure = ata_scsi_slave_config, 294 294 .bios_param = ata_std_bios_param, 295 - .ordered_flush = 1, /* NCQ not supported yet */ 296 295 }; 297 296 298 297 static const struct ata_port_operations sil24_ops = {
-1
drivers/scsi/sata_sis.c
··· 99 99 .dma_boundary = ATA_DMA_BOUNDARY, 100 100 .slave_configure = ata_scsi_slave_config, 101 101 .bios_param = ata_std_bios_param, 102 - .ordered_flush = 1, 103 102 }; 104 103 105 104 static const struct ata_port_operations sis_ops = {
-1
drivers/scsi/sata_svw.c
··· 303 303 .proc_info = k2_sata_proc_info, 304 304 #endif 305 305 .bios_param = ata_std_bios_param, 306 - .ordered_flush = 1, 307 306 }; 308 307 309 308
-1
drivers/scsi/sata_sx4.c
··· 194 194 .dma_boundary = ATA_DMA_BOUNDARY, 195 195 .slave_configure = ata_scsi_slave_config, 196 196 .bios_param = ata_std_bios_param, 197 - .ordered_flush = 1, 198 197 }; 199 198 200 199 static const struct ata_port_operations pdc_20621_ops = {
-1
drivers/scsi/sata_uli.c
··· 87 87 .dma_boundary = ATA_DMA_BOUNDARY, 88 88 .slave_configure = ata_scsi_slave_config, 89 89 .bios_param = ata_std_bios_param, 90 - .ordered_flush = 1, 91 90 }; 92 91 93 92 static const struct ata_port_operations uli_ops = {
-1
drivers/scsi/sata_via.c
··· 106 106 .dma_boundary = ATA_DMA_BOUNDARY, 107 107 .slave_configure = ata_scsi_slave_config, 108 108 .bios_param = ata_std_bios_param, 109 - .ordered_flush = 1, 110 109 }; 111 110 112 111 static const struct ata_port_operations svia_sata_ops = {
-1
drivers/scsi/sata_vsc.c
··· 235 235 .dma_boundary = ATA_DMA_BOUNDARY, 236 236 .slave_configure = ata_scsi_slave_config, 237 237 .bios_param = ata_std_bios_param, 238 - .ordered_flush = 1, 239 238 }; 240 239 241 240
+2 -48
drivers/scsi/scsi_lib.c
··· 308 308 309 309 static kmem_cache_t *scsi_io_context_cache; 310 310 311 - static void scsi_end_async(struct request *req) 311 + static void scsi_end_async(struct request *req, int uptodate) 312 312 { 313 313 struct scsi_io_context *sioc = req->end_io_data; 314 314 ··· 791 791 spin_lock_irqsave(q->queue_lock, flags); 792 792 if (blk_rq_tagged(req)) 793 793 blk_queue_end_tag(q, req); 794 - end_that_request_last(req); 794 + end_that_request_last(req, uptodate); 795 795 spin_unlock_irqrestore(q->queue_lock, flags); 796 796 797 797 /* ··· 931 931 struct scsi_sense_hdr sshdr; 932 932 int sense_valid = 0; 933 933 int sense_deferred = 0; 934 - 935 - if (blk_complete_barrier_rq(q, req, good_bytes >> 9)) 936 - return; 937 934 938 935 /* 939 936 * Free up any indirection buffers we allocated for DMA purposes. ··· 1194 1197 scsi_release_buffers(cmd); 1195 1198 scsi_put_command(cmd); 1196 1199 return BLKPREP_KILL; 1197 - } 1198 - 1199 - static int scsi_prepare_flush_fn(request_queue_t *q, struct request *rq) 1200 - { 1201 - struct scsi_device *sdev = q->queuedata; 1202 - struct scsi_driver *drv; 1203 - 1204 - if (sdev->sdev_state == SDEV_RUNNING) { 1205 - drv = *(struct scsi_driver **) rq->rq_disk->private_data; 1206 - 1207 - if (drv->prepare_flush) 1208 - return drv->prepare_flush(q, rq); 1209 - } 1210 - 1211 - return 0; 1212 - } 1213 - 1214 - static void scsi_end_flush_fn(request_queue_t *q, struct request *rq) 1215 - { 1216 - struct scsi_device *sdev = q->queuedata; 1217 - struct request *flush_rq = rq->end_io_data; 1218 - struct scsi_driver *drv; 1219 - 1220 - if (flush_rq->errors) { 1221 - printk("scsi: barrier error, disabling flush support\n"); 1222 - blk_queue_ordered(q, QUEUE_ORDERED_NONE); 1223 - } 1224 - 1225 - if (sdev->sdev_state == SDEV_RUNNING) { 1226 - drv = *(struct scsi_driver **) rq->rq_disk->private_data; 1227 - drv->end_flush(q, rq); 1228 - } 1229 1200 } 1230 1201 1231 1202 static int scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk, ··· 1667 1702 blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost)); 1668 1703 blk_queue_segment_boundary(q, shost->dma_boundary); 1669 1704 blk_queue_issue_flush_fn(q, scsi_issue_flush_fn); 1670 - 1671 - /* 1672 - * ordered tags are superior to flush ordering 1673 - */ 1674 - if (shost->ordered_tag) 1675 - blk_queue_ordered(q, QUEUE_ORDERED_TAG); 1676 - else if (shost->ordered_flush) { 1677 - blk_queue_ordered(q, QUEUE_ORDERED_FLUSH); 1678 - q->prepare_flush_fn = scsi_prepare_flush_fn; 1679 - q->end_flush_fn = scsi_end_flush_fn; 1680 - } 1681 1705 1682 1706 if (!shost->use_clustering) 1683 1707 clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags);
+45 -40
drivers/scsi/sd.c
··· 102 102 u8 write_prot; 103 103 unsigned WCE : 1; /* state of disk WCE bit */ 104 104 unsigned RCD : 1; /* state of disk RCD bit, unused */ 105 + unsigned DPOFUA : 1; /* state of disk DPOFUA bit */ 105 106 }; 106 107 107 108 static DEFINE_IDR(sd_index_idr); ··· 122 121 static void sd_rescan(struct device *); 123 122 static int sd_init_command(struct scsi_cmnd *); 124 123 static int sd_issue_flush(struct device *, sector_t *); 125 - static void sd_end_flush(request_queue_t *, struct request *); 126 - static int sd_prepare_flush(request_queue_t *, struct request *); 124 + static void sd_prepare_flush(request_queue_t *, struct request *); 127 125 static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname, 128 126 unsigned char *buffer); 129 127 ··· 137 137 .rescan = sd_rescan, 138 138 .init_command = sd_init_command, 139 139 .issue_flush = sd_issue_flush, 140 - .prepare_flush = sd_prepare_flush, 141 - .end_flush = sd_end_flush, 142 140 }; 143 141 144 142 /* ··· 344 346 345 347 if (block > 0xffffffff) { 346 348 SCpnt->cmnd[0] += READ_16 - READ_6; 349 + SCpnt->cmnd[1] |= blk_fua_rq(rq) ? 0x8 : 0; 347 350 SCpnt->cmnd[2] = sizeof(block) > 4 ? (unsigned char) (block >> 56) & 0xff : 0; 348 351 SCpnt->cmnd[3] = sizeof(block) > 4 ? (unsigned char) (block >> 48) & 0xff : 0; 349 352 SCpnt->cmnd[4] = sizeof(block) > 4 ? (unsigned char) (block >> 40) & 0xff : 0; ··· 364 365 this_count = 0xffff; 365 366 366 367 SCpnt->cmnd[0] += READ_10 - READ_6; 368 + SCpnt->cmnd[1] |= blk_fua_rq(rq) ? 0x8 : 0; 367 369 SCpnt->cmnd[2] = (unsigned char) (block >> 24) & 0xff; 368 370 SCpnt->cmnd[3] = (unsigned char) (block >> 16) & 0xff; 369 371 SCpnt->cmnd[4] = (unsigned char) (block >> 8) & 0xff; ··· 373 373 SCpnt->cmnd[7] = (unsigned char) (this_count >> 8) & 0xff; 374 374 SCpnt->cmnd[8] = (unsigned char) this_count & 0xff; 375 375 } else { 376 + if (unlikely(blk_fua_rq(rq))) { 377 + /* 378 + * This happens only if this drive failed 379 + * 10byte rw command with ILLEGAL_REQUEST 380 + * during operation and thus turned off 381 + * use_10_for_rw. 382 + */ 383 + printk(KERN_ERR "sd: FUA write on READ/WRITE(6) drive\n"); 384 + return 0; 385 + } 386 + 376 387 SCpnt->cmnd[1] |= (unsigned char) ((block >> 16) & 0x1f); 377 388 SCpnt->cmnd[2] = (unsigned char) ((block >> 8) & 0xff); 378 389 SCpnt->cmnd[3] = (unsigned char) block & 0xff; ··· 740 729 return ret; 741 730 } 742 731 743 - static void sd_end_flush(request_queue_t *q, struct request *flush_rq) 732 + static void sd_prepare_flush(request_queue_t *q, struct request *rq) 744 733 { 745 - struct request *rq = flush_rq->end_io_data; 746 - struct scsi_cmnd *cmd = rq->special; 747 - unsigned int bytes = rq->hard_nr_sectors << 9; 748 - 749 - if (!flush_rq->errors) { 750 - spin_unlock(q->queue_lock); 751 - scsi_io_completion(cmd, bytes, 0); 752 - spin_lock(q->queue_lock); 753 - } else if (blk_barrier_postflush(rq)) { 754 - spin_unlock(q->queue_lock); 755 - scsi_io_completion(cmd, 0, bytes); 756 - spin_lock(q->queue_lock); 757 - } else { 758 - /* 759 - * force journal abort of barriers 760 - */ 761 - end_that_request_first(rq, -EOPNOTSUPP, rq->hard_nr_sectors); 762 - end_that_request_last(rq); 763 - } 764 - } 765 - 766 - static int sd_prepare_flush(request_queue_t *q, struct request *rq) 767 - { 768 - struct scsi_device *sdev = q->queuedata; 769 - struct scsi_disk *sdkp = dev_get_drvdata(&sdev->sdev_gendev); 770 - 771 - if (!sdkp || !sdkp->WCE) 772 - return 0; 773 - 774 734 memset(rq->cmd, 0, sizeof(rq->cmd)); 775 - rq->flags |= REQ_BLOCK_PC | REQ_SOFTBARRIER; 735 + rq->flags |= REQ_BLOCK_PC; 776 736 rq->timeout = SD_TIMEOUT; 777 737 rq->cmd[0] = SYNCHRONIZE_CACHE; 778 - return 1; 738 + rq->cmd_len = 10; 779 739 } 780 740 781 741 static void sd_rescan(struct device *dev) ··· 1409 1427 sdkp->RCD = 0; 1410 1428 } 1411 1429 1430 + sdkp->DPOFUA = (data.device_specific & 0x10) != 0; 1431 + if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw) { 1432 + printk(KERN_NOTICE "SCSI device %s: uses " 1433 + "READ/WRITE(6), disabling FUA\n", diskname); 1434 + sdkp->DPOFUA = 0; 1435 + } 1436 + 1412 1437 ct = sdkp->RCD + 2*sdkp->WCE; 1413 1438 1414 - printk(KERN_NOTICE "SCSI device %s: drive cache: %s\n", 1415 - diskname, types[ct]); 1439 + printk(KERN_NOTICE "SCSI device %s: drive cache: %s%s\n", 1440 + diskname, types[ct], 1441 + sdkp->DPOFUA ? " w/ FUA" : ""); 1416 1442 1417 1443 return; 1418 1444 } ··· 1452 1462 struct scsi_disk *sdkp = scsi_disk(disk); 1453 1463 struct scsi_device *sdp = sdkp->device; 1454 1464 unsigned char *buffer; 1465 + unsigned ordered; 1455 1466 1456 1467 SCSI_LOG_HLQUEUE(3, printk("sd_revalidate_disk: disk=%s\n", disk->disk_name)); 1457 1468 ··· 1489 1498 sd_read_write_protect_flag(sdkp, disk->disk_name, buffer); 1490 1499 sd_read_cache_type(sdkp, disk->disk_name, buffer); 1491 1500 } 1492 - 1501 + 1502 + /* 1503 + * We now have all cache related info, determine how we deal 1504 + * with ordered requests. Note that as the current SCSI 1505 + * dispatch function can alter request order, we cannot use 1506 + * QUEUE_ORDERED_TAG_* even when ordered tag is supported. 1507 + */ 1508 + if (sdkp->WCE) 1509 + ordered = sdkp->DPOFUA 1510 + ? QUEUE_ORDERED_DRAIN_FUA : QUEUE_ORDERED_DRAIN_FLUSH; 1511 + else 1512 + ordered = QUEUE_ORDERED_DRAIN; 1513 + 1514 + blk_queue_ordered(sdkp->disk->queue, ordered, sd_prepare_flush); 1515 + 1493 1516 set_capacity(disk, sdkp->capacity); 1494 1517 kfree(buffer); 1495 1518 ··· 1603 1598 strcpy(gd->devfs_name, sdp->devfs_name); 1604 1599 1605 1600 gd->private_data = &sdkp->driver; 1601 + gd->queue = sdkp->device->request_queue; 1606 1602 1607 1603 sd_revalidate_disk(gd); 1608 1604 ··· 1611 1605 gd->flags = GENHD_FL_DRIVERFS; 1612 1606 if (sdp->removable) 1613 1607 gd->flags |= GENHD_FL_REMOVABLE; 1614 - gd->queue = sdkp->device->request_queue; 1615 1608 1616 1609 dev_set_drvdata(dev, sdkp); 1617 1610 add_disk(gd);
+24 -2
fs/bio.c
··· 325 325 if (unlikely(bio_flagged(bio, BIO_CLONED))) 326 326 return 0; 327 327 328 - if (bio->bi_vcnt >= bio->bi_max_vecs) 328 + if (((bio->bi_size + len) >> 9) > max_sectors) 329 329 return 0; 330 330 331 - if (((bio->bi_size + len) >> 9) > max_sectors) 331 + /* 332 + * For filesystems with a blocksize smaller than the pagesize 333 + * we will often be called with the same page as last time and 334 + * a consecutive offset. Optimize this special case. 335 + */ 336 + if (bio->bi_vcnt > 0) { 337 + struct bio_vec *prev = &bio->bi_io_vec[bio->bi_vcnt - 1]; 338 + 339 + if (page == prev->bv_page && 340 + offset == prev->bv_offset + prev->bv_len) { 341 + prev->bv_len += len; 342 + if (q->merge_bvec_fn && 343 + q->merge_bvec_fn(q, bio, prev) < len) { 344 + prev->bv_len -= len; 345 + return 0; 346 + } 347 + 348 + goto done; 349 + } 350 + } 351 + 352 + if (bio->bi_vcnt >= bio->bi_max_vecs) 332 353 return 0; 333 354 334 355 /* ··· 403 382 bio->bi_vcnt++; 404 383 bio->bi_phys_segments++; 405 384 bio->bi_hw_segments++; 385 + done: 406 386 bio->bi_size += len; 407 387 return len; 408 388 }
+5 -1
include/linux/ata.h
··· 129 129 ATA_CMD_READ_EXT = 0x25, 130 130 ATA_CMD_WRITE = 0xCA, 131 131 ATA_CMD_WRITE_EXT = 0x35, 132 + ATA_CMD_WRITE_FUA_EXT = 0x3D, 132 133 ATA_CMD_PIO_READ = 0x20, 133 134 ATA_CMD_PIO_READ_EXT = 0x24, 134 135 ATA_CMD_PIO_WRITE = 0x30, ··· 138 137 ATA_CMD_READ_MULTI_EXT = 0x29, 139 138 ATA_CMD_WRITE_MULTI = 0xC5, 140 139 ATA_CMD_WRITE_MULTI_EXT = 0x39, 140 + ATA_CMD_WRITE_MULTI_FUA_EXT = 0xCE, 141 141 ATA_CMD_SET_FEATURES = 0xEF, 142 142 ATA_CMD_PACKET = 0xA0, 143 143 ATA_CMD_VERIFY = 0x40, ··· 196 194 ATA_TFLAG_DEVICE = (1 << 2), /* enable r/w to device reg */ 197 195 ATA_TFLAG_WRITE = (1 << 3), /* data dir: host->dev==1 (write) */ 198 196 ATA_TFLAG_LBA = (1 << 4), /* enable LBA */ 197 + ATA_TFLAG_FUA = (1 << 5), /* enable FUA */ 199 198 }; 200 199 201 200 enum ata_tf_protocols { ··· 250 247 #define ata_id_is_sata(id) ((id)[93] == 0) 251 248 #define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6)) 252 249 #define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5)) 253 - #define ata_id_has_flush(id) ((id)[83] & (1 << 12)) 250 + #define ata_id_has_fua(id) ((id)[84] & (1 << 6)) 251 + #define ata_id_has_flush(id) ((id)[83] & (1 << 12)) 254 252 #define ata_id_has_flush_ext(id) ((id)[83] & (1 << 13)) 255 253 #define ata_id_has_lba48(id) ((id)[83] & (1 << 10)) 256 254 #define ata_id_has_wcache(id) ((id)[82] & (1 << 5))
+61 -30
include/linux/blkdev.h
··· 102 102 void swap_io_context(struct io_context **ioc1, struct io_context **ioc2); 103 103 104 104 struct request; 105 - typedef void (rq_end_io_fn)(struct request *); 105 + typedef void (rq_end_io_fn)(struct request *, int); 106 106 107 107 struct request_list { 108 108 int count[2]; ··· 207 207 __REQ_SORTED, /* elevator knows about this request */ 208 208 __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ 209 209 __REQ_HARDBARRIER, /* may not be passed by drive either */ 210 + __REQ_FUA, /* forced unit access */ 210 211 __REQ_CMD, /* is a regular fs rw request */ 211 212 __REQ_NOMERGE, /* don't touch this for merging */ 212 213 __REQ_STARTED, /* drive already may have started this one */ ··· 231 230 __REQ_PM_SUSPEND, /* suspend request */ 232 231 __REQ_PM_RESUME, /* resume request */ 233 232 __REQ_PM_SHUTDOWN, /* shutdown request */ 234 - __REQ_BAR_PREFLUSH, /* barrier pre-flush done */ 235 - __REQ_BAR_POSTFLUSH, /* barrier post-flush */ 236 - __REQ_BAR_FLUSH, /* rq is the flush request */ 233 + __REQ_ORDERED_COLOR, /* is before or after barrier */ 237 234 __REQ_NR_BITS, /* stops here */ 238 235 }; 239 236 ··· 240 241 #define REQ_SORTED (1 << __REQ_SORTED) 241 242 #define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) 242 243 #define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER) 244 + #define REQ_FUA (1 << __REQ_FUA) 243 245 #define REQ_CMD (1 << __REQ_CMD) 244 246 #define REQ_NOMERGE (1 << __REQ_NOMERGE) 245 247 #define REQ_STARTED (1 << __REQ_STARTED) ··· 260 260 #define REQ_PM_SUSPEND (1 << __REQ_PM_SUSPEND) 261 261 #define REQ_PM_RESUME (1 << __REQ_PM_RESUME) 262 262 #define REQ_PM_SHUTDOWN (1 << __REQ_PM_SHUTDOWN) 263 - #define REQ_BAR_PREFLUSH (1 << __REQ_BAR_PREFLUSH) 264 - #define REQ_BAR_POSTFLUSH (1 << __REQ_BAR_POSTFLUSH) 265 - #define REQ_BAR_FLUSH (1 << __REQ_BAR_FLUSH) 263 + #define REQ_ORDERED_COLOR (1 << __REQ_ORDERED_COLOR) 266 264 267 265 /* 268 266 * State information carried for REQ_PM_SUSPEND and REQ_PM_RESUME ··· 290 292 typedef int (merge_bvec_fn) (request_queue_t *, struct bio *, struct bio_vec *); 291 293 typedef void (activity_fn) (void *data, int rw); 292 294 typedef int (issue_flush_fn) (request_queue_t *, struct gendisk *, sector_t *); 293 - typedef int (prepare_flush_fn) (request_queue_t *, struct request *); 294 - typedef void (end_flush_fn) (request_queue_t *, struct request *); 295 + typedef void (prepare_flush_fn) (request_queue_t *, struct request *); 295 296 296 297 enum blk_queue_state { 297 298 Queue_down, ··· 332 335 activity_fn *activity_fn; 333 336 issue_flush_fn *issue_flush_fn; 334 337 prepare_flush_fn *prepare_flush_fn; 335 - end_flush_fn *end_flush_fn; 336 338 337 339 /* 338 340 * Dispatch queue sorting ··· 416 420 /* 417 421 * reserved for flush operations 418 422 */ 419 - struct request *flush_rq; 420 - unsigned char ordered; 421 - }; 422 - 423 - enum { 424 - QUEUE_ORDERED_NONE, 425 - QUEUE_ORDERED_TAG, 426 - QUEUE_ORDERED_FLUSH, 423 + unsigned int ordered, next_ordered, ordseq; 424 + int orderr, ordcolor; 425 + struct request pre_flush_rq, bar_rq, post_flush_rq; 426 + struct request *orig_bar_rq; 427 + unsigned int bi_size; 427 428 }; 428 429 429 430 #define RQ_INACTIVE (-1) ··· 438 445 #define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */ 439 446 #define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */ 440 447 #define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */ 441 - #define QUEUE_FLAG_FLUSH 9 /* doing barrier flush sequence */ 448 + 449 + enum { 450 + /* 451 + * Hardbarrier is supported with one of the following methods. 452 + * 453 + * NONE : hardbarrier unsupported 454 + * DRAIN : ordering by draining is enough 455 + * DRAIN_FLUSH : ordering by draining w/ pre and post flushes 456 + * DRAIN_FUA : ordering by draining w/ pre flush and FUA write 457 + * TAG : ordering by tag is enough 458 + * TAG_FLUSH : ordering by tag w/ pre and post flushes 459 + * TAG_FUA : ordering by tag w/ pre flush and FUA write 460 + */ 461 + QUEUE_ORDERED_NONE = 0x00, 462 + QUEUE_ORDERED_DRAIN = 0x01, 463 + QUEUE_ORDERED_TAG = 0x02, 464 + 465 + QUEUE_ORDERED_PREFLUSH = 0x10, 466 + QUEUE_ORDERED_POSTFLUSH = 0x20, 467 + QUEUE_ORDERED_FUA = 0x40, 468 + 469 + QUEUE_ORDERED_DRAIN_FLUSH = QUEUE_ORDERED_DRAIN | 470 + QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH, 471 + QUEUE_ORDERED_DRAIN_FUA = QUEUE_ORDERED_DRAIN | 472 + QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_FUA, 473 + QUEUE_ORDERED_TAG_FLUSH = QUEUE_ORDERED_TAG | 474 + QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH, 475 + QUEUE_ORDERED_TAG_FUA = QUEUE_ORDERED_TAG | 476 + QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_FUA, 477 + 478 + /* 479 + * Ordered operation sequence 480 + */ 481 + QUEUE_ORDSEQ_STARTED = 0x01, /* flushing in progress */ 482 + QUEUE_ORDSEQ_DRAIN = 0x02, /* waiting for the queue to be drained */ 483 + QUEUE_ORDSEQ_PREFLUSH = 0x04, /* pre-flushing in progress */ 484 + QUEUE_ORDSEQ_BAR = 0x08, /* original barrier req in progress */ 485 + QUEUE_ORDSEQ_POSTFLUSH = 0x10, /* post-flushing in progress */ 486 + QUEUE_ORDSEQ_DONE = 0x20, 487 + }; 442 488 443 489 #define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags) 444 490 #define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags) 445 491 #define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags) 446 - #define blk_queue_flushing(q) test_bit(QUEUE_FLAG_FLUSH, &(q)->queue_flags) 492 + #define blk_queue_flushing(q) ((q)->ordseq) 447 493 448 494 #define blk_fs_request(rq) ((rq)->flags & REQ_CMD) 449 495 #define blk_pc_request(rq) ((rq)->flags & REQ_BLOCK_PC) ··· 498 466 499 467 #define blk_sorted_rq(rq) ((rq)->flags & REQ_SORTED) 500 468 #define blk_barrier_rq(rq) ((rq)->flags & REQ_HARDBARRIER) 501 - #define blk_barrier_preflush(rq) ((rq)->flags & REQ_BAR_PREFLUSH) 502 - #define blk_barrier_postflush(rq) ((rq)->flags & REQ_BAR_POSTFLUSH) 469 + #define blk_fua_rq(rq) ((rq)->flags & REQ_FUA) 503 470 504 471 #define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist) 505 472 ··· 591 560 extern void generic_make_request(struct bio *bio); 592 561 extern void blk_put_request(struct request *); 593 562 extern void __blk_put_request(request_queue_t *, struct request *); 594 - extern void blk_end_sync_rq(struct request *rq); 563 + extern void blk_end_sync_rq(struct request *rq, int error); 595 564 extern void blk_attempt_remerge(request_queue_t *, struct request *); 596 565 extern struct request *blk_get_request(request_queue_t *, int, gfp_t); 597 566 extern void blk_insert_request(request_queue_t *, struct request *, int, void *); ··· 613 582 extern int blk_execute_rq(request_queue_t *, struct gendisk *, 614 583 struct request *, int); 615 584 extern void blk_execute_rq_nowait(request_queue_t *, struct gendisk *, 616 - struct request *, int, 617 - void (*done)(struct request *)); 585 + struct request *, int, rq_end_io_fn *); 618 586 619 587 static inline request_queue_t *bdev_get_queue(struct block_device *bdev) 620 588 { ··· 644 614 */ 645 615 extern int end_that_request_first(struct request *, int, int); 646 616 extern int end_that_request_chunk(struct request *, int, int); 647 - extern void end_that_request_last(struct request *); 617 + extern void end_that_request_last(struct request *, int); 648 618 extern void end_request(struct request *req, int uptodate); 649 619 650 620 /* ··· 695 665 extern void blk_queue_merge_bvec(request_queue_t *, merge_bvec_fn *); 696 666 extern void blk_queue_dma_alignment(request_queue_t *, int); 697 667 extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); 698 - extern void blk_queue_ordered(request_queue_t *, int); 668 + extern int blk_queue_ordered(request_queue_t *, unsigned, prepare_flush_fn *); 699 669 extern void blk_queue_issue_flush_fn(request_queue_t *, issue_flush_fn *); 700 - extern struct request *blk_start_pre_flush(request_queue_t *,struct request *); 701 - extern int blk_complete_barrier_rq(request_queue_t *, struct request *, int); 702 - extern int blk_complete_barrier_rq_locked(request_queue_t *, struct request *, int); 670 + extern int blk_do_ordered(request_queue_t *, struct request **); 671 + extern unsigned blk_ordered_cur_seq(request_queue_t *); 672 + extern unsigned blk_ordered_req_seq(struct request *); 673 + extern void blk_ordered_complete_seq(request_queue_t *, unsigned, int); 703 674 704 675 extern int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *); 705 676 extern void blk_dump_rq_flags(struct request *, char *);
+1
include/linux/elevator.h
··· 130 130 #define ELEVATOR_INSERT_FRONT 1 131 131 #define ELEVATOR_INSERT_BACK 2 132 132 #define ELEVATOR_INSERT_SORT 3 133 + #define ELEVATOR_INSERT_REQUEUE 4 133 134 134 135 /* 135 136 * return values from elevator_may_queue_fn
+2 -1
include/linux/libata.h
··· 488 488 extern void ata_bmdma_irq_clear(struct ata_port *ap); 489 489 extern void ata_qc_complete(struct ata_queued_cmd *qc); 490 490 extern void ata_eng_timeout(struct ata_port *ap); 491 - extern void ata_scsi_simulate(u16 *id, struct scsi_cmnd *cmd, 491 + extern void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, 492 + struct scsi_cmnd *cmd, 492 493 void (*done)(struct scsi_cmnd *)); 493 494 extern int ata_std_bios_param(struct scsi_device *sdev, 494 495 struct block_device *bdev,
-1
include/scsi/scsi_driver.h
··· 15 15 void (*rescan)(struct device *); 16 16 int (*issue_flush)(struct device *, sector_t *); 17 17 int (*prepare_flush)(struct request_queue *, struct request *); 18 - void (*end_flush)(struct request_queue *, struct request *); 19 18 }; 20 19 #define to_scsi_driver(drv) \ 21 20 container_of((drv), struct scsi_driver, gendrv)
-1
include/scsi/scsi_host.h
··· 398 398 /* 399 399 * ordered write support 400 400 */ 401 - unsigned ordered_flush:1; 402 401 unsigned ordered_tag:1; 403 402 404 403 /*