Commit bddd87c7e622ea681c665049027ed84cdcafcb09

Authored by Akinobu Mita
Committed by Jens Axboe
1 parent d02f0cff1d

blk-core: use BIO list management functions

Now that the bio list management stuff is generic, convert
generic_make_request to use bio lists instead of its own private bio
list implementation.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>

Showing 2 changed files with 16 additions and 19 deletions Side-by-side Diff

... ... @@ -1490,9 +1490,9 @@
1490 1490 /*
1491 1491 * We only want one ->make_request_fn to be active at a time,
1492 1492 * else stack usage with stacked devices could be a problem.
1493   - * So use current->bio_{list,tail} to keep a list of requests
  1493 + * So use current->bio_list to keep a list of requests
1494 1494 * submited by a make_request_fn function.
1495   - * current->bio_tail is also used as a flag to say if
  1495 + * current->bio_list is also used as a flag to say if
1496 1496 * generic_make_request is currently active in this task or not.
1497 1497 * If it is NULL, then no make_request is active. If it is non-NULL,
1498 1498 * then a make_request is active, and new requests should be added
1499 1499  
... ... @@ -1500,11 +1500,11 @@
1500 1500 */
1501 1501 void generic_make_request(struct bio *bio)
1502 1502 {
1503   - if (current->bio_tail) {
  1503 + struct bio_list bio_list_on_stack;
  1504 +
  1505 + if (current->bio_list) {
1504 1506 /* make_request is active */
1505   - *(current->bio_tail) = bio;
1506   - bio->bi_next = NULL;
1507   - current->bio_tail = &bio->bi_next;
  1507 + bio_list_add(current->bio_list, bio);
1508 1508 return;
1509 1509 }
1510 1510 /* following loop may be a bit non-obvious, and so deserves some
1511 1511  
1512 1512  
1513 1513  
1514 1514  
1515 1515  
... ... @@ -1512,30 +1512,27 @@
1512 1512 * Before entering the loop, bio->bi_next is NULL (as all callers
1513 1513 * ensure that) so we have a list with a single bio.
1514 1514 * We pretend that we have just taken it off a longer list, so
1515   - * we assign bio_list to the next (which is NULL) and bio_tail
1516   - * to &bio_list, thus initialising the bio_list of new bios to be
  1515 + * we assign bio_list to a pointer to the bio_list_on_stack,
  1516 + * thus initialising the bio_list of new bios to be
1517 1517 * added. __generic_make_request may indeed add some more bios
1518 1518 * through a recursive call to generic_make_request. If it
1519 1519 * did, we find a non-NULL value in bio_list and re-enter the loop
1520 1520 * from the top. In this case we really did just take the bio
1521   - * of the top of the list (no pretending) and so fixup bio_list and
1522   - * bio_tail or bi_next, and call into __generic_make_request again.
  1521 + * of the top of the list (no pretending) and so remove it from
  1522 + * bio_list, and call into __generic_make_request again.
1523 1523 *
1524 1524 * The loop was structured like this to make only one call to
1525 1525 * __generic_make_request (which is important as it is large and
1526 1526 * inlined) and to keep the structure simple.
1527 1527 */
1528 1528 BUG_ON(bio->bi_next);
  1529 + bio_list_init(&bio_list_on_stack);
  1530 + current->bio_list = &bio_list_on_stack;
1529 1531 do {
1530   - current->bio_list = bio->bi_next;
1531   - if (bio->bi_next == NULL)
1532   - current->bio_tail = &current->bio_list;
1533   - else
1534   - bio->bi_next = NULL;
1535 1532 __generic_make_request(bio);
1536   - bio = current->bio_list;
  1533 + bio = bio_list_pop(current->bio_list);
1537 1534 } while (bio);
1538   - current->bio_tail = NULL; /* deactivate */
  1535 + current->bio_list = NULL; /* deactivate */
1539 1536 }
1540 1537 EXPORT_SYMBOL(generic_make_request);
1541 1538  
include/linux/sched.h
... ... @@ -97,7 +97,7 @@
97 97 struct exec_domain;
98 98 struct futex_pi_state;
99 99 struct robust_list_head;
100   -struct bio;
  100 +struct bio_list;
101 101 struct fs_struct;
102 102 struct bts_context;
103 103 struct perf_event_context;
... ... @@ -1466,7 +1466,7 @@
1466 1466 void *journal_info;
1467 1467  
1468 1468 /* stacked block device info */
1469   - struct bio *bio_list, **bio_tail;
  1469 + struct bio_list *bio_list;
1470 1470  
1471 1471 /* VM state */
1472 1472 struct reclaim_state *reclaim_state;