Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6105878rwl; Tue, 4 Apr 2023 07:58:18 -0700 (PDT) X-Google-Smtp-Source: AKy350asODOlJuP47OAVEyQ0qEdrqPEKCBLXPMRvjmoJum+cF8KC60Ks/XUPnGjVPXscMv36zvrk X-Received: by 2002:a17:906:3551:b0:948:6e3d:a030 with SMTP id s17-20020a170906355100b009486e3da030mr2407546eja.42.1680620298437; Tue, 04 Apr 2023 07:58:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680620298; cv=none; d=google.com; s=arc-20160816; b=i2JhG4dQ6T/NoedqbCvdFzhOjy3T9gbniE+hwmWflIINc84z+OSH5hPmdbIc+PDwL3 F0wHgqCIg+ugFhW1RPLGYFdrxZYK/9cOG3533V/xttwetLqPg5MNvAp3xlaCPi4bcxu4 TMugUXgeXTLMQn1O3WNHIs9yZgwt8FQJx5IKNLT3UZuL6XHeB985N0dh/m9jg5C+YHKT rSH+3Bk9LwACPYEBoKSSjFMxIPVBchZrVgdrTdSEgE2hz1ZDnKtLpJRCczIs6XC7YqVc rodX2Iog4b9NM7ouMrj5+WGlXZ0sq2tS3VdcjzmvQ/5jT1XAyxG+OK3SJsoQY6E3gsnf mBBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WW1Er4PupDb0BosAfd03U+k3CW0R0JjVRop2pX5rde0=; b=qS56mx2keSLTaSzLwNI0XAzaKUdT/gX3sP47FXKhfsOPJ7dkAfDNxIrlAUZ8a6+HHm 6KnyXTGiE+qEUuPUHiITVwKK3GcgCHVHXlLw31JACR4V8qNIdjljh04pco0xoVrTY2fn 0upSko49iJJ8a7c/mJbZPzqnf9d9szd6vDk5+rttAOraPQXMb0o7iaAHEhBkUgedsYOp nkj2f8HDNM5ESXeOh3c3oEJ1/a7UlocKj7hbVcznrPjUsXlQMVAdvg15/sHObgjT6qNz uKlIvWi/p1FU9lCbV8EA6yyrj/oj99CZL/cT2t/tOBB93sifFcZLq7RL770B974KwjDC Skaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Ns/UZNRl"; 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 m14-20020a056402050e00b004eab3b519b4si3194edv.207.2023.04.04.07.57.54; Tue, 04 Apr 2023 07:58:18 -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="Ns/UZNRl"; 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 S234843AbjDDO5O (ORCPT + 99 others); Tue, 4 Apr 2023 10:57:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234834AbjDDO4i (ORCPT ); Tue, 4 Apr 2023 10:56:38 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3802E2710 for ; Tue, 4 Apr 2023 07:55:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680620148; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WW1Er4PupDb0BosAfd03U+k3CW0R0JjVRop2pX5rde0=; b=Ns/UZNRlHjaaZVlcezRRj/+fIW7kXbvwV9C9aRmZjzaxYuimKF5ib0Zq4Jc89cF2NrjBHo OXgY1xTAFnOZkav6vUDnuCqBhvlRPre3vQpF9D6G59jU4RBTScINDtNE9/u9oIpTh6pt1t PYCyIVIhs2AG10RINkvGBteLE+9PumU= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-264-dxtIFiJzOZim5uCWo3uWyA-1; Tue, 04 Apr 2023 10:55:45 -0400 X-MC-Unique: dxtIFiJzOZim5uCWo3uWyA-1 Received: by mail-qt1-f197.google.com with SMTP id a19-20020a05622a02d300b003e4ecb5f613so16800640qtx.21 for ; Tue, 04 Apr 2023 07:55:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680620145; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WW1Er4PupDb0BosAfd03U+k3CW0R0JjVRop2pX5rde0=; b=mk5YR4FhuRNtK8Ajx+lfT5MWP7pBSzoRi6oZDy1Mo/rdDqYdXqHVmRdomcJkl8Txzt rfrtPDH6ZK9F4zPgpnCswaTKfUpnsFdYzydck8Ke4NvES532fHF4Hnjwu79xnAhVfhKg U5/UXu5QuQZJZN/80hmSghTOqjdZTlDUvHfpmh6OeBMFg/1y/M+0Ilq2Yzt0LLKPsHj5 Jh1Zpksqscf2wz7/XblknDHTlTymlhEtCmYoPn3WuUziI52/ZUfotiIsn9+C9o863/7e 4198dLgDLWNzoLL3bLzpqD7mI+fkyL2jJP9Yy/y2JExMdH0T9s74hg/Ushgp1mtHkgHK da6A== X-Gm-Message-State: AAQBX9dO2yWigd1MDcG8q8nKHZIRBCGfTp3yU8Tlj3c7ZZbDz51IMfRB 73W9NqzdwQf1e9tTs48xUNV9Syq9zPlCe4hCU22Bby9CEPL49B61MLqAqRxeDEAouWGG524c46S gcsYVp4/zO4hhIW+2LC7F X-Received: by 2002:ac8:5c84:0:b0:3bf:da69:8f74 with SMTP id r4-20020ac85c84000000b003bfda698f74mr3767033qta.39.1680620144611; Tue, 04 Apr 2023 07:55:44 -0700 (PDT) X-Received: by 2002:ac8:5c84:0:b0:3bf:da69:8f74 with SMTP id r4-20020ac85c84000000b003bfda698f74mr3766987qta.39.1680620144232; Tue, 04 Apr 2023 07:55:44 -0700 (PDT) Received: from aalbersh.remote.csb ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id j4-20020ac86644000000b003e6387431dcsm3296539qtp.7.2023.04.04.07.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 07:55:43 -0700 (PDT) From: Andrey Albershteyn To: djwong@kernel.org, dchinner@redhat.com, ebiggers@kernel.org, hch@infradead.org, linux-xfs@vger.kernel.org, fsverity@lists.linux.dev Cc: 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, Andrey Albershteyn Subject: [PATCH v2 19/23] xfs: disable direct read path for fs-verity sealed files Date: Tue, 4 Apr 2023 16:53:15 +0200 Message-Id: <20230404145319.2057051-20-aalbersh@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230404145319.2057051-1-aalbersh@redhat.com> References: <20230404145319.2057051-1-aalbersh@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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); + } if (ret > 0) XFS_STATS_ADD(mp, xs_read_bytes, ret); -- 2.38.4