{"id":2221457,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2221457/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260409131404.1545834-9-aalbersh@kernel.org/","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/1.2/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,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260409131404.1545834-9-aalbersh@kernel.org>","list_archive_url":null,"date":"2026-04-09T13:13:40","name":"[v7,08/22] iomap: teach iomap to read files with fsverity","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"09e7cf91ea2f6e70067fda13ce4183c3d4535326","submitter":{"id":92821,"url":"http://patchwork.ozlabs.org/api/1.2/people/92821/?format=json","name":"Andrey Albershteyn","email":"aalbersh@kernel.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260409131404.1545834-9-aalbersh@kernel.org/mbox/","series":[{"id":499292,"url":"http://patchwork.ozlabs.org/api/1.2/series/499292/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/list/?series=499292","date":"2026-04-09T13:13:34","name":"fs-verity support for XFS with post EOF merkle tree","version":7,"mbox":"http://patchwork.ozlabs.org/series/499292/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2221457/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221457/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <SRS0=aubd=CI=vger.kernel.org=linux-ext4+bounces-15705-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=ZrjIey44;\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=aubd=ci=vger.kernel.org=linux-ext4+bounces-15705-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)","gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=\"2600:3c04:e001:36c::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=ZrjIey44;\n\tdkim-atps=neutral","gandalf.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15705-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=\"ZrjIey44\"","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 4fs0v40Rlsz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 23:21:20 +1000 (AEST)","from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4fs0v372dkz4wLM\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 23:21:19 +1000 (AEST)","by gandalf.ozlabs.org (Postfix)\n\tid 4fs0v36wvfz4wLh; Thu, 09 Apr 2026 23:21:19 +1000 (AEST)","from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::12fc:5321])\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 gandalf.ozlabs.org (Postfix) with ESMTPS id 4fs0v02Cw7z4wLM\n\tfor <patchwork-incoming@ozlabs.org>; Thu, 09 Apr 2026 23:21:16 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 95F053002793\n\tfor <patchwork-incoming@ozlabs.org>; Thu,  9 Apr 2026 13:16:03 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 958743B635C;\n\tThu,  9 Apr 2026 13:14:35 +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 34A263D6469;\n\tThu,  9 Apr 2026 13:14:34 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 4A293C2BCB0;\n\tThu,  9 Apr 2026 13:14:32 +0000 (UTC)"],"ARC-Seal":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1775740879; cv=pass;\n\tb=W+hzyNBR/M9x22V98pb4bKImcOc7cBMv3FlkDZ/4vDMGMdhelEe+dQgoET5q9G8UmuCcL5pI9EYmmI4i/PA9MdPoxaZLhhly6tokPjqZTlF7xuMkrSd8xgNZxThjwmkPum1fnA5Nl2hQmLs1nHkIOcMAdTJPL/hDD4woIXfYAjlcJKf1toPlJVqPtKYQaCubUcTbOuLn2a27uKSmLrLxwUeQsCHFa4A5N3fWbGIluaWaxk6gvzYMEL3M3pdsKWlGEvdtUvxORTlX2Ppi5VAwnparyGUnUZtzQkBLWoDBfzz6+Ptx+ywbxL+p7acg8wNM9fp+ZcQyM4zLF+ftq7mpEw==","i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775740475; cv=none;\n b=AZUXdy1PHlQa60QnbxK7jy4lywKciYnsqwl87Dr8ULyxcMnl3CcjhK6J3yhNcdcsHVgvIM4o+HZG3DG2nB8giNREqWjTAIV2A9+qQzke5iZklxy8Bir7yE2cM3FUyBk0cwQ+3qJ1JKr0OwVidVui2mbgkpPJYSH9W/MaKpDsadY="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1775740879; c=relaxed/relaxed;\n\tbh=yoyh3UlA9TZ7k4TARLbtf9/vHDIlY0ClXxGrXy/3jMQ=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=jHQV0WaCmUaTjC7BmN1fp7kNxCb1Veuu7ghjtYEhfQFD5ma8HNo3H5xByJqSGOz3xyIStaGvNohxYRwGtGyBRP4Xnhw2RVBNGlt2ujkDbDlTQItobjdGM4C2qaBXm2ZJl6BcYRqHzd2DrKn7xn8mrGxbILtildkU2dmD/PaKXKmvtkkNgD+kxaUYcXMkXgyi0qOv7ssWn68kh511Y3E40QzCYMl3HGeoee/9WNxTefr/OLIAlyPoTIrMiR0s3OXdIEJ5WdfJ8NYA4m9b2CmFEcKq8yyaxNT7Y6upsRpOhmNLfaZmyJf60O6xPx7ijdRXeVS1AIt6VgpbwzV8w0qN3A==","i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775740475; c=relaxed/simple;\n\tbh=828QqygZ+rCpf7T6T6f7PIgnPBQ8F12tnt1TM4pNE9M=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=uQHplywvK6IrA1B34OVQuMR6dK05xi8w03m3GotQllOq8WLS+WZB9iBJKiAFcDH58edh5g7qoLStGABK5jhhZJU0v5kLtYX88+Zd/5c+R3s+rgob+/HLBwuSTl4rlFRMhGtCM7+hJ3DgCqJBF3bJC4AoALTPDHWTzDnmTaCF4QM="],"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=ZrjIey44; dkim-atps=neutral;\n spf=pass (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15705-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=ZrjIey44; 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=1775740474;\n\tbh=828QqygZ+rCpf7T6T6f7PIgnPBQ8F12tnt1TM4pNE9M=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ZrjIey44NbP3a/0szRu03W+a82OE5hpTdNaspyPviqE5KFOJSXMs7+x2gfipmUwYU\n\t RhDXv485Ixg0N4nMuIfda8Wcorrpzq+JfNYtKJljUEodSd6EYIQmCAF7/hUOfRvwiI\n\t Jm6i5GswO5UzTUHghQyTQj3LZhHrl6Mup7k9yshFFB04E7oTcazvFbH0VGDcDjD+EO\n\t +BsQompVhiaBfM17Vzk6hgZtHo0MMM565Q4UypaSL3Vz2mEJ9geRZftovgqBD7efet\n\t 5EYluswG62ZL94310DnKOTWtcwUSAaM2ekP1AvqYxRzza0qIhgIBp0cfBl0GW2o9h6\n\t cF7iW7FgGnzvg==","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\tdjwong@kernel.org","Subject":"[PATCH v7 08/22] iomap: teach iomap to read files with fsverity","Date":"Thu,  9 Apr 2026 15:13:40 +0200","Message-ID":"<20260409131404.1545834-9-aalbersh@kernel.org>","X-Mailer":"git-send-email 2.51.2","In-Reply-To":"<20260409131404.1545834-1-aalbersh@kernel.org>","References":"<20260409131404.1545834-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":"Obtain fsverity info for folios with file data and fsverity metadata.\nFilesystem can pass vi down to ioend and then to fsverity for\nverification. This is different from other filesystems ext4, f2fs, btrfs\nsupporting fsverity, these filesystems don't need fsverity_info for\nreading fsverity metadata. While reading merkle tree iomap requires\nfsverity info to synthesize hashes for zeroed data block.\n\nfsverity metadata has two kinds of holes - ones in merkle tree and one\nafter fsverity descriptor.\n\nMerkle tree holes are blocks full of hashes of zeroed data blocks. These\nare not stored on the disk but synthesized on the fly. This saves a bit\nof space for sparse files. Due to this iomap also need to lookup\nfsverity_info for folios with fsverity metadata. ->vi has a hash of the\nzeroed data block which will be used to fill the merkle tree block.\n\nThe hole past descriptor is interpreted as end of metadata region. As we\ndon't have EOF here we use this hole as an indication that rest of the\nfolio is empty. This patch marks rest of the folio beyond fsverity\ndescriptor as uptodate.\n\nFor file data, fsverity needs to verify consistency of the whole file\nagainst the root hash, hashes of holes are included in the merkle tree.\nVerify them too.\n\nIssue reading of fsverity merkle tree on the fsverity inodes. This way\nmetadata will be available at I/O completion time.\n\nReviewed-by: Darrick J. Wong <djwong@kernel.org>\nReviewed-by: Christoph Hellwig <hch@lst.de>\nSigned-off-by: Andrey Albershteyn <aalbersh@kernel.org>\n---\n fs/iomap/buffered-io.c | 41 +++++++++++++++++++++++++++++++++++++++--\n include/linux/iomap.h  |  2 ++\n 2 files changed, 41 insertions(+), 2 deletions(-)","diff":"diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c\nindex 38c9592fba43..843314852663 100644\n--- a/fs/iomap/buffered-io.c\n+++ b/fs/iomap/buffered-io.c\n@@ -9,6 +9,7 @@\n #include <linux/swap.h>\n #include <linux/migrate.h>\n #include <linux/fserror.h>\n+#include <linux/fsverity.h>\n #include \"internal.h\"\n #include \"trace.h\"\n \n@@ -561,9 +562,27 @@ static int iomap_read_folio_iter(struct iomap_iter *iter,\n \t\tif (plen == 0)\n \t\t\treturn 0;\n \n-\t\t/* zero post-eof blocks as the page may be mapped */\n-\t\tif (iomap_block_needs_zeroing(iter, pos)) {\n+\t\t/*\n+\t\t * Handling of fsverity \"holes\". We hit this for two case:\n+\t\t *   1. No need to go further, the hole after fsverity\n+\t\t *\tdescriptor is the end of the fsverity metadata.\n+\t\t *\n+\t\t *   2. This folio contains merkle tree blocks which need to be\n+\t\t *\tsynthesized. If we already have fsverity info (ctx->vi)\n+\t\t *\tsynthesize these blocks.\n+\t\t */\n+\t\tif ((iomap->flags & IOMAP_F_FSVERITY) &&\n+\t\t    iomap->type == IOMAP_HOLE) {\n+\t\t\tif (ctx->vi)\n+\t\t\t\tfsverity_fill_zerohash(folio, poff, plen,\n+\t\t\t\t\t\t       ctx->vi);\n+\t\t\tiomap_set_range_uptodate(folio, poff, plen);\n+\t\t} else if (iomap_block_needs_zeroing(iter, pos)) {\n+\t\t\t/* zero post-eof blocks as the page may be mapped */\n \t\t\tfolio_zero_range(folio, poff, plen);\n+\t\t\tif (ctx->vi &&\n+\t\t\t    !fsverity_verify_blocks(ctx->vi, folio, plen, poff))\n+\t\t\t\treturn -EIO;\n \t\t\tiomap_set_range_uptodate(folio, poff, plen);\n \t\t} else {\n \t\t\tif (!*bytes_submitted)\n@@ -614,6 +633,15 @@ void iomap_read_folio(const struct iomap_ops *ops,\n \n \ttrace_iomap_readpage(iter.inode, 1);\n \n+\t/*\n+\t * Fetch fsverity_info for both data and fsverity metadata, as iomap\n+\t * needs zeroed hash for merkle tree block synthesis\n+\t */\n+\tctx->vi = fsverity_get_info(iter.inode);\n+\tif (ctx->vi && iter.pos < i_size_read(iter.inode))\n+\t\tfsverity_readahead(ctx->vi, folio->index,\n+\t\t\t\t   folio_nr_pages(folio));\n+\n \twhile ((ret = iomap_iter(&iter, ops)) > 0)\n \t\titer.status = iomap_read_folio_iter(&iter, ctx,\n \t\t\t\t&bytes_submitted);\n@@ -681,6 +709,15 @@ void iomap_readahead(const struct iomap_ops *ops,\n \n \ttrace_iomap_readahead(rac->mapping->host, readahead_count(rac));\n \n+\t/*\n+\t * Fetch fsverity_info for both data and fsverity metadata, as iomap\n+\t * needs zeroed hash for merkle tree block synthesis\n+\t */\n+\tctx->vi = fsverity_get_info(iter.inode);\n+\tif (ctx->vi && iter.pos < i_size_read(iter.inode))\n+\t\tfsverity_readahead(ctx->vi, readahead_index(rac),\n+\t\t\t\treadahead_count(rac));\n+\n \twhile (iomap_iter(&iter, ops) > 0)\n \t\titer.status = iomap_readahead_iter(&iter, ctx,\n \t\t\t\t\t&cur_bytes_submitted);\ndiff --git a/include/linux/iomap.h b/include/linux/iomap.h\nindex 4506a99d5285..4d9202cae29f 100644\n--- a/include/linux/iomap.h\n+++ b/include/linux/iomap.h\n@@ -435,6 +435,7 @@ struct iomap_ioend {\n \tloff_t\t\t\tio_offset;\t/* offset in the file */\n \tsector_t\t\tio_sector;\t/* start sector of ioend */\n \tvoid\t\t\t*io_private;\t/* file system private data */\n+\tstruct fsverity_info\t*io_vi;\t\t/* fsverity info */\n \tstruct bio\t\tio_bio;\t\t/* MUST BE LAST! */\n };\n \n@@ -509,6 +510,7 @@ struct iomap_read_folio_ctx {\n \tstruct readahead_control *rac;\n \tvoid\t\t\t*read_ctx;\n \tloff_t\t\t\tread_ctx_file_offset;\n+\tstruct fsverity_info\t*vi;\n };\n \n struct iomap_read_ops {\n","prefixes":["v7","08/22"]}