From patchwork Tue Nov 21 16:32:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13463362 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="LEqreQjI" Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B884319A; Tue, 21 Nov 2023 08:32:39 -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=1700584359; x=1732120359; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=bS+izt25i86OJPhEwD89NOAR8tVmlYBFUeLwZDlkh0I=; b=LEqreQjIyUPVJ8z8l7ODxwQFpbfwBjbGI/XQ2dh5L1YaNseHULYYSoWF /+ucOxyUp8U8XIGTFgUW4fTunRBihedbFNQEu5TTBxKVhp9USc1RwODhx PFqjDEVy4RGtHSGTAg7wzpxxelVCHdWN9NnFSWtXcypYHKGD1Wm+ykSKL pSO7lok9jse1l8KPJaKGaCBdSU2YH/4wE3JijAcJlxrYNqJhSSkOyupCm fNb0NyJuU5tIL4fLWt2bmQncMs9IjvnngJnDNnrj53GkLOLQHlgTFfsP5 8CHmrrpzIGawBFYYJss6yFxqUXMvhg24m/CPlc2akgIulUowZqEBPROEp Q==; X-CSE-ConnectionGUID: KUMxJjYARR+J9pxun3k16A== X-CSE-MsgGUID: ZR4JLwuCSEu64OxxxBAd0A== X-IronPort-AV: E=Sophos;i="6.04,216,1695657600"; d="scan'208";a="3076035" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Nov 2023 00:32:36 +0800 IronPort-SDR: 6rk3XbVXN9iBuM4qhPXHRwKILhfISyHEyDRoe+rV6gmO0fHuc4ZF048AoQSXkA3A7iOFX81ZNg 8BIluOz3WnlKYXWRfEH14sVtW4dGAe5RStj0k4zNM0llwZ/MM3Bk09+LAq2ZAsQyp+gbAapsMK sjizi/1OCVPle69qKPJwRx0mi5M00ArMiZc1cmX5CFAFNlhjQg48JXmvTp0PJ+G5VKNKCEilGy U0qu06LPwOOyznKBDIjlOyJShkrYI7KoE7TdJiXrnwh1Y5UY9qVpiGcV2rLvtNU/WvB9GCZxeI Dhg= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Nov 2023 07:38:15 -0800 IronPort-SDR: UNUqSkBJ/ydA/hw5JjSvecmx5zIzlhg5WZC2gvr0LS/EFtyRqpTvbjpr0+vHKjn9fjoJQG0mRw QZeGugMR1HTR5fOP1GpZVA1YxWe/Kumrwznd+IxVqQWc5L+uS7MeU9bdzf8xfaJGB49qNwnC3w Payzzu+OPzvwdtZ+HOcQ8l3oNk8yuZAS8LTFwU7dXct+zAPa7UEjm/8Y3nRm37B2qedlzyuUKW msWiLI9W2e6o0xX3oMocxbvBh+dnM9vCn3hLxJOpw8Yfs55VZzYZC3saK5bQr8yVh0WltxzoWv LUI= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 21 Nov 2023 08:32:37 -0800 From: Johannes Thumshirn Date: Tue, 21 Nov 2023 08:32:30 -0800 Subject: [PATCH 1/5] btrfs: rename EXTENT_BUFFER_NO_CHECK to EXTENT_BUFFER_CANCELLED Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231121-josef-generic-163-v1-1-049e37185841@wdc.com> References: <20231121-josef-generic-163-v1-0-049e37185841@wdc.com> In-Reply-To: <20231121-josef-generic-163-v1-0-049e37185841@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=1700584354; l=3043; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=bS+izt25i86OJPhEwD89NOAR8tVmlYBFUeLwZDlkh0I=; b=FCEmPciCRqRb3Maq3MBRz4eaMfqNnROnTcW1n6V8DYNA61YPlWKSobzJ36gbBsCEXj6X9nJAH xETkC9h6hEwCoi3gZSnNH+lOE2g50q0yUlkvHJg2xNGgKIe0ItAcDym X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= EXTENT_BUFFER_CANCELLED better describes the state of the extent buffer, namely its writeout has been cancelled. Signed-off-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig --- 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..ff6140e7eef7 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_CANCELLED, &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..f6cbbec539fa 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_CANCELLED, &buf->bflags); set_extent_buffer_uptodate(buf); diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 03cef28d9e37..74f984885719 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_CANCELLED, &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..d5c9079dc578 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 write out is cancelled (for zoned) */ + EXTENT_BUFFER_CANCELLED, /* 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..89cd1664efe1 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_CANCELLED, &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 Tue Nov 21 16:32:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13463365 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="VOeMVvJm" Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52CFB19E; Tue, 21 Nov 2023 08:32:40 -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=1700584360; x=1732120360; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=L3NVSoa0Cpx4pPFIb1TUWiVH9DFoJOyUHEUP90OBa2o=; b=VOeMVvJmaIxB9oqY60BqtyFKYrkSxRBb1mq2L1T3iR7qHnEf4At7hJwY 0orSLXxrxFvtE7CG27IRrOyhrB/xj1u0Kb/LQQhSlJR0o4hmd6ffKmdT3 EoHjbO1Es3ND4apR0b3F1oW2MkTZv/chhnVGwhQ2N1zHcwvRFDCIkz75l YY60XsKE0tqg8Wvg6MN33m0IJ6qd0MxmBpioH+jzNMGLbaOvJWHXhF/QV tYnxx5WuIi62s/cxHOnq+1JUPWNO2ya3SUeNFigQQpDH1yylP/7WRNTKS JkapmtWtWwxnBO+ToOQOnRFMEN4kQ8tXXxla/H2d///dc7Ph9VqiiJLM7 A==; X-CSE-ConnectionGUID: 3JGdFnzGRSWh2k++jw3oxw== X-CSE-MsgGUID: nzNMQh8DQPmy/kX0jkgMBw== X-IronPort-AV: E=Sophos;i="6.04,216,1695657600"; d="scan'208";a="3076038" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Nov 2023 00:32:38 +0800 IronPort-SDR: ZW7tzteNq4G/Ea4JGzf0Pp9WSW6Bz19/35qspf9REDQQlIa5nQ9IjgKpvDd30WnGdgakJeiH/k Kiqltc7Y+ua481d33pw1U8n0pLYDRc17Y5vatPQF34ByKz4v9ftxsLBC7eUjqrCkbFMx2mbNFI JWeppZgicR8RtGnkC9T0A3EieioOw0zMfa+2xP+DFkxulHTxcSnR3nkG+eeJ/pUxjf3z+lK9FO 4LNipNJrvFUcZ5q2tUcPjkB4OFiHgsVEP2Unl11FC3p4dDVlkF0JVXm7T7ZlMYyd3IORMrwXpx +Fs= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Nov 2023 07:38:16 -0800 IronPort-SDR: IOKuH+FE/Sxtimd3j5gs6rbKKgH4w5JW7AtaTKCl1+ZX6G+wtmAZPCkaIlDsSVHaZkYYWFk8Oq 0vxxGEVQKzpUL8lCaE7fCxR1cEsMMRtPenl/6oFiMuh1fxMGoFDh3N7uJskra70O/A/Odk6lKL 6cUJOLxCBc21SesKtl25Xnijz1f8JwpRfdyiPx6lSZgKMy4BTSfKGqHYnMjhnJnG5sBq9URVIL EmHHQ/WrieVC8aMYMd+1G1mwd8Kb/xGQnFqym/zstEBKRMQ8YG6ZfQ+CxETtpz0bQtIvTFG13Z Kuc= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 21 Nov 2023 08:32:38 -0800 From: Johannes Thumshirn Date: Tue, 21 Nov 2023 08:32:31 -0800 Subject: [PATCH 2/5] btrfs: zoned: don't clear dirty flag of extent buffer Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231121-josef-generic-163-v1-2-049e37185841@wdc.com> References: <20231121-josef-generic-163-v1-0-049e37185841@wdc.com> In-Reply-To: <20231121-josef-generic-163-v1-0-049e37185841@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=1700584354; l=2264; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=L3NVSoa0Cpx4pPFIb1TUWiVH9DFoJOyUHEUP90OBa2o=; b=T9kBt7f2Hj0NyDJUnB2/A2fnDALdHmF2eaDZtiMrukTgRelffox9lplELS0/Arzh7ecOgcrM6 1OmbzpOZOpzCtJdugdkd6eXglwZSesqiGu59vI2GkXuBp+uKTtTS3ib X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= One a zoned filesystem, never clear the dirty flag of an extent buffer, but instead mark it as cancelled. On writeout, when encountering cancelled extent_buffers, zero them out. Signed-off-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig --- fs/btrfs/disk-io.c | 2 +- fs/btrfs/extent_io.c | 7 +++++-- fs/btrfs/zoned.c | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index ff6140e7eef7..f259bae1c3ee 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -255,7 +255,7 @@ blk_status_t btree_csum_one_bio(struct btrfs_bio *bbio) return BLK_STS_IOERR; if (test_bit(EXTENT_BUFFER_CANCELLED, &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 74f984885719..8bc5025ce278 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3748,6 +3748,11 @@ void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans, if (trans && btrfs_header_generation(eb) != trans->transid) return; + if (btrfs_is_zoned(fs_info)) { + set_bit(EXTENT_BUFFER_CANCELLED, &eb->bflags); + return; + } + if (!test_and_clear_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)) return; @@ -4139,8 +4144,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_CANCELLED, &eb->bflags)); - if (check_eb_range(eb, start, len)) return; diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 89cd1664efe1..117e041bdc7a 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_CANCELLED, &eb->bflags)); memzero_extent_buffer(eb, 0, eb->len); set_bit(EXTENT_BUFFER_CANCELLED, &eb->bflags); From patchwork Tue Nov 21 16:32:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13463364 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="LdRK/UFB" Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3EAC1A1; Tue, 21 Nov 2023 08:32:40 -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=1700584360; x=1732120360; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=4x9R0AUQK9GRVyrX+VtnFLrU6NC+W4I+bSE1UwCceA4=; b=LdRK/UFBflkZ7wkdBupPi3NgHGOjw6tc8f6cPcnTwb3gg6Dw8a7arE55 zFR+P7C5RrISc8cq6lF/L4Tokma2onD45zq+3IE8IcEtuwoEMDpf/3AsQ S/zfAi97+Oh7GVojy2uK5kB9m7bfH21XKEz+6YRdj0wJsDrYZ6dhJQ+6F C9nzYPWarllCg3cDtkgWY7i233XH33Y5BtU1hx4JwgVL3zRpZHRT/fAIl ZnYJOyh1udBmyw/juCNL4y4x8S9VaK/IvXw+2NtBsXE9Or9aKxYN2Y4dZ qDMBU3LRNZ0rx5OssfimMFfFpYnueF89Gu+IXPFknIa1gCnSAiZjYn20a w==; X-CSE-ConnectionGUID: zoB9iurbSQyP9XntX2r2Bg== X-CSE-MsgGUID: i+5U2UjVS2K2fnllLZb3qA== X-IronPort-AV: E=Sophos;i="6.04,216,1695657600"; d="scan'208";a="3076041" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Nov 2023 00:32:39 +0800 IronPort-SDR: TAkEFTY1z1bdNrIVPgm88VV+nzcUD0QS/+E/vnPfnzXj+RlPfJX8OVuKFuuZP3lCCipmczmcD1 t/QeMS0q4BWzLiPw76pp+lApx2b0c9jA2s/XLZpv/jNvjVbOOeovvIobhykLgdQ9pWb0X2KryJ bTnTBdlAI8XLixibQWAEPyoEgZOWo6c4FQ4RZ2q9Hta2tlPx3nL5/7XmmqTuMCLQnOP+tagaD/ 30G7Auu6AjdhIsUhcodnFNF7tzuxEP8dc4370pVNMmMSgYXd2ZN++Kh1HFDoLrite0yB+EC651 b0c= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Nov 2023 07:38:17 -0800 IronPort-SDR: GR1ZMbJhEH2SHBk4dtqaQNpLlAoNwKPwcEmFj3egwXbL6nrVNUVXKU1RjdDyhEuWBYo7sBam57 0FLqajz9AICXWEUb7rmxVCROQB68wAulgzqAR9Y+wullZrvfa2Y34sH+9pShoejEJ3YygcWviz GPPLSm5QtfG938z6nZZMdWRz33kbnDShc+6c030L+tpcfJ+MoDsSfLBADSD58nNGcOF7i5Mmwd s2VloPU+6OSWzMVHaCPUrxwza33lVTHHmB6045tv8DjxFaPzJC5fELu0tIfzi8+oX8RgqVwur7 mT4= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 21 Nov 2023 08:32:39 -0800 From: Johannes Thumshirn Date: Tue, 21 Nov 2023 08:32:32 -0800 Subject: [PATCH 3/5] btrfs: remove now unneeded btrfs_redirty_list_add Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231121-josef-generic-163-v1-3-049e37185841@wdc.com> References: <20231121-josef-generic-163-v1-0-049e37185841@wdc.com> In-Reply-To: <20231121-josef-generic-163-v1-0-049e37185841@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=1700584354; l=3915; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=4x9R0AUQK9GRVyrX+VtnFLrU6NC+W4I+bSE1UwCceA4=; b=WltesEGdCChgU2zlttMM6Os6XzuHwaithQPvnaT3s4u8tUjmDjB7YY0/3dfGrvaHQbd1da6Te +r2QE6li6P9BFUff+3aYvgGSt3fMdpkro4lye6FYnW/3Ml8HauQ3CcG X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= 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. Signed-off-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig --- 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 f6cbbec539fa..6beff11e692e 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 117e041bdc7a..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_CANCELLED, &eb->bflags)); - - memzero_extent_buffer(eb, 0, eb->len); - set_bit(EXTENT_BUFFER_CANCELLED, &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 Tue Nov 21 16:32:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13463363 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="jM9j26vZ" Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DAEB191; Tue, 21 Nov 2023 08:32:41 -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=1700584360; x=1732120360; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=GyvvIo5B3m5fGvInoKE69As5yRuaY1/RgWCjARzh/rw=; b=jM9j26vZJOBAKKVdVjcY129zRyY79LEi6aQKTbTzglYTKjliga+blJRT mZ6DoQkoKx4DkKMKyaOfnGK5LckBxcaXXp4Vva5iEEUk+8+eyvwvFliYf oJ/urYu6oJHzIjWnjC+Nhezr53VIHJOx7Trc5eTyeXkZEM4cDCe4txbAT OHvIBLGxuipnMbDG1qzJApTpRBdN8kPRX8+BRmNyNkqlBgCiHxDZFVY+l 1FcgkliBukxU5sj/pNsjQdD4zMMEvH4o52u03ru31TGnLrQ1BhRwkB991 B+lDVAADTnPUDABT0kHKcUWYNxVEf8Z+vbrFcxsSC7zbqW8syQ+p+nKJu w==; X-CSE-ConnectionGUID: y8vfalxwQ0eniSeCGttfGw== X-CSE-MsgGUID: tBt0p4GZRWimZH5ipT19NA== X-IronPort-AV: E=Sophos;i="6.04,216,1695657600"; d="scan'208";a="3076045" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Nov 2023 00:32:40 +0800 IronPort-SDR: Wp5f1ERwQPdg+fGAzlqwt76SsDbLn2jGV2i5MMfEBG8W1GYeL9gQDw+kBUT4ussrJMy3X6K4xa 3VJTSQZDUL+7DFTV+fe3DMvBaNJv9aEtI1N7ri1KRD12OG3T6WBEpR7iKvWWvd7nPzBA5WXL2c qGUu8rF8ZZxyIEcQ6hejSWCpiAM3ArMZgXzW8Q1q/Ccbwl+YdyiR7xTX5vRG98ItDDJLszGnaq nvMMYMqflA0nvUjpCos1xwS9l1Kq1rznqyEyMA3PJpwPWbyR+xcWPIv4mdShabCSfaUyxoL/rS cFU= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Nov 2023 07:38:18 -0800 IronPort-SDR: 7L7Q4yvS9exJiAN/L1dW7y9uCIoQVMGIUMbigYogWdwet3lBZyJP+8fXe+jlSF9d9/LSfEyibe PuyzKCgNiaoNrXN7TCJJi1ex576ynXYw16alUSvPP7gkAqUZZLJwnz4kbreKmNXiwG9GXALJ4I z8YrZ2UUaNTm5azLvYJmXCsSlmdsQJ1qewk5AZ9wSI238hesBJIdF7q2JzRHxsFCHatUxyQG8e +2kg65KTWq8IqFiluK4rbvXOvydJNrP1TnN3ZZ3RpFtuEZs5cnTWgPgrJyrZQJK28OgMXQ3NfG 3zc= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 21 Nov 2023 08:32:40 -0800 From: Johannes Thumshirn Date: Tue, 21 Nov 2023 08:32:33 -0800 Subject: [PATCH 4/5] btrfs: use memset_page instead of opencoding it Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231121-josef-generic-163-v1-4-049e37185841@wdc.com> References: <20231121-josef-generic-163-v1-0-049e37185841@wdc.com> In-Reply-To: <20231121-josef-generic-163-v1-0-049e37185841@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=1700584354; l=742; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=GyvvIo5B3m5fGvInoKE69As5yRuaY1/RgWCjARzh/rw=; b=ThZ7PZrN2xKIjW1JXyMxUy8WWGY2yZ/ltGzTllLzrcLzQ41lrHZFdy3awwUOHF9UcvbuK2+rG 3KpETc+qTy5AR//+WtQ3qet+HbGL0Vm4Kb/m8xenuYBrU4ffEY/i9dg X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= Use memset_page() in memset_extent_buffer() instead of opencoding it. This does not not change any functionality. Signed-off-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig --- 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 8bc5025ce278..b8a73ebe3485 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4186,7 +4186,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 Tue Nov 21 16:32:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13463366 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="oD1XuMxl" Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25FDDCB; Tue, 21 Nov 2023 08:32:42 -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=1700584362; x=1732120362; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=KYqF9Y5hRQDC61iuaRlo/mKWBf6FC4946cc3kDbAJmc=; b=oD1XuMxl2CvXEXzm4Aylf06lD7TVp70xA22QmDKQ+9pIGskW0vlIEuTS pZZXXp9QjQjFWxoNMHV+YUpuZZcvzPRB+Hs4ttTnzMcD1SvReUmeOCgYx b49OE1cMYTgnVrBsz0n8HBOLnVq6D+hbEZCOz0i6oi1b+/P1pT0a87Oub lUYPMwZtup+AYG1VT3PKSk2+wPEfYsZkUEfrjmNb4BCXWacXnAzqUrdiW af24ksLEvGqywpuUyrtOTO1MxRI+dkGmNdsKvBTAfwHEW0JHx3Win+wnR MLxLUON6jUElR0LdWV5+i8zGDeye9zAsZK5DJATrhTkoozCECtaEQOopf A==; X-CSE-ConnectionGUID: ugCgiAD8QXWlw5+6DlZFsg== X-CSE-MsgGUID: QJXf+cY3Q8OAyQwC/1SwFA== X-IronPort-AV: E=Sophos;i="6.04,216,1695657600"; d="scan'208";a="3076051" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Nov 2023 00:32:41 +0800 IronPort-SDR: j3l+E8rPcpsZUg/+pFEc3TAkRf+tmcAyBRYNx5XsLIV8rU6xGGVtUFfXiR0w12KVMRKPl1Jjbd Q/i0mvWHJUfdbOViDK+VP4QAQ1yErNGpMq0f4fmw+EIJEZsbOB9Dz+vmUqbLcyWAolVaLYASLj ZPaym0LGmQZRxfs7BIY13h0+k9WkQI6N1eCJsJOCDOO6YcrFiNBtERy/PmOVOnZm+vqvPusFAA 7oBCspVk59ZXf31mIJKvC0lT53oRY0HbCDMrT4jRyXU5OY3zIx4lvV/EFALIjskv5cxZtEplQe oqc= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Nov 2023 07:38:20 -0800 IronPort-SDR: ca2BAHrdk9ddzxV8YKca5R7ndER5uM47/utscY1m97ayjWTHF8noM5kSAjcshucyYxkcV3ar9A ueOz0/s9oYfylSYDx0q7PzepthzOG3ULzr8RJre3veOnMOzFa0IuWXxnaIqCOqYI2lM58+1LZ7 usMEgLVkJ7BF4uhutJf0TDa1GlEo19VKhPLefsIaDnkLmcM9n6hs3rEz1cMrgh98qcMwdmCg67 xToNewAOuNRwnLU1PV7KXHovu3x5Ul1oKbsKLeyZ1OPCFuR6oNKqYM2nhJ5b2YLhZ68bSR/Atb A+E= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 21 Nov 2023 08:32:41 -0800 From: Johannes Thumshirn Date: Tue, 21 Nov 2023 08:32:34 -0800 Subject: [PATCH 5/5] btrfs: reflow btrfs_free_tree_block Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231121-josef-generic-163-v1-5-049e37185841@wdc.com> References: <20231121-josef-generic-163-v1-0-049e37185841@wdc.com> In-Reply-To: <20231121-josef-generic-163-v1-0-049e37185841@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=1700584354; l=4860; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=KYqF9Y5hRQDC61iuaRlo/mKWBf6FC4946cc3kDbAJmc=; b=wmuqCBrp/etRWMbyM6GgwtlfU9ST83Bn9NyF3BoTDRms6V2Z6xSEOFGRsRFmplvg4yHqXru2+ X+4GWpr2gZiC2u/kworslxXGYqhqze4MdHgeIbchpvrAg67LolKQUBF X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= Reflow btrfs_free_tree_block() so that there is one level of indentation needed. This patch has no functional changes. Signed-off-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig --- 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 6beff11e692e..06818fe90fff 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 */