Commit 9a42891
block: fix lost bio for plug enabled bio based device
With the following two conditions, bio will be lost:
1) blk plug is not enabled, for example, __blkdev_direct_IO_simple() and
__blkdev_direct_IO_async();
2) bio plug is enabled, for example write IO for raid1/raid10 while
bitmap is enabled;
Root cause is that blk_finish_plug() will add the bio to
curent->bio_list, while such bio will not be handled:
__submit_bio_noacct
current->bio_list = bio_list_on_stack;
blk_start_plug
do {
dm_submit_bio
md_handle_request
raid10_write_request
-> generate new bio for underlying disks
raid1_add_bio_to_plug -> bio is added to plug
} while ((bio = bio_list_pop(&bio_list_on_stack[0])))
-> previous bio are all handled
blk_finish_plug
raid10_unplug
raid1_submit_write
submit_bio_noacct
if (current->bio_list)
bio_list_add(¤t->bio_list[0], bio)
-> add new bio
current->bio_list = NULL
-> new bio is lost
Fix the problem by moving the plug into the while loop, so that
current->bio_list will still be handled after blk_finish_plug().
By the way, enable plug for raid1/raid10 in this case will also prevent
delay IO handling into daemon thread, which should also improve IO
performance.
Fixes: 060406c ("block: add plug while submitting IO")
Reported-by: Changhui Zhong <czhong@redhat.com>
Closes: https://lore.kernel.org/all/CAGVVp+Xsmzy2G9YuEatfMT6qv1M--YdOCQ0g7z7OVmcTbBxQAg@mail.gmail.com/
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Tested-by: Changhui Zhong <czhong@redhat.com>
Link: https://lore.kernel.org/r/20240521200308.983986-1-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>1 parent f0eab3e commit 9a42891
1 file changed
Lines changed: 7 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
613 | 613 | | |
614 | 614 | | |
615 | 615 | | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
616 | 619 | | |
617 | 620 | | |
618 | 621 | | |
| 622 | + | |
| 623 | + | |
619 | 624 | | |
620 | 625 | | |
621 | 626 | | |
| |||
624 | 629 | | |
625 | 630 | | |
626 | 631 | | |
| 632 | + | |
| 633 | + | |
627 | 634 | | |
628 | 635 | | |
629 | 636 | | |
| |||
648 | 655 | | |
649 | 656 | | |
650 | 657 | | |
651 | | - | |
652 | 658 | | |
653 | 659 | | |
654 | 660 | | |
655 | 661 | | |
656 | 662 | | |
657 | | - | |
658 | 663 | | |
659 | 664 | | |
660 | 665 | | |
| |||
688 | 693 | | |
689 | 694 | | |
690 | 695 | | |
691 | | - | |
692 | 696 | | |
693 | 697 | | |
694 | 698 | | |
695 | 699 | | |
696 | 700 | | |
697 | 701 | | |
698 | | - | |
699 | 702 | | |
700 | 703 | | |
701 | | - | |
702 | 704 | | |
703 | 705 | | |
704 | 706 | | |
705 | 707 | | |
706 | 708 | | |
707 | | - | |
708 | 709 | | |
709 | 710 | | |
710 | 711 | | |
| |||
0 commit comments