From patchwork Tue Mar 28 05:19:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13190509 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 40C86C76196 for ; Tue, 28 Mar 2023 05:20:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231970AbjC1FUb (ORCPT ); Tue, 28 Mar 2023 01:20:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231976AbjC1FU3 (ORCPT ); Tue, 28 Mar 2023 01:20:29 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A54ED211F for ; Mon, 27 Mar 2023 22:20:27 -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=6Ylr6w2t07ku0X5pX8I8Gr6hWRhaigyc66RGqOroY5o=; b=elMmR8I82xKSluw4YV7sJHBjgl yeIR0rIu9xv0eCeFf+EMGzjSX139ER6hqYB9RWeLxG5qJTVkCQqRkpJfc+uFDEs7NX7Qq/yZj1sp+ m/OCoXTuMaQMY6dsU4H1fuw05QZEcKiC8z2Ln7Kcxy2VUBbpR6JP0YaYCGZZknVe29lIIrlWUQ+ys EVFJWkFoe33I8ZjbEyvuroUd6R7WOdZwpC7ccjOgRQbSIsQ8aWg3hpHw+qvlGKbys7jrOwOfmG8g9 ENZm5bJdQiCtfrFVjJuph4o+mjIK0eeOwy08tz0jlqRet3PSpex1JAwdC17pLXjgcf0Abs1Ee720a rIkqRpCQ==; Received: from [182.171.77.115] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1ph1ku-00DAZK-1a; Tue, 28 Mar 2023 05:20:24 +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 10/11] btrfs: don't split nocow extent_maps in btrfs_extract_ordered_extent Date: Tue, 28 Mar 2023 14:19:56 +0900 Message-Id: <20230328051957.1161316-11-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 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 From: Boris Burkov Nocow writes just overwrite an existing extent map, which thus should not be split in btrfs_extract_ordered_extent. The nocow case can't currently happen as btrfs_extract_ordered_extent is only used on zoned devices that do not support nocow writes, but this will change soon. Signed-off-by: Boris Burkov [hch: split from a larger patch, wrote a commit log] Signed-off-by: Christoph Hellwig Tested-by: Johannes Thumshirn --- fs/btrfs/inode.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 042018271baa37..a791faabb2ec87 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2622,6 +2622,14 @@ int btrfs_extract_ordered_extent(struct btrfs_bio *bbio, ret = btrfs_split_ordered_extent(ordered, len); if (ret) return ret; + + /* + * Don't split the extent_map for nocow extents, as we're writing + * into a pre-existing one. + */ + if (test_bit(BTRFS_ORDERED_NOCOW, &ordered->flags)) + return 0; + return split_extent_map(inode, bbio->file_offset, ordered_len, len); }