Xiao Ni 76fed01420 md: account io_acct_set usage with active_io
io_acct_set was enabled for raid0/raid5 io accounting. bios that contain
md_io_acct are allocated in the i/o path. There isn't a good method to
monitor if these bios are all finished and freed. In the takeover process,
io_acct_set (which is used for bios with md_io_acct) need to be freed.
However, if some bios finish after io_acct_set is freed, it may trigger
the following panic:

[ 6973.767999] RIP: 0010:mempool_free+0x52/0x80
[ 6973.786098] Call Trace:
[ 6973.786549]  md_end_io_acct+0x31/0x40
[ 6973.787227]  blk_update_request+0x224/0x380
[ 6973.787994]  blk_mq_end_request+0x1a/0x130
[ 6973.788739]  blk_complete_reqs+0x35/0x50
[ 6973.789456]  __do_softirq+0xd7/0x2c8
[ 6973.790114]  ? sort_range+0x20/0x20
[ 6973.790763]  run_ksoftirqd+0x2a/0x40
[ 6973.791400]  smpboot_thread_fn+0xb5/0x150
[ 6973.792114]  kthread+0x10b/0x130
[ 6973.792724]  ? set_kthread_struct+0x50/0x50
[ 6973.793491]  ret_from_fork+0x1f/0x40

Fix this by increasing and decreasing active_io for each bio with
md_io_acct so that mddev_suspend() will wait until all bios from
io_acct_set finish before freeing io_acct_set.

Reported-by: Fine Fan <ffan@redhat.com>
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Song Liu <song@kernel.org>
2023-02-08 15:46:57 -08:00
..
2022-12-13 15:22:14 -08:00
2023-01-14 07:38:48 +09:00
2022-12-16 03:49:24 -08:00
2023-01-12 17:02:20 -06:00
2022-12-19 07:13:33 -06:00
2023-01-12 05:56:06 -06:00
2022-12-16 03:49:24 -08:00
2023-01-27 14:05:38 +01:00
2023-01-27 13:18:14 -08:00
2023-01-18 14:44:32 -08:00
2022-12-13 15:47:48 -08:00
2022-12-13 13:09:38 -08:00
2022-12-11 21:25:58 +01:00
2022-12-16 03:49:24 -08:00
2023-01-29 11:06:47 -08:00
2022-12-21 09:19:24 -08:00
2023-02-07 07:22:58 -07:00
2023-01-13 17:32:22 -06:00
2022-12-13 15:47:48 -08:00
2022-12-21 09:41:28 -08:00
2022-12-21 09:19:24 -08:00
2023-01-10 23:09:09 +01:00
2022-12-19 08:47:33 -06:00
2022-12-12 10:17:08 -08:00
2023-01-21 11:12:42 -08:00
2023-01-21 11:10:03 -08:00
2023-01-12 17:02:20 -06:00
2022-12-16 03:49:24 -08:00
2022-12-17 08:34:01 -06:00
2023-01-12 17:02:20 -06:00