From patchwork Wed Jan 17 18:17:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 13522082 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FE342374B for ; Wed, 17 Jan 2024 18:18:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515485; cv=none; b=nsE07Q06DX64+UvyzPT9aS3Ro5pH4XjSlYI1UCY7LPOfo2vDWSLhE6FCaUga+JccYJSJ9WEHG9RdXIeKpqDvDcwMibWyD9O+oBoPgcAFxAQqB8wA+oAuSWQI8aNoQkG2Ek3eK0uTNWhih952ygc4XxAg2ApJ4RkzwDS51ryINl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515485; c=relaxed/simple; bh=odaoLRetP6yq9eTrctHLbHR7C/CXSfIABfBoEMR3r/I=; h=DKIM-Signature:Received:X-MC-Unique:Received:Received:Received: Received:Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type:X-Scanned-By; b=CipKZxRiEVx6Hpzr5y0/ztbd/RINo2fNqknb5/TFbutkmiMiw07XJ58aa6YDNUZas+I5SyFol5IIeJlX/23LftHRWIWz2zuRXtLsdsIwPBE3d/yEUsdM3TEGM+G5WPXbKg71QDH/Z1Dl3DbkfEdyRZWUu/PsF/izCtfo2pTXas0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=XNTnbldM; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XNTnbldM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705515482; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OQbrENSM13PTlCIUi4M0i7iy9OOjiGDINAdzr/zFb8Q=; b=XNTnbldMn3ibj/shZiOsLs7bM/c1WwlTIocBOXHGey8bGoUwDBer1Rc6QFyGo73xB/nYSY TWDenFgBs63yXbHSaWUupMusF4qPoCIXnJjznesGfEW/mMfcAdNpaVHxGROldCgTyJcI+l gHLTwqjaJRms6GGbi8DRxhlzeJiC2VQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-gmWMPmWgONCymp9Oh6vp4A-1; Wed, 17 Jan 2024 13:17:58 -0500 X-MC-Unique: gmWMPmWgONCymp9Oh6vp4A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CF37A885626; Wed, 17 Jan 2024 18:17:57 +0000 (UTC) Received: from file1-rdu.file-001.prod.rdu2.dc.redhat.com (unknown [10.11.5.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C6E9640C6EB9; Wed, 17 Jan 2024 18:17:57 +0000 (UTC) Received: by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix, from userid 12668) id BDF2C30C039C; Wed, 17 Jan 2024 18:17:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix) with ESMTP id BD1973FB50; Wed, 17 Jan 2024 19:17:57 +0100 (CET) Date: Wed, 17 Jan 2024 19:17:57 +0100 (CET) From: Mikulas Patocka To: Yu Kuai , Song Liu , David Jeffery , Li Nan cc: dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, Mike Snitzer , Heinz Mauelshagen , Benjamin Marzinski Subject: [PATCH 1/7] md: Revert fa2bbff7b0b4 ("md: synchronize flush io with array reconfiguration") In-Reply-To: Message-ID: <2c29cbd4-736d-2f23-2bc-636881c150d6@redhat.com> References: Precedence: bulk X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 The commit fa2bbff7b0b4 breaks the LVM2 test shell/integrity-caching.sh, so let's revert it. sysrq: Show Blocked State task:lvm state:D stack:0 pid:8275 tgid:8275 ppid:1373 flags:0x00000002 Call Trace: __schedule+0x228/0x570 ? __percpu_ref_switch_mode+0xb7/0x1b0 schedule+0x29/0xa0 mddev_suspend+0xec/0x1a0 [md_mod] ? housekeeping_test_cpu+0x30/0x30 dm_table_postsuspend_targets+0x34/0x50 [dm_mod] __dm_destroy+0x1c5/0x1e0 [dm_mod] ? table_clear+0xa0/0xa0 [dm_mod] dev_remove+0xd4/0x110 [dm_mod] ctl_ioctl+0x2e1/0x570 [dm_mod] dm_ctl_ioctl+0x5/0x10 [dm_mod] __x64_sys_ioctl+0x85/0xa0 do_syscall_64+0x5d/0x1a0 entry_SYSCALL_64_after_hwframe+0x46/0x4e Signed-off-by: Mikulas Patocka Fixes: fa2bbff7b0b4 ("md: synchronize flush io with array reconfiguration") --- drivers/md/md.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) Index: linux-2.6/drivers/md/md.c =================================================================== --- linux-2.6.orig/drivers/md/md.c +++ linux-2.6/drivers/md/md.c @@ -543,9 +543,6 @@ static void md_end_flush(struct bio *bio rdev_dec_pending(rdev, mddev); if (atomic_dec_and_test(&mddev->flush_pending)) { - /* The pair is percpu_ref_get() from md_flush_request() */ - percpu_ref_put(&mddev->active_io); - /* The pre-request flush has finished */ queue_work(md_wq, &mddev->flush_work); } @@ -565,7 +562,12 @@ static void submit_flushes(struct work_s rdev_for_each_rcu(rdev, mddev) if (rdev->raid_disk >= 0 && !test_bit(Faulty, &rdev->flags)) { + /* Take two references, one is dropped + * when request finishes, one after + * we reclaim rcu_read_lock + */ struct bio *bi; + atomic_inc(&rdev->nr_pending); atomic_inc(&rdev->nr_pending); rcu_read_unlock(); @@ -577,6 +579,7 @@ static void submit_flushes(struct work_s atomic_inc(&mddev->flush_pending); submit_bio(bi); rcu_read_lock(); + rdev_dec_pending(rdev, mddev); } rcu_read_unlock(); if (atomic_dec_and_test(&mddev->flush_pending)) @@ -629,18 +632,6 @@ bool md_flush_request(struct mddev *mdde /* new request after previous flush is completed */ if (ktime_after(req_start, mddev->prev_flush_start)) { WARN_ON(mddev->flush_bio); - /* - * Grab a reference to make sure mddev_suspend() will wait for - * this flush to be done. - * - * md_flush_reqeust() is called under md_handle_request() and - * 'active_io' is already grabbed, hence percpu_ref_is_zero() - * won't pass, percpu_ref_tryget_live() can't be used because - * percpu_ref_kill() can be called by mddev_suspend() - * concurrently. - */ - WARN_ON(percpu_ref_is_zero(&mddev->active_io)); - percpu_ref_get(&mddev->active_io); mddev->flush_bio = bio; bio = NULL; } From patchwork Wed Jan 17 18:18:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 13522083 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74B4222EFF for ; Wed, 17 Jan 2024 18:18:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515533; cv=none; b=LGOHr2mmRvH62ocaVRduf+BlTgRc/Pm4i1QGLwreJlAVChKWfMpQIwZq7ValsVGyeAHqTsolHy+0+uCY3rijstAFMPTsu5d4kauT1eqszP4uPXqi44VtZtx8jen+MBj330XLL+AOq3T7k+1+wrY+YBocTNGYEHrnL17yz17pPxg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515533; c=relaxed/simple; bh=U/HOsuSALESYByEZMxsqkpAadSe0Ph12ksQGc6g63Dw=; h=DKIM-Signature:Received:X-MC-Unique:Received:Received:Received: Received:Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type:X-Scanned-By; b=BbQLzic3IrRaRxhQpcSk1uCgghabBJOmrPZZ7VEAbXuX+RWH0W/Q+Mm9IQsfRmi2OUpzmMXr8GvpTD/wqVTmNpQ4m7sFUtG5VMKNue3cZRwldCC69oxB7Ggzq5ayY+GuoQL5rbUfsOID+Nmrzq7x4by2cyDz1il9izlE1nPOpKw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dDHoOB6Y; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dDHoOB6Y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705515531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Nfo38sqj/Duul0x+61EoOlWpjTj/qTa2XQS7wYE8wfg=; b=dDHoOB6YfhsNjedjHYYGPplqW4tkQ04jqjeb1x47GEZmLyGaTndmzn8e4lJTl1IL8KZyWj HFa14wdJujuSRsU5yLYdDihT3mdgak/Fd+4i9SPmj0xY46iG+QNhHQAsjWKGAf0sLT4lv6 qcUizFzb4WGGBEziKv1F3qIuKKIBB3g= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-480-JiZ-FnulNk-PA-LnLmzq5A-1; Wed, 17 Jan 2024 13:18:48 -0500 X-MC-Unique: JiZ-FnulNk-PA-LnLmzq5A-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9F6313830090; Wed, 17 Jan 2024 18:18:47 +0000 (UTC) Received: from file1-rdu.file-001.prod.rdu2.dc.redhat.com (unknown [10.11.5.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 926BF492BE6; Wed, 17 Jan 2024 18:18:47 +0000 (UTC) Received: by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix, from userid 12668) id 8A7DF30C039C; Wed, 17 Jan 2024 18:18:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix) with ESMTP id 89C883FB50; Wed, 17 Jan 2024 19:18:47 +0100 (CET) Date: Wed, 17 Jan 2024 19:18:47 +0100 (CET) From: Mikulas Patocka To: Yu Kuai , Song Liu , David Jeffery , Li Nan cc: dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, Mike Snitzer , Heinz Mauelshagen , Benjamin Marzinski Subject: [PATCH 2/7] md: fix a race condition when stopping the sync thread In-Reply-To: Message-ID: <8fb335e-6d2c-dbb5-d7-ded8db5145a@redhat.com> References: Precedence: bulk X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 Note that md_wakeup_thread_directly is racy - it will do nothing if the thread is already running or it may cause spurious wake-up if the thread is blocked in another subsystem. In order to eliminate the race condition, we will retry md_wakeup_thread_directly after 0.1 seconds. Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org # v6.7 Fixes: 130443d60b1b ("md: refactor idle/frozen_sync_thread() to fix deadlock") --- drivers/md/md.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) Index: linux-2.6/drivers/md/md.c =================================================================== --- linux-2.6.orig/drivers/md/md.c +++ linux-2.6/drivers/md/md.c @@ -4889,6 +4889,7 @@ static void stop_sync_thread(struct mdde mddev_unlock(mddev); +retry: set_bit(MD_RECOVERY_INTR, &mddev->recovery); /* * Thread might be blocked waiting for metadata update which will now @@ -4898,9 +4899,11 @@ static void stop_sync_thread(struct mdde if (work_pending(&mddev->sync_work)) flush_work(&mddev->sync_work); - wait_event(resync_wait, + if (!wait_event_timeout(resync_wait, !test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) || - (check_seq && sync_seq != atomic_read(&mddev->sync_seq))); + (check_seq && sync_seq != atomic_read(&mddev->sync_seq)), + HZ / 10)) + goto retry; if (locked) mddev_lock_nointr(mddev); From patchwork Wed Jan 17 18:19:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 13522084 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEF7422EE0 for ; Wed, 17 Jan 2024 18:19:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515573; cv=none; b=TMBThlcXZutS9KbYmQI6hgEE8A3ZHAfqD3Rjsrq6c65fHdOZ3uUxSMcYVLNuVFZMqGRiBe8zFGYyTV2azf5jOQlIzMoU3RPSAqkRAWQ3817AUWtMHdAYs1Ryvrt3oD7o6kISMTMx59o9Fb1Y+zJow5n8+icAfOikYfYbv0EZO9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515573; c=relaxed/simple; bh=ydjyH3o9mGh/vlcml3f5BQGwcUUvIaeQjwxMIvKA/CQ=; h=DKIM-Signature:Received:X-MC-Unique:Received:Received:Received: Received:Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type:X-Scanned-By; b=Zb7/f1r0UMOsHt7sudVX+sjIPwda1XMtYAUhdCc0NK7fEly6BPWFK0hMSHM7cwqckCydfb8iKCQ4aVgS3ssicKr4rkOv2Q8Rvz/Z5OqanMpICLbylHbPU9AQcR23M7sEabLbD85NEjR58vOQk0kDI6VI2aR+sMSCIO6W49Cd3mk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CiKsA/cN; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CiKsA/cN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705515570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=khF1u9GEl7GnxafypCHqAXBIUn3A1Gll1R+lMdfFYY0=; b=CiKsA/cNRz9Mb2mvblzCa3wqRWjK2SrIb2DQAYl1FlLLzEoU28gxcfsgNRmsE9LUA60/nG MxYC4jSoHc+M+MNY8BM9pf7+eOvpKZ2Z0fldfwAnB/7AWGdQbAW0tHBTZsTWX1SwR1OEKG CBfQCsdPrnVuwIVOOK6e0xmXW0ZMO1E= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-177-fTds6cB9OcKB_w6dWvZ1cw-1; Wed, 17 Jan 2024 13:19:27 -0500 X-MC-Unique: fTds6cB9OcKB_w6dWvZ1cw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 927451C294A2; Wed, 17 Jan 2024 18:19:26 +0000 (UTC) Received: from file1-rdu.file-001.prod.rdu2.dc.redhat.com (unknown [10.11.5.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 88FA01C066AB; Wed, 17 Jan 2024 18:19:26 +0000 (UTC) Received: by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix, from userid 12668) id 7EDC130C039C; Wed, 17 Jan 2024 18:19:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix) with ESMTP id 7E1BC3FB50; Wed, 17 Jan 2024 19:19:26 +0100 (CET) Date: Wed, 17 Jan 2024 19:19:26 +0100 (CET) From: Mikulas Patocka To: Yu Kuai , Song Liu , David Jeffery , Li Nan cc: dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, Mike Snitzer , Heinz Mauelshagen , Benjamin Marzinski Subject: [PATCH 3/7] md: test for MD_RECOVERY_DONE in stop_sync_thread In-Reply-To: Message-ID: <9801e40-8ac7-e225-6a71-309dcf9dc9aa@redhat.com> References: Precedence: bulk X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 stop_sync_thread sets MD_RECOVERY_INTR and then waits for MD_RECOVERY_RUNNING to be cleared. However, md_do_sync will not clear MD_RECOVERY_RUNNING when exiting, it will set MD_RECOVERY_DONE instead. So, we must wait for MD_RECOVERY_DONE to be set as well. This patch fixes a deadlock in the LVM2 test shell/integrity-caching.sh. sysrq: Show Blocked State task:lvm state:D stack:0 pid:11422 tgid:11422 ppid:1374 flags:0x00004002 Call Trace: __schedule+0x228/0x570 schedule+0x29/0xa0 schedule_timeout+0x6a/0xd0 ? timer_shutdown_sync+0x10/0x10 stop_sync_thread+0x141/0x180 [md_mod] ? housekeeping_test_cpu+0x30/0x30 __md_stop_writes+0x10/0xd0 [md_mod] md_stop+0x9/0x20 [md_mod] raid_dtr+0x1e/0x60 [dm_raid] dm_table_destroy+0x53/0x110 [dm_mod] __dm_destroy+0x10b/0x1e0 [dm_mod] ? table_clear+0xa0/0xa0 [dm_mod] dev_remove+0xd4/0x110 [dm_mod] ctl_ioctl+0x2e1/0x570 [dm_mod] dm_ctl_ioctl+0x5/0x10 [dm_mod] __x64_sys_ioctl+0x85/0xa0 do_syscall_64+0x5d/0x1a0 entry_SYSCALL_64_after_hwframe+0x46/0x4e Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org # v6.7 Fixes: 130443d60b1b ("md: refactor idle/frozen_sync_thread() to fix deadlock") --- drivers/md/md.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Index: linux-2.6/drivers/md/md.c =================================================================== --- linux-2.6.orig/drivers/md/md.c +++ linux-2.6/drivers/md/md.c @@ -4881,7 +4881,8 @@ static void stop_sync_thread(struct mdde if (check_seq) sync_seq = atomic_read(&mddev->sync_seq); - if (!test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) { + if (!test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) || + test_bit(MD_RECOVERY_DONE, &mddev->recovery)) { if (!locked) mddev_unlock(mddev); return; @@ -4901,6 +4902,7 @@ retry: if (!wait_event_timeout(resync_wait, !test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) || + test_bit(MD_RECOVERY_DONE, &mddev->recovery) || (check_seq && sync_seq != atomic_read(&mddev->sync_seq)), HZ / 10)) goto retry; From patchwork Wed Jan 17 18:20:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 13522085 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5772B22EE0 for ; Wed, 17 Jan 2024 18:20:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515619; cv=none; b=Lm9jkq0A/zTxFmjfNTuV19MLdZgrIr0xOzcws0Qmvru1VSYafWpPdky8lp7Y0vw5L2PyiVo3EkcD7RXY/8rs85CC8t1jTiQEhRAyxZ0xP9nyI2vj4nLNKIF1GIRnaHcOspeVTka7Dd+JZRW27JupBHd4Pzb60WlRPR8OfQA1e1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515619; c=relaxed/simple; bh=etaA6fhQ5wBt/qt9TCxoYJgxUmhq3AgF6IM1tgMIjUw=; h=DKIM-Signature:Received:X-MC-Unique:Received:Received:Received: Received:Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type:X-Scanned-By; b=boYCpeN1cEACMmx1ELypcAxwfdcSv0/sBfgpaSUKHF4oakzlNkTKd8geXyVY0mVhn9ObvJfsdrB/WH+5gGOei6DWneyFUahH30p+lAqRK380lPNpe871SNrZiHx2sp1rGyjf1rttvhWcpGm/G/e9/5wP6J77/58qxbhebUXr8dI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=QVI5Cs67; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QVI5Cs67" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705515617; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8ivHleY87+YYgQ50ZwaeuC85r8tVB0aEOPq+W73pVX4=; b=QVI5Cs67uEYOy3KUtVCQdF10HlzVTO5iiCTtsM8wYvbNjZk3mYhvqaeZIt6oGEYTe7i4le P2MX4/OubPSOGP8GBIATCuyZVP6b3fSYpnLw3uNxwGSJOADeaO+hj1Tem+nRFokDKWUIt4 grVMoYj1Uf40gOsRSZsr30bOCHwVJc0= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-562-9QVdjnIHMv67seNjxi-7sQ-1; Wed, 17 Jan 2024 13:20:14 -0500 X-MC-Unique: 9QVdjnIHMv67seNjxi-7sQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 99E021C41B21; Wed, 17 Jan 2024 18:20:13 +0000 (UTC) Received: from file1-rdu.file-001.prod.rdu2.dc.redhat.com (unknown [10.11.5.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9386DFEEE; Wed, 17 Jan 2024 18:20:13 +0000 (UTC) Received: by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix, from userid 12668) id 8B42E30C039C; Wed, 17 Jan 2024 18:20:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix) with ESMTP id 8A80B3FB50; Wed, 17 Jan 2024 19:20:13 +0100 (CET) Date: Wed, 17 Jan 2024 19:20:13 +0100 (CET) From: Mikulas Patocka To: Yu Kuai , Song Liu , David Jeffery , Li Nan cc: dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, Mike Snitzer , Heinz Mauelshagen , Benjamin Marzinski Subject: [PATCH 4/7] md: call md_reap_sync_thread from __md_stop_writes In-Reply-To: Message-ID: References: Precedence: bulk X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 The commit f52f5c71f3d4 ("md: fix stopping sync thread") breaks the LVM2 test shell/lvconvert-raid-reshape-linear_to_raid6-single-type.sh There are many places that test for MD_RECOVERY_RUNNING or mddev->sync_thread. If we don't reap the thread, they would be confused. Signed-off-by: Mikulas Patocka Fixes: f52f5c71f3d4 ("md: fix stopping sync thread") Cc: stable@vger.kernel.org # v6.7 --- drivers/md/md.c | 6 ++++++ 1 file changed, 6 insertions(+) Index: linux-2.6/drivers/md/md.c =================================================================== --- linux-2.6.orig/drivers/md/md.c +++ linux-2.6/drivers/md/md.c @@ -6308,6 +6308,12 @@ static void md_clean(struct mddev *mddev static void __md_stop_writes(struct mddev *mddev) { stop_sync_thread(mddev, true, false); + + if (mddev->sync_thread) { + set_bit(MD_RECOVERY_INTR, &mddev->recovery); + md_reap_sync_thread(mddev); + } + del_timer_sync(&mddev->safemode_timer); if (mddev->pers && mddev->pers->quiesce) { From patchwork Wed Jan 17 18:21:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 13522086 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 577D122EFC for ; Wed, 17 Jan 2024 18:21:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515683; cv=none; b=dsi1El50dRckQ/02vfRVRBmnyNzK6PonLw83KprKvahi30/bpnRCf9JajSZLOFUf8T4sqT5LQMULfkG4tM2E7Roof+JwVmJzzzDLAwrQh51HCWcmVHdL6JCH0ulpG0WXjRXORHs/hdVeB+LUYatwQmYROg2QGNOrCyb6Ehqksuc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515683; c=relaxed/simple; bh=XOrPZkYfAHI/W4PT+jSquhG2aWQvQlifjO4edvwXWlE=; h=DKIM-Signature:Received:X-MC-Unique:Received:Received:Received: Received:Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type:X-Scanned-By; b=Exg+v1vMAVxUceL+VY5LYuUU7N8SRbzS2FYkrs+GR90mfua+UHhMMW3Qo5VjpDePFTIUCvloZHQDWJFycAYdp8KWm1fN0YJV/PiDB6bNPex0LNi17jainY5gQrXnE9rik6MByEzH1C089x9NEMsqx1y7IJeex374Rf8NRpoVX0o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=RbbFTzV3; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RbbFTzV3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705515681; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=cIqqbSPoded3Wn+vyLp5YJWW6srr8m4G6HETipUFS2g=; b=RbbFTzV3vu4SKBVsUlfaJPPV95IXH37upu97nabqA2wkAPwuD2w9/3OgnuWfmpTaCnFouc YJxwqB3QGILPkxDaxchdw1Tkcdig3iNc1cJcSIdqpmaopUCXrh0X+KYZaje2HzpoFfdkyP 7Bvhty+N0zD+xoYL9P4IW2Ml+DMGPBE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-215-4v5w3_AEPFWuYTiK6-pOQg-1; Wed, 17 Jan 2024 13:21:17 -0500 X-MC-Unique: 4v5w3_AEPFWuYTiK6-pOQg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CB66B82A6C3; Wed, 17 Jan 2024 18:21:16 +0000 (UTC) Received: from file1-rdu.file-001.prod.rdu2.dc.redhat.com (unknown [10.11.5.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C2A7840C6EB9; Wed, 17 Jan 2024 18:21:16 +0000 (UTC) Received: by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix, from userid 12668) id BA27430C039C; Wed, 17 Jan 2024 18:21:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix) with ESMTP id B93CF3FB50; Wed, 17 Jan 2024 19:21:16 +0100 (CET) Date: Wed, 17 Jan 2024 19:21:16 +0100 (CET) From: Mikulas Patocka To: Yu Kuai , Song Liu , David Jeffery , Li Nan cc: dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, Mike Snitzer , Heinz Mauelshagen , Benjamin Marzinski Subject: [PATCH 5/7] md: fix deadlock in shell/lvconvert-raid-reshape-linear_to_raid6-single-type.sh In-Reply-To: Message-ID: References: Precedence: bulk X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 This commit fixes a deadlock in the LVM2 test shell/lvconvert-raid-reshape-linear_to_raid6-single-type.sh When MD_RECOVERY_WAIT is set or when md_is_rdwr(mddev) is true, the function md_do_sync would not set MD_RECOVERY_DONE. Thus, stop_sync_thread would wait for the flag MD_RECOVERY_DONE indefinitely. Also, md_wakeup_thread_directly does nothing if the thread is waiting in md_thread on thread->wqueue (it wakes the thread up, the thread would check THREAD_WAKEUP and go to sleep again without doing anything). So, this commit introduces a call to md_wakeup_thread from md_wakeup_thread_directly. task:lvm state:D stack:0 pid:46322 tgid:46322 ppid:46079 flags:0x00004002 Call Trace: __schedule+0x228/0x570 schedule+0x29/0xa0 schedule_timeout+0x6a/0xd0 ? timer_shutdown_sync+0x10/0x10 stop_sync_thread+0x197/0x1c0 [md_mod] ? housekeeping_test_cpu+0x30/0x30 ? table_deps+0x1b0/0x1b0 [dm_mod] __md_stop_writes+0x10/0xd0 [md_mod] md_stop_writes+0x18/0x30 [md_mod] raid_postsuspend+0x32/0x40 [dm_raid] dm_table_postsuspend_targets+0x34/0x50 [dm_mod] dm_suspend+0xc4/0xd0 [dm_mod] dev_suspend+0x186/0x2d0 [dm_mod] ? table_deps+0x1b0/0x1b0 [dm_mod] ctl_ioctl+0x2e1/0x570 [dm_mod] dm_ctl_ioctl+0x5/0x10 [dm_mod] __x64_sys_ioctl+0x85/0xa0 do_syscall_64+0x5d/0x1a0 entry_SYSCALL_64_after_hwframe+0x46/0x4e Signed-off-by: Mikulas Patocka Fixes: f52f5c71f3d4 ("md: fix stopping sync thread") Cc: stable@vger.kernel.org # v6.7 --- drivers/md/md.c | 8 +++++++- drivers/md/raid5.c | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) Index: linux-2.6/drivers/md/md.c =================================================================== --- linux-2.6.orig/drivers/md/md.c +++ linux-2.6/drivers/md/md.c @@ -8029,6 +8029,8 @@ static void md_wakeup_thread_directly(st if (t) wake_up_process(t->tsk); rcu_read_unlock(); + + md_wakeup_thread(thread); } void md_wakeup_thread(struct md_thread __rcu *thread) @@ -8777,10 +8779,14 @@ void md_do_sync(struct md_thread *thread /* just incase thread restarts... */ if (test_bit(MD_RECOVERY_DONE, &mddev->recovery) || - test_bit(MD_RECOVERY_WAIT, &mddev->recovery)) + test_bit(MD_RECOVERY_WAIT, &mddev->recovery)) { + if (test_bit(MD_RECOVERY_INTR, &mddev->recovery)) + set_bit(MD_RECOVERY_DONE, &mddev->recovery); return; + } if (!md_is_rdwr(mddev)) {/* never try to sync a read-only array */ set_bit(MD_RECOVERY_INTR, &mddev->recovery); + set_bit(MD_RECOVERY_DONE, &mddev->recovery); return; } From patchwork Wed Jan 17 18:22:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 13522087 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C232922EE0 for ; Wed, 17 Jan 2024 18:22:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515732; cv=none; b=AtVGtyAbvTF9Dt2eNV9zFWy+ihinpRDWujbLJRMNgWQkQuKAWbgmK9vqJR7ROot7Y1F+3XfATq/o58e43luF7kt/4hhSb9iXCScjMlhY49HheaVRgFpGqClK1J65XkcHfr+Hj5RxJQoAOp372c6GQthNs3ZsqDILDmqXiH/sB6U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515732; c=relaxed/simple; bh=PvLLl7v66q+PUHFprvCUDHoxKOwwMAQAhNVQXQYYT6I=; h=DKIM-Signature:Received:X-MC-Unique:Received:Received:Received: Received:Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type:X-Scanned-By; b=q2a3a3bkJGINVTk+aUp8LqCFIrsvCeJ7YVz/lQjdEQFgebUlbv/VDlDS9hcopOSnAAbRs3kX2ZI5OUuH0HSt7D4E2MP7cCZ4BbWJvd2vXpCK+/kWKXC9PwFgtbCv9GfH/dBAUGcKK+bRsiJAtSBqa//riW/wgWEIGfqvljBtbQ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=gg9RbEab; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gg9RbEab" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705515729; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GG9fyFkKr1M4arY8M7JnB5SochcGhl1C3lyQQS9soBo=; b=gg9RbEabzWLq1DTLp9NB6o1GsPIC7VyYtD18bmYvSxOwt2WgCcRro3glN9HOFjRL4us5le Mdy2Tig79a5cRr8yTaf7Zs4mBecBOxypKC26xdd+eBkgDD322qnAkQj2d1gKS24LgX7qto HqSLLCYXdflJYkmZ3G27lEne05Hbxyk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-508-bfiZ0wIIMPy6uwRahF5gWQ-1; Wed, 17 Jan 2024 13:22:06 -0500 X-MC-Unique: bfiZ0wIIMPy6uwRahF5gWQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA777185A791; Wed, 17 Jan 2024 18:22:05 +0000 (UTC) Received: from file1-rdu.file-001.prod.rdu2.dc.redhat.com (unknown [10.11.5.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E32872166B33; Wed, 17 Jan 2024 18:22:05 +0000 (UTC) Received: by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix, from userid 12668) id DB3C730C039C; Wed, 17 Jan 2024 18:22:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix) with ESMTP id DA6513FB50; Wed, 17 Jan 2024 19:22:05 +0100 (CET) Date: Wed, 17 Jan 2024 19:22:05 +0100 (CET) From: Mikulas Patocka To: Yu Kuai , Song Liu , David Jeffery , Li Nan cc: dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, Mike Snitzer , Heinz Mauelshagen , Benjamin Marzinski Subject: [PATCH 6/7] md: partially revert "md/raid6: use valid sector values to determine if an I/O should wait on the reshape" In-Reply-To: Message-ID: References: Precedence: bulk X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 Revert the commit c467e97f079f ("md/raid6: use valid sector values to determine if an I/O should wait on the reshape") - it causes deadlock in the LVM2 test shell/lvconvert-raid-reshape.sh sysrq: Show Blocked State task:(udev-worker) state:D stack:0 pid:98633 tgid:98633 ppid:320 flags:0x00000006 Call Trace: __schedule+0x213/0x550 schedule+0x29/0xa0 schedule_timeout+0xbe/0xd0 ? __wake_up+0x3b/0x50 wait_woken+0x47/0x50 raid5_make_request+0x501/0x10e0 [raid456] ? swake_up_all+0xb0/0xb0 md_handle_request+0x132/0x1e0 [md_mod] raid_map+0x20/0x30 [dm_raid] __map_bio+0x179/0x1a0 [dm_mod] dm_submit_bio+0x166/0x4c0 [dm_mod] __submit_bio+0x78/0xf0 submit_bio_noacct_nocheck+0xb6/0x290 mpage_readahead+0xc7/0xe0 ? blkdev_iomap_begin+0x80/0x80 read_pages+0x42/0x1e0 page_cache_ra_unbounded+0x128/0x170 force_page_cache_ra+0x8c/0xb0 filemap_get_pages+0xf3/0x530 ? current_time+0x16/0xc0 filemap_read+0xb3/0x2b0 ? sgl_alloc_order+0xf0/0x1c0 ? dm_copy_name_and_uuid+0x6c/0x90 [dm_mod] ? dm_attr_uuid_show+0x1a/0x40 [dm_mod] ? do_wp_page+0x20c/0xaf0 ? dm_attr_show+0x32/0x50 [dm_mod] ? __pte_offset_map+0x12/0x170 blkdev_read_iter+0x62/0x140 vfs_read+0x1a9/0x2a0 ksys_read+0x4e/0xc0 do_syscall_64+0x3c/0x110 entry_SYSCALL_64_after_hwframe+0x46/0x4e task:lvm state:D stack:0 pid:151667 tgid:151667 ppid:150522 flags:0x00000002 Call Trace: __schedule+0x213/0x550 schedule+0x29/0xa0 schedule_timeout+0xbe/0xd0 ? queue_delayed_work_on+0x1b/0x30 ? srcu_gp_start_if_needed+0x33e/0x4a0 wait_for_completion+0x6d/0x110 __synchronize_srcu.part.0+0x6f/0x80 ? get_rcu_tasks_trace_gp_kthread+0x10/0x10 __dm_suspend+0x50/0x180 [dm_mod] ? table_deps+0x1b0/0x1b0 [dm_mod] dm_suspend+0xaf/0xd0 [dm_mod] dev_suspend+0x186/0x2d0 [dm_mod] ? table_deps+0x1b0/0x1b0 [dm_mod] ctl_ioctl+0x2e1/0x570 [dm_mod] dm_ctl_ioctl+0x5/0x10 [dm_mod] __x64_sys_ioctl+0x85/0xa0 do_syscall_64+0x3c/0x110 entry_SYSCALL_64_after_hwframe+0x46/0x4e Signed-off-by: Mikulas Patocka Fixes: c467e97f079f ("md/raid6: use valid sector values to determine if an I/O should wait on the reshape") Cc: stable@vger.kernel.org # v6.1+ --- drivers/md/raid5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux-2.6/drivers/md/raid5.c =================================================================== --- linux-2.6.orig/drivers/md/raid5.c +++ linux-2.6/drivers/md/raid5.c @@ -5851,7 +5851,7 @@ static bool stripe_ahead_of_reshape(stru continue; min_sector = min(min_sector, sh->dev[dd_idx].sector); - max_sector = max(max_sector, sh->dev[dd_idx].sector); + max_sector = min(max_sector, sh->dev[dd_idx].sector); } spin_lock_irq(&conf->device_lock); From patchwork Wed Jan 17 18:22:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 13522088 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3070022EE4 for ; Wed, 17 Jan 2024 18:22:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515763; cv=none; b=DLi5ih7h7E5IKMen8MIgeTudBi/AX5tnrFiesJK0ZHz3ftU9UeIYTO+20g90Vx6XzOCFp73ItxUuZC76a+kZNDvVrcEtR5i3XMy9X9c9fLwZoZnc+gtCd1DZ3vB2kUAD/XH3U2IAyXZhes8n/p7xeWyg37HZ9PtLdqaMSpakxwY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515763; c=relaxed/simple; bh=V8R9j4TYEy4pGFHA0w+YlUVkrb0ecevYuEGI9WoaKco=; h=DKIM-Signature:Received:X-MC-Unique:Received:Received:Received: Received:Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type:X-Scanned-By; b=M2a7rcImGsXzWEznfVEvaPQMWVAC4KVRyDSPeQDgq4W+Amo6kbYUWMQ3hrdYKCvVesM0IYpbgRM2rxzhecas5H+y4luXGTHorvyjvqutMoLB2iCatX5PUvPvDOE6JAavn4s1EQRXxF/xNsHNc85t03RAfWje3jx44D2RU42kI0g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=WPKFXq5f; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WPKFXq5f" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705515761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=z09U/kH5aTZB7jjyJSH8zHLRV8pSgNSa2hUWXWZNzSg=; b=WPKFXq5fnr89y2q8muWwd7HBgrBPlEy3F6p/qborZz+7ax80FiW7APSoiNwVwHf9r/9owf 8W+w5Vo4cC1BRQQUcxg5twYnFiuI69x6N6Rb2FK/9tO+B5g40KbCsvVqp2mt9tEhbnhsFC 4QnT7rvnVIQXATjBHW1vnCm/aH5vuvw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-241-ng3Nu4FMNIS2uCOcjaNjhg-1; Wed, 17 Jan 2024 13:22:36 -0500 X-MC-Unique: ng3Nu4FMNIS2uCOcjaNjhg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7B94F85A58B; Wed, 17 Jan 2024 18:22:36 +0000 (UTC) Received: from file1-rdu.file-001.prod.rdu2.dc.redhat.com (unknown [10.11.5.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 73FB13C27; Wed, 17 Jan 2024 18:22:36 +0000 (UTC) Received: by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix, from userid 12668) id 6B74830C039C; Wed, 17 Jan 2024 18:22:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix) with ESMTP id 6ABB53FB50; Wed, 17 Jan 2024 19:22:36 +0100 (CET) Date: Wed, 17 Jan 2024 19:22:36 +0100 (CET) From: Mikulas Patocka To: Yu Kuai , Song Liu , David Jeffery , Li Nan cc: dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, Mike Snitzer , Heinz Mauelshagen , Benjamin Marzinski Subject: [PATCH 7/7] md: fix a suspicious RCU usage warning In-Reply-To: Message-ID: <51539879-e1ca-fde3-b8b4-8934ddedcbc@redhat.com> References: Precedence: bulk X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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: 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 Signed-off-by: Mikulas Patocka Fixes: ca294b34aaf3 ("md/raid1: support read error check") Reviewed-by: Yu Kuai --- 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;