From patchwork Thu Nov 23 15:47:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 169006 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp538620vqx; Thu, 23 Nov 2023 07:48:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IE79eFuIkrtHJ/Q1JbwhSqmqUvo4ec8pkYi2W12bwysWZzSsame0UENJItr46B0quL+5ffV X-Received: by 2002:a9d:75c3:0:b0:6d7:d84e:f1f4 with SMTP id c3-20020a9d75c3000000b006d7d84ef1f4mr6438627otl.11.1700754522543; Thu, 23 Nov 2023 07:48:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700754522; cv=none; d=google.com; s=arc-20160816; b=ptLRBLdOQuaFfeGWtGKM2XePuMwb7wes2P8oCbGqPdb+QNBIgwPJNaEn6tLPHaU04r 72N9jcOTksyAXxeyZnDJd56VE7KpjZ2/ZJnikknYkEW/HJJqsrB/+ncsqYCKvHGVfUMi DOLQhqTZxMxEi8JBgHEAtSLwt+GX/ejy5ZtZwqlbYfFP82f+HzdJXOadcI+xbq7mz3Vi kAuQa8LzdTqK1NS2MCWkvDKTODxPup+Fv7pqtkU0AHqNA4RKZimnE3HaVLNa8K5IZEVu VLtVqiNkB+X+h3XQ559OAQg6t7NGbU3oCJd3RE3Wm3gXUJeqfketW3jrBIWzqpCyQTJs UaYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :wdcironportexception:ironport-sdr:ironport-sdr:dkim-signature; bh=v8CusPqn9Kg01uhFk9wt+76sSBiwuR56udarGlom3z4=; fh=5/viNv8Fzx+nCNW5PGLTL+Se/9D0Q8TrzLPV3SudCmU=; b=wge6FbfifVIeo6DP2xJHolCE8VspgqU9gKkcoGV7X171ONeuGF6XsAvmPTEvciM660 A0qt9qZ8YNpmqcE3n0XdWwZKJO7CT/jAW3lw1iU9uxaHs2m7CzJs0eZ4l9Pn7stjHjCz ufeot86D/0wMd7qRYXgavNQF8VkgnV81RtvGsEvXIzSHauuwAJ1ABc1AA7t5Jht/ic1I N+7KY2hpCjKJjc0VmGbQcbE7JCf104+lhCmcsBDwQu6IIdS/Jp9PGwQWBalg57B4FMxc Kcx4PZdvcKMiOZ3FF9FelSHHUjk0DVTfXHiF/UAJSgX/FHqR5+Q4qYGiRPwxB+yfWH68 5EXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=rahNFFSN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id bm6-20020a656e86000000b005bdbd1b52d4si1612347pgb.270.2023.11.23.07.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 07:48:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=rahNFFSN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id AC9078068E2F; Thu, 23 Nov 2023 07:48:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346182AbjKWPsB (ORCPT + 99 others); Thu, 23 Nov 2023 10:48:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346190AbjKWPr6 (ORCPT ); Thu, 23 Nov 2023 10:47:58 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 394BA10C4; Thu, 23 Nov 2023 07:48:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1700754485; x=1732290485; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=YR0t4kJbsg/rQjWSgH2abh/zRKciGglDOIEvPoc2P7I=; b=rahNFFSNEKCl9wp3tFBb3T3d+FL4YTJLkDPgL04lMb6k50TcqiY3VViT EMclWijOGmzsQNzSbOWY8LesyEDROwKbS8zJPeBONPhrJ73VAKKaac3NZ xy9HFMlk56NpmpUgm920c+3Cri6FxKZczfwPmv5s2mo8LLLC+yTTgCmpO kwDmZxfps8tp1fqM8JAKubqgdWuFuwGuFnmnut1DnwduLjGQg/Mct+9+6 fZBl4/T4Fx/DFovsUIOHkILmIOF+Q83r0eJe/xogeaBv/fO4bkBF7KwN6 TBDqLVEC+dq9W2G4DNznTX1GhqnxjRoeiJ0eL91vGs5Oi5Scuc7vwk5BJ A==; X-CSE-ConnectionGUID: JowBlqUCTcejboqeqn3hkw== X-CSE-MsgGUID: rgWc+jNbSTuzevXQlWiasw== X-IronPort-AV: E=Sophos;i="6.04,222,1695657600"; d="scan'208";a="3129200" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 23 Nov 2023 23:47:27 +0800 IronPort-SDR: H2b91i91NAiwEos5V1g0Z4jHH0hCm6eSBg0Lrxm2+EhQH9+trT46xFLtWexJjnwqD7JpB5l/az FiQaPAgOBizEmuCT4ENGlLW5ig47aPb8BjPpU869sKXaysxMV854KjuocJrzG6Of0oWFP7hoJe dlI2DYDoyYXmrQjMyoBf7RhaeSme1OWNNAYo7/2YBJN/RFXJStunqJU3NIcjXPLi+yEgO5zt83 YVlgOaJZxhkIJpFTFLJlk3vBCaohdHNyc5LfKMIa6xaYMWv1x2ju6zG/gHN5UvBpFh2mI+p9j9 s4Q= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 23 Nov 2023 06:58:43 -0800 IronPort-SDR: 0z6dPAeIYvdBScoL+Y/i3Iff/c07B61B/rY/Z6npaAVJYfe+K6htIJjpnjmCMlVv/VN5nlnrvY A0AkbTzyZubCf5cF774S2sK/92jeAX6yuGZIDn2vz2SEx9hS67/f8bp37nJf5EBwgZbmLQIc8A ns9TaUTH/6VydUzBBmg9tullFJHsqpQ3qDk+HAaXDgLe6O3+Zf+u8a+knQn6u5sdIIXMRo8A2m u4Vupthh+nsKWeYScULbV3pqYevK2ng46GV+DUEA3ZELYyfezdZdjwsqdBk+QLKnbbdkD1UYL3 VGg= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip01.wdc.com with ESMTP; 23 Nov 2023 07:47:26 -0800 From: Johannes Thumshirn Date: Thu, 23 Nov 2023 07:47:15 -0800 Subject: [PATCH v2 1/5] btrfs: rename EXTENT_BUFFER_NO_CHECK to EXTENT_BUFFER_ZONED_ZEROOUT MIME-Version: 1.0 Message-Id: <20231123-josef-generic-163-v2-1-ed1a79a8e51e@wdc.com> References: <20231123-josef-generic-163-v2-0-ed1a79a8e51e@wdc.com> In-Reply-To: <20231123-josef-generic-163-v2-0-ed1a79a8e51e@wdc.com> To: Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Naohiro Aota , Johannes Thumshirn X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1700754443; l=3212; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=YR0t4kJbsg/rQjWSgH2abh/zRKciGglDOIEvPoc2P7I=; b=TkJecc8Wo6SeIaMwQIaMhC8B4+Q3j63Hbdtaowtmu0kWfKcsprkpN/fxhsJXiLhKnOouzRKSE YX41J3GMJPjCCBJKEA1nzOGIVxGN0jREPEJdFj2FLnJLZRiTcYW+FkB X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 23 Nov 2023 07:48:29 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783370374152734152 X-GMAIL-MSGID: 1783370374152734152 EXTENT_BUFFER_ZONED_ZEROOUT better describes the state of the extent buffer, namely it is written as all zeros. This is needed in zoned mode, to preserve I/O ordering. Reviewed-by: Christoph Hellwig Reviewed-by: Josef Bacik Signed-off-by: Johannes Thumshirn --- fs/btrfs/disk-io.c | 2 +- fs/btrfs/extent-tree.c | 2 +- fs/btrfs/extent_io.c | 2 +- fs/btrfs/extent_io.h | 3 ++- fs/btrfs/zoned.c | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 5ac6789ca55f..460b88526f56 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -254,7 +254,7 @@ blk_status_t btree_csum_one_bio(struct btrfs_bio *bbio) if (WARN_ON_ONCE(bbio->bio.bi_iter.bi_size != eb->len)) return BLK_STS_IOERR; - if (test_bit(EXTENT_BUFFER_NO_CHECK, &eb->bflags)) { + if (test_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags)) { WARN_ON_ONCE(found_start != 0); return BLK_STS_OK; } diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 0455935ff558..2d8379d34a24 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -5041,7 +5041,7 @@ btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root, __btrfs_tree_lock(buf, nest); btrfs_clear_buffer_dirty(trans, buf); clear_bit(EXTENT_BUFFER_STALE, &buf->bflags); - clear_bit(EXTENT_BUFFER_NO_CHECK, &buf->bflags); + clear_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &buf->bflags); set_extent_buffer_uptodate(buf); diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 03cef28d9e37..49514ef829fb 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4139,7 +4139,7 @@ static void __write_extent_buffer(const struct extent_buffer *eb, /* For unmapped (dummy) ebs, no need to check their uptodate status. */ const bool check_uptodate = !test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags); - WARN_ON(test_bit(EXTENT_BUFFER_NO_CHECK, &eb->bflags)); + WARN_ON(test_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags)); if (check_eb_range(eb, start, len)) return; diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index 2171057a4477..b8adb5b6fb21 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -28,7 +28,8 @@ enum { EXTENT_BUFFER_IN_TREE, /* write IO error */ EXTENT_BUFFER_WRITE_ERR, - EXTENT_BUFFER_NO_CHECK, + /* Indicate the extent buffer is written zeroed out (for zoned) */ + EXTENT_BUFFER_ZONED_ZEROOUT, /* Indicate that extent buffer pages a being read */ EXTENT_BUFFER_READING, }; diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 188378ca19c7..b9bfde6fb929 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1725,7 +1725,7 @@ void btrfs_redirty_list_add(struct btrfs_transaction *trans, ASSERT(!test_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)); memzero_extent_buffer(eb, 0, eb->len); - set_bit(EXTENT_BUFFER_NO_CHECK, &eb->bflags); + set_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags); set_extent_buffer_dirty(eb); set_extent_bit(&trans->dirty_pages, eb->start, eb->start + eb->len - 1, EXTENT_DIRTY, NULL); From patchwork Thu Nov 23 15:47:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 169005 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp538612vqx; Thu, 23 Nov 2023 07:48:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGlkpq6usf04nFJyhVb5omOR4h0Jy471hnmPJxZ+NsxDxPKOx3gGxhoG6xvjHo3XHWktXz4 X-Received: by 2002:a17:902:8341:b0:1c3:1f0c:fb82 with SMTP id z1-20020a170902834100b001c31f0cfb82mr4835036pln.41.1700754520510; Thu, 23 Nov 2023 07:48:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700754520; cv=none; d=google.com; s=arc-20160816; b=Kw8FXD2Zjpzf8DxGhAP47beJnNl0fakJAmQIAvGIAsdFec6HqBVQerx90koRCeJ0Ir Pozl/CgrMRDEiwrxJkTHFOSvbmJlAom0nqWURQyAqQYoBsgu//gFud9RZHQSDSm26GgR RdlNpLROwPUu27IgN5DWYexYMHOHcTP6k1+v+uegQAzYc/h6t7ZTLtrvXZ6T2O21Il2i sxbkbI3xIkjuFiqSHNcru5QE+W9Hto26BVbEnHVYYvvvLOK9MDuyYgkfINKPW0J4esNj +g42xKl9EkpXNwXjQtrlichnJ5YC+rOcAY8N29GP7KmJzLIMPFBh2+r8lOKUlYXwgKy4 BvLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :wdcironportexception:ironport-sdr:ironport-sdr:dkim-signature; bh=cRqnRQ+A/26ZyuQR771lSW30xSFox6va9f6CMgoA7Rc=; fh=5/viNv8Fzx+nCNW5PGLTL+Se/9D0Q8TrzLPV3SudCmU=; b=qxYs6zqq6CWpjbCCs3iSQ1VFaA3BwJ2uM0yw/1em0wySvvb627K3BvBFMm7tBLdPMM BNEyJyp1Ec1vvgibDHTfw9mGHpTlWwcDmMf5Tlhv/f+MFcd+d0GIFzneBwAgPYpUUNcM 9XSY2Bg3XlHrQWe6/5OUAjm6hxj+Di26BsrnwPneEeHlzwoUIrWG2i6mmJUwl34mhgr6 5xJradi499+uL0Y8wGFl3gTChH8DowSMH6SIdi5xM0GuqGoW8JQ3SSc8Vu3sVp1P3wDq Ew9PacD1LV/wEoaFccocQcodujxkYocx8WVSQWQmSb6gkADtWy6i4I0hEh7yC/k4Ty07 atAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="R+9dpOg/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id l15-20020a170903244f00b001c624cbc92dsi1409908pls.296.2023.11.23.07.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 07:48:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="R+9dpOg/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 93B31823C82F; Thu, 23 Nov 2023 07:48:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346209AbjKWPsG (ORCPT + 99 others); Thu, 23 Nov 2023 10:48:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346191AbjKWPr6 (ORCPT ); Thu, 23 Nov 2023 10:47:58 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60E7310C7; Thu, 23 Nov 2023 07:48:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1700754485; x=1732290485; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=wDRvUXJ6mVtVEukoOw489ax7uRNihNJAyUogAfyAXjo=; b=R+9dpOg/6Hp3aHGsBdmm0rvSxUfETtUxXGRJrfe4pDF0I6dES9gQQwUl dkNlQNcTF++HUIZM+w9PsFDUVlMS9/USXW5czV5kJbRtvM3JqtNeFJ0r+ NO9s6I8T6b/LOnf7i3At4Kw7vGu30xBtR+Uh4C8MarjCLlQ6UwrMh2vpD mkhXgQ/EfojE1WhN2sCvUpuZwfQd/lrJ3NwnlHtWSEKO2k7jobRfzZNyq qoLGgkUGtV01hW4JAzdEs0x8ILESpNdQmixRAElFypUSm+opPCtKprNA9 oqjKuh0aY81loE4aa3ZZ9cEeGOYUCUswYbfoKGIa1qhOGcswRbhbHHNvU Q==; X-CSE-ConnectionGUID: qm7DTtz6QSmbuesitw53/A== X-CSE-MsgGUID: dn+w52BeRFuwgv74kXNuBA== X-IronPort-AV: E=Sophos;i="6.04,222,1695657600"; d="scan'208";a="3129202" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 23 Nov 2023 23:47:30 +0800 IronPort-SDR: iQWjHGWnJ2d3Al3koAjvSDHT6ncLcFx6OLwirWGTxoRWOVkAAG93GoZ/J9gKGFZt73/bndgdYb gldZet+AtQDEyrOjMC1YoCj68EWhgrYY0HaoxJ7AitfbSfN8H3tb/948RLhT85c1ffLoeP/mMx ghclrDD7DJHG/tswgccqFZNyy/O/hUjqwQgw2jGj4r5mbKlGoUS40uUm2WaDEzkALoj4Lgyb9h fMFVT59YyOBvleveehkFzLor6S9ORxp7ihkMHqgJT3Q5d/z8RAANpgxrfGcia5xcVMuhWv4XTY HFI= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 23 Nov 2023 06:58:46 -0800 IronPort-SDR: lsfs8oPCU2giWsDgpzJxi9WE8DUXV7CFkSxklSygvHSG9EcNPfeN4Q4gYK83j5EJMjQauUSJbN 0LuCQNzc8GKl7XOJHWw3MJ+mLXoUhI5RZcpXcSLj930p2e7dQtsmHT4fVu7TAtaRYQTXgcM6Zy 6IWKfhkMtvD1srEUhdqhmdJ/3i9CZu9u99dUftFIVRXFOML7abbd3wAoYXeS/ooUCeN2BPlt5p 7neHxvd2fgcTfUu0rwpk/OSaWS44EGWxlLLPpceVXBfNJ7SmN8Phgzsj/OnS4lVDNSIPfCzto3 JsU= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip01.wdc.com with ESMTP; 23 Nov 2023 07:47:27 -0800 From: Johannes Thumshirn Date: Thu, 23 Nov 2023 07:47:16 -0800 Subject: [PATCH v2 2/5] btrfs: zoned: don't clear dirty flag of extent buffer MIME-Version: 1.0 Message-Id: <20231123-josef-generic-163-v2-2-ed1a79a8e51e@wdc.com> References: <20231123-josef-generic-163-v2-0-ed1a79a8e51e@wdc.com> In-Reply-To: <20231123-josef-generic-163-v2-0-ed1a79a8e51e@wdc.com> To: Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Naohiro Aota , Johannes Thumshirn X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1700754443; l=3002; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=wDRvUXJ6mVtVEukoOw489ax7uRNihNJAyUogAfyAXjo=; b=sWqCwaHo+SgYIPyXduOpD5Wi4szyqt/vJ2WunGbdgKcWSpUf3mkQvzvJRN8D03LagqUwYT2YG ExQbTtlzkgRBdoyFKyIELaHsoyYWiZUrx4ehZgrX39GtkPzHYsyrjo1 X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 23 Nov 2023 07:48:37 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783370371874147282 X-GMAIL-MSGID: 1783370371874147282 One a zoned filesystem, never clear the dirty flag of an extent buffer, but instead mark it as zeroout. On writeout, when encountering a marked extent_buffer, zero it out. Reviewed-by: Christoph Hellwig Reviewed-by: Josef Bacik Signed-off-by: Johannes Thumshirn --- fs/btrfs/disk-io.c | 7 ++++++- fs/btrfs/extent_io.c | 16 ++++++++++++++-- fs/btrfs/zoned.c | 3 ++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 460b88526f56..9c09062d3d0a 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -254,8 +254,13 @@ blk_status_t btree_csum_one_bio(struct btrfs_bio *bbio) if (WARN_ON_ONCE(bbio->bio.bi_iter.bi_size != eb->len)) return BLK_STS_IOERR; + /* + * If an extent_buffer is marked as EXTENT_BUFFER_ZONED_ZEROOUT, don't + * checksum it but zero-out its content. This is done to preserve + * ordering of I/O without unnecessarily writing out data. + */ if (test_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags)) { - WARN_ON_ONCE(found_start != 0); + memzero_extent_buffer(eb, 0, eb->len); return BLK_STS_OK; } diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 49514ef829fb..c378094b5cc8 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3748,6 +3748,20 @@ void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans, if (trans && btrfs_header_generation(eb) != trans->transid) return; + /* + * Instead of clearing the dirty flag off of the buffer, mark it as + * EXTENT_BUFFER_ZONED_ZEROOUT. This allows us to preserve + * write-ordering in zoned mode, without the need to later re-dirty + * the extent_buffer. + * + * The actual zeroout of the buffer will happen later in + * btree_csum_one_bio. + */ + if (btrfs_is_zoned(fs_info)) { + set_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags); + return; + } + if (!test_and_clear_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)) return; @@ -4139,8 +4153,6 @@ static void __write_extent_buffer(const struct extent_buffer *eb, /* For unmapped (dummy) ebs, no need to check their uptodate status. */ const bool check_uptodate = !test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags); - WARN_ON(test_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags)); - if (check_eb_range(eb, start, len)) return; diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index b9bfde6fb929..ed8e002b33e7 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1722,7 +1722,8 @@ void btrfs_redirty_list_add(struct btrfs_transaction *trans, btrfs_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN)) return; - ASSERT(!test_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)); + ASSERT(test_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)); + ASSERT(test_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags)); memzero_extent_buffer(eb, 0, eb->len); set_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags); From patchwork Thu Nov 23 15:47:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 169008 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp538970vqx; Thu, 23 Nov 2023 07:49:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGI+W84iV3mwN9UBdk5bZR/vMIEEZSgl9Krbl9afO6wSvDT+ee1jaLA+JO2A6br4IIUH/LQ X-Received: by 2002:a05:6a00:3992:b0:6c4:e7a0:af4a with SMTP id fi18-20020a056a00399200b006c4e7a0af4amr6671477pfb.32.1700754554187; Thu, 23 Nov 2023 07:49:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700754554; cv=none; d=google.com; s=arc-20160816; b=TrlzHM9V0s1DY412tDe3XXnYhoDSPgpzf6hEopNByOr0ULfUdajBd9TSnURaTLk+D4 dpkZyyHKJAprS/3nrIDd1sWeNF8KPG36VpdMaS36emR9A0Hw5hf6DDfQDlRHLna7GSt+ pEJOr3ZpmgxhAu1gnLmXPJHjE3swq8yLOWIW+qj2ACuBKdfyi/rez25xyWYF3cY9Mc/+ n/uul4XRM27RdaquCdX/GKo1Wd1XsCjXgzLr10DYtCW0vA9DH+eSylLthEqtAxjnAJvV v7aBQV4yvK/+0iWATrxlcBphsHkIegC8s2VKYCqNJSJZ7tILU+xnV2/Jf65fuiAOccRX VcjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :wdcironportexception:ironport-sdr:ironport-sdr:dkim-signature; bh=13kGOsIskFNMNbuYckRX7bAVAvExR89ma0xMrnVpzco=; fh=5/viNv8Fzx+nCNW5PGLTL+Se/9D0Q8TrzLPV3SudCmU=; b=TpPn6lLqEtI5obkBs8xENRhwRWKsk5yBjgbH8vP+nR61TCfwxvhVnYdVLI2N5h/fUB aDHCvlWWSiFSCO/ZUvKwOBR2XxEgSISZmCSmbHGP0Ozucbu36EPgDBCkODzpYXpK419R OsfVVXhZpE7O6VozEBgZ/vw5X5GAUHm/P4gp+lqLtrxIQUWwKg2+EHZic56YNffwBsqO uKS/ok7PiMiFX0b783JqVyB6q4CFez9Ffg1m+8plrhGVUMLj/urQ2Nh001HLA9l8BpB7 U0d3s4BtzUiwmKUBn/LfG22Ud33sf3LaInv87R6XwiyzcCKpLkRWHUJeiA92K6rjaVCv pi0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=qKFFCrTM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id i34-20020a635422000000b005c215b317e9si1496544pgb.478.2023.11.23.07.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 07:49:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=qKFFCrTM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 05A4A8068E1C; Thu, 23 Nov 2023 07:49:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346335AbjKWPtA (ORCPT + 99 others); Thu, 23 Nov 2023 10:49:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346291AbjKWPsj (ORCPT ); Thu, 23 Nov 2023 10:48:39 -0500 Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F352119BB; Thu, 23 Nov 2023 07:48:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1700754515; x=1732290515; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=HOPXPFmYGX+fut8IJwT4SBFWWVBiLfZukFL078WjfiM=; b=qKFFCrTMJLAKNXOmg0w5aPJH2wDR+rZv96RtSmvUdSKoCTpf4K3sxCTb N56NUx1BSx/BxKGFYWn0NEsAhFs8Co1/HSZKbeH7GWIB4rFYnpIlci6s5 0RwA0I6T+bZx0NgkUqJFIlfvp39gSum6fjkW+SZQHiqD90YwQ/2G1xUH0 l7POyvid6je/vwT51eTjoy6MDG6t/wEjCQRCjWXZCTVtAr0UUv3V9pdVy dR294BHPq5g7R+X52/3ItB+AqNY9At9YPmDfgdOQgfDefMRgQC7y2c5na mdS6U6dLuCkisany3NiTciKMKXnx1nZMPj5idXIWOgwplFaq351IL51KN A==; X-CSE-ConnectionGUID: 8g76Me+lSqOa0UHTWNox7Q== X-CSE-MsgGUID: /rJcyYQkQZqGU36K81u0Gw== X-IronPort-AV: E=Sophos;i="6.04,222,1695657600"; d="scan'208";a="3212875" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 23 Nov 2023 23:47:29 +0800 IronPort-SDR: ZexTaF7uWBJhCRTveBwUZshhKEJRzyspGrgwZ/RoueqGaCSCiGl4WJpjF/0Wl4wpZqb/8Arlke u1dY0QXPs5Q0PadUskqNEmrEMSUedrW89wjAg3CftAkFjESm8uqxSlehg6FBKom96ML5DaaN47 RommXjoTZtNO5DTFndIuhUZKgbCcyYrmHlNbms0fQnZOvB2mkOI4L/3vMuRuG3yLKC7PiiFvY9 1hV3mHEv+O8acLKkUN75fO8a2Skg96wAcdFgjYbBIbSY2aEAv2WIrffBBkA9msx6S0KEIW+ipK LB4= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 23 Nov 2023 06:53:05 -0800 IronPort-SDR: 4gWleuQO67fJvwyIVA88tf4O/Dey0Do5vlLfrzVDp4ztY/53HAoG2L8RaKoQxUVteukOjOgPdq DCbLRrxrCQvUsureKTV+gWqCwjns5hE0RgH1/SASaw1gH1aBGywdS37zYofD4E742Ca+WGHWq9 EKyFBVJhrZUyd43GcPQuLyicvfI2Ry629Xf51wSq1oeYCBCkJUVZpa/t9KZnmTTZTPUelYqibm pMibdUG4OCvbeaQ7VjyiDVsuXi31QlFnukDnDHbWzkI6dFU4BintgX/FXx2swREqYXattKcIUC GaI= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip01.wdc.com with ESMTP; 23 Nov 2023 07:47:28 -0800 From: Johannes Thumshirn Date: Thu, 23 Nov 2023 07:47:17 -0800 Subject: [PATCH v2 3/5] btrfs: remove now unneeded btrfs_redirty_list_add MIME-Version: 1.0 Message-Id: <20231123-josef-generic-163-v2-3-ed1a79a8e51e@wdc.com> References: <20231123-josef-generic-163-v2-0-ed1a79a8e51e@wdc.com> In-Reply-To: <20231123-josef-generic-163-v2-0-ed1a79a8e51e@wdc.com> To: Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Naohiro Aota , Johannes Thumshirn X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1700754443; l=4017; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=HOPXPFmYGX+fut8IJwT4SBFWWVBiLfZukFL078WjfiM=; b=PpgMqJdGC4GG6UrKRlG1b2nMBMiBzQ6QtGHv2seNaU/eGKxs5GbMloS7B2MAK46bcY6JpFTNy Fqvz3MSciDQAV0XVoIzaESI4b1cgrRxj0mAuuPC+6aYNMGb7N3BAyiZ X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 23 Nov 2023 07:49:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783370407461534040 X-GMAIL-MSGID: 1783370407461534040 Now that we're not clearing the dirty flag off of extent_buffers in zoned mode, all that is left of btrfs_redirty_list_add() is a memzero() and some ASSERT()ions. As we're also memzero()ing the buffer on write-out btrfs_redirty_list_add() has become obsolete and can be removed. Reviewed-by: Christoph Hellwig Reviewed-by: Josef Bacik Signed-off-by: Johannes Thumshirn --- fs/btrfs/extent-tree.c | 5 +---- fs/btrfs/tree-log.c | 1 - fs/btrfs/zoned.c | 17 ----------------- fs/btrfs/zoned.h | 5 ----- 4 files changed, 1 insertion(+), 27 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 2d8379d34a24..4044102271e9 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3445,10 +3445,8 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans, if (root_id != BTRFS_TREE_LOG_OBJECTID) { ret = check_ref_cleanup(trans, buf->start); - if (!ret) { - btrfs_redirty_list_add(trans->transaction, buf); + if (!ret) goto out; - } } cache = btrfs_lookup_block_group(fs_info, buf->start); @@ -3479,7 +3477,6 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans, must_pin = true; if (must_pin || btrfs_is_zoned(fs_info)) { - btrfs_redirty_list_add(trans->transaction, buf); pin_down_extent(trans, cache, buf->start, buf->len, 1); btrfs_put_block_group(cache); goto out; diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 7d6729d9fd2f..bee065851185 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -2575,7 +2575,6 @@ static int clean_log_buffer(struct btrfs_trans_handle *trans, ret = btrfs_pin_reserved_extent(trans, eb); if (ret) return ret; - btrfs_redirty_list_add(trans->transaction, eb); } else { unaccount_log_buffer(eb->fs_info, eb->start); } diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index ed8e002b33e7..931ccc839152 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1715,23 +1715,6 @@ void btrfs_calc_zone_unusable(struct btrfs_block_group *cache) cache->zone_unusable = unusable; } -void btrfs_redirty_list_add(struct btrfs_transaction *trans, - struct extent_buffer *eb) -{ - if (!btrfs_is_zoned(eb->fs_info) || - btrfs_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN)) - return; - - ASSERT(test_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)); - ASSERT(test_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags)); - - memzero_extent_buffer(eb, 0, eb->len); - set_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags); - set_extent_buffer_dirty(eb); - set_extent_bit(&trans->dirty_pages, eb->start, eb->start + eb->len - 1, - EXTENT_DIRTY, NULL); -} - bool btrfs_use_zone_append(struct btrfs_bio *bbio) { u64 start = (bbio->bio.bi_iter.bi_sector << SECTOR_SHIFT); diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h index b9cec523b778..7bfe1d677310 100644 --- a/fs/btrfs/zoned.h +++ b/fs/btrfs/zoned.h @@ -59,8 +59,6 @@ int btrfs_reset_device_zone(struct btrfs_device *device, u64 physical, int btrfs_ensure_empty_zones(struct btrfs_device *device, u64 start, u64 size); int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new); void btrfs_calc_zone_unusable(struct btrfs_block_group *cache); -void btrfs_redirty_list_add(struct btrfs_transaction *trans, - struct extent_buffer *eb); bool btrfs_use_zone_append(struct btrfs_bio *bbio); void btrfs_record_physical_zoned(struct btrfs_bio *bbio); int btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info, @@ -180,9 +178,6 @@ static inline int btrfs_load_block_group_zone_info( static inline void btrfs_calc_zone_unusable(struct btrfs_block_group *cache) { } -static inline void btrfs_redirty_list_add(struct btrfs_transaction *trans, - struct extent_buffer *eb) { } - static inline bool btrfs_use_zone_append(struct btrfs_bio *bbio) { return false; From patchwork Thu Nov 23 15:47:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 169007 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp538661vqx; Thu, 23 Nov 2023 07:48:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcBt+DamsPB23Tg/rmlTvfvb8haNe02w80nD8R6vwJM6DgJFk8D/qkfV+I6irAh9qSJUZI X-Received: by 2002:a05:6a20:a426:b0:187:f083:2cb2 with SMTP id z38-20020a056a20a42600b00187f0832cb2mr331pzk.31.1700754526347; Thu, 23 Nov 2023 07:48:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700754526; cv=none; d=google.com; s=arc-20160816; b=HuOmcoDZoZR+XHXYAuIGnaxWJ3JgeVsAtFn990MslmZwJDyudPTYECina3+s3xrxaT S1ObhCH3NEZ9mlo7392QDW7cxM53+Ni3v/biMWv8dlol+P4Ta4IiaMvxHqsLc5o8Kc31 J0CEpKQiKf5Nnkr/+5TiHvr7a1GJWZZGBN6OiR/4CfdcJ0wwi9+BoSReCiJVD+MUR8Q/ BDDQqDsJB9Fw5fGRe6i6efUDJvMP+XSXh2LOMi9DMOCbF8qnVsKBVbQC0IlC1ICVlyLt rlgWJ3YT2PaYpLJprDboC9vrB7DsarL9DL+mwR2YQ6Of2tbZ8WRQDr8gnhAyKvVHqm26 nW6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :wdcironportexception:ironport-sdr:ironport-sdr:dkim-signature; bh=0EFhPzwCLUVfygSWN8ogLrBEHyZy8e7JjExtZfR5oRk=; fh=5/viNv8Fzx+nCNW5PGLTL+Se/9D0Q8TrzLPV3SudCmU=; b=b5WVxOG5UwAykGB+LeF+52DYWamqDX4751GVb4R3VkKsn+N9/Br4oYhCMgQQ+k6OMO eSDKoQTQdPwmdKwzVU3N6Nn+z2dvGLfN4BwVoUcmVw332pra3InT1u8efkgVkCpP38SC dGIspU58VUhsleuO9YI6dQ9hTV0zEC3l8afOlvkah9bq6O8yBKJRBnfRhol5egH2veB9 NY4PlAAHiNs7+A4vB8n2RPPVlFfVxSxt4FO+B7601hKt1E+56Z1vK3EA8S7Rs14mp2kg PnSxCGYGQ3Mv07sh8Jx4/XroSEbySxXKQD4aXLLgBXZPERJ8lUq8zWgto/AYOSBaKa9+ kq8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=P9EkNK4F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id fi36-20020a056a0039a400b0068fe12b361dsi1519302pfb.249.2023.11.23.07.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 07:48:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=P9EkNK4F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id BCAAD8289519; Thu, 23 Nov 2023 07:48:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346241AbjKWPsM (ORCPT + 99 others); Thu, 23 Nov 2023 10:48:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346198AbjKWPr7 (ORCPT ); Thu, 23 Nov 2023 10:47:59 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 518B7D48; Thu, 23 Nov 2023 07:48:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1700754486; x=1732290486; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=vE95KoUEUEVqVM2tCNXr7cBWfNJDvBLd3iEA6GxxuoA=; b=P9EkNK4Fyxefg8Nh9xZheLqRAzjo1ZK4VNhQDMHH61KV5IBmK7T0Xodh G5Ei9E3eNkSVidZQIFlKyjlVZW66MmaczkmRR45GSeVZCXy2n2aggSqJB id/Foqx2N27YHT4bWJf4jXxfCLZOmKnAj+23dQSF3LJZOiXnpGx57gEsj EV/kheFJhACIEFepUrKZyax2G8Iublty/j4hzFY+C+oyGRcnycsN5Zi3P P+G+nBZIFpnLdWPePqK7pv/JKA4fSIEleEuUdSaS9BdedRo5TukZtx6mb roPX/eQ5khZWcYvpkKlg9xigs+X+bFm0m0rwPp6z5VCrugbBtmUOvgl9K Q==; X-CSE-ConnectionGUID: vSiKT64CRkSzXsD+cCFD9w== X-CSE-MsgGUID: JbJTO0MlRye4ZiuVbGwA9Q== X-IronPort-AV: E=Sophos;i="6.04,222,1695657600"; d="scan'208";a="3129203" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 23 Nov 2023 23:47:32 +0800 IronPort-SDR: Z7q65LVjTCH7EXeHHT7IptpGvmzIi2G7osYAHqE64cMT4u32kzGfFPHKTUinyp2CyKOOv209zY ur2iDFgzICKmCe7xOid7EkMkbIMSxPPshfnXGSE2uEGZMTcjfhSz1wTtxC2B/BXiKD197fC9pj p6mjFXBNYRYgYHjMWYpFAgQA6AbKsyuVWyxV1YzfsevMTQtRR3S5nSA5c9LRRtnlOqQafohhaz 4sidaBqF48gFZS1A20OB6envJSFNjGpkKVghW4i2D4CL5qVjhyWBp/yj4JHtGMvXNrK78buGjX JvE= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 23 Nov 2023 06:58:48 -0800 IronPort-SDR: gkVSIe/USso4kaxtBj74U9WtW20W9HtzS5y0cPCf4P5av6WUtxN02k2Y05XzJ8A64gsSWzKdfW LoVxtCD8HDxOFtXB51dBnxYl1lbxXNYJ1HaW7hyx5z9v9ciB+w5CazhjurvOUq3SkWFVTs8d/G nCAUVbMqFxH+B1DdDjPOTzNaqDnPK3mESlziLPhR1L+5Y8PxE/iR6cwjYzk2Pd0mwrVpZXthrs 3VUnQwVXUuxoJ2wsc31rebxXPTso+V2iHOdK4slndG1h94pjbEJp+j4wk831skmZlJSs9pfBUk Nsc= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip01.wdc.com with ESMTP; 23 Nov 2023 07:47:29 -0800 From: Johannes Thumshirn Date: Thu, 23 Nov 2023 07:47:18 -0800 Subject: [PATCH v2 4/5] btrfs: use memset_page instead of opencoding it MIME-Version: 1.0 Message-Id: <20231123-josef-generic-163-v2-4-ed1a79a8e51e@wdc.com> References: <20231123-josef-generic-163-v2-0-ed1a79a8e51e@wdc.com> In-Reply-To: <20231123-josef-generic-163-v2-0-ed1a79a8e51e@wdc.com> To: Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Naohiro Aota , Johannes Thumshirn X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1700754443; l=836; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=vE95KoUEUEVqVM2tCNXr7cBWfNJDvBLd3iEA6GxxuoA=; b=YSp9DFeqHURIML2/TvPPdaOoHQ8vExnmR6thl23Knk6cdcnLsOpQafOiB4KrzeJhrnb9xhqpd U8H7KAaTp7YCNmiTquGZIEx5wSB1bNInUPch3TZFNmOQvnz/qTsLzhA X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 23 Nov 2023 07:48:43 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783370378149232938 X-GMAIL-MSGID: 1783370378149232938 Use memset_page() in memset_extent_buffer() instead of opencoding it. This does not not change any functionality. Reviewed-by: Christoph Hellwig Reviewed-by: Josef Bacik Signed-off-by: Johannes Thumshirn --- fs/btrfs/extent_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index c378094b5cc8..defe0fa04572 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4195,7 +4195,7 @@ static void memset_extent_buffer(const struct extent_buffer *eb, int c, struct page *page = eb->pages[index]; assert_eb_page_uptodate(eb, page); - memset(page_address(page) + offset, c, cur_len); + memset_page(page, offset, c, cur_len); cur += cur_len; } From patchwork Thu Nov 23 15:47:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 169004 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp538472vqx; Thu, 23 Nov 2023 07:48:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZNUcmjKS+hhAPm/8VyJkxIrf7cMiyG33cpZoZtuJpwofHDTA4EsM5YPtOk4CsJG3SYHPA X-Received: by 2002:a05:6a20:548c:b0:187:636d:a61e with SMTP id i12-20020a056a20548c00b00187636da61emr6551456pzk.42.1700754506651; Thu, 23 Nov 2023 07:48:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700754506; cv=none; d=google.com; s=arc-20160816; b=oQgrm1gSjwVn/ZoC+aWEFcOcoU0tpqKhcyX3FUCwyXmhNOfXUmuZHB0pF6PXgVH+Hn Lk981vfj/4zTE/LRcfJmHvfQg720VK1wG15+n2+mGa9mNolfnGRuBBYY6YmJbubUt1Z3 SGUr0oPeF1ag55j4CkFgvVHPl/elSzb7u4ETZskfeaSagVagzvSl1G0l7+zYeOhO88zv InFopd4Aq+apE6G4/rm3eZa4KDwD0lPkdv9mhZ0OOngZdJty4GkPo48ommY+MUvJd2Hs EexYzxEbnwRQZ+QbWdSfONlKplWiLnPdix0WkT4u/uvVZM0tpVXZ6ASUZEhEgEL9w4ND qYGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :wdcironportexception:ironport-sdr:ironport-sdr:dkim-signature; bh=2DZSAJWvnLluOjiOpTDnGLQnSTDn/vQrEjog7MUuZnI=; fh=5/viNv8Fzx+nCNW5PGLTL+Se/9D0Q8TrzLPV3SudCmU=; b=GajhedLu5QveCKSTrzTW/e0u4w4hwLIdVwFOhvIOedA+oKh2KR+RJ/tqp2JGEVocOJ Kj6YuxSnoXc41uBohn9sdVnbr7cb6nBBh/xIvYhrSZbjqakhfegtrDYVZ527IxNokHxo q47cClfoEYz8Fu0LVIuNFNtVyHqvRGIy6ax4OOknKOqSPIaPACd++4ikNTCas1y0UhMe yuKW7YNBR1DWJieRR9AjyYIeNC6l7HaZJ+x0MRMaqgRgAW9sGmTtXEZV9HsvJX0vqGmF vh5BoFN/v//LfvMEaeiyWOHEYrkQmq27hNZw3eBoLRP5ZP1mEraqDJtZtYMkHGBp5OIe 67Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=XdqnoFa6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id h3-20020a63df43000000b005a9c40151b3si1508992pgj.804.2023.11.23.07.48.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 07:48:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=XdqnoFa6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 378F781EB9DF; Thu, 23 Nov 2023 07:48:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346237AbjKWPsJ (ORCPT + 99 others); Thu, 23 Nov 2023 10:48:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346072AbjKWPsA (ORCPT ); Thu, 23 Nov 2023 10:48:00 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69BC2D53; Thu, 23 Nov 2023 07:48:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1700754486; x=1732290486; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=Iv2Qzs4D9MzjAZ/+msRXyW+jC+y0zttCg1ew3aqF+2U=; b=XdqnoFa6SrYGCG6WtVw4QcggNxU+Zqsb1fSRmWEMaIT7CCW389TDj9c7 sM8y36pNpBLGE0eSozRH1dLlSotoAZVGxcah6XIdvL/BEJqyjuOx8tn5F /3sB501+EVDpZuZ3nPiizqCsW15FKixmYsNcs4e1LEVXnbsvGYynx/Wwx avQSLgqzSYejdTwf5sZ2U8qqH6qcilIFPqtmQ6Cxn5rb1YAnOvf06/KNY TC+ANC7BZkm3AhBnu7d2lRHsePbtTBbA9gUrjkQv7BKGxcxXHrniDkP/u ewq+jIuqHoco1/WE6CVFbfpWppc90hTc/l8IfT3b2iNFu3uqtA84LNb2V A==; X-CSE-ConnectionGUID: Vhq+0gP4QhqPhldSfqOCjw== X-CSE-MsgGUID: OusHH5ePR4udevI2Xk1IYA== X-IronPort-AV: E=Sophos;i="6.04,222,1695657600"; d="scan'208";a="3129205" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 23 Nov 2023 23:47:32 +0800 IronPort-SDR: yNSpfGHBkWSFijbzS2oZZ9uxivi5cNW88Z1XYcrF9DyAM3uh1j5tj4H6jq0ZRB9k/WjTKexBOH +L8NfEElF5MIirn1hD0LmhywCRXdOsiDH4rTUqsz9UpzL22A8r3TlXsg0kvQc3vdn8h9QMPg88 Mr84cqxgvDgycivn+XuVNHAK08ymayVdspbhVrLZNjCESvd5r/s7TM8tjiw/vtfy0x9C7Tumsq +LSG8JT2/10znpBImqrjYDN+o1IssTrYHiWOkwjjyCPz6hSgb7mOVFTuqrRVT0+j37x3fEnSQy 1Xo= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 23 Nov 2023 06:58:48 -0800 IronPort-SDR: 1PUIqR2s/9Ebt5mkbwQHyzg38pV/M8VUbJyDLr0N/g57npTB6w5L+mfhlIOI/ptILjgzxWhZzh DxBhermHVSngyJ+gAVltCBd6X6V9rIbOqhQoWtAyx4WnoMjAGVC/ewvGltK03WQxYRxaSbOvAo m0zwViSajrK7JnP8VvmfWp/q1A1tHYvhaxHSSxNwupgTO7pXN+hmE4I7VGy+BSvN9qLoCqiJLE TUdlkbxGh1WU8+z0wVkaOOAUkdByLZZ2iDEagu8Ud00+E3GUTvo5mZk1m5vHwB0OyVwcBBkTwY +rE= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip01.wdc.com with ESMTP; 23 Nov 2023 07:47:31 -0800 From: Johannes Thumshirn Date: Thu, 23 Nov 2023 07:47:19 -0800 Subject: [PATCH v2 5/5] btrfs: reflow btrfs_free_tree_block MIME-Version: 1.0 Message-Id: <20231123-josef-generic-163-v2-5-ed1a79a8e51e@wdc.com> References: <20231123-josef-generic-163-v2-0-ed1a79a8e51e@wdc.com> In-Reply-To: <20231123-josef-generic-163-v2-0-ed1a79a8e51e@wdc.com> To: Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Naohiro Aota , Johannes Thumshirn X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1700754443; l=4954; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=Iv2Qzs4D9MzjAZ/+msRXyW+jC+y0zttCg1ew3aqF+2U=; b=wBKec1gxRq/i9SilagPHNs70jWLvaxWae6ekUc2QGDkIjfdCvJRtWv2CFHXJdevEZTz4yce1d bFonXlHMBy+CsXhi6FcwJXSE5yrygMMK8EjIGN7QtY1j23VdHUsyt16 X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 23 Nov 2023 07:48:21 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783370357429265585 X-GMAIL-MSGID: 1783370357429265585 Reflow btrfs_free_tree_block() so that there is one level of indentation needed. This patch has no functional changes. Reviewed-by: Christoph Hellwig Reviewed-by: Josef Bacik Signed-off-by: Johannes Thumshirn Reviewed-by: Filipe Manana --- fs/btrfs/extent-tree.c | 97 +++++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 4044102271e9..093aaf7aeb3a 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3426,6 +3426,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans, { struct btrfs_fs_info *fs_info = trans->fs_info; struct btrfs_ref generic_ref = { 0 }; + struct btrfs_block_group *cache; int ret; btrfs_init_generic_ref(&generic_ref, BTRFS_DROP_DELAYED_REF, @@ -3439,64 +3440,64 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans, BUG_ON(ret); /* -ENOMEM */ } - if (last_ref && btrfs_header_generation(buf) == trans->transid) { - struct btrfs_block_group *cache; - bool must_pin = false; - - if (root_id != BTRFS_TREE_LOG_OBJECTID) { - ret = check_ref_cleanup(trans, buf->start); - if (!ret) - goto out; - } + if (!last_ref) + return; - cache = btrfs_lookup_block_group(fs_info, buf->start); + if (btrfs_header_generation(buf) != trans->transid) + goto out; - if (btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN)) { - pin_down_extent(trans, cache, buf->start, buf->len, 1); - btrfs_put_block_group(cache); + if (root_id != BTRFS_TREE_LOG_OBJECTID) { + ret = check_ref_cleanup(trans, buf->start); + if (!ret) goto out; - } + } - /* - * If there are tree mod log users we may have recorded mod log - * operations for this node. If we re-allocate this node we - * could replay operations on this node that happened when it - * existed in a completely different root. For example if it - * was part of root A, then was reallocated to root B, and we - * are doing a btrfs_old_search_slot(root b), we could replay - * operations that happened when the block was part of root A, - * giving us an inconsistent view of the btree. - * - * We are safe from races here because at this point no other - * node or root points to this extent buffer, so if after this - * check a new tree mod log user joins we will not have an - * existing log of operations on this node that we have to - * contend with. - */ - if (test_bit(BTRFS_FS_TREE_MOD_LOG_USERS, &fs_info->flags)) - must_pin = true; + cache = btrfs_lookup_block_group(fs_info, buf->start); - if (must_pin || btrfs_is_zoned(fs_info)) { - pin_down_extent(trans, cache, buf->start, buf->len, 1); - btrfs_put_block_group(cache); - goto out; - } + if (btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN)) { + pin_down_extent(trans, cache, buf->start, buf->len, 1); + btrfs_put_block_group(cache); + goto out; + } - WARN_ON(test_bit(EXTENT_BUFFER_DIRTY, &buf->bflags)); + /* + * If there are tree mod log users we may have recorded mod log + * operations for this node. If we re-allocate this node we + * could replay operations on this node that happened when it + * existed in a completely different root. For example if it + * was part of root A, then was reallocated to root B, and we + * are doing a btrfs_old_search_slot(root b), we could replay + * operations that happened when the block was part of root A, + * giving us an inconsistent view of the btree. + * + * We are safe from races here because at this point no other + * node or root points to this extent buffer, so if after this + * check a new tree mod log user joins we will not have an + * existing log of operations on this node that we have to + * contend with. + */ - btrfs_add_free_space(cache, buf->start, buf->len); - btrfs_free_reserved_bytes(cache, buf->len, 0); + if (test_bit(BTRFS_FS_TREE_MOD_LOG_USERS, &fs_info->flags) + || btrfs_is_zoned(fs_info)) { + pin_down_extent(trans, cache, buf->start, buf->len, 1); btrfs_put_block_group(cache); - trace_btrfs_reserved_extent_free(fs_info, buf->start, buf->len); + goto out; } + + WARN_ON(test_bit(EXTENT_BUFFER_DIRTY, &buf->bflags)); + + btrfs_add_free_space(cache, buf->start, buf->len); + btrfs_free_reserved_bytes(cache, buf->len, 0); + btrfs_put_block_group(cache); + trace_btrfs_reserved_extent_free(fs_info, buf->start, buf->len); + out: - if (last_ref) { - /* - * Deleting the buffer, clear the corrupt flag since it doesn't - * matter anymore. - */ - clear_bit(EXTENT_BUFFER_CORRUPT, &buf->bflags); - } + + /* + * Deleting the buffer, clear the corrupt flag since it doesn't + * matter anymore. + */ + clear_bit(EXTENT_BUFFER_CORRUPT, &buf->bflags); } /* Can return -ENOMEM */