From: Greg Kroah-Hartman Date: Fri, 15 Nov 2024 05:23:45 +0000 (+0100) Subject: 5.4-stable patches X-Git-Tag: v4.19.324~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d8c133c0453d4c70af5c1b49c0d5e145a5136c6;p=thirdparty%2Fkernel%2Fstable-queue.git 5.4-stable patches added patches: md-raid10-improve-code-of-mrdev-in-raid10_sync_request.patch --- diff --git a/queue-5.4/md-raid10-improve-code-of-mrdev-in-raid10_sync_request.patch b/queue-5.4/md-raid10-improve-code-of-mrdev-in-raid10_sync_request.patch new file mode 100644 index 00000000000..4a105ea4d6a --- /dev/null +++ b/queue-5.4/md-raid10-improve-code-of-mrdev-in-raid10_sync_request.patch @@ -0,0 +1,97 @@ +From 59f8f0b54c8ffb4521f6bbd1cb6f4dfa5022e75e Mon Sep 17 00:00:00 2001 +From: Li Nan +Date: Sat, 27 May 2023 15:22:16 +0800 +Subject: md/raid10: improve code of mrdev in raid10_sync_request + +From: Li Nan + +commit 59f8f0b54c8ffb4521f6bbd1cb6f4dfa5022e75e upstream. + +'need_recover' and 'mrdev' are equivalent in raid10_sync_request(), and +inc mrdev->nr_pending is unreasonable if don't need recovery. Replace +'need_recover' with 'mrdev', and only inc nr_pending when needed. + +Signed-off-by: Li Nan +Reviewed-by: Yu Kuai +Signed-off-by: Song Liu +Link: https://lore.kernel.org/r/20230527072218.2365857-3-linan666@huaweicloud.com +Cc: Hagar Gamal Halim +Signed-off-by: Greg Kroah-Hartman +--- + drivers/md/raid10.c | 23 ++++++++++++----------- + 1 file changed, 12 insertions(+), 11 deletions(-) + +--- a/drivers/md/raid10.c ++++ b/drivers/md/raid10.c +@@ -3069,7 +3069,6 @@ static sector_t raid10_sync_request(stru + sector_t sect; + int must_sync; + int any_working; +- int need_recover = 0; + struct raid10_info *mirror = &conf->mirrors[i]; + struct md_rdev *mrdev, *mreplace; + +@@ -3077,14 +3076,13 @@ static sector_t raid10_sync_request(stru + mrdev = rcu_dereference(mirror->rdev); + mreplace = rcu_dereference(mirror->replacement); + +- if (mrdev != NULL && +- !test_bit(Faulty, &mrdev->flags) && +- !test_bit(In_sync, &mrdev->flags)) +- need_recover = 1; ++ if (mrdev && (test_bit(Faulty, &mrdev->flags) || ++ test_bit(In_sync, &mrdev->flags))) ++ mrdev = NULL; + if (mreplace && test_bit(Faulty, &mreplace->flags)) + mreplace = NULL; + +- if (!need_recover && !mreplace) { ++ if (!mrdev && !mreplace) { + rcu_read_unlock(); + continue; + } +@@ -3118,7 +3116,8 @@ static sector_t raid10_sync_request(stru + rcu_read_unlock(); + continue; + } +- atomic_inc(&mrdev->nr_pending); ++ if (mrdev) ++ atomic_inc(&mrdev->nr_pending); + if (mreplace) + atomic_inc(&mreplace->nr_pending); + rcu_read_unlock(); +@@ -3205,7 +3204,7 @@ static sector_t raid10_sync_request(stru + r10_bio->devs[1].devnum = i; + r10_bio->devs[1].addr = to_addr; + +- if (need_recover) { ++ if (mrdev) { + bio = r10_bio->devs[1].bio; + bio->bi_next = biolist; + biolist = bio; +@@ -3250,7 +3249,7 @@ static sector_t raid10_sync_request(stru + for (k = 0; k < conf->copies; k++) + if (r10_bio->devs[k].devnum == i) + break; +- if (!test_bit(In_sync, ++ if (mrdev && !test_bit(In_sync, + &mrdev->flags) + && !rdev_set_badblocks( + mrdev, +@@ -3276,12 +3275,14 @@ static sector_t raid10_sync_request(stru + if (rb2) + atomic_dec(&rb2->remaining); + r10_bio = rb2; +- rdev_dec_pending(mrdev, mddev); ++ if (mrdev) ++ rdev_dec_pending(mrdev, mddev); + if (mreplace) + rdev_dec_pending(mreplace, mddev); + break; + } +- rdev_dec_pending(mrdev, mddev); ++ if (mrdev) ++ rdev_dec_pending(mrdev, mddev); + if (mreplace) + rdev_dec_pending(mreplace, mddev); + if (r10_bio->devs[0].bio->bi_opf & MD_FAILFAST) { diff --git a/queue-5.4/series b/queue-5.4/series index ddbccef363a..95a1a90960d 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -58,3 +58,4 @@ sound-make-config_snd-depend-on-indirect_iomem-inste.patch powerpc-powernv-free-name-on-error-in-opal_event_ini.patch fs-fix-uninitialized-value-issue-in-from_kuid-and-fr.patch net-usb-qmi_wwan-add-fibocom-fg132-0x0112-compositio.patch +md-raid10-improve-code-of-mrdev-in-raid10_sync_request.patch