From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Chinner Date: Thu, 6 Apr 2023 08:10:39 +1000 Subject: [Cluster-devel] [PATCH v2 19/23] xfs: disable direct read path for fs-verity sealed files In-Reply-To: <20230405150927.GD303486@frogsfrogsfrogs> References: <20230404145319.2057051-1-aalbersh@redhat.com> <20230404145319.2057051-20-aalbersh@redhat.com> <20230404161047.GA109974@frogsfrogsfrogs> <20230405150142.3jmxzo5i27bbc4c4@aalbersh.remote.csb> <20230405150927.GD303486@frogsfrogsfrogs> Message-ID: <20230405221039.GP3223426@dread.disaster.area> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Wed, Apr 05, 2023 at 08:09:27AM -0700, Darrick J. Wong wrote: > On Wed, Apr 05, 2023 at 05:01:42PM +0200, Andrey Albershteyn wrote: > > 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. > > Thinking about this a little more -- I suppose we shouldn't just go > breaking directio reads from a verity file if we can help it. Is there > a way to ask fsverity to perform its validation against some arbitrary > memory buffer that happens to be fs-block aligned? The memory buffer doesn't even need to be fs-block aligned - it just needs to be a pointer to memory the kernel can read... We also need fsverity to be able to handle being passed mapped kernel memory rather than pages/folios for the merkle tree interfaces. That way we can just pass it the mapped buffer memory straight from the xfs-buf and we don't have to do the whacky "copy from xattr xfs_bufs into pages so fsverity can take temporary reference counts on what it thinks are page cache pages" as it walks the merkle tree. -Dave. -- Dave Chinner david at fromorbit.com From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFA28C950 for ; Wed, 5 Apr 2023 22:10:43 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id o6-20020a17090a9f8600b0023f32869993so40962516pjp.1 for ; Wed, 05 Apr 2023 15:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20210112.gappssmtp.com; s=20210112; t=1680732643; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=B//xqY4ihi9FjKHnI/3HItAd5zkVskGSEhbTE9KO+uM=; b=STgTGHnum63TLfzSA43g0jKvWgwzTlnLbiRBsWUDeVndg2q0Tgh+Q3SOrbj2o7vE8S OqWTQe02GPPEl+JqPtH+BqPfmvs//jeLjVwIl0XhMyQ3tek4wkSILn+nMJgz4Ucj0eU6 j0kbTbgibsNwkwrKvah9VMelOuBXgvxgwHI0pALQfzh2rVeht1RKj8+pbzrOR/bp501l L/VGUA0YqBD4tzXgV0KmZb3YviN4H/dsXP/5STmaPKBN43t4NUaSN54t71hCcI0H1oaq zP9YTNcdWyFHeWlBYJ4HXGKqXy09Gf/KRy8kJqqXI11hkg8FYce95UQ1oCAGXdz0Kzst BsJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680732643; 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=B//xqY4ihi9FjKHnI/3HItAd5zkVskGSEhbTE9KO+uM=; b=ebh+rUEY/f5J4ffyVB3Lf3vnAralA70cUOPwfqlnk7TYRC9EVKzhxJoan4uvw8XDlL PeW4HiAOQgHR0aPnyw1Feg792zY2ATly9+BvvGcKUqXR9z3ymRwZ11Is2WItbOXgVP+S 0B/mDu6pNb5OxTZO59ZDSeaiyX7N//CFm1nhrUe78RYLpA0EdKnHhFyI4/3cS+ETxPVH gN6ijsMSYORvVWHbihkO+Mzcp3PAfXUo2JbepTAkpiPQPtHt23zS4Z1xE6AbdOYtNGvW qHm1oZdEmjBxiOSQ8d6a9kgsACJ8axynZ2nDYIqlJ9TudwLKoi334ifQ+OEoWm2Dpfjz Ezfw== X-Gm-Message-State: AAQBX9fZ0ANn06CQVg+rv5zJtYb+i0ckfPfrxvWRby7h52aZjxa8a6A/ aeOadTIHd2UAg4g8AuIyIZ38OQ== X-Google-Smtp-Source: AKy350bUfWmomBUgOSKakyDoihBlbriDnLkKr+maH+SmOymveI4bbkcZZJHlbNIaaMvcTwEjmj518w== X-Received: by 2002:a05:6a20:b213:b0:e1:2d3d:6b11 with SMTP id eh19-20020a056a20b21300b000e12d3d6b11mr798344pzb.11.1680732643261; Wed, 05 Apr 2023 15:10:43 -0700 (PDT) Received: from dread.disaster.area (pa49-181-91-157.pa.nsw.optusnet.com.au. [49.181.91.157]) by smtp.gmail.com with ESMTPSA id f9-20020a631009000000b004ff6b744248sm9594682pgl.48.2023.04.05.15.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 15:10:42 -0700 (PDT) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1pkBKx-00HUPP-6E; Thu, 06 Apr 2023 08:10:39 +1000 Date: Thu, 6 Apr 2023 08:10:39 +1000 From: Dave Chinner To: "Darrick J. Wong" Cc: Andrey Albershteyn , 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: <20230405221039.GP3223426@dread.disaster.area> References: <20230404145319.2057051-1-aalbersh@redhat.com> <20230404145319.2057051-20-aalbersh@redhat.com> <20230404161047.GA109974@frogsfrogsfrogs> <20230405150142.3jmxzo5i27bbc4c4@aalbersh.remote.csb> <20230405150927.GD303486@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: fsverity@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230405150927.GD303486@frogsfrogsfrogs> On Wed, Apr 05, 2023 at 08:09:27AM -0700, Darrick J. Wong wrote: > On Wed, Apr 05, 2023 at 05:01:42PM +0200, Andrey Albershteyn wrote: > > 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. > > Thinking about this a little more -- I suppose we shouldn't just go > breaking directio reads from a verity file if we can help it. Is there > a way to ask fsverity to perform its validation against some arbitrary > memory buffer that happens to be fs-block aligned? The memory buffer doesn't even need to be fs-block aligned - it just needs to be a pointer to memory the kernel can read... We also need fsverity to be able to handle being passed mapped kernel memory rather than pages/folios for the merkle tree interfaces. That way we can just pass it the mapped buffer memory straight from the xfs-buf and we don't have to do the whacky "copy from xattr xfs_bufs into pages so fsverity can take temporary reference counts on what it thinks are page cache pages" as it walks the merkle tree. -Dave. -- Dave Chinner david@fromorbit.com From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2E2B7C77B6C for ; Wed, 5 Apr 2023 22:10:59 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4PsJjs2pLwz3f9s for ; Thu, 6 Apr 2023 08:10:57 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ozlabs.org; s=201707; t=1680732657; bh=B//xqY4ihi9FjKHnI/3HItAd5zkVskGSEhbTE9KO+uM=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=o3NIVmfnGDmRs/Y9DpZbUBr+2HdDxHfYBh4NGn/R3QbMKh5EX9D2PFGsVSFzladiU WsTzgkjSXvSRYof5VV7LfJfv2XS1j1hD6aTCySJ2tAqzuiPUSvOxCbKWtJbDkl5Mb5 qXoXM0/osgtVmwaomROREW1MEwPLVPzF4XV5dJv3rLBrtGJYV7YLuut7f2XW4K6iGb YBtWqPwyayD3afaXjp3nYkFW6YEO9+ORSfSSMS7uEGxjIYfVFinhoAdTpXwVznD4Sr 6T2qex7c9YPOJRZYOORPMkaEIxtglbSa+7HBSalELdcnR+PQtdg1w/fPy9q9VZgzgy cFtsdLT9jSTzg== Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=fromorbit.com (client-ip=2607:f8b0:4864:20::102d; helo=mail-pj1-x102d.google.com; envelope-from=david@fromorbit.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=fromorbit-com.20210112.gappssmtp.com header.i=@fromorbit-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=STgTGHnu; dkim-atps=neutral Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4PsJjj5Z9Qz3c1K for ; Thu, 6 Apr 2023 08:10:47 +1000 (AEST) Received: by mail-pj1-x102d.google.com with SMTP id om3-20020a17090b3a8300b0023efab0e3bfso40954320pjb.3 for ; Wed, 05 Apr 2023 15:10:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680732643; 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=B//xqY4ihi9FjKHnI/3HItAd5zkVskGSEhbTE9KO+uM=; b=h7+Bra4/z8VeIMMYdo+UNbciLLAonc67qn+jynJe2iHUonuI6zNYidPz4npYFpwiaN 4PoqEEe/w4LDfSTE8pykuEXRuVaDpz+aXLPP0ddElfbgFKBLcLeS9iv5nrY2Rey+0QFg mHeghgPFUK18U3Ek8OBR2ZtBjSnA6gRPIg1hLyyEf7jdLJJOO1Nh76dRGcgqm4xrdK9m tB7+COKwkAxUF8cquz7LKDj0U54SBM5cH/Byzf09lxFF9tCRCIYgY93jshzn9nuvcp4z i3ZUl3X03fkhA/iisL0sKqHJHLElBVkv0UmKaJIYGRqCemGgnguCrL1Qk6XDLvdNzMBQ j4zA== X-Gm-Message-State: AAQBX9cXCruHk3+1t8KjQRFw7Z78Cl6oCwvlycSmdjUW1irEcrqg8Vvu QljpUMxmHnHHeSfCIxzzaipulA== X-Google-Smtp-Source: AKy350bUfWmomBUgOSKakyDoihBlbriDnLkKr+maH+SmOymveI4bbkcZZJHlbNIaaMvcTwEjmj518w== X-Received: by 2002:a05:6a20:b213:b0:e1:2d3d:6b11 with SMTP id eh19-20020a056a20b21300b000e12d3d6b11mr798344pzb.11.1680732643261; Wed, 05 Apr 2023 15:10:43 -0700 (PDT) Received: from dread.disaster.area (pa49-181-91-157.pa.nsw.optusnet.com.au. [49.181.91.157]) by smtp.gmail.com with ESMTPSA id f9-20020a631009000000b004ff6b744248sm9594682pgl.48.2023.04.05.15.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 15:10:42 -0700 (PDT) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1pkBKx-00HUPP-6E; Thu, 06 Apr 2023 08:10:39 +1000 Date: Thu, 6 Apr 2023 08:10:39 +1000 To: "Darrick J. Wong" Subject: Re: [PATCH v2 19/23] xfs: disable direct read path for fs-verity sealed files Message-ID: <20230405221039.GP3223426@dread.disaster.area> References: <20230404145319.2057051-1-aalbersh@redhat.com> <20230404145319.2057051-20-aalbersh@redhat.com> <20230404161047.GA109974@frogsfrogsfrogs> <20230405150142.3jmxzo5i27bbc4c4@aalbersh.remote.csb> <20230405150927.GD303486@frogsfrogsfrogs> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230405150927.GD303486@frogsfrogsfrogs> X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Dave Chinner via Linux-erofs Reply-To: Dave Chinner Cc: fsverity@lists.linux.dev, hch@infradead.org, jth@kernel.org, agruenba@redhat.com, linux-ext4@vger.kernel.org, Andrey Albershteyn , linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, dchinner@redhat.com, rpeterso@redhat.com, damien.lemoal@opensource.wdc.com, linux-erofs@lists.ozlabs.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" On Wed, Apr 05, 2023 at 08:09:27AM -0700, Darrick J. Wong wrote: > On Wed, Apr 05, 2023 at 05:01:42PM +0200, Andrey Albershteyn wrote: > > 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. > > Thinking about this a little more -- I suppose we shouldn't just go > breaking directio reads from a verity file if we can help it. Is there > a way to ask fsverity to perform its validation against some arbitrary > memory buffer that happens to be fs-block aligned? The memory buffer doesn't even need to be fs-block aligned - it just needs to be a pointer to memory the kernel can read... We also need fsverity to be able to handle being passed mapped kernel memory rather than pages/folios for the merkle tree interfaces. That way we can just pass it the mapped buffer memory straight from the xfs-buf and we don't have to do the whacky "copy from xattr xfs_bufs into pages so fsverity can take temporary reference counts on what it thinks are page cache pages" as it walks the merkle tree. -Dave. -- Dave Chinner david@fromorbit.com From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AB3C7C77B6C for ; Wed, 5 Apr 2023 22:11:06 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pkBLL-00067t-TB; Wed, 05 Apr 2023 22:11:03 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pkBLA-00067a-Bo for linux-f2fs-devel@lists.sourceforge.net; Wed, 05 Apr 2023 22:10:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=B//xqY4ihi9FjKHnI/3HItAd5zkVskGSEhbTE9KO+uM=; b=CetbPSP+mVxkTS1LGoKtuwNEiY VrYgPsR95eKDdgP2J0/dkwgTNKbuhACZ2EuTdk+uu+XRAReI32NiMusrppDS2Suut0bDi381XNcb2 q6jWapMBoNwd2jXqlCiFrVY9rLq0oOgF/pKxMi0IS+6/97AOcRMzFxiN3K1QQaSNYYBg=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=B//xqY4ihi9FjKHnI/3HItAd5zkVskGSEhbTE9KO+uM=; b=HX1aOLj8G78Q0KjlvBMeqySP0l 20tTCXKOI8QfQN7TsOxESII4WSbg0h8aDvqxKuLMCu9Myc58+lAO6EQD4yUKBVkrbvg49roIxWJW5 HxGrG69QoApm/D9AvTGizYqkwTkkuCzSMXU8tE0OwTdP0Y0cmMfBtF3V+BT2/rT2jUTU=; Received: from mail-pj1-f46.google.com ([209.85.216.46]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1pkBL6-00GKSw-Tq for linux-f2fs-devel@lists.sourceforge.net; Wed, 05 Apr 2023 22:10:51 +0000 Received: by mail-pj1-f46.google.com with SMTP id f6-20020a17090ac28600b0023b9bf9eb63so38722494pjt.5 for ; Wed, 05 Apr 2023 15:10:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20210112.gappssmtp.com; s=20210112; t=1680732643; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=B//xqY4ihi9FjKHnI/3HItAd5zkVskGSEhbTE9KO+uM=; b=STgTGHnum63TLfzSA43g0jKvWgwzTlnLbiRBsWUDeVndg2q0Tgh+Q3SOrbj2o7vE8S OqWTQe02GPPEl+JqPtH+BqPfmvs//jeLjVwIl0XhMyQ3tek4wkSILn+nMJgz4Ucj0eU6 j0kbTbgibsNwkwrKvah9VMelOuBXgvxgwHI0pALQfzh2rVeht1RKj8+pbzrOR/bp501l L/VGUA0YqBD4tzXgV0KmZb3YviN4H/dsXP/5STmaPKBN43t4NUaSN54t71hCcI0H1oaq zP9YTNcdWyFHeWlBYJ4HXGKqXy09Gf/KRy8kJqqXI11hkg8FYce95UQ1oCAGXdz0Kzst BsJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680732643; 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=B//xqY4ihi9FjKHnI/3HItAd5zkVskGSEhbTE9KO+uM=; b=JBGfuIpYx/BExEmQ+lB51jYEVKlCmNK+ylJIYni0XfdswmPstdgOMCawKq5xQ+9lq+ drMVwMsMeHwwgRcMmx8yIdyNL40cgYZlQ+x2Zn1kyCAnAAqKiIe7nmG9fI/xQ9ohAgLb /3CyBKY2kzMSKbNPyHWYsD0CwuDM1o7BhguzSAIu5UQEYVJ6sp02JmezkWNUoedxtmr5 1Q1QlHbH7rU9wfyBHH8oWjek0vKpBq6phW5u9PxA1mjwsOiYF/Pq7g1LWrfXrWBKLYwS 76YhkeN+Kyaw6O/2oRczRBoSUtXglrce9H/IBBpLxjp2Sf0X75Kys9JhL3eJaPcM3Zv4 qhxg== X-Gm-Message-State: AAQBX9druQpQl+X3NOdBcAnaYqnLrPX05UNrAIJTMNWIYFqhoZD/SBJP WpFOl66/73JFDc7pxHnLEcAXTg== X-Google-Smtp-Source: AKy350bUfWmomBUgOSKakyDoihBlbriDnLkKr+maH+SmOymveI4bbkcZZJHlbNIaaMvcTwEjmj518w== X-Received: by 2002:a05:6a20:b213:b0:e1:2d3d:6b11 with SMTP id eh19-20020a056a20b21300b000e12d3d6b11mr798344pzb.11.1680732643261; Wed, 05 Apr 2023 15:10:43 -0700 (PDT) Received: from dread.disaster.area (pa49-181-91-157.pa.nsw.optusnet.com.au. [49.181.91.157]) by smtp.gmail.com with ESMTPSA id f9-20020a631009000000b004ff6b744248sm9594682pgl.48.2023.04.05.15.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 15:10:42 -0700 (PDT) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1pkBKx-00HUPP-6E; Thu, 06 Apr 2023 08:10:39 +1000 Date: Thu, 6 Apr 2023 08:10:39 +1000 To: "Darrick J. Wong" Message-ID: <20230405221039.GP3223426@dread.disaster.area> References: <20230404145319.2057051-1-aalbersh@redhat.com> <20230404145319.2057051-20-aalbersh@redhat.com> <20230404161047.GA109974@frogsfrogsfrogs> <20230405150142.3jmxzo5i27bbc4c4@aalbersh.remote.csb> <20230405150927.GD303486@frogsfrogsfrogs> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230405150927.GD303486@frogsfrogsfrogs> X-Headers-End: 1pkBL6-00GKSw-Tq Subject: Re: [f2fs-dev] [PATCH v2 19/23] xfs: disable direct read path for fs-verity sealed files X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Dave Chinner via Linux-f2fs-devel Reply-To: Dave Chinner Cc: fsverity@lists.linux.dev, hch@infradead.org, jth@kernel.org, agruenba@redhat.com, linux-ext4@vger.kernel.org, Andrey Albershteyn , linux-f2fs-devel@lists.sourceforge.net, ebiggers@kernel.org, cluster-devel@redhat.com, dchinner@redhat.com, rpeterso@redhat.com, xiang@kernel.org, damien.lemoal@opensource.wdc.com, linux-erofs@lists.ozlabs.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On Wed, Apr 05, 2023 at 08:09:27AM -0700, Darrick J. Wong wrote: > On Wed, Apr 05, 2023 at 05:01:42PM +0200, Andrey Albershteyn wrote: > > 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. > > Thinking about this a little more -- I suppose we shouldn't just go > breaking directio reads from a verity file if we can help it. Is there > a way to ask fsverity to perform its validation against some arbitrary > memory buffer that happens to be fs-block aligned? The memory buffer doesn't even need to be fs-block aligned - it just needs to be a pointer to memory the kernel can read... We also need fsverity to be able to handle being passed mapped kernel memory rather than pages/folios for the merkle tree interfaces. That way we can just pass it the mapped buffer memory straight from the xfs-buf and we don't have to do the whacky "copy from xattr xfs_bufs into pages so fsverity can take temporary reference counts on what it thinks are page cache pages" as it walks the merkle tree. -Dave. -- Dave Chinner david@fromorbit.com _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel