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: 13522074 X-Patchwork-Delegate: snitzer@redhat.com 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 F07462374B for ; Wed, 17 Jan 2024 18:18:00 +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=1705515482; cv=none; b=PhL5kZZUVGAhJnDT83ncwofSp312LbV1Jwk0xBs71dvtgQGug7U3IsHv4KFadlQMzXWkWlFuLnRVPNXZt/KpdbPCb5vuZJDV7GmhozcWvd3BUZq6df4LHjw3AtSV3JI37vf/WFSE9t/9GWNVsjcI+e6ZTKEO1oIk4isOpapAE1g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515482; 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=qVEHhy3eaYwmEgZAIc9ve1Y9Ohjtaz9c7R+XKsts+rn6Aa+Ll+SGz28YEAFxiPRKCoYhbUoN5Y9ABuAJJsRMkFcQIP1+0YSOPe/eQV+VrBCULUaDMesTS3w6vSJUEjsBvpXrhFLDHF31dGKvFQNY8qcJllT7NqUKbp1NglgyfYk= 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=Y961S+sL; 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="Y961S+sL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705515479; 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=Y961S+sLOFwfqd1ZJzgjOmDcLceT+oCBoh9iBhxB/hznKxahDRR6TOPEFy2ul6lNSijreq byEOVMs1BaGHhMtNsMcp/HwxbxHsV+aFefbJqHdaAr47j3DTMa0DZsTdCRSjwTWfJL9tg9 XE4NaUrxm1zFhaKIXSWGl04t+u4JnRQ= 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: dm-devel@lists.linux.dev 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: 13522075 X-Patchwork-Delegate: snitzer@redhat.com 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 8349722EE0 for ; Wed, 17 Jan 2024 18:18:50 +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=1705515532; cv=none; b=QLl2Hynxe72AizQeZXpy4wB6RIyKLVOoonTj/mIQa8sPwovPAs+0Uw0aVZ/GsFlPw8c7e/EzkSo5UUjBpeOK5uzFEtLJJ+T72R1btkjIfbIuBbXf7Q8d/AAGNq5Om+Mm0R8jpKnyVlL/8aMNPOpobiEyjiUY1DBC+wCSPNz/nmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515532; 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=dy2baNkeJkr6M9U7NnVWi2VVgLW+K0YAaT1CAWmruYkMuazkr/l4j2nXoZXfGz4nPGWfOYIIR6oSBvloDha151JLDDOCCmV9l3DZ/J33OPme69SwphzD+cQC7UE5ma67bwLA5rEklkgxS86C221JBhkE6HvtesCAs6goLloe8ZI= 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=I4YoBYWR; 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="I4YoBYWR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705515529; 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=I4YoBYWRIcVFsTtDebyRSWve6pRbqGTf0P1Io7mhs5jL1Qw39x7XxAbAqbtDtecGUAM0Rg YO1V3+2+vJkLJMPTWIqp2rMh29EQaJ/K5cIImLYXk4FOXD6YYeWjGbtg9JM72jH8xkARLO 9Jg8XcpTjIOQn/74RY7UH0bmfJxrB9I= 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: dm-devel@lists.linux.dev 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: 13522076 X-Patchwork-Delegate: snitzer@redhat.com 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 6360822EF6 for ; Wed, 17 Jan 2024 18:19:33 +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=1705515574; cv=none; b=M1y78WUAQjrWys8DcujxGdJDXYK+8gfw5dd++SKdnuGxDLUoc+pqhW0mFW6MaPJL2n0iA/p6bnRNY2QtFmAhFmVKGvC/X11wd4lc/4Koiu0lkLBl1bG5S2DoKMGQksDf+YxNv/4+9i/MQHWuD7xQG4JeTu1GzBp9/c6z8sQ9LWM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515574; 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=OwjfIiLQssMwXLZubxGyl3XauARNh8BMNWXrq5a1v7fRwqAsQbuNPaiuCyb9LAYRziQEUlvEMhvxv+1WQ/s77nmDFgKHb8UJ7OeT42/DxDoFlNcEO8RmzziiDlbva5o2TTq9plFSakmoaHPcJXVFC2Ll6KjCASqBRi9+C6RSe7E= 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=KqdNco0H; 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="KqdNco0H" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705515571; 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=KqdNco0HvB8dIiyq3quzLEAL3Y9vgQZCvyyefH4vNJSPQ9t5jl/7Kj0VaVZUuX0EDCxAYw FH8NldAiAAIizOBtNg/MyuSzYebNeqZUsAc5drry/xEWVQF2/Ldx7GuaTojM+Lp5PJPuW1 fWKs9rd53gXrjzjljTxuehLdD7+iUt0= 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: dm-devel@lists.linux.dev 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: 13522077 X-Patchwork-Delegate: snitzer@redhat.com 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 A5AEE22EE0 for ; Wed, 17 Jan 2024 18:20:20 +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=1705515622; cv=none; b=l7WrmLM7KsbuUMkKN3KtsQFvO1W9C8dAtautUsSnGH5rdADmSxDGe3DX/hk3MwzyaWWrZnQp0HwJElFsnwK5sclKPmo9Tane4OCy2fRAdm4KZfh2iuB3JcPKvNsv1VJkm4HvGcbxWe1odC+pLE5kNU+1458dRBOW38qb6vWqGas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515622; 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=EtH3ajJXODze4aA6vNJq4h681ZG5sFFNtjmcnmSm7VeZLJbHd1HH30MGwhXSpTf+4PwaViAFL8/j74q47eMi/8bVRVn1SzTdjOFb9SYIssGHvS7KpOuoEXKEd+G9DDtSChTs6JyAX4iWOY4E16vmTHnl4rj7CRa4hV1U3KvAsyw= 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=VK30q1O5; 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="VK30q1O5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705515619; 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=VK30q1O5F0oCOFPC8V3v5uHMhyz4rutpB1elIZaLqE6vLuD/f6IKIUhMZt/RbP/GVY7Br8 DEaYl0s5X85OGQ0tgcMUsw5nPodSKnnqrFefeiTY18ZEh4PZT4Zer7PO1fKej536SkYcTd t79UDM3Yabl5AY9ViHcxoaW7To4Zhyg= 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: dm-devel@lists.linux.dev 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: 13522078 X-Patchwork-Delegate: snitzer@redhat.com 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 8AE9922EE0 for ; Wed, 17 Jan 2024 18:21:21 +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=qB9Co5RyssRURKNfkB5QLxO+Ub1SPQ3mETlk8C3o90VGVKr6nyYKPq044hW20WHyKUu2ASBlHAqWfTlWoRcAAmvr8CyVjMAFP/uI6vwED21uhWDqjgLNdnSV53XAWceJPoEChmdZVTmxdo++k34/l9/VXRUyRFtU2QGPRnQDx1A= 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=PlaycImd1nDVxRxQ3YdnebIICX1/432SEO+1kgCd8SlP7mqZSBO3v80BvAQDwoxmBl78ZuKX6vQ2mukW26VwPPiQCA8s1YIm/rK5x/awJ2Wf7f83Po1059Qv5rpqNjQo1JU1OuAU3eMH6B3cdnTw0VLFKyzAonDMcZuPJ2wXV0M= 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=IyfSYAWk; 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="IyfSYAWk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705515680; 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=IyfSYAWkfZT+MxxQtrKhv9E0+N98GeGxMG0OA0WIp3U9VG7VVxTxUd282SeN4pcC+G5CxY ShWKdev6w11HaJ9bW9JWQQuh93xC5VeXePnBbGsUh5FTO4y62wXxWeI+WQxDzP3n82Z5dd PhxvhQVFs16HWohcY+Wsfw5ZCmHaPnE= 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: dm-devel@lists.linux.dev 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: 13522079 X-Patchwork-Delegate: snitzer@redhat.com 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 249D222EFC for ; Wed, 17 Jan 2024 18:22:12 +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=1705515734; cv=none; b=HYtVSsNnNnMo0fxPsZl+gmmbHj/Je5MOWj0OqNAO3kyuDX1V1FU1W+apHyt0J1heteLG934x+Jj+/oxYnkthW1pbkHDx78VvFC46y5GAyuX48zOb1qVtb0uMsS9qCE3oF8EuQ2IcPIfp4Bedo3DEsjkvq9v1XV1rIGX0Gj35Q4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515734; 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=LOMaN1jIR5RGrUIFtrGShZ5OdpeQDKDE66hs5DRSVeIoUvvo3XFOQpojpC2WbtwM0fyPxz+vgTNZiJHtW0zNhmvFkIA4PeSShpvOc+AoauNSf2Ujbp6Z4+syvEBd0JYbKQzlNruiG1gPPl8mJLEwSrhF9WuI0EZ5PKRPf1Y2SMA= 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=Uxoz8wy9; 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="Uxoz8wy9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705515731; 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=Uxoz8wy9DckPcJSaQ3pVn9Vh9sHin48IVbnyBexgRMnB4d1ffiHJAoCASoaCXjUCU2Y5ch y30Tse2WmnXEdRDteA5y7ySuHHGisyhRPoW2prUARgiH6aV5U8VH05HqoNAI9xidiJM1TH hX/telUmOwbbDjmfkSJ/V1kSIlcLiS8= 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: dm-devel@lists.linux.dev 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: 13522080 X-Patchwork-Delegate: snitzer@redhat.com 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 2248A22EE4 for ; Wed, 17 Jan 2024 18:22:39 +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=1705515760; cv=none; b=XaxPVb/GvCq+10aMCDu58opGtGJM64sZQyYwsW/3Kcr6/SFQIvy9ttIlCpQ5H+u9bzf94resgZvgqllxL3YsTocqq0C1deaC+w8cugqPyez0u0b5fDdP3pd3QpMaw7k9+f7ReLIFoYtkAM9phPyfmrLhi0x9xYzSH0o49fZ7DnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705515760; 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=HZmBsibPYNqgNlLh+jeR2MWxZhqA67DHLorrxIl5bUDdM299q4gxt6r+hsSGzBQf1Hy9haInda2eAnMybsm4B08hfXOhEt8zrhUxrZ8qL048XBUauaWUW9d+tUuw0QFsKuFkzaT7S1qS8/QHThuVukhugR2W8/CwQXxIXaUS9yg= 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=RzuP6guJ; 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="RzuP6guJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705515758; 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=RzuP6guJtZmvJ1+0wXKxnHdN3iN/q/Ils6K2dqqHCAqNjXgRGzCaQI4v8Z3ZlDE9LONx7V vB8ogZeN5Q3Xta5wIEcrN3V9El9M9+Cjv33QPC7BFYresvAYAK5UtQWo8F0SspQKoW2eaR +C7c4CAHFSBRMf11ikWggXnqW0ZG9Ac= 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: dm-devel@lists.linux.dev 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;