Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp824706rwl; Wed, 5 Apr 2023 08:11:13 -0700 (PDT) X-Google-Smtp-Source: AKy350bfUD7du9NCZ8CezOqKukU8mM+RtJgdVEyoP/46OFmPsVykl0VbRGItLoLj1gLl682oYyQq X-Received: by 2002:a17:906:ece1:b0:93d:ae74:fa9e with SMTP id qt1-20020a170906ece100b0093dae74fa9emr3284046ejb.7.1680707472869; Wed, 05 Apr 2023 08:11:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680707472; cv=none; d=google.com; s=arc-20160816; b=dje0xOtUDmYm8rAkSJrhLkXuh2/IFTIlWFTWS/yY4lJ3mN2N5ATHp1vcHVMOHcd5pR 2T5CSW62sxjogQsZZ1reQDWSu7lBCIBkBbr5kKNoBSZoe7R0anf2IxSzQAtBUAtG7Zf4 Biy+sOqPlH0oKLL0y+ASgSFu1Z2yXg41YKVVG38iKrHMWh7qT5fr9DILln8aaQUv77Oa TKACM9idSthLnDRhcLq4q5TJSpO4tnv4uEqq4aKokE/4R/8ZbdsNTySGgFV+GwENhyw9 wlm/enftSFpCLHlflWk21r0etSRsb1vvY14wu9FKsM3/6ZKGY4ypIVVf1PUB7/gpu16x lgLA== 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=8TW4zWFYwr/04tnxh6yiM60594MaxgbDYPp7QcjoihU=; b=MdzfX+CTsDXSWQQKwX/xyivxU40WkW2yqOlVYl6DOD+gv4Ya9dR/f+lDx3lbyjNud5 uXwRVdiGxdygQcVOKpy1Ws1LCC2pmjiJYUQJ5LyRMsXMUhoz1lyKSnv6jXSDsFUAdCRN RUG7+W9w/zSsnlL6eTvf38aVazLmzroKCfmlXYBsYG2+a3/4zVtMo5uarLS78NoYGf0t vuqP43D7k/zdkNfoNvdF5fBL79Iq0WTx92q6aYE+GJwX2u42UEkqF7L71l84096lt+mm 0TC73dycl4fgcmS35K+u3f/V+V2H9V9s02K8qzziYzV8nK5hl9S7hWDN2KQcKpnR5zkw PKAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z0Y5O+66; 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 x12-20020a1709064a8c00b0093bd1b12b6esi8510984eju.385.2023.04.05.08.10.47; Wed, 05 Apr 2023 08:11:12 -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=Z0Y5O+66; 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 S238781AbjDEPKU (ORCPT + 99 others); Wed, 5 Apr 2023 11:10:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238880AbjDEPJy (ORCPT ); Wed, 5 Apr 2023 11:09:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC1347A8F; Wed, 5 Apr 2023 08:07:01 -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 8D5E463E79; Wed, 5 Apr 2023 15:06:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E90FCC4339E; Wed, 5 Apr 2023 15:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680707188; bh=mlni390c+gmIDMlX2RnZzsHsCPBkb+xutjeyTZL88LA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Z0Y5O+66tWXrhcV6ndCx07PGooMOJap5OIdpqEdvYFYnMHN0z5WiLYrWuKcSeaXHl UcZpAG3fUrlrKjP5/sAagW6AWG69d+rXgg1WBgDW+rC9NaJekXCvMerJzsJkjRnsXH m4Q6uAO39XKLOFgPn03RBth+eXeK/rY/VE0Yu1qLMe93Au/pMBUkCWq3xQz6voM133 knKAwxEb9wOgh0gF0jn6wi8T39XIQ/aCS62UgeWnfbPOpTkjgiMeytHY928u5OUjWN J9dEljNMTn2fktd2Sp1o8GdjUkAWHM/TRVCjrukbVy3Hv8BEKS4poWg1XrW7ftU4DI o6Z6xJuTGto9g== Date: Wed, 5 Apr 2023 08:06:27 -0700 From: "Darrick J. Wong" To: Andrey Albershteyn Cc: Christoph Hellwig , dchinner@redhat.com, ebiggers@kernel.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 09/23] iomap: allow filesystem to implement read path verification Message-ID: <20230405150627.GC303486@frogsfrogsfrogs> References: <20230404145319.2057051-1-aalbersh@redhat.com> <20230404145319.2057051-10-aalbersh@redhat.com> <20230405110116.ia5wv3qxbnpdciui@aalbersh.remote.csb> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230405110116.ia5wv3qxbnpdciui@aalbersh.remote.csb> X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,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 Wed, Apr 05, 2023 at 01:01:16PM +0200, Andrey Albershteyn wrote: > Hi Christoph, > > On Tue, Apr 04, 2023 at 08:37:02AM -0700, Christoph Hellwig wrote: > > > if (iomap_block_needs_zeroing(iter, pos)) { > > > folio_zero_range(folio, poff, plen); > > > + if (iomap->flags & IOMAP_F_READ_VERITY) { > > > > Wju do we need the new flag vs just testing that folio_ops and > > folio_ops->verify_folio is non-NULL? > > Yes, it can be just test, haven't noticed that it's used only here, > initially I used it in several places. > > > > > > - ctx->bio = bio_alloc(iomap->bdev, bio_max_segs(nr_vecs), > > > - REQ_OP_READ, gfp); > > > + ctx->bio = bio_alloc_bioset(iomap->bdev, bio_max_segs(nr_vecs), > > > + REQ_OP_READ, GFP_NOFS, &iomap_read_ioend_bioset); > > > > All other callers don't really need the larger bioset, so I'd avoid > > the unconditional allocation here, but more on that later. > > Ok, make sense. > > > > > > + ioend = container_of(ctx->bio, struct iomap_read_ioend, > > > + read_inline_bio); > > > + ioend->io_inode = iter->inode; > > > + if (ctx->ops && ctx->ops->prepare_ioend) > > > + ctx->ops->prepare_ioend(ioend); > > > + > > > > So what we're doing in writeback and direct I/O, is to: > > > > a) have a submit_bio hook > > b) allow the file system to then hook the bi_end_io caller > > c) (only in direct O/O for now) allow the file system to provide > > a bio_set to allocate from > > I see. > > > > > I wonder if that also makes sense and keep all the deferral in the > > file system. We'll need that for the btrfs iomap conversion anyway, > > and it seems more flexible. The ioend processing would then move into > > XFS. > > > > Not sure what you mean here. I /think/ Christoph is talking about allowing callers of iomap pagecache operations to supply a custom submit_bio function and a bio_set so that filesystems can add in their own post-IO processing and appropriately sized (read: minimum you can get away with) bios. I imagine btrfs has quite a lot of (read) ioend processing they need to do, as will xfs now that you're adding fsverity. > > > @@ -156,6 +160,11 @@ struct iomap_folio_ops { > > > * locked by the iomap code. > > > */ > > > bool (*iomap_valid)(struct inode *inode, const struct iomap *iomap); > > > + > > > + /* > > > + * Verify folio when successfully read > > > + */ > > > + bool (*verify_folio)(struct folio *folio, loff_t pos, unsigned int len); Any reason why we shouldn't return the usual negative errno? > > Why isn't this in iomap_readpage_ops? > > > > Yes, it can be. But it appears to me to be more relevant to > _folio_ops, any particular reason to move it there? Don't mind > moving it to iomap_readpage_ops. I think the point is that this is a general "check what we just read" hook, so it could be in readpage_ops since we're never going to need to re-validate verity contents, right? Hence it could be in readpage_ops instead of the general iomap_folio_ops. Is there a use case for ->verify_folio that isn't a read post- processing step? --D > -- > - Andrey >