Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796231756; b=u9mh2SxOFgC55AucdKXpw92T4dpQugkgDUiAKwATl7UUv2XRpNaT+n0UDp5Gcxg6T4uI 8kqhGsRWKHv3WGoto7M7OO/EInftwPzjNJwoehZzKoq7xCHY0Ys5TiTc+9j5mNqHEYvHM P4OKpUSBCkG+PxWPnH5K+E7US3jf8DM4TBEPVYWU/tbGleLgvxeeLtAK8m12O1GAeyiZb 4qmC4Au336Klavk9mFLb1XPGzttK5owJK5pwGqsJDz5iFJ4pzmBKzwXcCddQQvJT3Hti9 aWHb15RimSw8AW0B+u7Sl0Ak/wK3Bx2bvRl3DNOvum42fm9Ky7rIL7s7r4U6kxvNNXg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796231756; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=c5rK5noO/T5h7vnAKN7f4U495R6wgLBwHe6G1kE9l1E=; b=Px/f+qfnTePELGBV2uq+N4nAlVNSpsSK5CllZ5RKs2ZqU+rro6BXKInesL+P5WntnFd2 CAq1Inxc6XWBumx/fvczMVtbx3dEnZw29OxT/v+zdEPR1jO7MMGMKR4Xyvp14UH4zUXoG N8Z301opseSPxvoDDH5uUkdNGK9UZJnOIlnx3F19EieLskAXLGa5rM/6+4C7FsILmoCML 2kv4YukWYW4cw/QiBCqqT7lMwnv7FkyBjlBcdrKkixeZFl7ZG817C8C5cX4gkqcc1Bv0F 8qGiFkL6nP3CpAQN9MYOyYzCLK+be2SHZg7xK0EJPHE2XgOvUFfRPJ24nlmCGmig/yQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YeUugYXd; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1C56606A322; Wed, 2 Dec 2026 17:15:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YeUugYXd Received: by smtp.kernel.org (Postfix) with ESMTPSA id 128F11F00893; Wed, 2 Dec 2026 17:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796231756; bh=c5rK5noO/T5h7vnAKN7f4U495R6wgLBwHe6G1kE9l1E=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=YeUugYXdaOYiDHwDG3IFFPgbi0yxc0dvt1pGrN8ZlmO6mMS+f9ca3988vIS2BRf5f bUYeHoxpHZb74QdNExHxWnWzkH4DfatHJNGU5VIiKqo/BrUtMchkevH8bdivpsFqoc SQ5q3X2vBPDAYWE1g0xq25ZoopA0Y6sXWot6Z82v1E91CzY18uLGRAZEUGA3S5uoAN jpZawSsdbC/90TGyZM7AdRcU0zO7B+abn14Xap6pFXl9dIt5OxckCv4u+QKrpZkBvX HndflZaLooeEX+NC2iFxQ8uDH83VkUEsvP71CcsQM2KH0LrlnyhhwMtalWGtFTJ8ZM zFWeRKQ9VZM8A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v20 14/23] xfs: use read ioend for fsverity data verification Reply-To: sashiko-reviews@lists.linux.dev To: "Andrey Albershteyn" , linux-ext4 , "Eric Biggers" , "Christoph Hellwig" , "Carlos Maiolino" , fsverity Cc: "Christian Brauner" , david@fromorbit.com, dsterba@suse.cz, tytso@mit.edu In-Reply-To: <20261202165653.767961-15-aalbersh@kernel.org> References: <20261202165653.767961-1-aalbersh@kernel.org> <20261202165653.767961-15-aalbersh@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 17:15:55 +0000 X-Mailing-List: fsverity@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] xfs: workqueue deadlock on mempool_alloc() in xfs_end_io_read() -- commit 8bb973f44a8ada1e9937d03966b5a5b1e3c30932 Author: Andrey Albershteyn xfs: use read ioend for fsverity data verification This commit uses read ioends to defer fsverity data verification to the fsverity workqueue, passing fsverity_info down from the iomap read context. > diff --git a/fs/xfs/xfs_ioend.c b/fs/xfs/xfs_ioend.c > index 7f4a4a95afe50..61f211a3b8052 100644 > --- a/fs/xfs/xfs_ioend.c > +++ b/fs/xfs/xfs_ioend.c > @@ -18,7 +18,26 @@ > #include "xfs_ioend.h" > #include "xfs_error.h" > #include "xfs_errortag.h" > +#include "xfs_fsverity.h" > #include > +#include > + > +static void > +xfs_end_fsverity_io_read( > + struct work_struct *work) > +{ > + struct xfs_fsverity_ioend *fsv_ioend =3D > + container_of(work, struct xfs_fsverity_ioend, work); > + struct iomap_ioend *ioend =3D fsv_ioend->ioend; > + struct bio *bio =3D &ioend->io_bio; > + > + mempool_free(fsv_ioend, &xfs_fsverity_ioend_pool); > + > + if (!bio->bi_status) > + fsverity_verify_bio(ioend->io_vi, bio); > + > + iomap_finish_ioends(ioend, blk_status_to_errno(bio->bi_status)); > +} [ ... ] > @@ -117,6 +138,24 @@ xfs_end_io_read( > } > } > =20 > + /* > + * If we have fsverity on this bio, we need to run fsverity verification > + * of data folios from a separate fsverity workqueue. This is necessary > + * to avoid deadlocking due to fsverity issuing more reads of fsverity > + * metadata which would be processed by the same worker in the BIO > + * completion workqueue. > + */ > + if (IS_ENABLED(CONFIG_FS_VERITY) && !error && ioend->io_vi && > + xfs_fsverity_is_file_data(ip, ioend->io_offset)) { > + fsv_ioend =3D mempool_alloc(&xfs_fsverity_ioend_pool, > + GFP_NOFS); > + fsv_ioend->ioend =3D ioend; > + INIT_WORK(&fsv_ioend->work, xfs_end_fsverity_io_read); > + > + fsverity_enqueue_verify_work(&fsv_ioend->work); > + return; > + } > + > iomap_finish_ioends(ioend, error); > } [Severity: High] Can mempool_alloc(&xfs_fsverity_ioend_pool, GFP_NOFS) here deadlock bio_complete_wq against fsverity_read_workqueue? xfs_ioend_submit_read() sets BIO_COMPLETE_IN_TASK, so xfs_end_io_read() runs from bio_complete_work_fn() on the per-CPU bio_complete_wq. Because bio_complete_batch has a single work_struct per CPU and drains completed bios sequentially, blocking in xfs_end_io_read() stalls all later BIO_COMPLETE_IN_TASK completions queued on that CPU. Meanwhile, fsv_ioend is only returned to xfs_fsverity_ioend_pool once xfs_end_fsverity_io_read() begins executing on fsverity_read_workqueue. Under memory pressure, if the active fsverity_read_workqueue workers are blocked in fsverity_verify_bio() waiting for Merkle tree metadata reads or memory reclaim, pending work items on fsverity_read_workqueue can hold all 128 preallocated pool elements: bio_complete_wq fsverity_read_workqueue --------------- ----------------------- bio_complete_work_fn() xfs_end_fsverity_io_read() (128 data bios allocate fsverity_verify_bio() fsv_ioend and queue work) read_merkle_tree_page() (waits for metadata read / reclaim BIO_COMPLETE_IN_TASK completion on bio_complete_wq) xfs_end_io_read() (129th bio) mempool_alloc(&xfs_fsverity_ioend_pool, GFP_NOFS) <-- sleeps waiting for queued xfs_end_fsverity_io_read() to call mempool_free() *** DEADLOCK *** When bdev_has_integrity_csum() is true, xfs_get_iomap_read_ops() selects xfs_iomap_read_ops for Merkle tree metadata reads as well, so their completions also require bio_complete_work_fn() on bio_complete_wq, as do failed metadata read bios that defer completion via bio_complete_in_task() in iomap_read_end_io() and reclaim I/O completions on bio_complete_wq. Could fsv_ioend be allocated before submit_bio() (or embedded in the read ioend) so the bio completion path never blocks on the mempool? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202165653.7679= 61-1-aalbersh@kernel.org?part=3D14