]> git.baikalelectronics.ru Git - kernel.git/commit
dm: interlock pending dm_io and dm_wait_for_bios_completion
authorMike Snitzer <snitzer@redhat.com>
Fri, 18 Feb 2022 04:40:02 +0000 (23:40 -0500)
committerMike Snitzer <snitzer@redhat.com>
Mon, 21 Feb 2022 20:19:08 +0000 (15:19 -0500)
commit1d4c84f42389d733deac9b2b5f01bbff9475b923
treefcabdaea0e9f0c3306be15f39ee4dd9f71978c73
parent9bdc45e0576f2b846f46f2b43868d63fa57c7ae8
dm: interlock pending dm_io and dm_wait_for_bios_completion

Commit 57d5cfdbb2eb ("dm: fix mempool NULL pointer race when
completing IO") didn't go far enough.

When bio_end_io_acct ends the count of in-flight I/Os may reach zero
and the DM device may be suspended. There is a possibility that the
suspend races with dm_stats_account_io.

Fix this by adding percpu "pending_io" counters to track outstanding
dm_io. Move kicking of suspend queue to dm_io_dec_pending(). Also,
rename md_in_flight_bios() to dm_in_flight_bios() and update it to
iterate all pending_io counters.

Fixes: 57d5cfdbb2eb ("dm: fix mempool NULL pointer race when completing IO")
Cc: stable@vger.kernel.org
Co-developed-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-core.h
drivers/md/dm.c