From patchwork Wed May 31 06:04:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13261495 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 994A9C77B7A for ; Wed, 31 May 2023 06:05:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234316AbjEaGFU (ORCPT ); Wed, 31 May 2023 02:05:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbjEaGFT (ORCPT ); Wed, 31 May 2023 02:05:19 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBEFD11C for ; Tue, 30 May 2023 23:05:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=oAVqdlqWdwKkStitJSHtqa34ShHS8IoE+KVEKcpOlsw=; b=R2pUAVtIoMmuiT2wUMzPkffoCV ZVTDN8wTHT3cIcyOVW2BNfsCnVkJLXQyXpL2tijOQeGjkKqMFlB27FA8tZ9AVU1l1Mg3BKCBAInkw Uba8YRjGt0ZsDqrIqBUU1EvamtprkfUQUojMQucJV4GT9d0N91cZCUuybaWPxsFYkEHFF3f9saP0u jtqbH437gRxHoxWxHGxn4+9pNVNmV42LfXOfTnm9DfCOV8jGsnsKBJGQutDHgAU6ufwCUq/gFNfl/ NM20JXQJ9R86GwToI/jhTid1sQxikbVeDwQpUtq16vWvLIm4/HnKSpJ4phy+BTUZVtKXVfJ6Pc7sE uxRKkkLg==; Received: from [2001:4bb8:182:6d06:f5c3:53d7:b5aa:b6a7] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q4ExP-00GF3I-0S; Wed, 31 May 2023 06:05:15 +0000 From: Christoph Hellwig To: Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org Subject: [PATCH 02/16] btrfs: factor out a btrfs_verify_page helper Date: Wed, 31 May 2023 08:04:51 +0200 Message-Id: <20230531060505.468704-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531060505.468704-1-hch@lst.de> References: <20230531060505.468704-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Split all the conditionals for the fsverity calls in end_page_read into a btrfs_verify_page helper to keep the code readable and make additional refacoring easier. Signed-off-by: Christoph Hellwig --- fs/btrfs/extent_io.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 0726c82db309a2..8e42ce48b52e4a 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -481,6 +481,15 @@ void extent_clear_unlock_delalloc(struct btrfs_inode *inode, u64 start, u64 end, start, end, page_ops, NULL); } +static bool btrfs_verify_page(struct page *page, u64 start) +{ + if (!fsverity_active(page->mapping->host) || + PageError(page) || PageUptodate(page) || + start >= i_size_read(page->mapping->host)) + return true; + return fsverity_verify_page(page); +} + static void end_page_read(struct page *page, bool uptodate, u64 start, u32 len) { struct btrfs_fs_info *fs_info = btrfs_sb(page->mapping->host->i_sb); @@ -489,11 +498,7 @@ static void end_page_read(struct page *page, bool uptodate, u64 start, u32 len) start + len <= page_offset(page) + PAGE_SIZE); if (uptodate) { - if (fsverity_active(page->mapping->host) && - !PageError(page) && - !PageUptodate(page) && - start < i_size_read(page->mapping->host) && - !fsverity_verify_page(page)) { + if (!btrfs_verify_page(page, start)) { btrfs_page_set_error(fs_info, page, start, len); } else { btrfs_page_set_uptodate(fs_info, page, start, len);