From: Greg Kroah-Hartman Date: Tue, 10 May 2022 11:56:42 +0000 (+0200) Subject: 5.10-stable patches X-Git-Tag: v4.9.313~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=73391342333dfca11543bab280ce3f3350fc52bb;p=thirdparty%2Fkernel%2Fstable-queue.git 5.10-stable patches added patches: dm-interlock-pending-dm_io-and-dm_wait_for_bios_completion.patch --- diff --git a/queue-5.10/dm-interlock-pending-dm_io-and-dm_wait_for_bios_completion.patch b/queue-5.10/dm-interlock-pending-dm_io-and-dm_wait_for_bios_completion.patch new file mode 100644 index 00000000000..741a88fde85 --- /dev/null +++ b/queue-5.10/dm-interlock-pending-dm_io-and-dm_wait_for_bios_completion.patch @@ -0,0 +1,60 @@ +From 9f6dc633761006f974701d4c88da71ab68670749 Mon Sep 17 00:00:00 2001 +From: Mike Snitzer +Date: Thu, 17 Feb 2022 23:40:02 -0500 +Subject: dm: interlock pending dm_io and dm_wait_for_bios_completion + +From: Mike Snitzer + +commit 9f6dc633761006f974701d4c88da71ab68670749 upstream. + +Commit d208b89401e0 ("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: d208b89401e0 ("dm: fix mempool NULL pointer race when completing IO") +Cc: stable@vger.kernel.org +Co-developed-by: Mikulas Patocka +Signed-off-by: Mikulas Patocka +Signed-off-by: Mike Snitzer +Signed-off-by: Greg Kroah-Hartman +--- + drivers/md/dm.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +--- a/drivers/md/dm.c ++++ b/drivers/md/dm.c +@@ -612,13 +612,15 @@ static void end_io_acct(struct mapped_de + { + unsigned long duration = jiffies - start_time; + +- bio_end_io_acct(bio, start_time); +- + if (unlikely(dm_stats_used(&md->stats))) + dm_stats_account_io(&md->stats, bio_data_dir(bio), + bio->bi_iter.bi_sector, bio_sectors(bio), + true, duration, stats_aux); + ++ smp_wmb(); ++ ++ bio_end_io_acct(bio, start_time); ++ + /* nudge anyone waiting on suspend queue */ + if (unlikely(wq_has_sleeper(&md->wait))) + wake_up(&md->wait); +@@ -2348,6 +2350,8 @@ static int dm_wait_for_bios_completion(s + } + finish_wait(&md->wait, &wait); + ++ smp_rmb(); ++ + return r; + } + diff --git a/queue-5.10/series b/queue-5.10/series index f2a191bc90d..14f4360aa70 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -66,3 +66,4 @@ kvm-lapic-enable-timer-posted-interrupt-only-when-mw.patch rcu-fix-callbacks-processing-time-limit-retaining-cond_resched.patch rcu-apply-callbacks-processing-time-limit-only-on-softirq.patch block-map-add-__gfp_zero-flag-for-alloc_page-in-function-bio_copy_kern.patch +dm-interlock-pending-dm_io-and-dm_wait_for_bios_completion.patch