Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1343670rwl; Wed, 5 Apr 2023 15:58:02 -0700 (PDT) X-Google-Smtp-Source: AKy350ZTeW0pb1/xmKXNVJ96QedOmEOKRRX/m9CZuc163nGv3rpKfqiwMHEhQxP7bt4WvS8vOglt X-Received: by 2002:a05:6a20:8908:b0:d9:84d2:7aae with SMTP id i8-20020a056a20890800b000d984d27aaemr844012pzg.22.1680735481794; Wed, 05 Apr 2023 15:58:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680735481; cv=none; d=google.com; s=arc-20160816; b=bYozqmb31z/RlGqFG8/8X1Nuyw3IPTSHCr/iBtMAndjW8J4EOJNkj/ELjAvmmLm6tZ P06SW2hq1th3qrv3yq7xHXr40DqvAdHypE6dC+eITxcC3sThS6vVvmHmqpGffc90pAX2 1BGgUsoXI3jr8J0epQKBDLxYtl+8wE2/G+5Ol0YqxPMWK27mlJ1hfuvwgnWOJLUMIle8 kzNSv4JcZhRHKV5TZHOQM1rsQQoP8U8exbI73o1rPtkC1npF7uFL1n90Ajrtx37F7VUp tZMoMbiTGqJAEjMmIR9YKfiZFLQzddmE2ELTxqFQ66RBBl/odQ//nBcDC8jy4mmt0hS9 La3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6JUsAGKEXzuNd3ZoMR2OtLIul6CggHLj09DSy7aat6U=; b=CHhAlox6WW6hvQOlN11gi28gRAvhNpxmkHXiYnC4cKTzsaBMkIEOU30wsydC8KgIOl 4msvd8DI3OP4uOdYD0ZiM3UzbO4Qycvo3Yq+cL1qUwGWva3x5tlPTt1E7ReZRuYVw2S/ 4UaDs+Xi1jUC/IY/JU9P8f7gwN/VX4zfyZCyW9Bcpqg0HgpphR4xEhT9y3t1uagvD+lA d4oOLYoFYPUjPq5N2egkQSypHuNgAyYc5YeRBblDZQIcAjSkHydD6EzNcDaVdQG+bluV 0zFKQ+HNwKNDS72XOJJbcsyg/T2Yv6tRiP5s2rxnytC3hh/Pizi2kvKbI0jI/lwnwH7A /upA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="LovyRg/E"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u185-20020a6385c2000000b005133c334fe9si13562398pgd.847.2023.04.05.15.57.29; Wed, 05 Apr 2023 15:58:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="LovyRg/E"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231828AbjDEWyK (ORCPT + 99 others); Wed, 5 Apr 2023 18:54:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231245AbjDEWyJ (ORCPT ); Wed, 5 Apr 2023 18:54:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6CD940DA; Wed, 5 Apr 2023 15:54:08 -0700 (PDT) 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 5DE3D64143; Wed, 5 Apr 2023 22:54:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 722A6C433EF; Wed, 5 Apr 2023 22:54:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680735247; bh=y5XoOju2yBDL4YDibMiieXpA89mTn+Rteq91AiPxCaU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LovyRg/EAV0o26rHWyr3wwdJKBIWeqs2RWTqBiuMA93Uopo6KQP/kuk5d1BnGrKHX eXiQmEFzna6WH31jznXOQEsuU8fCZaqbF53Fy9IDiBzVWVzNlq3Fcms5RC/AHMk3CM OAU4zbey8PXa+toYXE1InTyNADGV791ee94FuTsdJtQmtxfk26JoNlrEZbAnyuI7RM Tdnt072GBeEL29vP8V8lyr806zJWwdzwvcrm09fKje0OdHL52/Fkji9DdhPvGeeRQZ JSFgndGfwhFR5/2N8nLhm2oMnQAOUpmI5ryVtmOxxrkwIl3UfC3Gz24KpM4fDrDRV4 EANBOVoAcG1Tg== Date: Wed, 5 Apr 2023 22:54:06 +0000 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: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230405222646.GR3223426@dread.disaster.area> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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. 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? 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. - Eric