]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
md/raid1: release pending accounting for an I/O only after write-behind is also finished
authorDavid Jeffery <djeffery@redhat.com>
Mon, 27 Jan 2020 15:26:19 +0000 (10:26 -0500)
committerSong Liu <songliubraving@fb.com>
Wed, 13 May 2020 18:22:31 +0000 (11:22 -0700)
commitc91114c2b89d5bea132d34b40568053f8bfa963d
tree247cf8510a08ef3abce51c1a7a0ee5ed785d2957
parent3024ba2d6c5573b4797e62006d98f17f47f7d103
md/raid1: release pending accounting for an I/O only after write-behind is also finished

When using RAID1 and write-behind, md can deadlock when errors occur. With
write-behind, r1bio structs can be accounted by raid1 as queued but not
counted as pending. The pending count is dropped when the original bio is
returned complete but write-behind for the r1bio may still be active.

This breaks the accounting used in some conditions to know when the raid1
md device has reached an idle state. It can result in calls to
freeze_array deadlocking. freeze_array will never complete from a negative
"unqueued" value being calculated due to a queued count larger than the
pending count.

To properly account for write-behind, move the call to allow_barrier from
call_bio_endio to raid_end_bio_io. When using write-behind, md can call
call_bio_endio before all write-behind I/O is complete. Using
raid_end_bio_io for the point to call allow_barrier will release the
pending count at a point where all I/O for an r1bio, even write-behind, is
done.

Signed-off-by: David Jeffery <djeffery@redhat.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
drivers/md/raid1.c