From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Biggers Date: Wed, 5 Apr 2023 17:44:34 -0700 Subject: [Cluster-devel] [PATCH v2 21/23] xfs: handle merkle tree block size != fs blocksize != PAGE_SIZE In-Reply-To: <20230405233753.GU3223426@dread.disaster.area> References: <20230404145319.2057051-1-aalbersh@redhat.com> <20230404145319.2057051-22-aalbersh@redhat.com> <20230404163602.GC109974@frogsfrogsfrogs> <20230405160221.he76fb5b45dud6du@aalbersh.remote.csb> <20230405163847.GG303486@frogsfrogsfrogs> <20230405222646.GR3223426@dread.disaster.area> <20230405233753.GU3223426@dread.disaster.area> Message-ID: <20230406004434.GA879@sol.localdomain> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Thu, Apr 06, 2023 at 09:37:53AM +1000, Dave Chinner wrote: > On Wed, Apr 05, 2023 at 10:54:06PM +0000, Eric Biggers wrote: > > On Thu, Apr 06, 2023 at 08:26:46AM +1000, Dave Chinner wrote: > > > > We could certainly think about moving to a design where fs/verity/ asks the > > > > filesystem to just *read* a Merkle tree block, without adding it to a cache, and > > > > then fs/verity/ implements the caching itself. That would require some large > > > > changes to each filesystem, though, unless we were to double-cache the Merkle > > > > tree blocks which would be inefficient. > > > > > > No, that's unnecessary. > > > > > > All we need if for fsverity to require filesystems to pass it byte > > > addressable data buffers that are externally reference counted. The > > > filesystem can take a page reference before mapping the page and > > > passing the kaddr to fsverity, then unmap and drop the reference > > > when the merkle tree walk is done as per Andrey's new drop callout. > > > > > > fsverity doesn't need to care what the buffer is made from, how it > > > is cached, what it's life cycle is, etc. The caching mechanism and > > > reference counting is entirely controlled by the filesystem callout > > > implementations, and fsverity only needs to deal with memory buffers > > > that are guaranteed to live for the entire walk of the merkle > > > tree.... > > > > Sure. Just a couple notes: > > > > First, fs/verity/ does still need to be able to tell whether the buffer is newly > > instantiated or not. > > Boolean flag from the caller. > > > Second, fs/verity/ uses the ahash API to do the hashing. ahash is a > > scatterlist-based API. Virtual addresses can still be used (see sg_set_buf()), > > but the memory cannot be vmalloc'ed memory, since virt_to_page() needs to work. > > Does XFS use vmalloc'ed memory for these buffers? > > Not vmalloc'ed, but vmapped. we allocate the pages individually, but > then call vm_map_page() to present the higher level code with a > single contiguous memory range if it is a multi-page buffer. > > We do have the backing info held in the buffer, and that's what we > use for IO. If fsverity needs a page based scatter/gather list > for hardware offload, it could ask the filesystem to provide it > for that given buffer... > > > BTW, converting fs/verity/ from ahash to shash is an option; I've really never > > been a fan of the scatterlist-based crypto APIs! The disadvantage of doing > > this, though, would be that it would remove support for all the hardware crypto > > drivers. > > > > That *might* actually be okay, as that approach to crypto acceleration > > has mostly fallen out of favor, in favor of CPU-based acceleration. But I do > > worry about e.g. someone coming out of the woodwork and saying they need to use > > fsverity on a low-powered ARM board that has a crypto accelerator like CAAM, and > > they MUST use their crypto accelerator to get acceptable performance. > > True, but we are very unlikely to be using XFS on such small > systems and I don't think we really care about XFS performance on > android sized systems, either. > FYI, I've sent an RFC patch that converts fs/verity/ from ahash to shash: https://lore.kernel.org/r/20230406003714.94580-1-ebiggers at kernel.org It would be great if we could do that. But I need to get a better sense for whether anyone will complain... - Eric 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 F1A7F7ED for ; Thu, 6 Apr 2023 00:44:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21089C433D2; Thu, 6 Apr 2023 00:44:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680741876; bh=zN0uoPG2wy3vEMLhzgjqbmHAqYYQld3AbN2XunzMIoU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bo8p3D+S8WueWIQeyXVhF9VsXJIkX3mi7lCuHYZ7OixWNIVgwe52hWCGQTCpabGiY 6mT1eHjUq2EedAyyBTpNdvhDNGB7ja0pxmv+2hAT4IOl/D6gtx0cKQGX4OsM8OaIJL qJbARzdhdEgqxF6P1iYB779hRD2iIfLqS229fGaWr23fMFpB+goPahUZxXr2Z0B7Lo U2dQSQsuy/cHfeInl7U1BHZohgOtSGQJM5WZTpux93iA31XE6NFlO2xoLtnQbmkcjC vNwntPVZYgHRIbIIfX+e89u8Evn868NI0UF/wcOyIkteZXz1d3WIzEoABhr37UZz1i A4vZrijh7VmiQ== Date: Wed, 5 Apr 2023 17:44:34 -0700 From: Eric Biggers To: Dave Chinner Cc: "Darrick J. Wong" , Andrey Albershteyn , dchinner@redhat.com, hch@infradead.org, linux-xfs@vger.kernel.org, fsverity@lists.linux.dev, rpeterso@redhat.com, agruenba@redhat.com, xiang@kernel.org, chao@kernel.org, damien.lemoal@opensource.wdc.com, jth@kernel.org, linux-erofs@lists.ozlabs.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com Subject: Re: [PATCH v2 21/23] xfs: handle merkle tree block size != fs blocksize != PAGE_SIZE Message-ID: <20230406004434.GA879@sol.localdomain> References: <20230404145319.2057051-1-aalbersh@redhat.com> <20230404145319.2057051-22-aalbersh@redhat.com> <20230404163602.GC109974@frogsfrogsfrogs> <20230405160221.he76fb5b45dud6du@aalbersh.remote.csb> <20230405163847.GG303486@frogsfrogsfrogs> <20230405222646.GR3223426@dread.disaster.area> <20230405233753.GU3223426@dread.disaster.area> Precedence: bulk X-Mailing-List: fsverity@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230405233753.GU3223426@dread.disaster.area> On Thu, Apr 06, 2023 at 09:37:53AM +1000, Dave Chinner wrote: > On Wed, Apr 05, 2023 at 10:54:06PM +0000, Eric Biggers wrote: > > On Thu, Apr 06, 2023 at 08:26:46AM +1000, Dave Chinner wrote: > > > > We could certainly think about moving to a design where fs/verity/ asks the > > > > filesystem to just *read* a Merkle tree block, without adding it to a cache, and > > > > then fs/verity/ implements the caching itself. That would require some large > > > > changes to each filesystem, though, unless we were to double-cache the Merkle > > > > tree blocks which would be inefficient. > > > > > > No, that's unnecessary. > > > > > > All we need if for fsverity to require filesystems to pass it byte > > > addressable data buffers that are externally reference counted. The > > > filesystem can take a page reference before mapping the page and > > > passing the kaddr to fsverity, then unmap and drop the reference > > > when the merkle tree walk is done as per Andrey's new drop callout. > > > > > > fsverity doesn't need to care what the buffer is made from, how it > > > is cached, what it's life cycle is, etc. The caching mechanism and > > > reference counting is entirely controlled by the filesystem callout > > > implementations, and fsverity only needs to deal with memory buffers > > > that are guaranteed to live for the entire walk of the merkle > > > tree.... > > > > Sure. Just a couple notes: > > > > First, fs/verity/ does still need to be able to tell whether the buffer is newly > > instantiated or not. > > Boolean flag from the caller. > > > Second, fs/verity/ uses the ahash API to do the hashing. ahash is a > > scatterlist-based API. Virtual addresses can still be used (see sg_set_buf()), > > but the memory cannot be vmalloc'ed memory, since virt_to_page() needs to work. > > Does XFS use vmalloc'ed memory for these buffers? > > Not vmalloc'ed, but vmapped. we allocate the pages individually, but > then call vm_map_page() to present the higher level code with a > single contiguous memory range if it is a multi-page buffer. > > We do have the backing info held in the buffer, and that's what we > use for IO. If fsverity needs a page based scatter/gather list > for hardware offload, it could ask the filesystem to provide it > for that given buffer... > > > BTW, converting fs/verity/ from ahash to shash is an option; I've really never > > been a fan of the scatterlist-based crypto APIs! The disadvantage of doing > > this, though, would be that it would remove support for all the hardware crypto > > drivers. > > > > That *might* actually be okay, as that approach to crypto acceleration > > has mostly fallen out of favor, in favor of CPU-based acceleration. But I do > > worry about e.g. someone coming out of the woodwork and saying they need to use > > fsverity on a low-powered ARM board that has a crypto accelerator like CAAM, and > > they MUST use their crypto accelerator to get acceptable performance. > > True, but we are very unlikely to be using XFS on such small > systems and I don't think we really care about XFS performance on > android sized systems, either. > FYI, I've sent an RFC patch that converts fs/verity/ from ahash to shash: https://lore.kernel.org/r/20230406003714.94580-1-ebiggers@kernel.org It would be great if we could do that. But I need to get a better sense for whether anyone will complain... - Eric 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.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 70BF7C7618D for ; Thu, 6 Apr 2023 00:44:49 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4PsN7M6jwzz3cjL for ; Thu, 6 Apr 2023 10:44:47 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=bo8p3D+S; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=139.178.84.217; helo=dfw.source.kernel.org; envelope-from=ebiggers@kernel.org; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=bo8p3D+S; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4PsN7D1yzyz3c1K for ; Thu, 6 Apr 2023 10:44:40 +1000 (AEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 422DD62A45; Thu, 6 Apr 2023 00:44:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21089C433D2; Thu, 6 Apr 2023 00:44:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680741876; bh=zN0uoPG2wy3vEMLhzgjqbmHAqYYQld3AbN2XunzMIoU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bo8p3D+S8WueWIQeyXVhF9VsXJIkX3mi7lCuHYZ7OixWNIVgwe52hWCGQTCpabGiY 6mT1eHjUq2EedAyyBTpNdvhDNGB7ja0pxmv+2hAT4IOl/D6gtx0cKQGX4OsM8OaIJL qJbARzdhdEgqxF6P1iYB779hRD2iIfLqS229fGaWr23fMFpB+goPahUZxXr2Z0B7Lo U2dQSQsuy/cHfeInl7U1BHZohgOtSGQJM5WZTpux93iA31XE6NFlO2xoLtnQbmkcjC vNwntPVZYgHRIbIIfX+e89u8Evn868NI0UF/wcOyIkteZXz1d3WIzEoABhr37UZz1i A4vZrijh7VmiQ== Date: Wed, 5 Apr 2023 17:44:34 -0700 From: Eric Biggers To: Dave Chinner Subject: Re: [PATCH v2 21/23] xfs: handle merkle tree block size != fs blocksize != PAGE_SIZE Message-ID: <20230406004434.GA879@sol.localdomain> References: <20230404145319.2057051-1-aalbersh@redhat.com> <20230404145319.2057051-22-aalbersh@redhat.com> <20230404163602.GC109974@frogsfrogsfrogs> <20230405160221.he76fb5b45dud6du@aalbersh.remote.csb> <20230405163847.GG303486@frogsfrogsfrogs> <20230405222646.GR3223426@dread.disaster.area> <20230405233753.GU3223426@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230405233753.GU3223426@dread.disaster.area> X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fsverity@lists.linux.dev, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, agruenba@redhat.com, "Darrick J. Wong" , Andrey Albershteyn , linux-f2fs-devel@lists.sourceforge.net, hch@infradead.org, cluster-devel@redhat.com, dchinner@redhat.com, rpeterso@redhat.com, jth@kernel.org, linux-erofs@lists.ozlabs.org, damien.lemoal@opensource.wdc.com, linux-btrfs@vger.kernel.org Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" On Thu, Apr 06, 2023 at 09:37:53AM +1000, Dave Chinner wrote: > On Wed, Apr 05, 2023 at 10:54:06PM +0000, Eric Biggers wrote: > > On Thu, Apr 06, 2023 at 08:26:46AM +1000, Dave Chinner wrote: > > > > We could certainly think about moving to a design where fs/verity/ asks the > > > > filesystem to just *read* a Merkle tree block, without adding it to a cache, and > > > > then fs/verity/ implements the caching itself. That would require some large > > > > changes to each filesystem, though, unless we were to double-cache the Merkle > > > > tree blocks which would be inefficient. > > > > > > No, that's unnecessary. > > > > > > All we need if for fsverity to require filesystems to pass it byte > > > addressable data buffers that are externally reference counted. The > > > filesystem can take a page reference before mapping the page and > > > passing the kaddr to fsverity, then unmap and drop the reference > > > when the merkle tree walk is done as per Andrey's new drop callout. > > > > > > fsverity doesn't need to care what the buffer is made from, how it > > > is cached, what it's life cycle is, etc. The caching mechanism and > > > reference counting is entirely controlled by the filesystem callout > > > implementations, and fsverity only needs to deal with memory buffers > > > that are guaranteed to live for the entire walk of the merkle > > > tree.... > > > > Sure. Just a couple notes: > > > > First, fs/verity/ does still need to be able to tell whether the buffer is newly > > instantiated or not. > > Boolean flag from the caller. > > > Second, fs/verity/ uses the ahash API to do the hashing. ahash is a > > scatterlist-based API. Virtual addresses can still be used (see sg_set_buf()), > > but the memory cannot be vmalloc'ed memory, since virt_to_page() needs to work. > > Does XFS use vmalloc'ed memory for these buffers? > > Not vmalloc'ed, but vmapped. we allocate the pages individually, but > then call vm_map_page() to present the higher level code with a > single contiguous memory range if it is a multi-page buffer. > > We do have the backing info held in the buffer, and that's what we > use for IO. If fsverity needs a page based scatter/gather list > for hardware offload, it could ask the filesystem to provide it > for that given buffer... > > > BTW, converting fs/verity/ from ahash to shash is an option; I've really never > > been a fan of the scatterlist-based crypto APIs! The disadvantage of doing > > this, though, would be that it would remove support for all the hardware crypto > > drivers. > > > > That *might* actually be okay, as that approach to crypto acceleration > > has mostly fallen out of favor, in favor of CPU-based acceleration. But I do > > worry about e.g. someone coming out of the woodwork and saying they need to use > > fsverity on a low-powered ARM board that has a crypto accelerator like CAAM, and > > they MUST use their crypto accelerator to get acceptable performance. > > True, but we are very unlikely to be using XFS on such small > systems and I don't think we really care about XFS performance on > android sized systems, either. > FYI, I've sent an RFC patch that converts fs/verity/ from ahash to shash: https://lore.kernel.org/r/20230406003714.94580-1-ebiggers@kernel.org It would be great if we could do that. But I need to get a better sense for whether anyone will complain... - Eric 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 83430C7618D for ; Thu, 6 Apr 2023 00:44:45 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pkDk5-0000oQ-5q; Thu, 06 Apr 2023 00:44:44 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pkDk4-0000oJ-An for linux-f2fs-devel@lists.sourceforge.net; Thu, 06 Apr 2023 00:44:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: 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=r8gbq9A+CVL6lExX2DdX2+SHU8p7UjFjmZ1IdBn1rhg=; b=Lp7bUZbqdv4mKeOcfbREerMO0f yy8o0Ob9X+ssWUs2AaSRkhgx1JBsMa8x6ZQ2lk1UXWkbBt2WOmE3Zc9YymMtxxbZFzw8qcAs2k197 Y8gXe8Oh265pLIRswnT/cr/Q7w9TOjwP8aL5fTeXZ3r2oZ0XCoYjThcKp1z9nHqTzIKE=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding: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=r8gbq9A+CVL6lExX2DdX2+SHU8p7UjFjmZ1IdBn1rhg=; b=SxrS7wVELymuGhEJmpZHmwiWvU DW41o6/n2V8y0kTkPoVjQFWcKAmdcfclgwlWadWc6EEsOsV/B9ct6WInBVFfWASkpzwF9dETLfwP3 aPy5hlQr6te364RXXkZ8PdeiP3KdObBR/hTnQUhEG2b8aNwosdwLofzEjy7INt7Gkm4M=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pkDk2-00GPjE-Kp for linux-f2fs-devel@lists.sourceforge.net; Thu, 06 Apr 2023 00:44:43 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 422DD62A45; Thu, 6 Apr 2023 00:44:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21089C433D2; Thu, 6 Apr 2023 00:44:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680741876; bh=zN0uoPG2wy3vEMLhzgjqbmHAqYYQld3AbN2XunzMIoU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bo8p3D+S8WueWIQeyXVhF9VsXJIkX3mi7lCuHYZ7OixWNIVgwe52hWCGQTCpabGiY 6mT1eHjUq2EedAyyBTpNdvhDNGB7ja0pxmv+2hAT4IOl/D6gtx0cKQGX4OsM8OaIJL qJbARzdhdEgqxF6P1iYB779hRD2iIfLqS229fGaWr23fMFpB+goPahUZxXr2Z0B7Lo U2dQSQsuy/cHfeInl7U1BHZohgOtSGQJM5WZTpux93iA31XE6NFlO2xoLtnQbmkcjC vNwntPVZYgHRIbIIfX+e89u8Evn868NI0UF/wcOyIkteZXz1d3WIzEoABhr37UZz1i A4vZrijh7VmiQ== Date: Wed, 5 Apr 2023 17:44:34 -0700 From: Eric Biggers To: Dave Chinner Message-ID: <20230406004434.GA879@sol.localdomain> References: <20230404145319.2057051-1-aalbersh@redhat.com> <20230404145319.2057051-22-aalbersh@redhat.com> <20230404163602.GC109974@frogsfrogsfrogs> <20230405160221.he76fb5b45dud6du@aalbersh.remote.csb> <20230405163847.GG303486@frogsfrogsfrogs> <20230405222646.GR3223426@dread.disaster.area> <20230405233753.GU3223426@dread.disaster.area> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230405233753.GU3223426@dread.disaster.area> X-Headers-End: 1pkDk2-00GPjE-Kp Subject: Re: [f2fs-dev] [PATCH v2 21/23] xfs: handle merkle tree block size != fs blocksize != PAGE_SIZE 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: , Cc: fsverity@lists.linux.dev, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, agruenba@redhat.com, "Darrick J. Wong" , Andrey Albershteyn , linux-f2fs-devel@lists.sourceforge.net, hch@infradead.org, cluster-devel@redhat.com, dchinner@redhat.com, rpeterso@redhat.com, xiang@kernel.org, jth@kernel.org, linux-erofs@lists.ozlabs.org, damien.lemoal@opensource.wdc.com, 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 On Thu, Apr 06, 2023 at 09:37:53AM +1000, Dave Chinner wrote: > On Wed, Apr 05, 2023 at 10:54:06PM +0000, Eric Biggers wrote: > > On Thu, Apr 06, 2023 at 08:26:46AM +1000, Dave Chinner wrote: > > > > We could certainly think about moving to a design where fs/verity/ asks the > > > > filesystem to just *read* a Merkle tree block, without adding it to a cache, and > > > > then fs/verity/ implements the caching itself. That would require some large > > > > changes to each filesystem, though, unless we were to double-cache the Merkle > > > > tree blocks which would be inefficient. > > > > > > No, that's unnecessary. > > > > > > All we need if for fsverity to require filesystems to pass it byte > > > addressable data buffers that are externally reference counted. The > > > filesystem can take a page reference before mapping the page and > > > passing the kaddr to fsverity, then unmap and drop the reference > > > when the merkle tree walk is done as per Andrey's new drop callout. > > > > > > fsverity doesn't need to care what the buffer is made from, how it > > > is cached, what it's life cycle is, etc. The caching mechanism and > > > reference counting is entirely controlled by the filesystem callout > > > implementations, and fsverity only needs to deal with memory buffers > > > that are guaranteed to live for the entire walk of the merkle > > > tree.... > > > > Sure. Just a couple notes: > > > > First, fs/verity/ does still need to be able to tell whether the buffer is newly > > instantiated or not. > > Boolean flag from the caller. > > > Second, fs/verity/ uses the ahash API to do the hashing. ahash is a > > scatterlist-based API. Virtual addresses can still be used (see sg_set_buf()), > > but the memory cannot be vmalloc'ed memory, since virt_to_page() needs to work. > > Does XFS use vmalloc'ed memory for these buffers? > > Not vmalloc'ed, but vmapped. we allocate the pages individually, but > then call vm_map_page() to present the higher level code with a > single contiguous memory range if it is a multi-page buffer. > > We do have the backing info held in the buffer, and that's what we > use for IO. If fsverity needs a page based scatter/gather list > for hardware offload, it could ask the filesystem to provide it > for that given buffer... > > > BTW, converting fs/verity/ from ahash to shash is an option; I've really never > > been a fan of the scatterlist-based crypto APIs! The disadvantage of doing > > this, though, would be that it would remove support for all the hardware crypto > > drivers. > > > > That *might* actually be okay, as that approach to crypto acceleration > > has mostly fallen out of favor, in favor of CPU-based acceleration. But I do > > worry about e.g. someone coming out of the woodwork and saying they need to use > > fsverity on a low-powered ARM board that has a crypto accelerator like CAAM, and > > they MUST use their crypto accelerator to get acceptable performance. > > True, but we are very unlikely to be using XFS on such small > systems and I don't think we really care about XFS performance on > android sized systems, either. > FYI, I've sent an RFC patch that converts fs/verity/ from ahash to shash: https://lore.kernel.org/r/20230406003714.94580-1-ebiggers@kernel.org It would be great if we could do that. But I need to get a better sense for whether anyone will complain... - Eric _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel