{"id":2229428,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2229428/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260428083332.768693-16-aalbersh@kernel.org/","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/1.1/projects/8/?format=json","name":"Linux ext4 filesystem development","link_name":"linux-ext4","list_id":"linux-ext4.vger.kernel.org","list_email":"linux-ext4@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260428083332.768693-16-aalbersh@kernel.org>","date":"2026-04-28T08:33:21","name":"[v9,15/22] xfs: use read ioend for fsverity data verification","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"da3452660d2a19900f7736c11eb6b4e44ee16b63","submitter":{"id":92821,"url":"http://patchwork.ozlabs.org/api/1.1/people/92821/?format=json","name":"Andrey Albershteyn","email":"aalbersh@kernel.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260428083332.768693-16-aalbersh@kernel.org/mbox/","series":[{"id":501796,"url":"http://patchwork.ozlabs.org/api/1.1/series/501796/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/list/?series=501796","date":"2026-04-28T08:33:09","name":"[v9,01/22] fsverity: report validation errors through fserror to fsnotify","version":9,"mbox":"http://patchwork.ozlabs.org/series/501796/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2229428/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2229428/checks/","tags":{},"headers":{"Return-Path":"\n <SRS0=Tz1w=C3=vger.kernel.org=linux-ext4+bounces-16161-patchwork-incoming=ozlabs.org@ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-ext4@vger.kernel.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","patchwork-incoming@ozlabs.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=rPyOrcJ1;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org\n (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org;\n envelope-from=srs0=tz1w=c3=vger.kernel.org=linux-ext4+bounces-16161-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)","gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=\"2600:3c0a:e001:db::12fc:5321\"\n arc.chain=subspace.kernel.org","gandalf.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org","gandalf.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=rPyOrcJ1;\n\tdkim-atps=neutral","gandalf.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-ext4+bounces-16161-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"rPyOrcJ1\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4Yvw4tZ1z1yHX\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 18:47:08 +1000 (AEST)","from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4g4Yvw4T4lz4wLT\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 18:47:08 +1000 (AEST)","by gandalf.ozlabs.org (Postfix)\n\tid 4g4Yvw4Q5Bz4wLj; Tue, 28 Apr 2026 18:47:08 +1000 (AEST)","from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby gandalf.ozlabs.org (Postfix) with ESMTPS id 4g4Yvs19PFz4wLT\n\tfor <patchwork-incoming@ozlabs.org>; Tue, 28 Apr 2026 18:47:05 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 2A36231F3860\n\tfor <patchwork-incoming@ozlabs.org>; Tue, 28 Apr 2026 08:36:10 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 60AE23DBD44;\n\tTue, 28 Apr 2026 08:34:40 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F6E12DCC01;\n\tTue, 28 Apr 2026 08:34:39 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 61742C2BCB7;\n\tTue, 28 Apr 2026 08:34:37 +0000 (UTC)"],"ARC-Seal":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1777366028; cv=pass;\n\tb=Br4P68a4RNZy1pmFZ1d4NpHmbv5fD3pKwYxgu/EJpWb+VUqD0GlKxjx/fQ3lob2YBwWyo5RdwRl5ToPcGVYNs+A+E87oibJkHA67Aol+3t9VI3lim1LPEiuZqTFcW8Y2/Iel1VdF8OuD/hzs/I4jLbDi6wVgkMOG8JWNyR0xGPPgUciUXh9Na1qTWzLP8mFXtlPL7Hyni9oCKyi5aJWe0hkxvusFMLf+WxfaQdrxzSGAS8BhfO6iqjlfvC/RbVjHSJvSszSbepsNrIjJsHJV3VtAxakG/0hH6Icu8HlWco4bBgEuuvj4UgUQZI1CYOqmJ5mtsjy+RcpC1TYw3IwNZA==","i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777365280; cv=none;\n b=tME2QPSlUrpZigPtqpYHB7tL1/Kqfgbv+2NkgLh0QQXMZCZwyNG6PZNvaNgrxZ6RH04yfj8lrNIMTukpdnGROJ1tb50i2y+i4ZHNBdLGcDEz3eYFSuwCbY50dDeYKPBo2QE44thIfi+tJzXUJc2D2VL+ylmjGxIB8JxOAMj2ba4="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1777366028; c=relaxed/relaxed;\n\tbh=lWM0vfhRoQN3XUnUh/hfhcB8qeHDbNjCnEWLhHQ7Rno=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=mouBQsCzaqqvjkuVTy0uvlnJyLa3kueZ8ov5bHatdrV/i1eX8zIMs5ktT+Oe2UC9BF07TifZ/ksqon0KJVKzjXu0t+JeenBLLPgPoGmFpZ4i7wVK+b8YJH4KSZV17vBL70tusZks1tvgsImKnCgjDSwYKwsekuRky7mE0a46GvHq5FwOEEtzZOYLS6Xzl1DNBk6Jy4+AQn9G72CPiKGOSqxGJpJAq0SVH/mS5nRgcpylppmog52vNby3AeQwPshtsKhAR6X5iZpWGfX71lSaC+bUFtydimcDd42WpzRT34VaINvd3LbbUtIG1e7I1OVd/e5b2yhtmoV3N8SMs+3xrw==","i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777365280; c=relaxed/simple;\n\tbh=+IPCnfTbYJgst2p5FA7yf8LN40/02HKXVjwkca7X0i4=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=EVaso14JM+Ba0OSV/s8vaQnF5GvMY1SAzhlL52Rzn2FMWm7JEea8Lm760SbYLP8OXoVoAFd/bSXDqeD/aUvIYQA+SPOFu/2TYKAKsytEqqr1bRsXeTpEXJU7JaFd3/h8Tw1dTAblF+S8LenQDeI317GZ3gf71jewh+bwlL2j4lA="],"ARC-Authentication-Results":["i=2; gandalf.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org;\n dkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=rPyOrcJ1; dkim-atps=neutral;\n spf=pass (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-ext4+bounces-16161-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org","i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=rPyOrcJ1; arc=none smtp.client-ip=10.30.226.201"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777365279;\n\tbh=+IPCnfTbYJgst2p5FA7yf8LN40/02HKXVjwkca7X0i4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=rPyOrcJ1vepJkZdXMhykU7Ofq7cO9eZoMKU4teExehYBlzOT2m1u6zVKsqac98dKf\n\t AsyeWnY2WVYhRIUTNz0JVXGaZFUEaZXcDQUwJa89XYE1/ZdrDNUBI5cHxXn++tN3+z\n\t 4qBjpGdW4eVvWDpFSgRBiRucJgSCFoDKcuPAaB9PBxMC5dPCSLOJovulTOlX2aqNJl\n\t U3YD1QuEEfb/yvTwuglmhEfSYxG9/KN9FBY8EaGyx8/Mp1S6QfIG0xMD1N7GwEIol/\n\t NHCQNupCBLlZgobMzShzw8mIreLsMJ0uHlNGQFYweo0U76eJxhnzc7ZAi3dbiM/2gj\n\t pSVIUnx632tcQ==","From":"Andrey Albershteyn <aalbersh@kernel.org>","To":"linux-xfs@vger.kernel.org,\n\tfsverity@lists.linux.dev,\n\tlinux-fsdevel@vger.kernel.org,\n\tebiggers@kernel.org","Cc":"Andrey Albershteyn <aalbersh@kernel.org>,\n\thch@lst.de,\n\tlinux-ext4@vger.kernel.org,\n\tlinux-f2fs-devel@lists.sourceforge.net,\n\tlinux-btrfs@vger.kernel.org,\n\tlinux-unionfs@vger.kernel.org,\n\tdjwong@kernel.org","Subject":"[PATCH v9 15/22] xfs: use read ioend for fsverity data verification","Date":"Tue, 28 Apr 2026 10:33:21 +0200","Message-ID":"<20260428083332.768693-16-aalbersh@kernel.org>","X-Mailer":"git-send-email 2.51.2","In-Reply-To":"<20260428083332.768693-1-aalbersh@kernel.org>","References":"<20260428083332.768693-1-aalbersh@kernel.org>","Precedence":"bulk","X-Mailing-List":"linux-ext4@vger.kernel.org","List-Id":"<linux-ext4.vger.kernel.org>","List-Subscribe":"<mailto:linux-ext4+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-ext4+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Spam-Status":"No, score=-1.2 required=5.0 tests=ARC_SIGNED,ARC_VALID,\n\tDKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,\n\tMAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled\n\tversion=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org"},"content":"Use read ioends for fsverity verification. Do not issues fsverity\nmetadata I/O through the same workqueue due to risk of a deadlock by a\nfilled workqueue.\n\nPass fsverity_info from iomap context down to the ioend as hashtable\nlookups are expensive.\n\nAdd a simple helper to check that this is not fsverity metadata but file\ndata that needs verification.\n\nReviewed-by: Christoph Hellwig <hch@lst.de>\nReviewed-by: Darrick J. Wong <djwong@kernel.org>\nSigned-off-by: Andrey Albershteyn <aalbersh@kernel.org>\n---\n fs/xfs/xfs_aops.c     | 46 ++++++++++++++++++++++++++++++++++---------\n fs/xfs/xfs_fsverity.c |  9 +++++++++\n fs/xfs/xfs_fsverity.h |  6 ++++++\n 3 files changed, 52 insertions(+), 9 deletions(-)","diff":"diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c\nindex 9503252a0fa4..ecb07f250956 100644\n--- a/fs/xfs/xfs_aops.c\n+++ b/fs/xfs/xfs_aops.c\n@@ -24,6 +24,7 @@\n #include \"xfs_rtgroup.h\"\n #include \"xfs_fsverity.h\"\n #include <linux/bio-integrity.h>\n+#include <linux/fsverity.h>\n \n struct xfs_writepage_ctx {\n \tstruct iomap_writepage_ctx ctx;\n@@ -171,6 +172,23 @@ xfs_end_ioend_write(\n \tmemalloc_nofs_restore(nofs_flag);\n }\n \n+/*\n+ * IO read completion.\n+ */\n+static void\n+xfs_end_ioend_read(\n+\tstruct iomap_ioend\t*ioend)\n+{\n+\tstruct xfs_inode\t*ip = XFS_I(ioend->io_inode);\n+\n+\tif (!ioend->io_bio.bi_status &&\n+\t\t\txfs_fsverity_is_file_data(ip, ioend->io_offset))\n+\t\tfsverity_verify_bio(ioend->io_vi,\n+\t\t\t\t    &ioend->io_bio);\n+\tiomap_finish_ioends(ioend,\n+\t\tblk_status_to_errno(ioend->io_bio.bi_status));\n+}\n+\n /*\n  * Finish all pending IO completions that require transactional modifications.\n  *\n@@ -205,8 +223,7 @@ xfs_end_io(\n \t\tlist_del_init(&ioend->io_list);\n \t\tiomap_ioend_try_merge(ioend, &tmp);\n \t\tif (bio_op(&ioend->io_bio) == REQ_OP_READ)\n-\t\t\tiomap_finish_ioends(ioend,\n-\t\t\t\tblk_status_to_errno(ioend->io_bio.bi_status));\n+\t\t\txfs_end_ioend_read(ioend);\n \t\telse\n \t\t\txfs_end_ioend_write(ioend);\n \t\tcond_resched();\n@@ -232,9 +249,14 @@ xfs_end_bio(\n \t}\n \n \tspin_lock_irqsave(&ip->i_ioend_lock, flags);\n-\tif (list_empty(&ip->i_ioend_list))\n-\t\tWARN_ON_ONCE(!queue_work(mp->m_unwritten_workqueue,\n+\tif (list_empty(&ip->i_ioend_list)) {\n+\t\tif (IS_ENABLED(CONFIG_FS_VERITY) && ioend->io_vi &&\n+\t\t    ioend->io_offset < xfs_fsverity_metadata_offset(ip))\n+\t\t\tfsverity_enqueue_verify_work(&ip->i_ioend_work);\n+\t\telse\n+\t\t\tWARN_ON_ONCE(!queue_work(mp->m_unwritten_workqueue,\n \t\t\t\t\t &ip->i_ioend_work));\n+\t}\n \tlist_add_tail(&ioend->io_list, &ip->i_ioend_list);\n \tspin_unlock_irqrestore(&ip->i_ioend_lock, flags);\n }\n@@ -764,9 +786,13 @@ xfs_bio_submit_read(\n \tstruct iomap_read_folio_ctx\t*ctx)\n {\n \tstruct bio\t\t\t*bio = ctx->read_ctx;\n+\tstruct iomap_ioend\t\t*ioend;\n \n \t/* defer read completions to the ioend workqueue */\n-\tiomap_init_ioend(iter->inode, bio, ctx->read_ctx_file_offset, 0);\n+\tioend = iomap_init_ioend(iter->inode, bio, ctx->read_ctx_file_offset,\n+\t\t\t0);\n+\tioend->io_vi = ctx->vi;\n+\n \tbio->bi_end_io = xfs_end_bio;\n \tsubmit_bio(bio);\n }\n@@ -779,11 +805,13 @@ static const struct iomap_read_ops xfs_iomap_read_ops = {\n \n static inline const struct iomap_read_ops *\n xfs_get_iomap_read_ops(\n-\tconst struct address_space\t*mapping)\n+\tconst struct address_space\t*mapping,\n+\tloff_t\t\t\t\tposition)\n {\n \tstruct xfs_inode\t\t*ip = XFS_I(mapping->host);\n \n-\tif (bdev_has_integrity_csum(xfs_inode_buftarg(ip)->bt_bdev))\n+\tif (bdev_has_integrity_csum(xfs_inode_buftarg(ip)->bt_bdev) ||\n+\t\t\txfs_fsverity_is_file_data(ip, position))\n \t\treturn &xfs_iomap_read_ops;\n \treturn &iomap_bio_read_ops;\n }\n@@ -795,7 +823,7 @@ xfs_vm_read_folio(\n {\n \tstruct iomap_read_folio_ctx\tctx = { .cur_folio = folio };\n \n-\tctx.ops = xfs_get_iomap_read_ops(folio->mapping);\n+\tctx.ops = xfs_get_iomap_read_ops(folio->mapping, folio_pos(folio));\n \tiomap_read_folio(&xfs_read_iomap_ops, &ctx, NULL);\n \treturn 0;\n }\n@@ -806,7 +834,7 @@ xfs_vm_readahead(\n {\n \tstruct iomap_read_folio_ctx\tctx = { .rac = rac };\n \n-\tctx.ops = xfs_get_iomap_read_ops(rac->mapping),\n+\tctx.ops = xfs_get_iomap_read_ops(rac->mapping, readahead_pos(rac));\n \tiomap_readahead(&xfs_read_iomap_ops, &ctx, NULL);\n }\n \ndiff --git a/fs/xfs/xfs_fsverity.c b/fs/xfs/xfs_fsverity.c\nindex 6e6a8636a577..b983e20bb5e1 100644\n--- a/fs/xfs/xfs_fsverity.c\n+++ b/fs/xfs/xfs_fsverity.c\n@@ -19,3 +19,12 @@ xfs_fsverity_metadata_offset(\n {\n \treturn round_up(i_size_read(VFS_IC(ip)), XFS_FSVERITY_START_ALIGN);\n }\n+\n+bool\n+xfs_fsverity_is_file_data(\n+\tconst struct xfs_inode\t*ip,\n+\tloff_t\t\t\toffset)\n+{\n+\treturn fsverity_active(VFS_IC(ip)) &&\n+\t\t\toffset < xfs_fsverity_metadata_offset(ip);\n+}\ndiff --git a/fs/xfs/xfs_fsverity.h b/fs/xfs/xfs_fsverity.h\nindex 5771db2cd797..ec77ba571106 100644\n--- a/fs/xfs/xfs_fsverity.h\n+++ b/fs/xfs/xfs_fsverity.h\n@@ -9,12 +9,18 @@\n \n #ifdef CONFIG_FS_VERITY\n loff_t xfs_fsverity_metadata_offset(const struct xfs_inode *ip);\n+bool xfs_fsverity_is_file_data(const struct xfs_inode *ip, loff_t offset);\n #else\n static inline loff_t xfs_fsverity_metadata_offset(const struct xfs_inode *ip)\n {\n \tWARN_ON_ONCE(1);\n \treturn ULLONG_MAX;\n }\n+static inline bool xfs_fsverity_is_file_data(const struct xfs_inode *ip,\n+\t\t\t\t\t    loff_t offset)\n+{\n+\treturn false;\n+}\n #endif\t/* CONFIG_FS_VERITY */\n \n #endif\t/* __XFS_FSVERITY_H__ */\n","prefixes":["v9","15/22"]}