Skip to content

md/raid10: Remove unnecessary rcu_dereference in raid10_handle_discard

Nigel Croxon requested to merge ncroxon/centos-stream-9:bz1965294_9 into main

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1965294

Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=39474528

Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

commit 46d4703b1db4c86ab5acb2331b10df999f005e8e

Author: Xiao Ni xni@redhat.com

Date: Wed Aug 18 13:57:48 2021 +0800

md/raid10: Remove unnecessary rcu_dereference in raid10_handle_discard

We are seeing the following warning in raid10_handle_discard. [ 695.110751] ============================= [ 695.131439] WARNING: suspicious RCU usage [ 695.151389] 4.18.0-319.el8.x86_64+debug #1 Not tainted [ 695.174413] ----------------------------- [ 695.192603] drivers/md/raid10.c:1776 suspicious rcu_dereference_check() usage! [ 695.225107] other info that might help us debug this: [ 695.260940] rcu_scheduler_active = 2, debug_locks = 1 [ 695.290157] no locks held by mkfs.xfs/10186.

In the first loop of function raid10_handle_discard. It already determines which disk need to handle discard request and add the rdev reference count rdev->nr_pending. So the conf->mirrors will not change until all bios come back from underlayer disks. It doesn't need to use rcu_dereference to get rdev.

Cc: stable@vger.kernel.org Fixes: d30588b2 ('md/raid10: improve raid10 discard request') Signed-off-by: Xiao Ni xni@redhat.com Acked-by: Guoqing Jiang guoqing.jiang@linux.dev Signed-off-by: Song Liu songliubraving@fb.com (cherry picked from commit 46d4703b1db4c86ab5acb2331b10df999f005e8e) Signed-off-by: Nigel Croxon ncroxon@redhat.com

Edited by Nigel Croxon

Merge request reports