-From e78ab9a5f5bdecc66b642b962fb92f875585c0d4 Mon Sep 17 00:00:00 2001
+From 7832fbe8bfeb93e59f733d34a8eb47add19040d3 Mon Sep 17 00:00:00 2001
From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 12 Dec 2022 21:01:43 +0100
+Date: Sun, 8 Jan 2023 08:24:19 -0500
Subject: btrfs: fix an error handling path in btrfs_defrag_leaves()
-From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
-
[ Upstream commit db0a4a7b8e95f9312a59a67cbd5bc589f090e13d ]
All error handling paths end to 'out', except this memory allocation
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- fs/btrfs/defrag.c | 6 ++++--
+ fs/btrfs/tree-defrag.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
-diff --git a/fs/btrfs/defrag.c b/fs/btrfs/defrag.c
+diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
index b6cf39f4e7e4..072ab9a1374b 100644
---- a/fs/btrfs/defrag.c
-+++ b/fs/btrfs/defrag.c
+--- a/fs/btrfs/tree-defrag.c
++++ b/fs/btrfs/tree-defrag.c
@@ -31,8 +31,10 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
goto out;
+++ /dev/null
-From 25d536ab2905e7d98cd6848de0f45f12711b84ff Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 19 Oct 2022 10:50:48 -0400
-Subject: btrfs: move assert helpers out of ctree.h
-
-From: Josef Bacik <josef@toxicpanda.com>
-
-[ Upstream commit e118578a8df7941a9bbc568851997852e5bc7338 ]
-
-These call functions that aren't defined in, or will be moved out of,
-ctree.h Move them to super.c where the other assert/error message code
-is defined. Drop the __noreturn attribute for btrfs_assertfail as
-objtool does not like it and fails with warnings like
-
- fs/btrfs/dir-item.o: warning: objtool: .text.unlikely: unexpected end of section
- fs/btrfs/xattr.o: warning: objtool: btrfs_setxattr() falls through to next function btrfs_setxattr_trans.cold()
- fs/btrfs/xattr.o: warning: objtool: .text.unlikely: unexpected end of section
-
-Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
-Reviewed-by: Anand Jain <anand.jain@oracle.com>
-Signed-off-by: Josef Bacik <josef@toxicpanda.com>
-Reviewed-by: David Sterba <dsterba@suse.com>
-Signed-off-by: David Sterba <dsterba@suse.com>
-Stable-dep-of: db0a4a7b8e95 ("btrfs: fix an error handling path in btrfs_defrag_leaves()")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- fs/btrfs/ctree.h | 18 +++---------------
- fs/btrfs/super.c | 14 ++++++++++++++
- 2 files changed, 17 insertions(+), 15 deletions(-)
-
-diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
-index 329277a5c6e8..d7869188f8b2 100644
---- a/fs/btrfs/ctree.h
-+++ b/fs/btrfs/ctree.h
-@@ -3609,18 +3609,11 @@ do { \
- } while (0)
-
- #ifdef CONFIG_BTRFS_ASSERT
--__cold __noreturn
--static inline void assertfail(const char *expr, const char *file, int line)
--{
-- pr_err("assertion failed: %s, in %s:%d\n", expr, file, line);
-- BUG();
--}
-+void __cold btrfs_assertfail(const char *expr, const char *file, int line);
-
- #define ASSERT(expr) \
-- (likely(expr) ? (void)0 : assertfail(#expr, __FILE__, __LINE__))
--
-+ (likely(expr) ? (void)0 : btrfs_assertfail(#expr, __FILE__, __LINE__))
- #else
--static inline void assertfail(const char *expr, const char* file, int line) { }
- #define ASSERT(expr) (void)(expr)
- #endif
-
-@@ -3680,12 +3673,7 @@ static inline unsigned long get_eb_page_index(unsigned long offset)
- #define EXPORT_FOR_TESTS
- #endif
-
--__cold
--static inline void btrfs_print_v0_err(struct btrfs_fs_info *fs_info)
--{
-- btrfs_err(fs_info,
--"Unsupported V0 extent filesystem detected. Aborting. Please re-create your filesystem with a newer kernel");
--}
-+void __cold btrfs_print_v0_err(struct btrfs_fs_info *fs_info);
-
- __printf(5, 6)
- __cold
-diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
-index adb0ce19a13c..7cdf27d807be 100644
---- a/fs/btrfs/super.c
-+++ b/fs/btrfs/super.c
-@@ -305,6 +305,20 @@ void __cold _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt,
- }
- #endif
-
-+#ifdef CONFIG_BTRFS_ASSERT
-+void __cold btrfs_assertfail(const char *expr, const char *file, int line)
-+{
-+ pr_err("assertion failed: %s, in %s:%d\n", expr, file, line);
-+ BUG();
-+}
-+#endif
-+
-+void __cold btrfs_print_v0_err(struct btrfs_fs_info *fs_info)
-+{
-+ btrfs_err(fs_info,
-+"Unsupported V0 extent filesystem detected. Aborting. Please re-create your filesystem with a newer kernel");
-+}
-+
- #if BITS_PER_LONG == 32
- void __cold btrfs_warn_32bit_limit(struct btrfs_fs_info *fs_info)
- {
---
-2.35.1
-
+++ /dev/null
-From 338cc4cbd738e55ae3b8dbe02b50d0b4d80cee00 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 14 Sep 2022 11:06:29 -0400
-Subject: btrfs: move btrfs_get_block_group helper out of disk-io.h
-
-From: Josef Bacik <josef@toxicpanda.com>
-
-[ Upstream commit 51129b33d3911c7a36e643d47cf7c00fba3089fe ]
-
-This inline helper calls btrfs_fs_compat_ro(), which is defined in
-another header. To avoid weird header dependency problems move this
-helper into disk-io.c with the rest of the global root helpers.
-
-Reviewed-by: Qu Wenruo <wqu@suse.com>
-Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
-Signed-off-by: Josef Bacik <josef@toxicpanda.com>
-Signed-off-by: David Sterba <dsterba@suse.com>
-Stable-dep-of: db0a4a7b8e95 ("btrfs: fix an error handling path in btrfs_defrag_leaves()")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- fs/btrfs/disk-io.c | 7 +++++++
- fs/btrfs/disk-io.h | 8 +-------
- 2 files changed, 8 insertions(+), 7 deletions(-)
-
-diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
-index 6538f52262ca..a93fff4f2892 100644
---- a/fs/btrfs/disk-io.c
-+++ b/fs/btrfs/disk-io.c
-@@ -1167,6 +1167,13 @@ struct btrfs_root *btrfs_extent_root(struct btrfs_fs_info *fs_info, u64 bytenr)
- return btrfs_global_root(fs_info, &key);
- }
-
-+struct btrfs_root *btrfs_block_group_root(struct btrfs_fs_info *fs_info)
-+{
-+ if (btrfs_fs_compat_ro(fs_info, BLOCK_GROUP_TREE))
-+ return fs_info->block_group_root;
-+ return btrfs_extent_root(fs_info, 0);
-+}
-+
- struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
- u64 objectid)
- {
-diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
-index 7322af63c0cc..ead1fa98ad3a 100644
---- a/fs/btrfs/disk-io.h
-+++ b/fs/btrfs/disk-io.h
-@@ -75,6 +75,7 @@ struct btrfs_root *btrfs_global_root(struct btrfs_fs_info *fs_info,
- struct btrfs_key *key);
- struct btrfs_root *btrfs_csum_root(struct btrfs_fs_info *fs_info, u64 bytenr);
- struct btrfs_root *btrfs_extent_root(struct btrfs_fs_info *fs_info, u64 bytenr);
-+struct btrfs_root *btrfs_block_group_root(struct btrfs_fs_info *fs_info);
-
- void btrfs_free_fs_info(struct btrfs_fs_info *fs_info);
- int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info);
-@@ -106,13 +107,6 @@ static inline struct btrfs_root *btrfs_grab_root(struct btrfs_root *root)
- return NULL;
- }
-
--static inline struct btrfs_root *btrfs_block_group_root(struct btrfs_fs_info *fs_info)
--{
-- if (btrfs_fs_compat_ro(fs_info, BLOCK_GROUP_TREE))
-- return fs_info->block_group_root;
-- return btrfs_extent_root(fs_info, 0);
--}
--
- void btrfs_put_root(struct btrfs_root *root);
- void btrfs_mark_buffer_dirty(struct extent_buffer *buf);
- int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid,
---
-2.35.1
-
+++ /dev/null
-From e2fe92702ae8bbcddb7edce39062555a7b4f0c64 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 14 Sep 2022 11:06:36 -0400
-Subject: btrfs: move btrfs_print_data_csum_error into inode.c
-
-From: Josef Bacik <josef@toxicpanda.com>
-
-[ Upstream commit f60acad355cf14ccccf420e6ea0ddd6de87cb210 ]
-
-This isn't used outside of inode.c, there's no reason to define it in
-btrfs_inode.h. Drop the inline and add __cold as it's for errors that
-are not in any hot path.
-
-Reviewed-by: Qu Wenruo <wqu@suse.com>
-Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
-Signed-off-by: Josef Bacik <josef@toxicpanda.com>
-Reviewed-by: David Sterba <dsterba@suse.com>
-Signed-off-by: David Sterba <dsterba@suse.com>
-Stable-dep-of: db0a4a7b8e95 ("btrfs: fix an error handling path in btrfs_defrag_leaves()")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- fs/btrfs/btrfs_inode.h | 26 --------------------------
- fs/btrfs/inode.c | 26 ++++++++++++++++++++++++++
- 2 files changed, 26 insertions(+), 26 deletions(-)
-
-diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
-index 54c2ccb36b61..530a0ebfab3f 100644
---- a/fs/btrfs/btrfs_inode.h
-+++ b/fs/btrfs/btrfs_inode.h
-@@ -410,30 +410,4 @@ static inline void btrfs_inode_split_flags(u64 inode_item_flags,
- /* Array of bytes with variable length, hexadecimal format 0x1234 */
- #define CSUM_FMT "0x%*phN"
- #define CSUM_FMT_VALUE(size, bytes) size, bytes
--
--static inline void btrfs_print_data_csum_error(struct btrfs_inode *inode,
-- u64 logical_start, u8 *csum, u8 *csum_expected, int mirror_num)
--{
-- struct btrfs_root *root = inode->root;
-- const u32 csum_size = root->fs_info->csum_size;
--
-- /* Output minus objectid, which is more meaningful */
-- if (root->root_key.objectid >= BTRFS_LAST_FREE_OBJECTID)
-- btrfs_warn_rl(root->fs_info,
--"csum failed root %lld ino %lld off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d",
-- root->root_key.objectid, btrfs_ino(inode),
-- logical_start,
-- CSUM_FMT_VALUE(csum_size, csum),
-- CSUM_FMT_VALUE(csum_size, csum_expected),
-- mirror_num);
-- else
-- btrfs_warn_rl(root->fs_info,
--"csum failed root %llu ino %llu off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d",
-- root->root_key.objectid, btrfs_ino(inode),
-- logical_start,
-- CSUM_FMT_VALUE(csum_size, csum),
-- CSUM_FMT_VALUE(csum_size, csum_expected),
-- mirror_num);
--}
--
- #endif
-diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
-index 0e516aefbf51..fafc8bc279c5 100644
---- a/fs/btrfs/inode.c
-+++ b/fs/btrfs/inode.c
-@@ -125,6 +125,32 @@ static struct extent_map *create_io_em(struct btrfs_inode *inode, u64 start,
- u64 ram_bytes, int compress_type,
- int type);
-
-+static void __cold btrfs_print_data_csum_error(struct btrfs_inode *inode,
-+ u64 logical_start, u8 *csum, u8 *csum_expected, int mirror_num)
-+{
-+ struct btrfs_root *root = inode->root;
-+ const u32 csum_size = root->fs_info->csum_size;
-+
-+ /* Output without objectid, which is more meaningful */
-+ if (root->root_key.objectid >= BTRFS_LAST_FREE_OBJECTID) {
-+ btrfs_warn_rl(root->fs_info,
-+"csum failed root %lld ino %lld off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d",
-+ root->root_key.objectid, btrfs_ino(inode),
-+ logical_start,
-+ CSUM_FMT_VALUE(csum_size, csum),
-+ CSUM_FMT_VALUE(csum_size, csum_expected),
-+ mirror_num);
-+ } else {
-+ btrfs_warn_rl(root->fs_info,
-+"csum failed root %llu ino %llu off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d",
-+ root->root_key.objectid, btrfs_ino(inode),
-+ logical_start,
-+ CSUM_FMT_VALUE(csum_size, csum),
-+ CSUM_FMT_VALUE(csum_size, csum_expected),
-+ mirror_num);
-+ }
-+}
-+
- /*
- * btrfs_inode_lock - lock inode i_rwsem based on arguments passed
- *
---
-2.35.1
-
+++ /dev/null
-From 5bdaedb4ba20395cf5c08bb3845b74143f1ad833 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 14 Sep 2022 11:06:35 -0400
-Subject: btrfs: move flush related definitions to space-info.h
-
-From: Josef Bacik <josef@toxicpanda.com>
-
-[ Upstream commit f1e5c6185ca166cde0c7c2eeeab5d233ef315140 ]
-
-This code is used in space-info.c, move the definitions to space-info.h.
-
-Reviewed-by: Qu Wenruo <wqu@suse.com>
-Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
-Signed-off-by: Josef Bacik <josef@toxicpanda.com>
-Reviewed-by: David Sterba <dsterba@suse.com>
-Signed-off-by: David Sterba <dsterba@suse.com>
-Stable-dep-of: db0a4a7b8e95 ("btrfs: fix an error handling path in btrfs_defrag_leaves()")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- fs/btrfs/ctree.h | 59 ----------------------------------------
- fs/btrfs/delayed-inode.c | 1 +
- fs/btrfs/inode-item.c | 1 +
- fs/btrfs/props.c | 1 +
- fs/btrfs/relocation.c | 1 +
- fs/btrfs/space-info.h | 59 ++++++++++++++++++++++++++++++++++++++++
- 6 files changed, 63 insertions(+), 59 deletions(-)
-
-diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
-index 9e6d48ff4597..2abdf6bab66d 100644
---- a/fs/btrfs/ctree.h
-+++ b/fs/btrfs/ctree.h
-@@ -2920,65 +2920,6 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
-
- void btrfs_clear_space_info_full(struct btrfs_fs_info *info);
-
--/*
-- * Different levels for to flush space when doing space reservations.
-- *
-- * The higher the level, the more methods we try to reclaim space.
-- */
--enum btrfs_reserve_flush_enum {
-- /* If we are in the transaction, we can't flush anything.*/
-- BTRFS_RESERVE_NO_FLUSH,
--
-- /*
-- * Flush space by:
-- * - Running delayed inode items
-- * - Allocating a new chunk
-- */
-- BTRFS_RESERVE_FLUSH_LIMIT,
--
-- /*
-- * Flush space by:
-- * - Running delayed inode items
-- * - Running delayed refs
-- * - Running delalloc and waiting for ordered extents
-- * - Allocating a new chunk
-- */
-- BTRFS_RESERVE_FLUSH_EVICT,
--
-- /*
-- * Flush space by above mentioned methods and by:
-- * - Running delayed iputs
-- * - Committing transaction
-- *
-- * Can be interrupted by a fatal signal.
-- */
-- BTRFS_RESERVE_FLUSH_DATA,
-- BTRFS_RESERVE_FLUSH_FREE_SPACE_INODE,
-- BTRFS_RESERVE_FLUSH_ALL,
--
-- /*
-- * Pretty much the same as FLUSH_ALL, but can also steal space from
-- * global rsv.
-- *
-- * Can be interrupted by a fatal signal.
-- */
-- BTRFS_RESERVE_FLUSH_ALL_STEAL,
--};
--
--enum btrfs_flush_state {
-- FLUSH_DELAYED_ITEMS_NR = 1,
-- FLUSH_DELAYED_ITEMS = 2,
-- FLUSH_DELAYED_REFS_NR = 3,
-- FLUSH_DELAYED_REFS = 4,
-- FLUSH_DELALLOC = 5,
-- FLUSH_DELALLOC_WAIT = 6,
-- FLUSH_DELALLOC_FULL = 7,
-- ALLOC_CHUNK = 8,
-- ALLOC_CHUNK_FORCE = 9,
-- RUN_DELAYED_IPUTS = 10,
-- COMMIT_TRANS = 11,
--};
--
- int btrfs_subvolume_reserve_metadata(struct btrfs_root *root,
- struct btrfs_block_rsv *rsv,
- int nitems, bool use_global_rsv);
-diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
-index cac5169eaf8d..a411f04a7b97 100644
---- a/fs/btrfs/delayed-inode.c
-+++ b/fs/btrfs/delayed-inode.c
-@@ -14,6 +14,7 @@
- #include "qgroup.h"
- #include "locking.h"
- #include "inode-item.h"
-+#include "space-info.h"
-
- #define BTRFS_DELAYED_WRITEBACK 512
- #define BTRFS_DELAYED_BACKGROUND 128
-diff --git a/fs/btrfs/inode-item.c b/fs/btrfs/inode-item.c
-index 0eeb5ea87894..366f3a788c6a 100644
---- a/fs/btrfs/inode-item.c
-+++ b/fs/btrfs/inode-item.c
-@@ -8,6 +8,7 @@
- #include "disk-io.h"
- #include "transaction.h"
- #include "print-tree.h"
-+#include "space-info.h"
-
- struct btrfs_inode_ref *btrfs_find_name_in_backref(struct extent_buffer *leaf,
- int slot, const char *name,
-diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
-index 055a631276ce..07f62e3ba6a5 100644
---- a/fs/btrfs/props.c
-+++ b/fs/btrfs/props.c
-@@ -10,6 +10,7 @@
- #include "ctree.h"
- #include "xattr.h"
- #include "compression.h"
-+#include "space-info.h"
-
- #define BTRFS_PROP_HANDLERS_HT_BITS 8
- static DEFINE_HASHTABLE(prop_handlers_ht, BTRFS_PROP_HANDLERS_HT_BITS);
-diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
-index 666a37a0ee89..748c171a9488 100644
---- a/fs/btrfs/relocation.c
-+++ b/fs/btrfs/relocation.c
-@@ -27,6 +27,7 @@
- #include "subpage.h"
- #include "zoned.h"
- #include "inode-item.h"
-+#include "space-info.h"
-
- /*
- * Relocation overview
-diff --git a/fs/btrfs/space-info.h b/fs/btrfs/space-info.h
-index ce66023a9eb8..7e17bb803436 100644
---- a/fs/btrfs/space-info.h
-+++ b/fs/btrfs/space-info.h
-@@ -5,6 +5,65 @@
-
- #include "volumes.h"
-
-+/*
-+ * Different levels for to flush space when doing space reservations.
-+ *
-+ * The higher the level, the more methods we try to reclaim space.
-+ */
-+enum btrfs_reserve_flush_enum {
-+ /* If we are in the transaction, we can't flush anything.*/
-+ BTRFS_RESERVE_NO_FLUSH,
-+
-+ /*
-+ * Flush space by:
-+ * - Running delayed inode items
-+ * - Allocating a new chunk
-+ */
-+ BTRFS_RESERVE_FLUSH_LIMIT,
-+
-+ /*
-+ * Flush space by:
-+ * - Running delayed inode items
-+ * - Running delayed refs
-+ * - Running delalloc and waiting for ordered extents
-+ * - Allocating a new chunk
-+ */
-+ BTRFS_RESERVE_FLUSH_EVICT,
-+
-+ /*
-+ * Flush space by above mentioned methods and by:
-+ * - Running delayed iputs
-+ * - Committing transaction
-+ *
-+ * Can be interrupted by a fatal signal.
-+ */
-+ BTRFS_RESERVE_FLUSH_DATA,
-+ BTRFS_RESERVE_FLUSH_FREE_SPACE_INODE,
-+ BTRFS_RESERVE_FLUSH_ALL,
-+
-+ /*
-+ * Pretty much the same as FLUSH_ALL, but can also steal space from
-+ * global rsv.
-+ *
-+ * Can be interrupted by a fatal signal.
-+ */
-+ BTRFS_RESERVE_FLUSH_ALL_STEAL,
-+};
-+
-+enum btrfs_flush_state {
-+ FLUSH_DELAYED_ITEMS_NR = 1,
-+ FLUSH_DELAYED_ITEMS = 2,
-+ FLUSH_DELAYED_REFS_NR = 3,
-+ FLUSH_DELAYED_REFS = 4,
-+ FLUSH_DELALLOC = 5,
-+ FLUSH_DELALLOC_WAIT = 6,
-+ FLUSH_DELALLOC_FULL = 7,
-+ ALLOC_CHUNK = 8,
-+ ALLOC_CHUNK_FORCE = 9,
-+ RUN_DELAYED_IPUTS = 10,
-+ COMMIT_TRANS = 11,
-+};
-+
- struct btrfs_space_info {
- spinlock_t lock;
-
---
-2.35.1
-
+++ /dev/null
-From ce1565843571a8604db5ebf3ac11d0b624d6b264 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 19 Oct 2022 10:50:47 -0400
-Subject: btrfs: move fs wide helpers out of ctree.h
-
-From: Josef Bacik <josef@toxicpanda.com>
-
-[ Upstream commit c7f13d428ea1bfe883f2741a9b5a5352d595eb09 ]
-
-We have several fs wide related helpers in ctree.h. The bulk of these
-are the incompat flag test helpers, but there are things such as
-btrfs_fs_closing() and the read only helpers that also aren't directly
-related to the ctree code. Move these into a fs.h header, which will
-serve as the location for file system wide related helpers.
-
-Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
-Reviewed-by: Anand Jain <anand.jain@oracle.com>
-Signed-off-by: Josef Bacik <josef@toxicpanda.com>
-Reviewed-by: David Sterba <dsterba@suse.com>
-Signed-off-by: David Sterba <dsterba@suse.com>
-Stable-dep-of: db0a4a7b8e95 ("btrfs: fix an error handling path in btrfs_defrag_leaves()")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- fs/btrfs/Makefile | 2 +-
- fs/btrfs/backref.c | 1 +
- fs/btrfs/block-group.c | 1 +
- fs/btrfs/ctree.h | 164 -------------------------------------
- fs/btrfs/disk-io.c | 1 +
- fs/btrfs/extent-tree.c | 1 +
- fs/btrfs/file-item.c | 1 +
- fs/btrfs/file.c | 1 +
- fs/btrfs/free-space-tree.c | 1 +
- fs/btrfs/fs.c | 92 +++++++++++++++++++++
- fs/btrfs/fs.h | 85 +++++++++++++++++++
- fs/btrfs/inode.c | 1 +
- fs/btrfs/ioctl.c | 1 +
- fs/btrfs/props.c | 1 +
- fs/btrfs/qgroup.c | 1 +
- fs/btrfs/relocation.c | 1 +
- fs/btrfs/scrub.c | 1 +
- fs/btrfs/space-info.c | 1 +
- fs/btrfs/super.c | 1 +
- fs/btrfs/transaction.c | 1 +
- fs/btrfs/tree-checker.c | 1 +
- fs/btrfs/tree-log.c | 1 +
- fs/btrfs/uuid-tree.c | 1 +
- fs/btrfs/verity.c | 1 +
- fs/btrfs/volumes.c | 1 +
- fs/btrfs/zoned.c | 1 +
- 26 files changed, 200 insertions(+), 165 deletions(-)
- create mode 100644 fs/btrfs/fs.c
- create mode 100644 fs/btrfs/fs.h
-
-diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
-index fa9ddcc9eb0b..eebb45c06485 100644
---- a/fs/btrfs/Makefile
-+++ b/fs/btrfs/Makefile
-@@ -31,7 +31,7 @@ btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
- backref.o ulist.o qgroup.o send.o dev-replace.o raid56.o \
- uuid-tree.o props.o free-space-tree.o tree-checker.o space-info.o \
- block-rsv.o delalloc-space.o block-group.o discard.o reflink.o \
-- subpage.o tree-mod-log.o extent-io-tree.o
-+ subpage.o tree-mod-log.o extent-io-tree.o fs.o
-
- btrfs-$(CONFIG_BTRFS_FS_POSIX_ACL) += acl.o
- btrfs-$(CONFIG_BTRFS_FS_CHECK_INTEGRITY) += check-integrity.o
-diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
-index 18cf801ab590..cbab685fe373 100644
---- a/fs/btrfs/backref.c
-+++ b/fs/btrfs/backref.c
-@@ -15,6 +15,7 @@
- #include "locking.h"
- #include "misc.h"
- #include "tree-mod-log.h"
-+#include "fs.h"
-
- /* Just an arbitrary number so we can be sure this happened */
- #define BACKREF_FOUND_SHARED 6
-diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
-index deebc8ddbd93..1fb8a4753735 100644
---- a/fs/btrfs/block-group.c
-+++ b/fs/btrfs/block-group.c
-@@ -17,6 +17,7 @@
- #include "discard.h"
- #include "raid56.h"
- #include "zoned.h"
-+#include "fs.h"
-
- /*
- * Return target flags in extended format or 0 if restripe for this chunk_type
-diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
-index 2abdf6bab66d..329277a5c6e8 100644
---- a/fs/btrfs/ctree.h
-+++ b/fs/btrfs/ctree.h
-@@ -3135,44 +3135,6 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
- struct extent_buffer *node,
- struct extent_buffer *parent);
--static inline int btrfs_fs_closing(struct btrfs_fs_info *fs_info)
--{
-- /*
-- * Do it this way so we only ever do one test_bit in the normal case.
-- */
-- if (test_bit(BTRFS_FS_CLOSING_START, &fs_info->flags)) {
-- if (test_bit(BTRFS_FS_CLOSING_DONE, &fs_info->flags))
-- return 2;
-- return 1;
-- }
-- return 0;
--}
--
--/*
-- * If we remount the fs to be R/O or umount the fs, the cleaner needn't do
-- * anything except sleeping. This function is used to check the status of
-- * the fs.
-- * We check for BTRFS_FS_STATE_RO to avoid races with a concurrent remount,
-- * since setting and checking for SB_RDONLY in the superblock's flags is not
-- * atomic.
-- */
--static inline int btrfs_need_cleaner_sleep(struct btrfs_fs_info *fs_info)
--{
-- return test_bit(BTRFS_FS_STATE_RO, &fs_info->fs_state) ||
-- btrfs_fs_closing(fs_info);
--}
--
--static inline void btrfs_set_sb_rdonly(struct super_block *sb)
--{
-- sb->s_flags |= SB_RDONLY;
-- set_bit(BTRFS_FS_STATE_RO, &btrfs_sb(sb)->fs_state);
--}
--
--static inline void btrfs_clear_sb_rdonly(struct super_block *sb)
--{
-- sb->s_flags &= ~SB_RDONLY;
-- clear_bit(BTRFS_FS_STATE_RO, &btrfs_sb(sb)->fs_state);
--}
-
- /* root-item.c */
- int btrfs_add_root_ref(struct btrfs_trans_handle *trans, u64 root_id,
-@@ -3805,132 +3767,6 @@ do { \
- } while (0)
-
-
--/* compatibility and incompatibility defines */
--
--#define btrfs_set_fs_incompat(__fs_info, opt) \
-- __btrfs_set_fs_incompat((__fs_info), BTRFS_FEATURE_INCOMPAT_##opt, \
-- #opt)
--
--static inline void __btrfs_set_fs_incompat(struct btrfs_fs_info *fs_info,
-- u64 flag, const char* name)
--{
-- struct btrfs_super_block *disk_super;
-- u64 features;
--
-- disk_super = fs_info->super_copy;
-- features = btrfs_super_incompat_flags(disk_super);
-- if (!(features & flag)) {
-- spin_lock(&fs_info->super_lock);
-- features = btrfs_super_incompat_flags(disk_super);
-- if (!(features & flag)) {
-- features |= flag;
-- btrfs_set_super_incompat_flags(disk_super, features);
-- btrfs_info(fs_info,
-- "setting incompat feature flag for %s (0x%llx)",
-- name, flag);
-- }
-- spin_unlock(&fs_info->super_lock);
-- }
--}
--
--#define btrfs_clear_fs_incompat(__fs_info, opt) \
-- __btrfs_clear_fs_incompat((__fs_info), BTRFS_FEATURE_INCOMPAT_##opt, \
-- #opt)
--
--static inline void __btrfs_clear_fs_incompat(struct btrfs_fs_info *fs_info,
-- u64 flag, const char* name)
--{
-- struct btrfs_super_block *disk_super;
-- u64 features;
--
-- disk_super = fs_info->super_copy;
-- features = btrfs_super_incompat_flags(disk_super);
-- if (features & flag) {
-- spin_lock(&fs_info->super_lock);
-- features = btrfs_super_incompat_flags(disk_super);
-- if (features & flag) {
-- features &= ~flag;
-- btrfs_set_super_incompat_flags(disk_super, features);
-- btrfs_info(fs_info,
-- "clearing incompat feature flag for %s (0x%llx)",
-- name, flag);
-- }
-- spin_unlock(&fs_info->super_lock);
-- }
--}
--
--#define btrfs_fs_incompat(fs_info, opt) \
-- __btrfs_fs_incompat((fs_info), BTRFS_FEATURE_INCOMPAT_##opt)
--
--static inline bool __btrfs_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag)
--{
-- struct btrfs_super_block *disk_super;
-- disk_super = fs_info->super_copy;
-- return !!(btrfs_super_incompat_flags(disk_super) & flag);
--}
--
--#define btrfs_set_fs_compat_ro(__fs_info, opt) \
-- __btrfs_set_fs_compat_ro((__fs_info), BTRFS_FEATURE_COMPAT_RO_##opt, \
-- #opt)
--
--static inline void __btrfs_set_fs_compat_ro(struct btrfs_fs_info *fs_info,
-- u64 flag, const char *name)
--{
-- struct btrfs_super_block *disk_super;
-- u64 features;
--
-- disk_super = fs_info->super_copy;
-- features = btrfs_super_compat_ro_flags(disk_super);
-- if (!(features & flag)) {
-- spin_lock(&fs_info->super_lock);
-- features = btrfs_super_compat_ro_flags(disk_super);
-- if (!(features & flag)) {
-- features |= flag;
-- btrfs_set_super_compat_ro_flags(disk_super, features);
-- btrfs_info(fs_info,
-- "setting compat-ro feature flag for %s (0x%llx)",
-- name, flag);
-- }
-- spin_unlock(&fs_info->super_lock);
-- }
--}
--
--#define btrfs_clear_fs_compat_ro(__fs_info, opt) \
-- __btrfs_clear_fs_compat_ro((__fs_info), BTRFS_FEATURE_COMPAT_RO_##opt, \
-- #opt)
--
--static inline void __btrfs_clear_fs_compat_ro(struct btrfs_fs_info *fs_info,
-- u64 flag, const char *name)
--{
-- struct btrfs_super_block *disk_super;
-- u64 features;
--
-- disk_super = fs_info->super_copy;
-- features = btrfs_super_compat_ro_flags(disk_super);
-- if (features & flag) {
-- spin_lock(&fs_info->super_lock);
-- features = btrfs_super_compat_ro_flags(disk_super);
-- if (features & flag) {
-- features &= ~flag;
-- btrfs_set_super_compat_ro_flags(disk_super, features);
-- btrfs_info(fs_info,
-- "clearing compat-ro feature flag for %s (0x%llx)",
-- name, flag);
-- }
-- spin_unlock(&fs_info->super_lock);
-- }
--}
--
--#define btrfs_fs_compat_ro(fs_info, opt) \
-- __btrfs_fs_compat_ro((fs_info), BTRFS_FEATURE_COMPAT_RO_##opt)
--
--static inline int __btrfs_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag)
--{
-- struct btrfs_super_block *disk_super;
-- disk_super = fs_info->super_copy;
-- return !!(btrfs_super_compat_ro_flags(disk_super) & flag);
--}
--
- /* acl.c */
- #ifdef CONFIG_BTRFS_FS_POSIX_ACL
- struct posix_acl *btrfs_get_acl(struct inode *inode, int type, bool rcu);
-diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
-index a93fff4f2892..98d1cc51ba8f 100644
---- a/fs/btrfs/disk-io.c
-+++ b/fs/btrfs/disk-io.c
-@@ -43,6 +43,7 @@
- #include "space-info.h"
- #include "zoned.h"
- #include "subpage.h"
-+#include "fs.h"
-
- #define BTRFS_SUPER_FLAG_SUPP (BTRFS_HEADER_FLAG_WRITTEN |\
- BTRFS_HEADER_FLAG_RELOC |\
-diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
-index 2801c991814f..bc010dbcb6b1 100644
---- a/fs/btrfs/extent-tree.c
-+++ b/fs/btrfs/extent-tree.c
-@@ -36,6 +36,7 @@
- #include "rcu-string.h"
- #include "zoned.h"
- #include "dev-replace.h"
-+#include "fs.h"
-
- #undef SCRAMBLE_DELAYED_REFS
-
-diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
-index 6bb9fa961a6a..824ff54d8155 100644
---- a/fs/btrfs/file-item.c
-+++ b/fs/btrfs/file-item.c
-@@ -16,6 +16,7 @@
- #include "volumes.h"
- #include "print-tree.h"
- #include "compression.h"
-+#include "fs.h"
-
- #define __MAX_CSUM_ITEMS(r, size) ((unsigned long)(((BTRFS_LEAF_DATA_SIZE(r) - \
- sizeof(struct btrfs_item) * 2) / \
-diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
-index 9bef8eaa074a..48b672220406 100644
---- a/fs/btrfs/file.c
-+++ b/fs/btrfs/file.c
-@@ -30,6 +30,7 @@
- #include "delalloc-space.h"
- #include "reflink.h"
- #include "subpage.h"
-+#include "fs.h"
-
- static struct kmem_cache *btrfs_inode_defrag_cachep;
- /*
-diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
-index 367bcfcf68f5..bfc21eb8ec63 100644
---- a/fs/btrfs/free-space-tree.c
-+++ b/fs/btrfs/free-space-tree.c
-@@ -11,6 +11,7 @@
- #include "free-space-tree.h"
- #include "transaction.h"
- #include "block-group.h"
-+#include "fs.h"
-
- static int __add_block_group_free_space(struct btrfs_trans_handle *trans,
- struct btrfs_block_group *block_group,
-diff --git a/fs/btrfs/fs.c b/fs/btrfs/fs.c
-new file mode 100644
-index 000000000000..d4ba948eba56
---- /dev/null
-+++ b/fs/btrfs/fs.c
-@@ -0,0 +1,92 @@
-+// SPDX-License-Identifier: GPL-2.0
-+
-+#include "ctree.h"
-+#include "fs.h"
-+
-+void __btrfs_set_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag,
-+ const char *name)
-+{
-+ struct btrfs_super_block *disk_super;
-+ u64 features;
-+
-+ disk_super = fs_info->super_copy;
-+ features = btrfs_super_incompat_flags(disk_super);
-+ if (!(features & flag)) {
-+ spin_lock(&fs_info->super_lock);
-+ features = btrfs_super_incompat_flags(disk_super);
-+ if (!(features & flag)) {
-+ features |= flag;
-+ btrfs_set_super_incompat_flags(disk_super, features);
-+ btrfs_info(fs_info,
-+ "setting incompat feature flag for %s (0x%llx)",
-+ name, flag);
-+ }
-+ spin_unlock(&fs_info->super_lock);
-+ }
-+}
-+
-+void __btrfs_clear_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag,
-+ const char *name)
-+{
-+ struct btrfs_super_block *disk_super;
-+ u64 features;
-+
-+ disk_super = fs_info->super_copy;
-+ features = btrfs_super_incompat_flags(disk_super);
-+ if (features & flag) {
-+ spin_lock(&fs_info->super_lock);
-+ features = btrfs_super_incompat_flags(disk_super);
-+ if (features & flag) {
-+ features &= ~flag;
-+ btrfs_set_super_incompat_flags(disk_super, features);
-+ btrfs_info(fs_info,
-+ "clearing incompat feature flag for %s (0x%llx)",
-+ name, flag);
-+ }
-+ spin_unlock(&fs_info->super_lock);
-+ }
-+}
-+
-+void __btrfs_set_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag,
-+ const char *name)
-+{
-+ struct btrfs_super_block *disk_super;
-+ u64 features;
-+
-+ disk_super = fs_info->super_copy;
-+ features = btrfs_super_compat_ro_flags(disk_super);
-+ if (!(features & flag)) {
-+ spin_lock(&fs_info->super_lock);
-+ features = btrfs_super_compat_ro_flags(disk_super);
-+ if (!(features & flag)) {
-+ features |= flag;
-+ btrfs_set_super_compat_ro_flags(disk_super, features);
-+ btrfs_info(fs_info,
-+ "setting compat-ro feature flag for %s (0x%llx)",
-+ name, flag);
-+ }
-+ spin_unlock(&fs_info->super_lock);
-+ }
-+}
-+
-+void __btrfs_clear_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag,
-+ const char *name)
-+{
-+ struct btrfs_super_block *disk_super;
-+ u64 features;
-+
-+ disk_super = fs_info->super_copy;
-+ features = btrfs_super_compat_ro_flags(disk_super);
-+ if (features & flag) {
-+ spin_lock(&fs_info->super_lock);
-+ features = btrfs_super_compat_ro_flags(disk_super);
-+ if (features & flag) {
-+ features &= ~flag;
-+ btrfs_set_super_compat_ro_flags(disk_super, features);
-+ btrfs_info(fs_info,
-+ "clearing compat-ro feature flag for %s (0x%llx)",
-+ name, flag);
-+ }
-+ spin_unlock(&fs_info->super_lock);
-+ }
-+}
-diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h
-new file mode 100644
-index 000000000000..8eda9ce0a904
---- /dev/null
-+++ b/fs/btrfs/fs.h
-@@ -0,0 +1,85 @@
-+/* SPDX-License-Identifier: GPL-2.0 */
-+
-+#ifndef BTRFS_FS_H
-+#define BTRFS_FS_H
-+
-+/* Compatibility and incompatibility defines */
-+void __btrfs_set_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag,
-+ const char *name);
-+void __btrfs_clear_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag,
-+ const char *name);
-+void __btrfs_set_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag,
-+ const char *name);
-+void __btrfs_clear_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag,
-+ const char *name);
-+
-+#define btrfs_set_fs_incompat(__fs_info, opt) \
-+ __btrfs_set_fs_incompat((__fs_info), BTRFS_FEATURE_INCOMPAT_##opt, #opt)
-+
-+#define btrfs_clear_fs_incompat(__fs_info, opt) \
-+ __btrfs_clear_fs_incompat((__fs_info), BTRFS_FEATURE_INCOMPAT_##opt, #opt)
-+
-+#define btrfs_fs_incompat(fs_info, opt) \
-+ __btrfs_fs_incompat((fs_info), BTRFS_FEATURE_INCOMPAT_##opt)
-+
-+#define btrfs_set_fs_compat_ro(__fs_info, opt) \
-+ __btrfs_set_fs_compat_ro((__fs_info), BTRFS_FEATURE_COMPAT_RO_##opt, #opt)
-+
-+#define btrfs_clear_fs_compat_ro(__fs_info, opt) \
-+ __btrfs_clear_fs_compat_ro((__fs_info), BTRFS_FEATURE_COMPAT_RO_##opt, #opt)
-+
-+#define btrfs_fs_compat_ro(fs_info, opt) \
-+ __btrfs_fs_compat_ro((fs_info), BTRFS_FEATURE_COMPAT_RO_##opt)
-+
-+static inline bool __btrfs_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag)
-+{
-+ struct btrfs_super_block *disk_super;
-+ disk_super = fs_info->super_copy;
-+ return !!(btrfs_super_incompat_flags(disk_super) & flag);
-+}
-+
-+static inline int __btrfs_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag)
-+{
-+ struct btrfs_super_block *disk_super;
-+ disk_super = fs_info->super_copy;
-+ return !!(btrfs_super_compat_ro_flags(disk_super) & flag);
-+}
-+
-+static inline int btrfs_fs_closing(struct btrfs_fs_info *fs_info)
-+{
-+ /* Do it this way so we only ever do one test_bit in the normal case. */
-+ if (test_bit(BTRFS_FS_CLOSING_START, &fs_info->flags)) {
-+ if (test_bit(BTRFS_FS_CLOSING_DONE, &fs_info->flags))
-+ return 2;
-+ return 1;
-+ }
-+ return 0;
-+}
-+
-+/*
-+ * If we remount the fs to be R/O or umount the fs, the cleaner needn't do
-+ * anything except sleeping. This function is used to check the status of
-+ * the fs.
-+ * We check for BTRFS_FS_STATE_RO to avoid races with a concurrent remount,
-+ * since setting and checking for SB_RDONLY in the superblock's flags is not
-+ * atomic.
-+ */
-+static inline int btrfs_need_cleaner_sleep(struct btrfs_fs_info *fs_info)
-+{
-+ return test_bit(BTRFS_FS_STATE_RO, &fs_info->fs_state) ||
-+ btrfs_fs_closing(fs_info);
-+}
-+
-+static inline void btrfs_set_sb_rdonly(struct super_block *sb)
-+{
-+ sb->s_flags |= SB_RDONLY;
-+ set_bit(BTRFS_FS_STATE_RO, &btrfs_sb(sb)->fs_state);
-+}
-+
-+static inline void btrfs_clear_sb_rdonly(struct super_block *sb)
-+{
-+ sb->s_flags &= ~SB_RDONLY;
-+ clear_bit(BTRFS_FS_STATE_RO, &btrfs_sb(sb)->fs_state);
-+}
-+
-+#endif
-diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
-index fafc8bc279c5..cc996828e4a8 100644
---- a/fs/btrfs/inode.c
-+++ b/fs/btrfs/inode.c
-@@ -55,6 +55,7 @@
- #include "zoned.h"
- #include "subpage.h"
- #include "inode-item.h"
-+#include "fs.h"
-
- struct btrfs_iget_args {
- u64 ino;
-diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
-index fd1902573cde..8e3512be6fb1 100644
---- a/fs/btrfs/ioctl.c
-+++ b/fs/btrfs/ioctl.c
-@@ -50,6 +50,7 @@
- #include "delalloc-space.h"
- #include "block-group.h"
- #include "subpage.h"
-+#include "fs.h"
-
- #ifdef CONFIG_64BIT
- /* If we have a 32-bit userspace and 64-bit kernel, then the UAPI
-diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
-index 07f62e3ba6a5..ef17014221e2 100644
---- a/fs/btrfs/props.c
-+++ b/fs/btrfs/props.c
-@@ -11,6 +11,7 @@
- #include "xattr.h"
- #include "compression.h"
- #include "space-info.h"
-+#include "fs.h"
-
- #define BTRFS_PROP_HANDLERS_HT_BITS 8
- static DEFINE_HASHTABLE(prop_handlers_ht, BTRFS_PROP_HANDLERS_HT_BITS);
-diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
-index b74105a10f16..e87a2f066f4d 100644
---- a/fs/btrfs/qgroup.c
-+++ b/fs/btrfs/qgroup.c
-@@ -24,6 +24,7 @@
- #include "block-group.h"
- #include "sysfs.h"
- #include "tree-mod-log.h"
-+#include "fs.h"
-
- /*
- * Helpers to access qgroup reservation
-diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
-index 748c171a9488..9fc6c7ce7c42 100644
---- a/fs/btrfs/relocation.c
-+++ b/fs/btrfs/relocation.c
-@@ -28,6 +28,7 @@
- #include "zoned.h"
- #include "inode-item.h"
- #include "space-info.h"
-+#include "fs.h"
-
- /*
- * Relocation overview
-diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
-index 196c4c6ed1ed..3562834cc1bc 100644
---- a/fs/btrfs/scrub.c
-+++ b/fs/btrfs/scrub.c
-@@ -21,6 +21,7 @@
- #include "raid56.h"
- #include "block-group.h"
- #include "zoned.h"
-+#include "fs.h"
-
- /*
- * This is only the first step towards a full-features scrub. It reads all
-diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
-index f171bf875633..024e033883d0 100644
---- a/fs/btrfs/space-info.c
-+++ b/fs/btrfs/space-info.c
-@@ -10,6 +10,7 @@
- #include "transaction.h"
- #include "block-group.h"
- #include "zoned.h"
-+#include "fs.h"
-
- /*
- * HOW DOES SPACE RESERVATION WORK
-diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
-index abfd7c897075..adb0ce19a13c 100644
---- a/fs/btrfs/super.c
-+++ b/fs/btrfs/super.c
-@@ -49,6 +49,7 @@
- #include "discard.h"
- #include "qgroup.h"
- #include "raid56.h"
-+#include "fs.h"
- #define CREATE_TRACE_POINTS
- #include <trace/events/btrfs.h>
-
-diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
-index d1f1da6820fb..6cee7f2fa5ec 100644
---- a/fs/btrfs/transaction.c
-+++ b/fs/btrfs/transaction.c
-@@ -23,6 +23,7 @@
- #include "block-group.h"
- #include "space-info.h"
- #include "zoned.h"
-+#include "fs.h"
-
- #define BTRFS_ROOT_TRANS_TAG 0
-
-diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
-index 43f905ab0a18..862d67798de5 100644
---- a/fs/btrfs/tree-checker.c
-+++ b/fs/btrfs/tree-checker.c
-@@ -25,6 +25,7 @@
- #include "volumes.h"
- #include "misc.h"
- #include "btrfs_inode.h"
-+#include "fs.h"
-
- /*
- * Error message should follow the following format:
-diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
-index c3cf3dabe0b1..e294c38f9b19 100644
---- a/fs/btrfs/tree-log.c
-+++ b/fs/btrfs/tree-log.c
-@@ -21,6 +21,7 @@
- #include "space-info.h"
- #include "zoned.h"
- #include "inode-item.h"
-+#include "fs.h"
-
- #define MAX_CONFLICT_INODES 10
-
-diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c
-index b458452a1aaf..2d7eb290fb9c 100644
---- a/fs/btrfs/uuid-tree.c
-+++ b/fs/btrfs/uuid-tree.c
-@@ -9,6 +9,7 @@
- #include "transaction.h"
- #include "disk-io.h"
- #include "print-tree.h"
-+#include "fs.h"
-
-
- static void btrfs_uuid_to_key(u8 *uuid, u8 type, struct btrfs_key *key)
-diff --git a/fs/btrfs/verity.c b/fs/btrfs/verity.c
-index ee00e33c309e..ab0b39badbbe 100644
---- a/fs/btrfs/verity.c
-+++ b/fs/btrfs/verity.c
-@@ -15,6 +15,7 @@
- #include "transaction.h"
- #include "disk-io.h"
- #include "locking.h"
-+#include "fs.h"
-
- /*
- * Implementation of the interface defined in struct fsverity_operations.
-diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
-index dba087ad40ea..762512be35e8 100644
---- a/fs/btrfs/volumes.c
-+++ b/fs/btrfs/volumes.c
-@@ -33,6 +33,7 @@
- #include "block-group.h"
- #include "discard.h"
- #include "zoned.h"
-+#include "fs.h"
-
- static struct bio_set btrfs_bioset;
-
-diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
-index c9e2b0c85309..2a7d856c232c 100644
---- a/fs/btrfs/zoned.c
-+++ b/fs/btrfs/zoned.c
-@@ -15,6 +15,7 @@
- #include "transaction.h"
- #include "dev-replace.h"
- #include "space-info.h"
-+#include "fs.h"
-
- /* Maximum number of zones to report per blkdev_report_zones() call */
- #define BTRFS_REPORT_NR_ZONES 4096
---
-2.35.1
-
+++ /dev/null
-From f8285fa41bee4b2346a277ca6da37205d2f81e7e Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 19 Oct 2022 10:50:49 -0400
-Subject: btrfs: move the printk helpers out of ctree.h
-
-From: Josef Bacik <josef@toxicpanda.com>
-
-[ Upstream commit 9b569ea0be6fb27a4985acc9325896a3edc95ede ]
-
-We have a bunch of printk helpers that are in ctree.h. These have
-nothing to do with ctree.c, so move them into their own header.
-Subsequent patches will cleanup the printk helpers.
-
-Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
-Signed-off-by: Josef Bacik <josef@toxicpanda.com>
-Reviewed-by: David Sterba <dsterba@suse.com>
-Signed-off-by: David Sterba <dsterba@suse.com>
-Stable-dep-of: db0a4a7b8e95 ("btrfs: fix an error handling path in btrfs_defrag_leaves()")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- fs/btrfs/backref.h | 1 +
- fs/btrfs/check-integrity.c | 1 +
- fs/btrfs/ctree.c | 1 +
- fs/btrfs/ctree.h | 249 ----------------------------------
- fs/btrfs/delalloc-space.c | 1 +
- fs/btrfs/delayed-inode.c | 1 +
- fs/btrfs/delayed-ref.c | 1 +
- fs/btrfs/dir-item.c | 1 +
- fs/btrfs/extent-io-tree.c | 1 +
- fs/btrfs/extent_map.c | 1 +
- fs/btrfs/file-item.c | 1 +
- fs/btrfs/free-space-cache.c | 1 +
- fs/btrfs/free-space-tree.c | 1 +
- fs/btrfs/fs.c | 1 +
- fs/btrfs/inode-item.c | 1 +
- fs/btrfs/lzo.c | 1 +
- fs/btrfs/messages.h | 259 ++++++++++++++++++++++++++++++++++++
- fs/btrfs/ordered-data.c | 1 +
- fs/btrfs/print-tree.c | 1 +
- fs/btrfs/props.c | 1 +
- fs/btrfs/raid56.c | 1 +
- fs/btrfs/ref-verify.c | 1 +
- fs/btrfs/reflink.c | 1 +
- fs/btrfs/root-tree.c | 1 +
- fs/btrfs/struct-funcs.c | 1 +
- fs/btrfs/subpage.c | 1 +
- fs/btrfs/super.c | 1 +
- fs/btrfs/sysfs.c | 2 +-
- fs/btrfs/tree-checker.c | 1 +
- fs/btrfs/tree-log.h | 1 +
- fs/btrfs/tree-mod-log.c | 1 +
- fs/btrfs/ulist.c | 1 +
- fs/btrfs/uuid-tree.c | 1 +
- fs/btrfs/verity.c | 1 +
- fs/btrfs/xattr.c | 1 +
- fs/btrfs/zoned.h | 1 +
- 36 files changed, 293 insertions(+), 250 deletions(-)
- create mode 100644 fs/btrfs/messages.h
-
-diff --git a/fs/btrfs/backref.h b/fs/btrfs/backref.h
-index 8e69584d538d..e59236c3e5b7 100644
---- a/fs/btrfs/backref.h
-+++ b/fs/btrfs/backref.h
-@@ -7,6 +7,7 @@
- #define BTRFS_BACKREF_H
-
- #include <linux/btrfs.h>
-+#include "messages.h"
- #include "ulist.h"
- #include "disk-io.h"
- #include "extent_io.h"
-diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
-index 98c6e5feab19..e8e1a92b30ac 100644
---- a/fs/btrfs/check-integrity.c
-+++ b/fs/btrfs/check-integrity.c
-@@ -82,6 +82,7 @@
- #include <linux/mm.h>
- #include <linux/string.h>
- #include <crypto/hash.h>
-+#include "messages.h"
- #include "ctree.h"
- #include "disk-io.h"
- #include "transaction.h"
-diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
-index dcb510f38dda..49d487ca0ad4 100644
---- a/fs/btrfs/ctree.c
-+++ b/fs/btrfs/ctree.c
-@@ -8,6 +8,7 @@
- #include <linux/rbtree.h>
- #include <linux/mm.h>
- #include <linux/error-injection.h>
-+#include "messages.h"
- #include "ctree.h"
- #include "disk-io.h"
- #include "transaction.h"
-diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
-index d7869188f8b2..79835f2a2c30 100644
---- a/fs/btrfs/ctree.h
-+++ b/fs/btrfs/ctree.h
-@@ -3444,179 +3444,6 @@ int btrfs_sync_fs(struct super_block *sb, int wait);
- char *btrfs_get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info,
- u64 subvol_objectid);
-
--static inline __printf(2, 3) __cold
--void btrfs_no_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
--{
--}
--
--#ifdef CONFIG_PRINTK_INDEX
--
--#define btrfs_printk(fs_info, fmt, args...) \
--do { \
-- printk_index_subsys_emit("%sBTRFS %s (device %s): ", NULL, fmt); \
-- _btrfs_printk(fs_info, fmt, ##args); \
--} while (0)
--
--__printf(2, 3)
--__cold
--void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
--
--#elif defined(CONFIG_PRINTK)
--
--#define btrfs_printk(fs_info, fmt, args...) \
-- _btrfs_printk(fs_info, fmt, ##args)
--
--__printf(2, 3)
--__cold
--void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
--
--#else
--
--#define btrfs_printk(fs_info, fmt, args...) \
-- btrfs_no_printk(fs_info, fmt, ##args)
--#endif
--
--#define btrfs_emerg(fs_info, fmt, args...) \
-- btrfs_printk(fs_info, KERN_EMERG fmt, ##args)
--#define btrfs_alert(fs_info, fmt, args...) \
-- btrfs_printk(fs_info, KERN_ALERT fmt, ##args)
--#define btrfs_crit(fs_info, fmt, args...) \
-- btrfs_printk(fs_info, KERN_CRIT fmt, ##args)
--#define btrfs_err(fs_info, fmt, args...) \
-- btrfs_printk(fs_info, KERN_ERR fmt, ##args)
--#define btrfs_warn(fs_info, fmt, args...) \
-- btrfs_printk(fs_info, KERN_WARNING fmt, ##args)
--#define btrfs_notice(fs_info, fmt, args...) \
-- btrfs_printk(fs_info, KERN_NOTICE fmt, ##args)
--#define btrfs_info(fs_info, fmt, args...) \
-- btrfs_printk(fs_info, KERN_INFO fmt, ##args)
--
--/*
-- * Wrappers that use printk_in_rcu
-- */
--#define btrfs_emerg_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_in_rcu(fs_info, KERN_EMERG fmt, ##args)
--#define btrfs_alert_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_in_rcu(fs_info, KERN_ALERT fmt, ##args)
--#define btrfs_crit_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_in_rcu(fs_info, KERN_CRIT fmt, ##args)
--#define btrfs_err_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_in_rcu(fs_info, KERN_ERR fmt, ##args)
--#define btrfs_warn_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_in_rcu(fs_info, KERN_WARNING fmt, ##args)
--#define btrfs_notice_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_in_rcu(fs_info, KERN_NOTICE fmt, ##args)
--#define btrfs_info_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_in_rcu(fs_info, KERN_INFO fmt, ##args)
--
--/*
-- * Wrappers that use a ratelimited printk_in_rcu
-- */
--#define btrfs_emerg_rl_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_rl_in_rcu(fs_info, KERN_EMERG fmt, ##args)
--#define btrfs_alert_rl_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_rl_in_rcu(fs_info, KERN_ALERT fmt, ##args)
--#define btrfs_crit_rl_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_rl_in_rcu(fs_info, KERN_CRIT fmt, ##args)
--#define btrfs_err_rl_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_rl_in_rcu(fs_info, KERN_ERR fmt, ##args)
--#define btrfs_warn_rl_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_rl_in_rcu(fs_info, KERN_WARNING fmt, ##args)
--#define btrfs_notice_rl_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_rl_in_rcu(fs_info, KERN_NOTICE fmt, ##args)
--#define btrfs_info_rl_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_rl_in_rcu(fs_info, KERN_INFO fmt, ##args)
--
--/*
-- * Wrappers that use a ratelimited printk
-- */
--#define btrfs_emerg_rl(fs_info, fmt, args...) \
-- btrfs_printk_ratelimited(fs_info, KERN_EMERG fmt, ##args)
--#define btrfs_alert_rl(fs_info, fmt, args...) \
-- btrfs_printk_ratelimited(fs_info, KERN_ALERT fmt, ##args)
--#define btrfs_crit_rl(fs_info, fmt, args...) \
-- btrfs_printk_ratelimited(fs_info, KERN_CRIT fmt, ##args)
--#define btrfs_err_rl(fs_info, fmt, args...) \
-- btrfs_printk_ratelimited(fs_info, KERN_ERR fmt, ##args)
--#define btrfs_warn_rl(fs_info, fmt, args...) \
-- btrfs_printk_ratelimited(fs_info, KERN_WARNING fmt, ##args)
--#define btrfs_notice_rl(fs_info, fmt, args...) \
-- btrfs_printk_ratelimited(fs_info, KERN_NOTICE fmt, ##args)
--#define btrfs_info_rl(fs_info, fmt, args...) \
-- btrfs_printk_ratelimited(fs_info, KERN_INFO fmt, ##args)
--
--#if defined(CONFIG_DYNAMIC_DEBUG)
--#define btrfs_debug(fs_info, fmt, args...) \
-- _dynamic_func_call_no_desc(fmt, btrfs_printk, \
-- fs_info, KERN_DEBUG fmt, ##args)
--#define btrfs_debug_in_rcu(fs_info, fmt, args...) \
-- _dynamic_func_call_no_desc(fmt, btrfs_printk_in_rcu, \
-- fs_info, KERN_DEBUG fmt, ##args)
--#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
-- _dynamic_func_call_no_desc(fmt, btrfs_printk_rl_in_rcu, \
-- fs_info, KERN_DEBUG fmt, ##args)
--#define btrfs_debug_rl(fs_info, fmt, args...) \
-- _dynamic_func_call_no_desc(fmt, btrfs_printk_ratelimited, \
-- fs_info, KERN_DEBUG fmt, ##args)
--#elif defined(DEBUG)
--#define btrfs_debug(fs_info, fmt, args...) \
-- btrfs_printk(fs_info, KERN_DEBUG fmt, ##args)
--#define btrfs_debug_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
--#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
-- btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
--#define btrfs_debug_rl(fs_info, fmt, args...) \
-- btrfs_printk_ratelimited(fs_info, KERN_DEBUG fmt, ##args)
--#else
--#define btrfs_debug(fs_info, fmt, args...) \
-- btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
--#define btrfs_debug_in_rcu(fs_info, fmt, args...) \
-- btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
--#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
-- btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
--#define btrfs_debug_rl(fs_info, fmt, args...) \
-- btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
--#endif
--
--#define btrfs_printk_in_rcu(fs_info, fmt, args...) \
--do { \
-- rcu_read_lock(); \
-- btrfs_printk(fs_info, fmt, ##args); \
-- rcu_read_unlock(); \
--} while (0)
--
--#define btrfs_no_printk_in_rcu(fs_info, fmt, args...) \
--do { \
-- rcu_read_lock(); \
-- btrfs_no_printk(fs_info, fmt, ##args); \
-- rcu_read_unlock(); \
--} while (0)
--
--#define btrfs_printk_ratelimited(fs_info, fmt, args...) \
--do { \
-- static DEFINE_RATELIMIT_STATE(_rs, \
-- DEFAULT_RATELIMIT_INTERVAL, \
-- DEFAULT_RATELIMIT_BURST); \
-- if (__ratelimit(&_rs)) \
-- btrfs_printk(fs_info, fmt, ##args); \
--} while (0)
--
--#define btrfs_printk_rl_in_rcu(fs_info, fmt, args...) \
--do { \
-- rcu_read_lock(); \
-- btrfs_printk_ratelimited(fs_info, fmt, ##args); \
-- rcu_read_unlock(); \
--} while (0)
--
--#ifdef CONFIG_BTRFS_ASSERT
--void __cold btrfs_assertfail(const char *expr, const char *file, int line);
--
--#define ASSERT(expr) \
-- (likely(expr) ? (void)0 : btrfs_assertfail(#expr, __FILE__, __LINE__))
--#else
--#define ASSERT(expr) (void)(expr)
--#endif
--
- #if BITS_PER_LONG == 32
- #define BTRFS_32BIT_MAX_FILE_SIZE (((u64)ULONG_MAX + 1) << PAGE_SHIFT)
- /*
-@@ -3673,88 +3500,12 @@ static inline unsigned long get_eb_page_index(unsigned long offset)
- #define EXPORT_FOR_TESTS
- #endif
-
--void __cold btrfs_print_v0_err(struct btrfs_fs_info *fs_info);
--
--__printf(5, 6)
--__cold
--void __btrfs_handle_fs_error(struct btrfs_fs_info *fs_info, const char *function,
-- unsigned int line, int errno, const char *fmt, ...);
--
--const char * __attribute_const__ btrfs_decode_error(int errno);
--
--__cold
--void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
-- const char *function,
-- unsigned int line, int errno, bool first_hit);
--
--bool __cold abort_should_print_stack(int errno);
--
--/*
-- * Call btrfs_abort_transaction as early as possible when an error condition is
-- * detected, that way the exact stack trace is reported for some errors.
-- */
--#define btrfs_abort_transaction(trans, errno) \
--do { \
-- bool first = false; \
-- /* Report first abort since mount */ \
-- if (!test_and_set_bit(BTRFS_FS_STATE_TRANS_ABORTED, \
-- &((trans)->fs_info->fs_state))) { \
-- first = true; \
-- if (WARN(abort_should_print_stack(errno), \
-- KERN_DEBUG \
-- "BTRFS: Transaction aborted (error %d)\n", \
-- (errno))) { \
-- /* Stack trace printed. */ \
-- } else { \
-- btrfs_debug((trans)->fs_info, \
-- "Transaction aborted (error %d)", \
-- (errno)); \
-- } \
-- } \
-- __btrfs_abort_transaction((trans), __func__, \
-- __LINE__, (errno), first); \
--} while (0)
--
--#ifdef CONFIG_PRINTK_INDEX
--
--#define btrfs_handle_fs_error(fs_info, errno, fmt, args...) \
--do { \
-- printk_index_subsys_emit( \
-- "BTRFS: error (device %s%s) in %s:%d: errno=%d %s", \
-- KERN_CRIT, fmt); \
-- __btrfs_handle_fs_error((fs_info), __func__, __LINE__, \
-- (errno), fmt, ##args); \
--} while (0)
--
--#else
--
--#define btrfs_handle_fs_error(fs_info, errno, fmt, args...) \
-- __btrfs_handle_fs_error((fs_info), __func__, __LINE__, \
-- (errno), fmt, ##args)
--
--#endif
--
- #define BTRFS_FS_ERROR(fs_info) (unlikely(test_bit(BTRFS_FS_STATE_ERROR, \
- &(fs_info)->fs_state)))
- #define BTRFS_FS_LOG_CLEANUP_ERROR(fs_info) \
- (unlikely(test_bit(BTRFS_FS_STATE_LOG_CLEANUP_ERROR, \
- &(fs_info)->fs_state)))
-
--__printf(5, 6)
--__cold
--void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
-- unsigned int line, int errno, const char *fmt, ...);
--/*
-- * If BTRFS_MOUNT_PANIC_ON_FATAL_ERROR is in mount_opt, __btrfs_panic
-- * will panic(). Otherwise we BUG() here.
-- */
--#define btrfs_panic(fs_info, errno, fmt, args...) \
--do { \
-- __btrfs_panic(fs_info, __func__, __LINE__, errno, fmt, ##args); \
-- BUG(); \
--} while (0)
--
--
- /* acl.c */
- #ifdef CONFIG_BTRFS_FS_POSIX_ACL
- struct posix_acl *btrfs_get_acl(struct inode *inode, int type, bool rcu);
-diff --git a/fs/btrfs/delalloc-space.c b/fs/btrfs/delalloc-space.c
-index 118b2e20b2e1..045545145a2b 100644
---- a/fs/btrfs/delalloc-space.c
-+++ b/fs/btrfs/delalloc-space.c
-@@ -1,5 +1,6 @@
- // SPDX-License-Identifier: GPL-2.0
-
-+#include "messages.h"
- #include "ctree.h"
- #include "delalloc-space.h"
- #include "block-rsv.h"
-diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
-index a411f04a7b97..8cf5ee646147 100644
---- a/fs/btrfs/delayed-inode.c
-+++ b/fs/btrfs/delayed-inode.c
-@@ -6,6 +6,7 @@
-
- #include <linux/slab.h>
- #include <linux/iversion.h>
-+#include "messages.h"
- #include "misc.h"
- #include "delayed-inode.h"
- #include "disk-io.h"
-diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
-index 36a3debe9493..c775ff4f1cb1 100644
---- a/fs/btrfs/delayed-ref.c
-+++ b/fs/btrfs/delayed-ref.c
-@@ -6,6 +6,7 @@
- #include <linux/sched.h>
- #include <linux/slab.h>
- #include <linux/sort.h>
-+#include "messages.h"
- #include "ctree.h"
- #include "delayed-ref.h"
- #include "transaction.h"
-diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
-index 72fb2c518a2b..be5c1c2a8da5 100644
---- a/fs/btrfs/dir-item.c
-+++ b/fs/btrfs/dir-item.c
-@@ -3,6 +3,7 @@
- * Copyright (C) 2007 Oracle. All rights reserved.
- */
-
-+#include "messages.h"
- #include "ctree.h"
- #include "disk-io.h"
- #include "transaction.h"
-diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
-index 09ae0e73e680..015851eb97fb 100644
---- a/fs/btrfs/extent-io-tree.c
-+++ b/fs/btrfs/extent-io-tree.c
-@@ -2,6 +2,7 @@
-
- #include <linux/slab.h>
- #include <trace/events/btrfs.h>
-+#include "messages.h"
- #include "ctree.h"
- #include "extent-io-tree.h"
- #include "btrfs_inode.h"
-diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
-index 6092a4eedc92..ba8fb176601b 100644
---- a/fs/btrfs/extent_map.c
-+++ b/fs/btrfs/extent_map.c
-@@ -3,6 +3,7 @@
- #include <linux/err.h>
- #include <linux/slab.h>
- #include <linux/spinlock.h>
-+#include "messages.h"
- #include "ctree.h"
- #include "volumes.h"
- #include "extent_map.h"
-diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
-index 824ff54d8155..675987e2d652 100644
---- a/fs/btrfs/file-item.c
-+++ b/fs/btrfs/file-item.c
-@@ -9,6 +9,7 @@
- #include <linux/highmem.h>
- #include <linux/sched/mm.h>
- #include <crypto/hash.h>
-+#include "messages.h"
- #include "misc.h"
- #include "ctree.h"
- #include "disk-io.h"
-diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
-index f4023651dd68..f8ccc6cfd42b 100644
---- a/fs/btrfs/free-space-cache.c
-+++ b/fs/btrfs/free-space-cache.c
-@@ -11,6 +11,7 @@
- #include <linux/ratelimit.h>
- #include <linux/error-injection.h>
- #include <linux/sched/mm.h>
-+#include "messages.h"
- #include "misc.h"
- #include "ctree.h"
- #include "free-space-cache.h"
-diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
-index bfc21eb8ec63..026214d74a02 100644
---- a/fs/btrfs/free-space-tree.c
-+++ b/fs/btrfs/free-space-tree.c
-@@ -5,6 +5,7 @@
-
- #include <linux/kernel.h>
- #include <linux/sched/mm.h>
-+#include "messages.h"
- #include "ctree.h"
- #include "disk-io.h"
- #include "locking.h"
-diff --git a/fs/btrfs/fs.c b/fs/btrfs/fs.c
-index d4ba948eba56..a59504b59435 100644
---- a/fs/btrfs/fs.c
-+++ b/fs/btrfs/fs.c
-@@ -1,5 +1,6 @@
- // SPDX-License-Identifier: GPL-2.0
-
-+#include "messages.h"
- #include "ctree.h"
- #include "fs.h"
-
-diff --git a/fs/btrfs/inode-item.c b/fs/btrfs/inode-item.c
-index 366f3a788c6a..b301d8e3df87 100644
---- a/fs/btrfs/inode-item.c
-+++ b/fs/btrfs/inode-item.c
-@@ -3,6 +3,7 @@
- * Copyright (C) 2007 Oracle. All rights reserved.
- */
-
-+#include "messages.h"
- #include "ctree.h"
- #include "inode-item.h"
- #include "disk-io.h"
-diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
-index 89bc5f825e0a..6751874a3e69 100644
---- a/fs/btrfs/lzo.c
-+++ b/fs/btrfs/lzo.c
-@@ -13,6 +13,7 @@
- #include <linux/bio.h>
- #include <linux/lzo.h>
- #include <linux/refcount.h>
-+#include "messages.h"
- #include "compression.h"
- #include "ctree.h"
-
-diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h
-new file mode 100644
-index 000000000000..ace5bb02820a
---- /dev/null
-+++ b/fs/btrfs/messages.h
-@@ -0,0 +1,259 @@
-+/* SPDX-License-Identifier: GPL-2.0 */
-+
-+#ifndef BTRFS_MESSAGES_H
-+#define BTRFS_MESSAGES_H
-+
-+#include <linux/types.h>
-+
-+struct btrfs_fs_info;
-+struct btrfs_trans_handle;
-+
-+static inline __printf(2, 3) __cold
-+void btrfs_no_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
-+{
-+}
-+
-+#ifdef CONFIG_PRINTK_INDEX
-+
-+#define btrfs_printk(fs_info, fmt, args...) \
-+do { \
-+ printk_index_subsys_emit("%sBTRFS %s (device %s): ", NULL, fmt); \
-+ _btrfs_printk(fs_info, fmt, ##args); \
-+} while (0)
-+
-+__printf(2, 3)
-+__cold
-+void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
-+
-+#elif defined(CONFIG_PRINTK)
-+
-+#define btrfs_printk(fs_info, fmt, args...) \
-+ _btrfs_printk(fs_info, fmt, ##args)
-+
-+__printf(2, 3)
-+__cold
-+void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
-+
-+#else
-+
-+#define btrfs_printk(fs_info, fmt, args...) \
-+ btrfs_no_printk(fs_info, fmt, ##args)
-+#endif
-+
-+#define btrfs_emerg(fs_info, fmt, args...) \
-+ btrfs_printk(fs_info, KERN_EMERG fmt, ##args)
-+#define btrfs_alert(fs_info, fmt, args...) \
-+ btrfs_printk(fs_info, KERN_ALERT fmt, ##args)
-+#define btrfs_crit(fs_info, fmt, args...) \
-+ btrfs_printk(fs_info, KERN_CRIT fmt, ##args)
-+#define btrfs_err(fs_info, fmt, args...) \
-+ btrfs_printk(fs_info, KERN_ERR fmt, ##args)
-+#define btrfs_warn(fs_info, fmt, args...) \
-+ btrfs_printk(fs_info, KERN_WARNING fmt, ##args)
-+#define btrfs_notice(fs_info, fmt, args...) \
-+ btrfs_printk(fs_info, KERN_NOTICE fmt, ##args)
-+#define btrfs_info(fs_info, fmt, args...) \
-+ btrfs_printk(fs_info, KERN_INFO fmt, ##args)
-+
-+/*
-+ * Wrappers that use printk_in_rcu
-+ */
-+#define btrfs_emerg_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_in_rcu(fs_info, KERN_EMERG fmt, ##args)
-+#define btrfs_alert_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_in_rcu(fs_info, KERN_ALERT fmt, ##args)
-+#define btrfs_crit_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_in_rcu(fs_info, KERN_CRIT fmt, ##args)
-+#define btrfs_err_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_in_rcu(fs_info, KERN_ERR fmt, ##args)
-+#define btrfs_warn_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_in_rcu(fs_info, KERN_WARNING fmt, ##args)
-+#define btrfs_notice_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_in_rcu(fs_info, KERN_NOTICE fmt, ##args)
-+#define btrfs_info_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_in_rcu(fs_info, KERN_INFO fmt, ##args)
-+
-+/*
-+ * Wrappers that use a ratelimited printk_in_rcu
-+ */
-+#define btrfs_emerg_rl_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_rl_in_rcu(fs_info, KERN_EMERG fmt, ##args)
-+#define btrfs_alert_rl_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_rl_in_rcu(fs_info, KERN_ALERT fmt, ##args)
-+#define btrfs_crit_rl_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_rl_in_rcu(fs_info, KERN_CRIT fmt, ##args)
-+#define btrfs_err_rl_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_rl_in_rcu(fs_info, KERN_ERR fmt, ##args)
-+#define btrfs_warn_rl_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_rl_in_rcu(fs_info, KERN_WARNING fmt, ##args)
-+#define btrfs_notice_rl_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_rl_in_rcu(fs_info, KERN_NOTICE fmt, ##args)
-+#define btrfs_info_rl_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_rl_in_rcu(fs_info, KERN_INFO fmt, ##args)
-+
-+/*
-+ * Wrappers that use a ratelimited printk
-+ */
-+#define btrfs_emerg_rl(fs_info, fmt, args...) \
-+ btrfs_printk_ratelimited(fs_info, KERN_EMERG fmt, ##args)
-+#define btrfs_alert_rl(fs_info, fmt, args...) \
-+ btrfs_printk_ratelimited(fs_info, KERN_ALERT fmt, ##args)
-+#define btrfs_crit_rl(fs_info, fmt, args...) \
-+ btrfs_printk_ratelimited(fs_info, KERN_CRIT fmt, ##args)
-+#define btrfs_err_rl(fs_info, fmt, args...) \
-+ btrfs_printk_ratelimited(fs_info, KERN_ERR fmt, ##args)
-+#define btrfs_warn_rl(fs_info, fmt, args...) \
-+ btrfs_printk_ratelimited(fs_info, KERN_WARNING fmt, ##args)
-+#define btrfs_notice_rl(fs_info, fmt, args...) \
-+ btrfs_printk_ratelimited(fs_info, KERN_NOTICE fmt, ##args)
-+#define btrfs_info_rl(fs_info, fmt, args...) \
-+ btrfs_printk_ratelimited(fs_info, KERN_INFO fmt, ##args)
-+
-+#if defined(CONFIG_DYNAMIC_DEBUG)
-+#define btrfs_debug(fs_info, fmt, args...) \
-+ _dynamic_func_call_no_desc(fmt, btrfs_printk, \
-+ fs_info, KERN_DEBUG fmt, ##args)
-+#define btrfs_debug_in_rcu(fs_info, fmt, args...) \
-+ _dynamic_func_call_no_desc(fmt, btrfs_printk_in_rcu, \
-+ fs_info, KERN_DEBUG fmt, ##args)
-+#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
-+ _dynamic_func_call_no_desc(fmt, btrfs_printk_rl_in_rcu, \
-+ fs_info, KERN_DEBUG fmt, ##args)
-+#define btrfs_debug_rl(fs_info, fmt, args...) \
-+ _dynamic_func_call_no_desc(fmt, btrfs_printk_ratelimited, \
-+ fs_info, KERN_DEBUG fmt, ##args)
-+#elif defined(DEBUG)
-+#define btrfs_debug(fs_info, fmt, args...) \
-+ btrfs_printk(fs_info, KERN_DEBUG fmt, ##args)
-+#define btrfs_debug_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
-+#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
-+ btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
-+#define btrfs_debug_rl(fs_info, fmt, args...) \
-+ btrfs_printk_ratelimited(fs_info, KERN_DEBUG fmt, ##args)
-+#else
-+#define btrfs_debug(fs_info, fmt, args...) \
-+ btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
-+#define btrfs_debug_in_rcu(fs_info, fmt, args...) \
-+ btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
-+#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
-+ btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
-+#define btrfs_debug_rl(fs_info, fmt, args...) \
-+ btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
-+#endif
-+
-+#define btrfs_printk_in_rcu(fs_info, fmt, args...) \
-+do { \
-+ rcu_read_lock(); \
-+ btrfs_printk(fs_info, fmt, ##args); \
-+ rcu_read_unlock(); \
-+} while (0)
-+
-+#define btrfs_no_printk_in_rcu(fs_info, fmt, args...) \
-+do { \
-+ rcu_read_lock(); \
-+ btrfs_no_printk(fs_info, fmt, ##args); \
-+ rcu_read_unlock(); \
-+} while (0)
-+
-+#define btrfs_printk_ratelimited(fs_info, fmt, args...) \
-+do { \
-+ static DEFINE_RATELIMIT_STATE(_rs, \
-+ DEFAULT_RATELIMIT_INTERVAL, \
-+ DEFAULT_RATELIMIT_BURST); \
-+ if (__ratelimit(&_rs)) \
-+ btrfs_printk(fs_info, fmt, ##args); \
-+} while (0)
-+
-+#define btrfs_printk_rl_in_rcu(fs_info, fmt, args...) \
-+do { \
-+ rcu_read_lock(); \
-+ btrfs_printk_ratelimited(fs_info, fmt, ##args); \
-+ rcu_read_unlock(); \
-+} while (0)
-+
-+#ifdef CONFIG_BTRFS_ASSERT
-+void __cold btrfs_assertfail(const char *expr, const char *file, int line);
-+
-+#define ASSERT(expr) \
-+ (likely(expr) ? (void)0 : btrfs_assertfail(#expr, __FILE__, __LINE__))
-+#else
-+#define ASSERT(expr) (void)(expr)
-+#endif
-+
-+void __cold btrfs_print_v0_err(struct btrfs_fs_info *fs_info);
-+
-+__printf(5, 6)
-+__cold
-+void __btrfs_handle_fs_error(struct btrfs_fs_info *fs_info, const char *function,
-+ unsigned int line, int errno, const char *fmt, ...);
-+
-+const char * __attribute_const__ btrfs_decode_error(int errno);
-+
-+__cold
-+void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
-+ const char *function,
-+ unsigned int line, int errno, bool first_hit);
-+
-+bool __cold abort_should_print_stack(int errno);
-+
-+/*
-+ * Call btrfs_abort_transaction as early as possible when an error condition is
-+ * detected, that way the exact stack trace is reported for some errors.
-+ */
-+#define btrfs_abort_transaction(trans, errno) \
-+do { \
-+ bool first = false; \
-+ /* Report first abort since mount */ \
-+ if (!test_and_set_bit(BTRFS_FS_STATE_TRANS_ABORTED, \
-+ &((trans)->fs_info->fs_state))) { \
-+ first = true; \
-+ if (WARN(abort_should_print_stack(errno), \
-+ KERN_DEBUG \
-+ "BTRFS: Transaction aborted (error %d)\n", \
-+ (errno))) { \
-+ /* Stack trace printed. */ \
-+ } else { \
-+ btrfs_debug((trans)->fs_info, \
-+ "Transaction aborted (error %d)", \
-+ (errno)); \
-+ } \
-+ } \
-+ __btrfs_abort_transaction((trans), __func__, \
-+ __LINE__, (errno), first); \
-+} while (0)
-+
-+#ifdef CONFIG_PRINTK_INDEX
-+
-+#define btrfs_handle_fs_error(fs_info, errno, fmt, args...) \
-+do { \
-+ printk_index_subsys_emit( \
-+ "BTRFS: error (device %s%s) in %s:%d: errno=%d %s", \
-+ KERN_CRIT, fmt); \
-+ __btrfs_handle_fs_error((fs_info), __func__, __LINE__, \
-+ (errno), fmt, ##args); \
-+} while (0)
-+
-+#else
-+
-+#define btrfs_handle_fs_error(fs_info, errno, fmt, args...) \
-+ __btrfs_handle_fs_error((fs_info), __func__, __LINE__, \
-+ (errno), fmt, ##args)
-+
-+#endif
-+
-+__printf(5, 6)
-+__cold
-+void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
-+ unsigned int line, int errno, const char *fmt, ...);
-+/*
-+ * If BTRFS_MOUNT_PANIC_ON_FATAL_ERROR is in mount_opt, __btrfs_panic
-+ * will panic(). Otherwise we BUG() here.
-+ */
-+#define btrfs_panic(fs_info, errno, fmt, args...) \
-+do { \
-+ __btrfs_panic(fs_info, __func__, __LINE__, errno, fmt, ##args); \
-+ BUG(); \
-+} while (0)
-+
-+#endif
-diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
-index e54f8280031f..cf6b2a466e59 100644
---- a/fs/btrfs/ordered-data.c
-+++ b/fs/btrfs/ordered-data.c
-@@ -7,6 +7,7 @@
- #include <linux/blkdev.h>
- #include <linux/writeback.h>
- #include <linux/sched/mm.h>
-+#include "messages.h"
- #include "misc.h"
- #include "ctree.h"
- #include "transaction.h"
-diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
-index dd8777872143..708facaede2c 100644
---- a/fs/btrfs/print-tree.c
-+++ b/fs/btrfs/print-tree.c
-@@ -3,6 +3,7 @@
- * Copyright (C) 2007 Oracle. All rights reserved.
- */
-
-+#include "messages.h"
- #include "ctree.h"
- #include "disk-io.h"
- #include "print-tree.h"
-diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
-index ef17014221e2..6e11eda7acd4 100644
---- a/fs/btrfs/props.c
-+++ b/fs/btrfs/props.c
-@@ -4,6 +4,7 @@
- */
-
- #include <linux/hashtable.h>
-+#include "messages.h"
- #include "props.h"
- #include "btrfs_inode.h"
- #include "transaction.h"
-diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
-index 82c8e991300e..d047032a5d46 100644
---- a/fs/btrfs/raid56.c
-+++ b/fs/btrfs/raid56.c
-@@ -13,6 +13,7 @@
- #include <linux/list_sort.h>
- #include <linux/raid/xor.h>
- #include <linux/mm.h>
-+#include "messages.h"
- #include "misc.h"
- #include "ctree.h"
- #include "disk-io.h"
-diff --git a/fs/btrfs/ref-verify.c b/fs/btrfs/ref-verify.c
-index a248f46cfe72..f7535b8b62f5 100644
---- a/fs/btrfs/ref-verify.c
-+++ b/fs/btrfs/ref-verify.c
-@@ -5,6 +5,7 @@
-
- #include <linux/sched.h>
- #include <linux/stacktrace.h>
-+#include "messages.h"
- #include "ctree.h"
- #include "disk-io.h"
- #include "locking.h"
-diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
-index f50586ff85c8..6179864de6e7 100644
---- a/fs/btrfs/reflink.c
-+++ b/fs/btrfs/reflink.c
-@@ -2,6 +2,7 @@
-
- #include <linux/blkdev.h>
- #include <linux/iversion.h>
-+#include "messages.h"
- #include "compression.h"
- #include "ctree.h"
- #include "delalloc-space.h"
-diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
-index e1f599d7a916..44c8c8ad0a16 100644
---- a/fs/btrfs/root-tree.c
-+++ b/fs/btrfs/root-tree.c
-@@ -5,6 +5,7 @@
-
- #include <linux/err.h>
- #include <linux/uuid.h>
-+#include "messages.h"
- #include "ctree.h"
- #include "transaction.h"
- #include "disk-io.h"
-diff --git a/fs/btrfs/struct-funcs.c b/fs/btrfs/struct-funcs.c
-index 12455b2b41de..6ba16c018d7f 100644
---- a/fs/btrfs/struct-funcs.c
-+++ b/fs/btrfs/struct-funcs.c
-@@ -5,6 +5,7 @@
-
- #include <asm/unaligned.h>
-
-+#include "messages.h"
- #include "ctree.h"
-
- static bool check_setget_bounds(const struct extent_buffer *eb,
-diff --git a/fs/btrfs/subpage.c b/fs/btrfs/subpage.c
-index 9a176af847d7..dd46b978ac2c 100644
---- a/fs/btrfs/subpage.c
-+++ b/fs/btrfs/subpage.c
-@@ -1,6 +1,7 @@
- // SPDX-License-Identifier: GPL-2.0
-
- #include <linux/slab.h>
-+#include "messages.h"
- #include "ctree.h"
- #include "subpage.h"
- #include "btrfs_inode.h"
-diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
-index 7cdf27d807be..501aa4b8d8b5 100644
---- a/fs/btrfs/super.c
-+++ b/fs/btrfs/super.c
-@@ -26,6 +26,7 @@
- #include <linux/ratelimit.h>
- #include <linux/crc32c.h>
- #include <linux/btrfs.h>
-+#include "messages.h"
- #include "delayed-inode.h"
- #include "ctree.h"
- #include "disk-io.h"
-diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
-index 74fef1f49c35..693b139d17da 100644
---- a/fs/btrfs/sysfs.c
-+++ b/fs/btrfs/sysfs.c
-@@ -10,7 +10,7 @@
- #include <linux/completion.h>
- #include <linux/bug.h>
- #include <crypto/hash.h>
--
-+#include "messages.h"
- #include "ctree.h"
- #include "discard.h"
- #include "disk-io.h"
-diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
-index 862d67798de5..fa9536110d69 100644
---- a/fs/btrfs/tree-checker.c
-+++ b/fs/btrfs/tree-checker.c
-@@ -18,6 +18,7 @@
- #include <linux/types.h>
- #include <linux/stddef.h>
- #include <linux/error-injection.h>
-+#include "messages.h"
- #include "ctree.h"
- #include "tree-checker.h"
- #include "disk-io.h"
-diff --git a/fs/btrfs/tree-log.h b/fs/btrfs/tree-log.h
-index aed1e05e9879..f5770829d075 100644
---- a/fs/btrfs/tree-log.h
-+++ b/fs/btrfs/tree-log.h
-@@ -6,6 +6,7 @@
- #ifndef BTRFS_TREE_LOG_H
- #define BTRFS_TREE_LOG_H
-
-+#include "messages.h"
- #include "ctree.h"
- #include "transaction.h"
-
-diff --git a/fs/btrfs/tree-mod-log.c b/fs/btrfs/tree-mod-log.c
-index 8a3a14686d3e..bf894de47731 100644
---- a/fs/btrfs/tree-mod-log.c
-+++ b/fs/btrfs/tree-mod-log.c
-@@ -1,5 +1,6 @@
- // SPDX-License-Identifier: GPL-2.0
-
-+#include "messages.h"
- #include "tree-mod-log.h"
- #include "disk-io.h"
-
-diff --git a/fs/btrfs/ulist.c b/fs/btrfs/ulist.c
-index 3374c9e9be67..f2f20c8d84aa 100644
---- a/fs/btrfs/ulist.c
-+++ b/fs/btrfs/ulist.c
-@@ -5,6 +5,7 @@
- */
-
- #include <linux/slab.h>
-+#include "messages.h"
- #include "ulist.h"
- #include "ctree.h"
-
-diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c
-index 2d7eb290fb9c..190f752a2e10 100644
---- a/fs/btrfs/uuid-tree.c
-+++ b/fs/btrfs/uuid-tree.c
-@@ -5,6 +5,7 @@
-
- #include <linux/uuid.h>
- #include <asm/unaligned.h>
-+#include "messages.h"
- #include "ctree.h"
- #include "transaction.h"
- #include "disk-io.h"
-diff --git a/fs/btrfs/verity.c b/fs/btrfs/verity.c
-index ab0b39badbbe..35445855df4d 100644
---- a/fs/btrfs/verity.c
-+++ b/fs/btrfs/verity.c
-@@ -10,6 +10,7 @@
- #include <linux/iversion.h>
- #include <linux/fsverity.h>
- #include <linux/sched/mm.h>
-+#include "messages.h"
- #include "ctree.h"
- #include "btrfs_inode.h"
- #include "transaction.h"
-diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
-index 5bb8d8c86311..d12903f01f83 100644
---- a/fs/btrfs/xattr.c
-+++ b/fs/btrfs/xattr.c
-@@ -12,6 +12,7 @@
- #include <linux/posix_acl_xattr.h>
- #include <linux/iversion.h>
- #include <linux/sched/mm.h>
-+#include "messages.h"
- #include "ctree.h"
- #include "btrfs_inode.h"
- #include "transaction.h"
-diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h
-index 8bd16d40b7c6..f43990985d80 100644
---- a/fs/btrfs/zoned.h
-+++ b/fs/btrfs/zoned.h
-@@ -5,6 +5,7 @@
-
- #include <linux/types.h>
- #include <linux/blkdev.h>
-+#include "messages.h"
- #include "volumes.h"
- #include "disk-io.h"
- #include "block-group.h"
---
-2.35.1
-
+++ /dev/null
-From 6861093cb95084bdcaf3eec2a90aa65208d1f876 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 19 Oct 2022 10:50:58 -0400
-Subject: btrfs: rename struct-funcs.c to accessors.c
-
-From: Josef Bacik <josef@toxicpanda.com>
-
-[ Upstream commit 818fe33aed42ddd5052171328a3f708e98357e10 ]
-
-Rename struct-funcs.c to accessors.c so we can move the item accessors
-out of ctree.h. accessors.c is a better description of the code that is
-contained in these files.
-
-Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
-Reviewed-by: Anand Jain <anand.jain@oracle.com>
-Signed-off-by: Josef Bacik <josef@toxicpanda.com>
-Reviewed-by: David Sterba <dsterba@suse.com>
-Signed-off-by: David Sterba <dsterba@suse.com>
-Stable-dep-of: db0a4a7b8e95 ("btrfs: fix an error handling path in btrfs_defrag_leaves()")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- fs/btrfs/Makefile | 2 +-
- fs/btrfs/{struct-funcs.c => accessors.c} | 1 -
- 2 files changed, 1 insertion(+), 2 deletions(-)
- rename fs/btrfs/{struct-funcs.c => accessors.c} (99%)
-
-diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
-index eebb45c06485..76f90dcfb14d 100644
---- a/fs/btrfs/Makefile
-+++ b/fs/btrfs/Makefile
-@@ -24,7 +24,7 @@ obj-$(CONFIG_BTRFS_FS) := btrfs.o
- btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
- file-item.o inode-item.o disk-io.o \
- transaction.o inode.o file.o tree-defrag.o \
-- extent_map.o sysfs.o struct-funcs.o xattr.o ordered-data.o \
-+ extent_map.o sysfs.o accessors.o xattr.o ordered-data.o \
- extent_io.o volumes.o async-thread.o ioctl.o locking.o orphan.o \
- export.o tree-log.o free-space-cache.o zlib.o lzo.o zstd.o \
- compression.o delayed-ref.o relocation.o delayed-inode.o scrub.o \
-diff --git a/fs/btrfs/struct-funcs.c b/fs/btrfs/accessors.c
-similarity index 99%
-rename from fs/btrfs/struct-funcs.c
-rename to fs/btrfs/accessors.c
-index 6ba16c018d7f..118bfd1c0e3e 100644
---- a/fs/btrfs/struct-funcs.c
-+++ b/fs/btrfs/accessors.c
-@@ -4,7 +4,6 @@
- */
-
- #include <asm/unaligned.h>
--
- #include "messages.h"
- #include "ctree.h"
-
---
-2.35.1
-
+++ /dev/null
-From 77ecdb1cdc88d28e19778e517e54aa7a6df2c7f0 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 26 Oct 2022 15:08:22 -0400
-Subject: btrfs: rename tree-defrag.c to defrag.c
-
-From: Josef Bacik <josef@toxicpanda.com>
-
-[ Upstream commit 778dd695dd4d5a21eff07bb1570b570da69dfbd9 ]
-
-This currently has only one helper in it, and it's for tree based
-defrag. We have the various defrag code in 3 different places, so
-rename this to defrag.c. Followup patches will move the code into this
-new file.
-
-Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
-Signed-off-by: Josef Bacik <josef@toxicpanda.com>
-Reviewed-by: David Sterba <dsterba@suse.com>
-Signed-off-by: David Sterba <dsterba@suse.com>
-Stable-dep-of: db0a4a7b8e95 ("btrfs: fix an error handling path in btrfs_defrag_leaves()")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- fs/btrfs/Makefile | 2 +-
- fs/btrfs/{tree-defrag.c => defrag.c} | 0
- 2 files changed, 1 insertion(+), 1 deletion(-)
- rename fs/btrfs/{tree-defrag.c => defrag.c} (100%)
-
-diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
-index 76f90dcfb14d..a7885fff9105 100644
---- a/fs/btrfs/Makefile
-+++ b/fs/btrfs/Makefile
-@@ -23,7 +23,7 @@ obj-$(CONFIG_BTRFS_FS) := btrfs.o
-
- btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
- file-item.o inode-item.o disk-io.o \
-- transaction.o inode.o file.o tree-defrag.o \
-+ transaction.o inode.o file.o defrag.o \
- extent_map.o sysfs.o accessors.o xattr.o ordered-data.o \
- extent_io.o volumes.o async-thread.o ioctl.o locking.o orphan.o \
- export.o tree-log.o free-space-cache.o zlib.o lzo.o zstd.o \
-diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/defrag.c
-similarity index 100%
-rename from fs/btrfs/tree-defrag.c
-rename to fs/btrfs/defrag.c
---
-2.35.1
-
perf-probe-use-dwarf_attr_integrate-as-generic-dwarf.patch
perf-probe-fix-to-get-the-dw_at_decl_file-and-dw_at_.patch
phy-qcom-qmp-combo-fix-broken-power-on.patch
-btrfs-move-btrfs_get_block_group-helper-out-of-disk-.patch
-btrfs-move-flush-related-definitions-to-space-info.h.patch
-btrfs-move-btrfs_print_data_csum_error-into-inode.c.patch
-btrfs-move-fs-wide-helpers-out-of-ctree.h.patch
-btrfs-move-assert-helpers-out-of-ctree.h.patch
-btrfs-move-the-printk-helpers-out-of-ctree.h.patch
-btrfs-rename-struct-funcs.c-to-accessors.c.patch
-btrfs-rename-tree-defrag.c-to-defrag.c.patch
btrfs-fix-an-error-handling-path-in-btrfs_defrag_lea.patch
sunrpc-ensure-the-matching-upcall-is-in-flight-upon-.patch
wifi-ath9k-use-proper-statements-in-conditionals.patch