From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7695F3EDAC1; Mon, 9 Mar 2026 19:24:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773084270; cv=none; b=WpUEsLOl5F8STdaPH8vtQmOGXBuRN7MxBk8cmc6DamXNZSYQJZ+XydfmOujHE6oLR42VXpGs81agb9NKTPXpvFGuSzCiNSuxWlhKliNTgSj8hy3J+CvDvbBUqk94i3TH7GoRo/udWFpp66fe1bU32+TS4HefAtweUameWaMrbBo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773084270; c=relaxed/simple; bh=wQRuJnCf1bULDEahMxnM6u0R5pEwhxszCldFWiYsTqQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NMVuhJOCw+piQLxoeL/Gju5eG7DFRslNocPT9d+miGav4cBd8dog3e728/uVmvI0gwwdL9d9d4qlJAw74UjYxmafJm0wVgDIz/QsEZwtLJ+hyvALmWd3OOaRXCjwpHZtoHuu5/hX61f3OZNRG2tya02hnOMmwEztrpTkhsQnGDU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ID2p+Eo+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ID2p+Eo+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5E2DC4CEF7; Mon, 9 Mar 2026 19:24:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773084270; bh=wQRuJnCf1bULDEahMxnM6u0R5pEwhxszCldFWiYsTqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ID2p+Eo+e08ZZOZC57sSvuvTBJtizCjXJ4fzzhYNy8Fwql+R/vEWBetzWP+yBvjV0 bLK2/950zqMciWaKwUevSKUWjRmAJhkHXFPFpfhe5C53tijfJKQq5UG8KBigncNWWK fDqcZl3Hu3/Vnql36DdugEsKPOp0nN4XVPJhsp1SobyyUL3zvMzK11AVg885E3pm6b N4ZTEDIOYwoiMXPSWgIz9dgknfvGp94fEhsiMwG9i1HA+xmBA+VibQilM0aZ24stK5 Y+5XTW0j/0k8PmphYpugwN4bxQMHgNEsAKkOv58236nwDji3EyWtll8dqgiM5nVrjK vve0zIMh02X/A== From: Andrey Albershteyn To: linux-xfs@vger.kernel.org, fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, ebiggers@kernel.org Cc: Andrey Albershteyn , hch@lst.de, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, djwong@kernel.org Subject: [PATCH v4 04/25] fsverity: introduce fsverity_folio_zero_hash() Date: Mon, 9 Mar 2026 20:23:19 +0100 Message-ID: <20260309192355.176980-5-aalbersh@kernel.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20260309192355.176980-1-aalbersh@kernel.org> References: <20260309192355.176980-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: fsverity@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Helper to pre-fill folio with hashes of empty blocks. This will be used by iomap to synthesize blocks full of zero hashes on the fly. Signed-off-by: Andrey Albershteyn --- fs/verity/pagecache.c | 22 ++++++++++++++++++++++ include/linux/fsverity.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/fs/verity/pagecache.c b/fs/verity/pagecache.c index 1819314ecaa3..1d94bf73f38c 100644 --- a/fs/verity/pagecache.c +++ b/fs/verity/pagecache.c @@ -2,6 +2,7 @@ /* * Copyright 2019 Google LLC */ +#include "fsverity_private.h" #include #include @@ -56,3 +57,24 @@ void generic_readahead_merkle_tree(struct inode *inode, pgoff_t index, folio_put(folio); } EXPORT_SYMBOL_GPL(generic_readahead_merkle_tree); + +/** + * fsverity_folio_zero_hash() - fill folio with hashes of zero data block + * @folio: folio to fill + * @poff: offset in the folio to start + * @plen: length of the range to fill with hashes + * @vi: fsverity info + */ +void fsverity_folio_zero_hash(struct folio *folio, size_t poff, size_t plen, + struct fsverity_info *vi) +{ + size_t offset = poff; + + WARN_ON_ONCE(!IS_ALIGNED(poff, vi->tree_params.digest_size)); + WARN_ON_ONCE(!IS_ALIGNED(plen, vi->tree_params.digest_size)); + + for (; offset < (poff + plen); offset += vi->tree_params.digest_size) + memcpy_to_folio(folio, offset, vi->tree_params.zero_digest, + vi->tree_params.digest_size); +} +EXPORT_SYMBOL_GPL(fsverity_folio_zero_hash); diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h index 8ba7806b225e..b490b2c8a393 100644 --- a/include/linux/fsverity.h +++ b/include/linux/fsverity.h @@ -321,5 +321,7 @@ void fsverity_cleanup_inode(struct inode *inode); struct page *generic_read_merkle_tree_page(struct inode *inode, pgoff_t index); void generic_readahead_merkle_tree(struct inode *inode, pgoff_t index, unsigned long nr_pages); +void fsverity_folio_zero_hash(struct folio *folio, size_t poff, size_t plen, + struct fsverity_info *vi); #endif /* _LINUX_FSVERITY_H */ -- 2.51.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E4E0FCA178 for ; Mon, 9 Mar 2026 19:24:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:References:In-Reply-To: Message-ID:Date:To:Sender:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=eJrLyH2TmRpfKoni9U4+fP7tLOZnQJyufi7JGfnUBxY=; b=gtw2WmTSbTx1UCLt5rgbHVuTcC QhkhXKFKwoe6yoZ5gxn4+b0Cg9ovGDUTQB3USF1sOnNGfDQKnaXtOvxbv3y1mI54pjCiWVw7xkjfZ 0aUaL2xSh0iijf0D6yrm9C5iGTaDW86uuoWcTHmaTPHrvo3fE48PGMe34tjpJEYD4U+8=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1vzgDU-0006vz-Eb; Mon, 09 Mar 2026 19:24:37 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1vzgDT-0006vn-55 for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Mar 2026 19:24:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=lyEJMtq4Vg9tz4ZnfqvDdE6VSjgbsxeep3Vbyon4cOs=; b=AvFXBhEB6Rq0LSePZ1Az1w+X6c dn7xOt9yZVmYzAdAW0dJD7y1X3iuMY9qzBB9rz7qY2WGEpRv0J8WbqFOqdb4vdA1cQkP5BN2y9YXo /MUCakJ9sLo6dKGotWmVXOKK7Q6EeynpIc6YzZASkLDwhUoOpZ3qqU+msmfvU4jdcns0=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=lyEJMtq4Vg9tz4ZnfqvDdE6VSjgbsxeep3Vbyon4cOs=; b=fagZtqkjC6Oz6B6RSpYIdM6iF4 mwD/aMBnkVIvN63r4rAQX47sTgvPspHQtCO3f1SakdgFwjxB8I1iAaPsau0Ky0ILn68RWCVAJwOFW KtUzXdhRqjyZJ1W5KMiRVk2g/8gfGpnV52u/yQqj8HLr9aSA/S0+SIz1lWgoj4fECD5E=; Received: from sea.source.kernel.org ([172.234.252.31]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1vzgDT-0001El-IQ for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Mar 2026 19:24:35 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 4902444389; Mon, 9 Mar 2026 19:24:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5E2DC4CEF7; Mon, 9 Mar 2026 19:24:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773084270; bh=wQRuJnCf1bULDEahMxnM6u0R5pEwhxszCldFWiYsTqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ID2p+Eo+e08ZZOZC57sSvuvTBJtizCjXJ4fzzhYNy8Fwql+R/vEWBetzWP+yBvjV0 bLK2/950zqMciWaKwUevSKUWjRmAJhkHXFPFpfhe5C53tijfJKQq5UG8KBigncNWWK fDqcZl3Hu3/Vnql36DdugEsKPOp0nN4XVPJhsp1SobyyUL3zvMzK11AVg885E3pm6b N4ZTEDIOYwoiMXPSWgIz9dgknfvGp94fEhsiMwG9i1HA+xmBA+VibQilM0aZ24stK5 Y+5XTW0j/0k8PmphYpugwN4bxQMHgNEsAKkOv58236nwDji3EyWtll8dqgiM5nVrjK vve0zIMh02X/A== To: linux-xfs@vger.kernel.org, fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, ebiggers@kernel.org Date: Mon, 9 Mar 2026 20:23:19 +0100 Message-ID: <20260309192355.176980-5-aalbersh@kernel.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20260309192355.176980-1-aalbersh@kernel.org> References: <20260309192355.176980-1-aalbersh@kernel.org> MIME-Version: 1.0 X-Headers-End: 1vzgDT-0001El-IQ Subject: [f2fs-dev] [PATCH v4 04/25] fsverity: introduce fsverity_folio_zero_hash() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Andrey Albershteyn via Linux-f2fs-devel Reply-To: Andrey Albershteyn Cc: Andrey Albershteyn , djwong@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org, hch@lst.de, linux-btrfs@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Helper to pre-fill folio with hashes of empty blocks. This will be used by iomap to synthesize blocks full of zero hashes on the fly. Signed-off-by: Andrey Albershteyn --- fs/verity/pagecache.c | 22 ++++++++++++++++++++++ include/linux/fsverity.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/fs/verity/pagecache.c b/fs/verity/pagecache.c index 1819314ecaa3..1d94bf73f38c 100644 --- a/fs/verity/pagecache.c +++ b/fs/verity/pagecache.c @@ -2,6 +2,7 @@ /* * Copyright 2019 Google LLC */ +#include "fsverity_private.h" #include #include @@ -56,3 +57,24 @@ void generic_readahead_merkle_tree(struct inode *inode, pgoff_t index, folio_put(folio); } EXPORT_SYMBOL_GPL(generic_readahead_merkle_tree); + +/** + * fsverity_folio_zero_hash() - fill folio with hashes of zero data block + * @folio: folio to fill + * @poff: offset in the folio to start + * @plen: length of the range to fill with hashes + * @vi: fsverity info + */ +void fsverity_folio_zero_hash(struct folio *folio, size_t poff, size_t plen, + struct fsverity_info *vi) +{ + size_t offset = poff; + + WARN_ON_ONCE(!IS_ALIGNED(poff, vi->tree_params.digest_size)); + WARN_ON_ONCE(!IS_ALIGNED(plen, vi->tree_params.digest_size)); + + for (; offset < (poff + plen); offset += vi->tree_params.digest_size) + memcpy_to_folio(folio, offset, vi->tree_params.zero_digest, + vi->tree_params.digest_size); +} +EXPORT_SYMBOL_GPL(fsverity_folio_zero_hash); diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h index 8ba7806b225e..b490b2c8a393 100644 --- a/include/linux/fsverity.h +++ b/include/linux/fsverity.h @@ -321,5 +321,7 @@ void fsverity_cleanup_inode(struct inode *inode); struct page *generic_read_merkle_tree_page(struct inode *inode, pgoff_t index); void generic_readahead_merkle_tree(struct inode *inode, pgoff_t index, unsigned long nr_pages); +void fsverity_folio_zero_hash(struct folio *folio, size_t poff, size_t plen, + struct fsverity_info *vi); #endif /* _LINUX_FSVERITY_H */ -- 2.51.2 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel