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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BEBBC76196 for ; Tue, 28 Mar 2023 05:20:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231833AbjC1FUS (ORCPT ); Tue, 28 Mar 2023 01:20:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231904AbjC1FUP (ORCPT ); Tue, 28 Mar 2023 01:20:15 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28F482709 for ; Mon, 27 Mar 2023 22:20:14 -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=iBTsjEEL1InbVMyfyileoSgPUNS/IueXumKnKaOXdhY=; b=NMXEvIodrgaYME41ZHwmUDeQbt 6rXW8M9dC9/O1yfaRAiCfnAXENB4pBMJqluJ6i8yvUhZ5luEmBl9/0f4SsrKzqkAkBE9Hz6tWizHo a57NEiBkcA5rIZW++GkhX6aYTtp9M2DP683DwBW2riKvEXhbYVOQy3GtT20s7x5ixOEJaURcmPZ2E 0mHVO3LpGrc9U7eBtx5/vOrL4/kQWkP7mWOO60nHDC6diKdvfiV/722zO17ujd989zFNz34TyD967 9HEBAXGC8rUw1nqrlAyGIIztGvvc5IfxC8a/4eYWKvxRkQ4hO3UhjeGLrIjayt1iRNngIKBpafopV UdYYDDog==; Received: from [182.171.77.115] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1ph1kg-00DAVM-2b; Tue, 28 Mar 2023 05:20:11 +0000 From: Christoph Hellwig To: Chris Mason , Josef Bacik , David Sterba Cc: Boris Burkov , Johannes Thumshirn , Naohiro Aota , linux-btrfs@vger.kernel.org, Johannes Thumshirn Subject: [PATCH 04/11] btrfs: move ordered_extent internal sanity checks into btrfs_split_ordered_extent Date: Tue, 28 Mar 2023 14:19:50 +0900 Message-Id: <20230328051957.1161316-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230328051957.1161316-1-hch@lst.de> References: <20230328051957.1161316-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Move the three checks that are about ordered extent internal sanity checking into btrfs_split_ordered_extent instead of doing them in the higher level btrfs_extract_ordered_extent routine. Signed-off-by: Christoph Hellwig Tested-by: Johannes Thumshirn --- fs/btrfs/inode.c | 18 ------------------ fs/btrfs/ordered-data.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 1441fe89a208d9..5013d1b0b00e29 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2646,18 +2646,6 @@ blk_status_t btrfs_extract_ordered_extent(struct btrfs_bio *bbio) if (ordered->disk_num_bytes == len) goto out; - /* We cannot split once end_bio'd ordered extent */ - if (WARN_ON_ONCE(ordered->bytes_left != ordered->disk_num_bytes)) { - ret = -EINVAL; - goto out; - } - - /* We cannot split a compressed ordered extent */ - if (WARN_ON_ONCE(ordered->disk_num_bytes != ordered->num_bytes)) { - ret = -EINVAL; - goto out; - } - ordered_end = ordered->disk_bytenr + ordered->disk_num_bytes; /* bio must be in one ordered extent */ if (WARN_ON_ONCE(start < ordered->disk_bytenr || end > ordered_end)) { @@ -2665,12 +2653,6 @@ blk_status_t btrfs_extract_ordered_extent(struct btrfs_bio *bbio) goto out; } - /* Checksum list should be empty */ - if (WARN_ON_ONCE(!list_empty(&ordered->list))) { - ret = -EINVAL; - goto out; - } - file_len = ordered->num_bytes; pre = start - ordered->disk_bytenr; post = ordered_end - end; diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index 1848d0d1a9c41e..4b46406c0c8af5 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -1149,6 +1149,16 @@ int btrfs_split_ordered_extent(struct btrfs_ordered_extent *ordered, u64 pre, trace_btrfs_ordered_extent_split(BTRFS_I(inode), ordered); + /* We cannot split once end_bio'd ordered extent */ + if (WARN_ON_ONCE(ordered->bytes_left != ordered->disk_num_bytes)) + return -EINVAL; + /* We cannot split a compressed ordered extent */ + if (WARN_ON_ONCE(ordered->disk_num_bytes != ordered->num_bytes)) + return -EINVAL; + /* Checksum list should be empty */ + if (WARN_ON_ONCE(!list_empty(&ordered->list))) + return -EINVAL; + spin_lock_irq(&tree->lock); /* Remove from tree once */ node = &ordered->rb_node; -- 2.39.2