{"id":2221454,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2221454/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260409131404.1545834-7-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-7-aalbersh@kernel.org>","list_archive_url":null,"date":"2026-04-09T13:13:38","name":"[v7,06/22] fsverity: hoist pagecache_read from f2fs/ext4 to fsverity","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"7c4a7af0f87f71f4e09f701939957b461c16a7e9","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-7-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/2221454/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221454/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <SRS0=D5Tm=CI=vger.kernel.org=linux-ext4+bounces-15703-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=oWYkfxeb;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org\n (client-ip=150.107.74.76; helo=mail.ozlabs.org;\n envelope-from=srs0=d5tm=ci=vger.kernel.org=linux-ext4+bounces-15703-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)","gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=172.105.105.114 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=oWYkfxeb;\n\tdkim-atps=neutral","gandalf.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15703-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=\"oWYkfxeb\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76])\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 4fs0sg38lkz1yD3\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 23:20:07 +1000 (AEST)","from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4fs0sg2Xwsz4wLh\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 23:20:07 +1000 (AEST)","by gandalf.ozlabs.org (Postfix)\n\tid 4fs0sg2PNGz4wSS; Thu, 09 Apr 2026 23:20:07 +1000 (AEST)","from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])\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 4fs0sb5blfz4wLh\n\tfor <patchwork-incoming@ozlabs.org>; Thu, 09 Apr 2026 23:20:03 +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 A4AF930651E1\n\tfor <patchwork-incoming@ozlabs.org>; Thu,  9 Apr 2026 13:15:38 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id D466E3D47DD;\n\tThu,  9 Apr 2026 13:14:29 +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 5A39D3D2FF5;\n\tThu,  9 Apr 2026 13:14:29 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 69009C4CEF7;\n\tThu,  9 Apr 2026 13:14:26 +0000 (UTC)"],"ARC-Seal":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1775740807; cv=pass;\n\tb=RXScWpW50sU70ZSbb05TAq46OQn1TChpykdKVSc5VXx6siYnWgpyH7qVRxKlENPll7dvoqHjbKB2iX3doLPBEfcxTbQyFDHCkOfTxC/c/rsY6o85ye31b+Ud0OqfwTqugTNItrvhT25E9Kw4AhOpZxASGpl/6B0XCTCKHNx4fZcJw8UAtefNAd2uDNmi5e3EZpWiZNn6RfhO0WbfaYslSfWBwujv1n7xf17FY+WzoBouDm1YmrtkNl+VNBqL4RQe8bsSyC+UQxevyCTlpVwHCbuo2FJLHjwK03fMNvH1ghKGyIA82JKV/legehAGKEZrbsN1Mi4Xf58qYpWn1nVEgg==","i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775740469; cv=none;\n b=qdbUZJeZzKBIlK+tBkxgeELREgp1pi8dzL8PijNX7JqhvdDeY34P1tprR1eiwamR354KSeoVsBaybkPudgzY1TUz+5Piof0FSn3Mis+QRjjH4E+wOo3NLUc1rnURCZJO/7GZGKLjDW/qABzeKAEY2nfmHnUCz5kn7d3UKBNh4qw="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1775740807; c=relaxed/relaxed;\n\tbh=f7IHxWQpkPA2/qLRHVWoyq7+c0bPN2ca23hVV4DXnjk=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=yg82v0V1jj2THXt3+jXpxQO3M2W5IZN8P5alj+qiNNlhu6pe7X/y4z/JTDg0urX5oLtaP+1TsXeyieGfJMGqeFfrdbo1qK0aq7fO0xUYMID+Twgpq107KMkEN1sQdNlczI5fBXR5kvIeArGaH5N1r+A37DxHwdkIIaH4hL5Q3MTmsxARHNJuSG30SuZ1AcV64QJ5m2s1SCCzn/Za/kdh75MrvUbuyqQ7ijWeLuBbK8/XILEoCUGcz8QzuK0a6QZusDetYxGqlDk45NDH8Tk7LApemyorFFqyEpApKLH7qeTe5R8FFj01mJuZIJ9rewGooJbgOwjYE4TG2Sujt0T3fg==","i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775740469; c=relaxed/simple;\n\tbh=z/3roTCD1Ne1/qpsmQCo6JII54WvnylPhblXVUf/ZIA=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=DcUvPIgztDoUo7O2/TH2FEyfC+DHVXjEfC8v7UDL/y5+XwH2Iz1GxjwByiK38btpHSDzGlKGYjzdya13ZZGPn2eeiHVss1qGnLAx2Dadvq+YMaLWkbOapHVzZ+JegcbCIognR3rQ2UWphEhpu8Vmt8SEpRqKGO5h3qypqqpBqEw="],"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=oWYkfxeb; dkim-atps=neutral;\n spf=pass (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15703-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=oWYkfxeb; 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=1775740468;\n\tbh=z/3roTCD1Ne1/qpsmQCo6JII54WvnylPhblXVUf/ZIA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=oWYkfxebSDFijB/s5osKTHfcyTX6KwztlsAsQrvuvGmJ+ELPb8Cihz5OuTRo8GVOF\n\t BUcRspYP0yicqYH0COcIk3stEbuTRuiR1DbRXdYklbzLb7ZDzVmeufucJxNRnZXeMr\n\t hPxwrnsAnCEkePbuQP6p5CQrzOLwtkQkFPRNmetac5p41kqEFBxT+ddPCh79y87cfE\n\t y/4MvqeId+1chQ7nFy3AoezodhnGPG4LiXCxUZBWbqsfLvbvC2uI4o/XG1Ra5g44BQ\n\t q7ESd1Dlr9o6k75PjnvCs76zXWlYVX2FpeAETqwp41nsE/Qgc5aKdhsqHqOMTl+h25\n\t IEbo4KxB58CYA==","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 06/22] fsverity: hoist pagecache_read from f2fs/ext4 to\n fsverity","Date":"Thu,  9 Apr 2026 15:13:38 +0200","Message-ID":"<20260409131404.1545834-7-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":"This is the same function to read from pageache. XFS will also need\nthis, so move this to core fsverity.\n\nNote that f2fs and ext4 functions diverged a bit, as ext4 operated over\nfolios and f2fs operated over pages. The common one will operate over\nfolios.\n\nReviewed-by: Darrick J. Wong <djwong@kernel.org>\nReviewed-by: Christoph Hellwig <hch@lst.de>\nAcked-by: Eric Biggers <ebiggers@kernel.org>\nSigned-off-by: Andrey Albershteyn <aalbersh@kernel.org>\n---\n fs/ext4/verity.c         | 32 +++-----------------------------\n fs/f2fs/verity.c         | 30 +-----------------------------\n fs/verity/pagecache.c    | 33 +++++++++++++++++++++++++++++++++\n include/linux/fsverity.h |  2 ++\n 4 files changed, 39 insertions(+), 58 deletions(-)","diff":"diff --git a/fs/ext4/verity.c b/fs/ext4/verity.c\nindex 347945ac23a4..ac5c133f5529 100644\n--- a/fs/ext4/verity.c\n+++ b/fs/ext4/verity.c\n@@ -34,32 +34,6 @@ static inline loff_t ext4_verity_metadata_pos(const struct inode *inode)\n \treturn round_up(inode->i_size, 65536);\n }\n \n-/*\n- * Read some verity metadata from the inode.  __vfs_read() can't be used because\n- * we need to read beyond i_size.\n- */\n-static int pagecache_read(struct inode *inode, void *buf, size_t count,\n-\t\t\t  loff_t pos)\n-{\n-\twhile (count) {\n-\t\tstruct folio *folio;\n-\t\tsize_t n;\n-\n-\t\tfolio = read_mapping_folio(inode->i_mapping, pos >> PAGE_SHIFT,\n-\t\t\t\t\t NULL);\n-\t\tif (IS_ERR(folio))\n-\t\t\treturn PTR_ERR(folio);\n-\n-\t\tn = memcpy_from_file_folio(buf, folio, pos, count);\n-\t\tfolio_put(folio);\n-\n-\t\tbuf += n;\n-\t\tpos += n;\n-\t\tcount -= n;\n-\t}\n-\treturn 0;\n-}\n-\n /*\n  * Write some verity metadata to the inode for FS_IOC_ENABLE_VERITY.\n  * kernel_write() can't be used because the file descriptor is readonly.\n@@ -311,8 +285,8 @@ static int ext4_get_verity_descriptor_location(struct inode *inode,\n \t\tgoto bad;\n \tdesc_size_pos -= sizeof(desc_size_disk);\n \n-\terr = pagecache_read(inode, &desc_size_disk, sizeof(desc_size_disk),\n-\t\t\t     desc_size_pos);\n+\terr = fsverity_pagecache_read(inode, &desc_size_disk,\n+\t\t\t\t      sizeof(desc_size_disk), desc_size_pos);\n \tif (err)\n \t\treturn err;\n \tdesc_size = le32_to_cpu(desc_size_disk);\n@@ -352,7 +326,7 @@ static int ext4_get_verity_descriptor(struct inode *inode, void *buf,\n \tif (buf_size) {\n \t\tif (desc_size > buf_size)\n \t\t\treturn -ERANGE;\n-\t\terr = pagecache_read(inode, buf, desc_size, desc_pos);\n+\t\terr = fsverity_pagecache_read(inode, buf, desc_size, desc_pos);\n \t\tif (err)\n \t\t\treturn err;\n \t}\ndiff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c\nindex b3b3e71604ac..5ea0a9b40443 100644\n--- a/fs/f2fs/verity.c\n+++ b/fs/f2fs/verity.c\n@@ -36,34 +36,6 @@ static inline loff_t f2fs_verity_metadata_pos(const struct inode *inode)\n \treturn round_up(inode->i_size, 65536);\n }\n \n-/*\n- * Read some verity metadata from the inode.  __vfs_read() can't be used because\n- * we need to read beyond i_size.\n- */\n-static int pagecache_read(struct inode *inode, void *buf, size_t count,\n-\t\t\t  loff_t pos)\n-{\n-\twhile (count) {\n-\t\tsize_t n = min_t(size_t, count,\n-\t\t\t\t PAGE_SIZE - offset_in_page(pos));\n-\t\tstruct page *page;\n-\n-\t\tpage = read_mapping_page(inode->i_mapping, pos >> PAGE_SHIFT,\n-\t\t\t\t\t NULL);\n-\t\tif (IS_ERR(page))\n-\t\t\treturn PTR_ERR(page);\n-\n-\t\tmemcpy_from_page(buf, page, offset_in_page(pos), n);\n-\n-\t\tput_page(page);\n-\n-\t\tbuf += n;\n-\t\tpos += n;\n-\t\tcount -= n;\n-\t}\n-\treturn 0;\n-}\n-\n /*\n  * Write some verity metadata to the inode for FS_IOC_ENABLE_VERITY.\n  * kernel_write() can't be used because the file descriptor is readonly.\n@@ -248,7 +220,7 @@ static int f2fs_get_verity_descriptor(struct inode *inode, void *buf,\n \tif (buf_size) {\n \t\tif (size > buf_size)\n \t\t\treturn -ERANGE;\n-\t\tres = pagecache_read(inode, buf, size, pos);\n+\t\tres = fsverity_pagecache_read(inode, buf, size, pos);\n \t\tif (res)\n \t\t\treturn res;\n \t}\ndiff --git a/fs/verity/pagecache.c b/fs/verity/pagecache.c\nindex 99f5f53eea98..9d82e6b74ba1 100644\n--- a/fs/verity/pagecache.c\n+++ b/fs/verity/pagecache.c\n@@ -78,3 +78,36 @@ void fsverity_fill_zerohash(struct folio *folio, size_t offset, size_t len,\n \t\t\t\tvi->tree_params.digest_size);\n }\n EXPORT_SYMBOL_GPL(fsverity_fill_zerohash);\n+\n+/**\n+ * fsverity_pagecache_read() - read page and copy data to buffer\n+ * @inode:\tcopy from this inode's address space\n+ * @buf:\tbuffer to copy to\n+ * @count:\tnumber of bytes to copy\n+ * @pos:\tposition of the folio to copy from\n+ *\n+ * Read some verity metadata from the inode.  __vfs_read() can't be used because\n+ * we need to read beyond i_size.\n+ */\n+int fsverity_pagecache_read(struct inode *inode, void *buf, size_t count,\n+\t\t\t  loff_t pos)\n+{\n+\twhile (count) {\n+\t\tstruct folio *folio;\n+\t\tsize_t n;\n+\n+\t\tfolio = read_mapping_folio(inode->i_mapping, pos >> PAGE_SHIFT,\n+\t\t\t\t\t NULL);\n+\t\tif (IS_ERR(folio))\n+\t\t\treturn PTR_ERR(folio);\n+\n+\t\tn = memcpy_from_file_folio(buf, folio, pos, count);\n+\t\tfolio_put(folio);\n+\n+\t\tbuf += n;\n+\t\tpos += n;\n+\t\tcount -= n;\n+\t}\n+\treturn 0;\n+}\n+EXPORT_SYMBOL_GPL(fsverity_pagecache_read);\ndiff --git a/include/linux/fsverity.h b/include/linux/fsverity.h\nindex a5645ec07aa8..a2ae5cc649ad 100644\n--- a/include/linux/fsverity.h\n+++ b/include/linux/fsverity.h\n@@ -328,5 +328,7 @@ void fsverity_cleanup_inode(struct inode *inode);\n struct page *generic_read_merkle_tree_page(struct inode *inode, pgoff_t index);\n void generic_readahead_merkle_tree(struct inode *inode, pgoff_t index,\n \t\t\t\t   unsigned long nr_pages);\n+int fsverity_pagecache_read(struct inode *inode, void *buf, size_t count,\n+\t\t\t    loff_t pos);\n \n #endif\t/* _LINUX_FSVERITY_H */\n","prefixes":["v7","06/22"]}