Commit eae0bdb9 authored by Yu Kuai's avatar Yu Kuai Committed by openeuler-sync-bot
Browse files

md/raid1-10: limit the number of plugged bio

mainline inclusion
from mainline-v6.5-rc1
commit 460af1f9
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8UKFJ
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=460af1f9d9e62acce4a21f9bd00b5bcd5963bcd4



----------------------------------------

bio can be added to plug infinitely, and following writeback test can
trigger huge amount of plugged bio:

Test script:
modprobe brd rd_nr=4 rd_size=10485760
mdadm -CR /dev/md0 -l10 -n4 /dev/ram[0123] --assume-clean --bitmap=internal
echo 0 > /proc/sys/vm/dirty_background_ratio
fio -filename=/dev/md0 -ioengine=libaio -rw=write -bs=4k -numjobs=1 -iodepth=128 -name=test

Test result:
Monitor /sys/block/md0/inflight will found that inflight keep increasing
until fio finish writing, after running for about 2 minutes:

[root@fedora ~]# cat /sys/block/md0/inflight
       0  4474191

Fix the problem by limiting the number of plugged bio based on the number
of copies for original bio.

Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Signed-off-by: default avatarSong Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230529131106.2123367-8-yukuai1@huaweicloud.com



Conflicts:
  Commit 309dca30 ("block: store a block_device pointer in struct bio")
  changed "mbio->bi_disk" to "mbio->bi_bdev";
  Commit 2e94275e ("md/raid1: use rdev in raid1_write_request directly")
  changed "conf->mirrors[i].rdev" to "rdev";
Signed-off-by: default avatarLi Lingfeng <lilingfeng3@huawei.com>
(cherry picked from commit ad1dabc8)
parent baf87f5f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment