From patchwork Tue Apr 4 14:53:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13200431 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9072C77B60 for ; Tue, 4 Apr 2023 14:57:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234892AbjDDO5O (ORCPT ); Tue, 4 Apr 2023 10:57:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234844AbjDDO4k (ORCPT ); Tue, 4 Apr 2023 10:56:40 -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 448685259 for ; Tue, 4 Apr 2023 07:55:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680620146; 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=bs5A23V9oINVqTDyeoVr/OlCaBp0vLe/bmsA5ihgo79MtQdMeohrne85ZgA1SALr0a09bP UgDupIoVYrK1qqpNpQknI1vBYuIopw/eXLmHV3Cr0Lq5za9ew0PYF5RS48gm+IfZ1r3O6S 42lyEhUikqsNRC3WkHp/PYqxJWUsmgA= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-262-BMaK_XUBNF2geXxoegxJsw-1; Tue, 04 Apr 2023 10:55:45 -0400 X-MC-Unique: BMaK_XUBNF2geXxoegxJsw-1 Received: by mail-qt1-f200.google.com with SMTP id u22-20020a05622a011600b003dfd61e8594so22278727qtw.15 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=1680620144; 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=NSeBaCAK5MAlNBS3AHK6Yju1uAZO5rayy9qclMJ2SgeHMLoZ2Tbbvb5Gi4rXXzuaV9 84mhUo82HziLFKGdhp70sqAdagveCyXCiZ+hahymkBJUAKJzIdBbvqFH9hEQ7FJ+dAPa ZLVg6SoOdZZE1oEtlzl9TDULeXd0f1sa8O1LSsUv5B6RVILmLgWEMoP22XsG8JqTyhU1 GA+VCzJa1RY7I2qX60Xl2y3jJdQIglTF0x/AVHEXlljVesZtanvj9+iZiERLCod+E73k 2kwPpf21TslCHCSjfFCiZ+2rZn8w+xRJnLF82+zfuNC43hQZ2LvQYTjhpxmNRjXaPYP6 EYeQ== X-Gm-Message-State: AAQBX9fGqR7kcM5pahXBLq6OJYmnAs2T0lsrTqkPWZy9XEWZl+q/cNKe Tmt+XOJqgvRy7V3lko0BdxIYZVfVOcIyYc8NyBxXWEBTW7ko5TLcvXA2ESTP8uMLvr5Sltp1aqj y9tXgOCgmo7KSkPZaAyP7xg== X-Received: by 2002:ac8:5c84:0:b0:3bf:da69:8f74 with SMTP id r4-20020ac85c84000000b003bfda698f74mr3767024qta.39.1680620144603; Tue, 04 Apr 2023 07:55:44 -0700 (PDT) X-Google-Smtp-Source: AKy350aLDs2V7JY0pZuUB09/Ptq0L7v7I2lb1rRcVAQ1NVCDKigQ1vtszHxXzaOscw9+3+n++r92jw== 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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@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);