Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp817124rwl; Wed, 5 Apr 2023 08:06:29 -0700 (PDT) X-Google-Smtp-Source: AKy350aNzc9Vs+P7RjuhSzZ+XdQglPQx/cQebIXI7QYPgMiOkNcH3sOIE3bxmk98WzMseYHPDIz9 X-Received: by 2002:a05:6a20:8b24:b0:cd:91bc:a9af with SMTP id l36-20020a056a208b2400b000cd91bca9afmr4568623pzh.58.1680707189184; Wed, 05 Apr 2023 08:06:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680707189; cv=none; d=google.com; s=arc-20160816; b=rJor2YSemFThFtAdkL6Mjklt1SY8XNcnqqSVk6A1Mxy/dHEqa8UPDX0Cl2LG2s76mD Jr9UmqqlIFoEti+YMhe+Kd5XtM19FSEMY2lf2KcKI53HCC9go58WSosyXy1COD0bMjas eWqYkZLCR0ahrVUcDNVuQrr1wBGS0/P7yxJRJCNAQ6SU62qG0ToqqSIiyn9YZ+DHtAFK 1HuLjxmQB7aSOIFcEDwCbowNdHj6pB1bN5uZk2DTLOwPKtrm0DqcQLFIQVqhpcH2lfwn N95V+6/1pVxiH5/EW04r/djEQk/1GHYuF+wlaoGDz0E6SRdiboJT4kd8jQB0Cnnu8ypN srJg== 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=ijdR/MHnRs9yin6C5jhmGmV2EeFx7fyGP+HaH521iTo=; b=y6Drkjv/kcdlHBpPu8Yo1vSPf2flbitrjTChHkzysl8Gg512h5QMN2ebpCGhyeQ6Zx 2lr/e6dJNG9D8lUUUhe8hK1fevtFn/+W3qrBc6M9TzvQd9YI76EySqtfmjjeAcXOFou1 8BWzGymlK4YV3GFglndg6l7aV0MHPPxjrC9ymMj1VPHTCsyocvB4BA+wCe+x5ew7ccNZ 6clwHLG+6OJ8O9XK+XAzgS2scwZMYw4UQtwzDfNBlbRUFd4ppVd+2aQqysxQmRqb8rbB y710kxm5TEjKk5SsmCWpLU/1nk8BfyFlVsMGF4v/FY3FABLi1uXDQZqQoNn8MA+SLtSy T+dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KPJd0hYt; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 22-20020a630316000000b004ff6f80f6c4si13108839pgd.285.2023.04.05.08.06.13; Wed, 05 Apr 2023 08:06:29 -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=@redhat.com header.s=mimecast20190719 header.b=KPJd0hYt; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238441AbjDEPC7 (ORCPT + 99 others); Wed, 5 Apr 2023 11:02:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238619AbjDEPCz (ORCPT ); Wed, 5 Apr 2023 11:02:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CB926A4C for ; Wed, 5 Apr 2023 08:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680706914; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ijdR/MHnRs9yin6C5jhmGmV2EeFx7fyGP+HaH521iTo=; b=KPJd0hYt3c5izrhpy8yGFXwyKW5C/oJQdja5Oj02Fz6ZK2dazO8gFmaqYySwoMGpvXa2fu kqwuZgm8LXEvY8qxbmZuaFbKMYXlnGKF00L9y0CxTcIWAMEXr1rnqIWSLAO7Coao0lk3PY MzE0W0Z1ipIIk/cWBkt8h+WPc0QljT8= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-447-lUBhphiNP2qkaDhlfQcVLQ-1; Wed, 05 Apr 2023 11:01:51 -0400 X-MC-Unique: lUBhphiNP2qkaDhlfQcVLQ-1 Received: by mail-qk1-f197.google.com with SMTP id 206-20020a370cd7000000b007467b5765d2so16431507qkm.0 for ; Wed, 05 Apr 2023 08:01:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680706911; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ijdR/MHnRs9yin6C5jhmGmV2EeFx7fyGP+HaH521iTo=; b=LFkSEVEk4Q2sVJhH/H6XYNjDX2SaAH0sH3f3SX6VZJlY18bNdNCX9twpzG/s3QKRDP DPbFY7syHry4iR47P+LN9w/398DFgY++dN0+Z8o8AfsKmOnwRvvH7U+PBLCFxn/ginpn q0XkDmUEkpbavfBjFPpgp6nwY6ghJVRMh0FqxAmVBER3GU6a/nzjmwgKWpfHUmWciJS2 rYTFMoW88JeC50LmMlf5BsdgYg8xbUgPkYIMdFg+a+daGAcC9lY/qJlASPFhIBN3+FxR 1enJjF4w2BviVbPyp3v+B36YcvLhWidzem1IAT4H4I6aAOk4XcZcTpGRklrrbccCnHT0 mRJQ== X-Gm-Message-State: AAQBX9dGWQgHyOF14NK9jo2NYuQK2p7bSCQI2nzM16p8TdfdMuaAbqUc huiTt3OAjpm2UIwyup4xKVerU5j2YBp+G3f8oT2M1nGIP03/PBkA9CdTUfHHV3Hsvs3C9zsyI17 MAJDJ8dLbdJ6PJyNS2URw X-Received: by 2002:a05:6214:2504:b0:5a3:cbc6:8145 with SMTP id gf4-20020a056214250400b005a3cbc68145mr11557264qvb.19.1680706910927; Wed, 05 Apr 2023 08:01:50 -0700 (PDT) X-Received: by 2002:a05:6214:2504:b0:5a3:cbc6:8145 with SMTP id gf4-20020a056214250400b005a3cbc68145mr11557235qvb.19.1680706910656; Wed, 05 Apr 2023 08:01:50 -0700 (PDT) Received: from aalbersh.remote.csb ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id o8-20020a0cc388000000b005dd8b93457dsm4236165qvi.21.2023.04.05.08.01.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 08:01:49 -0700 (PDT) Date: Wed, 5 Apr 2023 17:01:42 +0200 From: Andrey Albershteyn To: "Darrick J. Wong" Cc: dchinner@redhat.com, ebiggers@kernel.org, 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 19/23] xfs: disable direct read path for fs-verity sealed files Message-ID: <20230405150142.3jmxzo5i27bbc4c4@aalbersh.remote.csb> References: <20230404145319.2057051-1-aalbersh@redhat.com> <20230404145319.2057051-20-aalbersh@redhat.com> <20230404161047.GA109974@frogsfrogsfrogs> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230404161047.GA109974@frogsfrogsfrogs> X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 Tue, Apr 04, 2023 at 09:10:47AM -0700, Darrick J. Wong wrote: > On Tue, Apr 04, 2023 at 04:53:15PM +0200, Andrey Albershteyn wrote: > > The direct path is not supported on verity files. Attempts to use direct > > I/O path on such files should fall back to buffered I/O path. > > > > Signed-off-by: Andrey Albershteyn > > --- > > fs/xfs/xfs_file.c | 14 +++++++++++--- > > 1 file changed, 11 insertions(+), 3 deletions(-) > > > > diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c > > index 947b5c436172..9e072e82f6c1 100644 > > --- a/fs/xfs/xfs_file.c > > +++ b/fs/xfs/xfs_file.c > > @@ -244,7 +244,8 @@ xfs_file_dax_read( > > struct kiocb *iocb, > > struct iov_iter *to) > > { > > - struct xfs_inode *ip = XFS_I(iocb->ki_filp->f_mapping->host); > > + struct inode *inode = iocb->ki_filp->f_mapping->host; > > + struct xfs_inode *ip = XFS_I(inode); > > ssize_t ret = 0; > > > > trace_xfs_file_dax_read(iocb, to); > > @@ -297,10 +298,17 @@ xfs_file_read_iter( > > > > if (IS_DAX(inode)) > > ret = xfs_file_dax_read(iocb, to); > > - else if (iocb->ki_flags & IOCB_DIRECT) > > + else if (iocb->ki_flags & IOCB_DIRECT && !fsverity_active(inode)) > > ret = xfs_file_dio_read(iocb, to); > > - else > > + else { > > + /* > > + * In case fs-verity is enabled, we also fallback to the > > + * buffered read from the direct read path. Therefore, > > + * IOCB_DIRECT is set and need to be cleared > > + */ > > + iocb->ki_flags &= ~IOCB_DIRECT; > > ret = xfs_file_buffered_read(iocb, to); > > XFS doesn't usually allow directio fallback to the pagecache. Why > would fsverity be any different? Didn't know that, this is what happens on ext4 so I did the same. Then it probably make sense to just error on DIRECT on verity sealed file. > > --D > > > + } > > > > if (ret > 0) > > XFS_STATS_ADD(mp, xs_read_bytes, ret); > > -- > > 2.38.4 > > > -- - Andrey