dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Song Liu <song@kernel.org>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: Yu Kuai <yukuai3@huawei.com>, David Jeffery <djeffery@redhat.com>,
	 Li Nan <linan122@huawei.com>,
	dm-devel@lists.linux.dev, linux-raid@vger.kernel.org,
	 Mike Snitzer <msnitzer@redhat.com>,
	Heinz Mauelshagen <heinzm@redhat.com>,
	 Benjamin Marzinski <bmarzins@redhat.com>
Subject: Re: [PATCH 7/7] md: fix a suspicious RCU usage warning
Date: Wed, 17 Jan 2024 15:59:54 -0800	[thread overview]
Message-ID: <CAPhsuW42XBw4nUWzssSMh7i=ULL++yF5twFB8d0digmVLXQ6AA@mail.gmail.com> (raw)
In-Reply-To: <51539879-e1ca-fde3-b8b4-8934ddedcbc@redhat.com>

On Wed, Jan 17, 2024 at 10:22 AM Mikulas Patocka <mpatocka@redhat.com> wrote:
>
> RCU protection was removed in the commit 2d32777d60de ("raid1: remove rcu
> protection to access rdev from conf").
>
> However, the code in fix_read_error does rcu_dereference outside
> rcu_read_lock - this triggers the following warning. The warning is
> triggered by a LVM2 test shell/integrity-caching.sh.
>
> This commit removes rcu_dereference.
>
> =============================
> WARNING: suspicious RCU usage
> 6.7.0 #2 Not tainted
> -----------------------------
> drivers/md/raid1.c:2265 suspicious rcu_dereference_check() usage!
>
> other info that might help us debug this:
>
> rcu_scheduler_active = 2, debug_locks = 1
> no locks held by mdX_raid1/1859.
>
> stack backtrace:
> CPU: 2 PID: 1859 Comm: mdX_raid1 Not tainted 6.7.0 #2
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
> Call Trace:
>  <TASK>
>  dump_stack_lvl+0x60/0x70
>  lockdep_rcu_suspicious+0x153/0x1b0
>  raid1d+0x1732/0x1750 [raid1]
>  ? lock_acquire+0x9f/0x270
>  ? finish_wait+0x3d/0x80
>  ? md_thread+0xf7/0x130 [md_mod]
>  ? lock_release+0xaa/0x230
>  ? md_register_thread+0xd0/0xd0 [md_mod]
>  md_thread+0xa0/0x130 [md_mod]
>  ? housekeeping_test_cpu+0x30/0x30
>  kthread+0xdc/0x110
>  ? kthread_complete_and_exit+0x20/0x20
>  ret_from_fork+0x28/0x40
>  ? kthread_complete_and_exit+0x20/0x20
>  ret_from_fork_asm+0x11/0x20
>  </TASK>
>
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> Fixes: ca294b34aaf3 ("md/raid1: support read error check")

This makes sense to me.

Li Nan, please review this fix.

Thanks,
Song

>
> ---
>  drivers/md/raid1.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: linux-2.6/drivers/md/raid1.c
> ===================================================================
> --- linux-2.6.orig/drivers/md/raid1.c
> +++ linux-2.6/drivers/md/raid1.c
> @@ -2262,7 +2262,7 @@ static void fix_read_error(struct r1conf
>         int sectors = r1_bio->sectors;
>         int read_disk = r1_bio->read_disk;
>         struct mddev *mddev = conf->mddev;
> -       struct md_rdev *rdev = rcu_dereference(conf->mirrors[read_disk].rdev);
> +       struct md_rdev *rdev = conf->mirrors[read_disk].rdev;
>
>         if (exceed_read_errors(mddev, rdev)) {
>                 r1_bio->bios[r1_bio->read_disk] = IO_BLOCKED;
>

  reply	other threads:[~2024-01-18  0:00 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17 18:16 [PATCH 0/7] MD fixes for the LVM2 testsuite Mikulas Patocka
2024-01-17 18:17 ` [PATCH 1/7] md: Revert fa2bbff7b0b4 ("md: synchronize flush io with array reconfiguration") Mikulas Patocka
2024-01-18  1:27   ` Yu Kuai
2024-01-17 18:18 ` [PATCH 2/7] md: fix a race condition when stopping the sync thread Mikulas Patocka
2024-01-18  1:32   ` Yu Kuai
2024-01-18 13:07     ` Mikulas Patocka
2024-01-18 13:20       ` Yu Kuai
2024-01-18 13:28         ` Mikulas Patocka
2024-01-17 18:19 ` [PATCH 3/7] md: test for MD_RECOVERY_DONE in stop_sync_thread Mikulas Patocka
2024-01-18  0:19   ` Song Liu
2024-01-18 13:23     ` Mikulas Patocka
2024-01-18 21:10       ` Song Liu
2024-01-22 16:34         ` Mikulas Patocka
2024-01-23  2:31           ` Benjamin Marzinski
2024-01-26  9:17             ` Yu Kuai
2024-01-26  9:37               ` Yu Kuai
2024-01-26 10:29                 ` Zdenek Kabelac
2024-01-27  1:13                   ` Yu Kuai
2024-01-27  1:19                     ` Yu Kuai
2024-01-18  1:35   ` Yu Kuai
2024-01-17 18:20 ` [PATCH 4/7] md: call md_reap_sync_thread from __md_stop_writes Mikulas Patocka
2024-01-18  1:38   ` Yu Kuai
2024-01-17 18:21 ` [PATCH 5/7] md: fix deadlock in shell/lvconvert-raid-reshape-linear_to_raid6-single-type.sh Mikulas Patocka
2024-01-18  1:12   ` Song Liu
2024-01-18  1:51   ` Yu Kuai
2024-01-17 18:22 ` [PATCH 6/7] md: partially revert "md/raid6: use valid sector values to determine if an I/O should wait on the reshape" Mikulas Patocka
2024-01-17 23:56   ` Song Liu
2024-01-17 18:22 ` [PATCH 7/7] md: fix a suspicious RCU usage warning Mikulas Patocka
2024-01-17 23:59   ` Song Liu [this message]
2024-01-18  1:56   ` Yu Kuai
2024-01-25 17:31     ` Song Liu
2024-01-17 19:27 ` [PATCH 0/7] MD fixes for the LVM2 testsuite Song Liu
2024-01-18  2:03   ` Yu Kuai
2024-01-27  7:57 ` Yu Kuai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPhsuW42XBw4nUWzssSMh7i=ULL++yF5twFB8d0digmVLXQ6AA@mail.gmail.com' \
    --to=song@kernel.org \
    --cc=bmarzins@redhat.com \
    --cc=djeffery@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=heinzm@redhat.com \
    --cc=linan122@huawei.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=msnitzer@redhat.com \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).