Skip to contentSkip to conversation

btrfs: strip out btrfs_fs_info dependencies

PATCH In review Josef Bacik 4 participants 49 messages Sep 14, 2022 – Sep 20, 2022 Btrfs file system

lore
Share & tools
lore
#0 lore raw

cover btrfs: strip out btrfs_fs_info dependencies

Part of the cleaning up of ctree.h is being able to move btrfs_fs_info out of it. This is actually pretty difficult because we essentially rely on ctree.h being included before everything else, so all other header files have fs_info defined for their helpers.

This series starts this work. There are a variety of other small moves as well, but the bulk is trying to pull any helpers that access fs_info members inside of their header files into their respective c files, or alternatively reworking the code to drop the dependency. Thanks,

Josef

Josef Bacik (15):
btrfs: move btrfs_caching_type to block-group.h
btrfs: move btrfs_full_stripe_locks_tree into block-group.h
btrfs: move btrfs_init_async_reclaim_work prototype to space-info.h
btrfs: move btrfs_pinned_by_swapfile prototype into volumes.h
btrfs: remove temporary btrfs_map_token declaration in ctree.h
btrfs: move static_assert() for btrfs_super_block into fs.c
btrfs: move btrfs_swapfile_pin into volumes.h
btrfs: move fs_info struct declarations to the top of ctree.h
btrfs: move btrfs_csum_ptr to inode.c
btrfs: move the fs_info related helpers closer to fs_info in ctree.h
btrfs: move btrfs_ordered_sum_size into file-item.c
btrfs: delete btrfs_inode_sectorsize helper
btrfs: delete btrfs_insert_inode_hash helper
btrfs: use a runtime flag to indicate an inode is a free space inode
btrfs: add struct declarations in dev-replace.h

 fs/btrfs/block-group.c  |   3 +-
 fs/btrfs/block-group.h  |  15 +++
 fs/btrfs/btrfs_inode.h  |  22 +---
 fs/btrfs/ctree.h        | 260 ++++++++++++++++------------------------
 fs/btrfs/dev-replace.h  |   4 +
 fs/btrfs/disk-io.c      |   4 +-
 fs/btrfs/extent_io.c    |   4 +-
 fs/btrfs/file-item.c    |  12 ++
 fs/btrfs/file.c         |  11 +-
 fs/btrfs/fs.c           |   2 +
 fs/btrfs/inode.c        |  13 ++
 fs/btrfs/ordered-data.h |  12 --
 fs/btrfs/space-info.h   |   1 +
 fs/btrfs/volumes.h      |  26 ++++
 14 files changed, 188 insertions(+), 201 deletions(-)
Signature · 1 line
2.26.3
#1 lore raw

PATCH 1/15 btrfs: move btrfs_caching_type to block-group.h

This is a block group related definition, move it into block-group.h.

---
 fs/btrfs/block-group.h | 7 +++++++
 fs/btrfs/ctree.h       | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)
fs/btrfs/block-group.h +7 -0
index e34cb80ffb25..558fa0a21fb4 100644
@@ -57,6 +57,13 @@ enum btrfs_block_group_flags {
 	BLOCK_GROUP_FLAG_ZONED_DATA_RELOC,
 };
 
+enum btrfs_caching_type {
+	BTRFS_CACHE_NO,
+	BTRFS_CACHE_STARTED,
+	BTRFS_CACHE_FINISHED,
+	BTRFS_CACHE_ERROR,
+};
+
 struct btrfs_caching_control {
 	struct list_head list;
 	struct mutex mutex;
fs/btrfs/ctree.h +0 -7
index 8271b3dccf16..725c187d5c4b 100644
@@ -180,13 +180,6 @@ struct btrfs_free_cluster {
 	struct list_head block_group_list;
 };
 
-enum btrfs_caching_type {
-	BTRFS_CACHE_NO,
-	BTRFS_CACHE_STARTED,
-	BTRFS_CACHE_FINISHED,
-	BTRFS_CACHE_ERROR,
-};
-
 /*
  * Tree to record all locked full stripes of a RAID5/6 block group
  */
Signature · 1 line
2.26.3
#4 lore raw

PATCH 2/15 btrfs: move btrfs_full_stripe_locks_tree into block-group.h

In reply to Josef Bacik

This is actually embedded in struct btrfs_block_group, so move this definition to block-group.h, and then open-code the init of the tree where we init the rest of the block group instead of using a helper.

---
 fs/btrfs/block-group.c |  3 ++-
 fs/btrfs/block-group.h |  8 ++++++++
 fs/btrfs/ctree.h       | 14 --------------
 3 files changed, 10 insertions(+), 15 deletions(-)
fs/btrfs/block-group.c +2 -1
index 20da92ae5c6b..e21382a13fe4 100644
@@ -1940,7 +1940,8 @@ static struct btrfs_block_group *btrfs_create_block_group_cache(
 	btrfs_init_free_space_ctl(cache, cache->free_space_ctl);
 	atomic_set(&cache->frozen, 0);
 	mutex_init(&cache->free_space_lock);
-	btrfs_init_full_stripe_locks_tree(&cache->full_stripe_locks_root);
+	cache->full_stripe_locks_root.root = RB_ROOT;
+	mutex_init(&cache->full_stripe_locks_root.lock);
 
 	return cache;
 }
fs/btrfs/block-group.h +8 -0
index 558fa0a21fb4..6c970a486b68 100644
@@ -76,6 +76,14 @@ struct btrfs_caching_control {
 /* Once caching_thread() finds this much free space, it will wake up waiters. */
 #define CACHING_CTL_WAKE_UP SZ_2M
 
+/*
+ * Tree to record all locked full stripes of a RAID5/6 block group
+ */
+struct btrfs_full_stripe_locks_tree {
+	struct rb_root root;
+	struct mutex lock;
+};
+
 struct btrfs_block_group {
 	struct btrfs_fs_info *fs_info;
 	struct inode *inode;
fs/btrfs/ctree.h +0 -14
index 725c187d5c4b..12d626e78182 100644
@@ -180,14 +180,6 @@ struct btrfs_free_cluster {
 	struct list_head block_group_list;
 };
 
-/*
- * Tree to record all locked full stripes of a RAID5/6 block group
- */
-struct btrfs_full_stripe_locks_tree {
-	struct rb_root root;
-	struct mutex lock;
-};
-
 /* Discard control. */
 /*
  * Async discard uses multiple lists to differentiate the discard filter
@@ -1944,12 +1936,6 @@ int btrfs_scrub_cancel(struct btrfs_fs_info *info);
 int btrfs_scrub_cancel_dev(struct btrfs_device *dev);
 int btrfs_scrub_progress(struct btrfs_fs_info *fs_info, u64 devid,
 			 struct btrfs_scrub_progress *progress);
-static inline void btrfs_init_full_stripe_locks_tree(
-			struct btrfs_full_stripe_locks_tree *locks_root)
-{
-	locks_root->root = RB_ROOT;
-	mutex_init(&locks_root->lock);
-}
 
 /* dev-replace.c */
 void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info);
Signature · 1 line
2.26.3
#7 lore raw

PATCH 3/15 btrfs: move btrfs_init_async_reclaim_work prototype to space-info.h

In reply to Josef Bacik

The code for this helper is in space-info.c, move the prototype to space-info.h.

---
 fs/btrfs/ctree.h      | 2 --
 fs/btrfs/space-info.h | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/ctree.h +0 -2
index 12d626e78182..0c5a6ea2eeb3 100644
@@ -211,8 +211,6 @@ struct btrfs_discard_ctl {
 	atomic64_t discard_bytes_saved;
 };
 
-void btrfs_init_async_reclaim_work(struct btrfs_fs_info *fs_info);
-
 /* fs_info */
 struct reloc_control;
 struct btrfs_device;
fs/btrfs/space-info.h +1 -0
index 729820582fa7..6e2947688c53 100644
@@ -217,5 +217,6 @@ static inline void btrfs_space_info_free_bytes_may_use(
 int btrfs_reserve_data_bytes(struct btrfs_fs_info *fs_info, u64 bytes,
 			     enum btrfs_reserve_flush_enum flush);
 void btrfs_dump_space_info_for_trans_abort(struct btrfs_fs_info *fs_info);
+void btrfs_init_async_reclaim_work(struct btrfs_fs_info *fs_info);
 
 #endif /* BTRFS_SPACE_INFO_H */
Signature · 1 line
2.26.3
#13 lore raw

PATCH 5/15 btrfs: remove temporary btrfs_map_token declaration in ctree.h

In reply to Josef Bacik

This was added while I was moving this code to its new home, it can be removed now.

---
 fs/btrfs/ctree.h | 2 --
 1 file changed, 2 deletions(-)
fs/btrfs/ctree.h +0 -2
index 36a473f05831..a790c58b4c73 100644
@@ -46,8 +46,6 @@ struct btrfs_ref;
 struct btrfs_bio;
 struct btrfs_ioctl_encoded_io_args;
 
-struct btrfs_map_token;
-
 #define BTRFS_OLDEST_GENERATION	0ULL
 
 #define BTRFS_EMPTY_DIR_SIZE 0
Signature · 1 line
2.26.3
#10 lore raw

PATCH 4/15 btrfs: move btrfs_pinned_by_swapfile prototype into volumes.h

In reply to Josef Bacik

This is defined in volumes.c, move the prototype into volumes.h.

---
 fs/btrfs/ctree.h   | 2 --
 fs/btrfs/volumes.h | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/ctree.h +0 -2
index 0c5a6ea2eeb3..36a473f05831 100644
@@ -243,8 +243,6 @@ struct btrfs_swapfile_pin {
 	int bg_extent_count;
 };
 
-bool btrfs_pinned_by_swapfile(struct btrfs_fs_info *fs_info, void *ptr);
-
 /*
  * Exclusive operations (device replace, resize, device add/remove, balance)
  */
fs/btrfs/volumes.h +1 -0
index 96a7b437ff20..db4cf51134fd 100644
@@ -731,4 +731,5 @@ const char *btrfs_bg_type_to_raid_name(u64 flags);
 int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info);
 bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical);
 unsigned long btrfs_chunk_item_size(int num_stripes);
+bool btrfs_pinned_by_swapfile(struct btrfs_fs_info *fs_info, void *ptr);
 #endif
Signature · 1 line
2.26.3
#17 lore raw

PATCH 6/15 btrfs: move static_assert() for btrfs_super_block into fs.c

In reply to Josef Bacik

We shouldn't have static_assert()'s in header files in general, but especially since btrfs_super_block isn't defined in ctree.h.

---
 fs/btrfs/ctree.h | 1 -
 fs/btrfs/fs.c    | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/ctree.h +0 -1
index a790c58b4c73..3cb4e0aca058 100644
@@ -56,7 +56,6 @@ struct btrfs_ioctl_encoded_io_args;
 
 #define BTRFS_SUPER_INFO_OFFSET			SZ_64K
 #define BTRFS_SUPER_INFO_SIZE			4096
-static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE);
 
 /*
  * The reserved space at the beginning of each device.
fs/btrfs/fs.c +2 -0
index a95d86679d14..c54ee0f943ce 100644
@@ -106,3 +106,5 @@ int __btrfs_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag)
 	disk_super = fs_info->super_copy;
 	return !!(btrfs_super_compat_ro_flags(disk_super) & flag);
 }
+
+static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE);
Signature · 1 line
2.26.3
#21 lore raw

PATCH 7/15 btrfs: move btrfs_swapfile_pin into volumes.h

In reply to Josef Bacik

This isn't a great spot for this, but one of the swapfile helper functions is in volumes.c, so move the struct to volumes.h. In the future when we have better separation of code there will be a more natural spot for this.

---
 fs/btrfs/ctree.h   | 25 -------------------------
 fs/btrfs/volumes.h | 25 +++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 25 deletions(-)
fs/btrfs/ctree.h +0 -25
index 3cb4e0aca058..b9e848a22290 100644
@@ -215,31 +215,6 @@ struct btrfs_fs_devices;
 struct btrfs_balance_control;
 struct btrfs_delayed_root;
 
-/*
- * Block group or device which contains an active swapfile. Used for preventing
- * unsafe operations while a swapfile is active.
- *
- * These are sorted on (ptr, inode) (note that a block group or device can
- * contain more than one swapfile). We compare the pointer values because we
- * don't actually care what the object is, we just need a quick check whether
- * the object exists in the rbtree.
- */
-struct btrfs_swapfile_pin {
-	struct rb_node node;
-	void *ptr;
-	struct inode *inode;
-	/*
-	 * If true, ptr points to a struct btrfs_block_group. Otherwise, ptr
-	 * points to a struct btrfs_device.
-	 */
-	bool is_block_group;
-	/*
-	 * Only used when 'is_block_group' is true and it is the number of
-	 * extents used by a swapfile for this block group ('ptr' field).
-	 */
-	int bg_extent_count;
-};
-
 /*
  * Exclusive operations (device replace, resize, device add/remove, balance)
  */
fs/btrfs/volumes.h +25 -0
index db4cf51134fd..2bf7dbe739fd 100644
@@ -180,6 +180,31 @@ struct btrfs_device {
 	u64 scrub_speed_max;
 };
 
+/*
+ * Block group or device which contains an active swapfile. Used for preventing
+ * unsafe operations while a swapfile is active.
+ *
+ * These are sorted on (ptr, inode) (note that a block group or device can
+ * contain more than one swapfile). We compare the pointer values because we
+ * don't actually care what the object is, we just need a quick check whether
+ * the object exists in the rbtree.
+ */
+struct btrfs_swapfile_pin {
+	struct rb_node node;
+	void *ptr;
+	struct inode *inode;
+	/*
+	 * If true, ptr points to a struct btrfs_block_group. Otherwise, ptr
+	 * points to a struct btrfs_device.
+	 */
+	bool is_block_group;
+	/*
+	 * Only used when 'is_block_group' is true and it is the number of
+	 * extents used by a swapfile for this block group ('ptr' field).
+	 */
+	int bg_extent_count;
+};
+
 /*
  * If we read those variants at the context of their own lock, we needn't
  * use the following helpers, reading them directly is safe.
Signature · 1 line
2.26.3
#24 lore raw

PATCH 8/15 btrfs: move fs_info struct declarations to the top of ctree.h

In reply to Josef Bacik

In order to make it more straightforward to move the fs_info struct and it's related structures, move the struct declarations to the top of ctree.h. This will make it easier to clean up after the fact.

---
 fs/btrfs/ctree.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
fs/btrfs/ctree.h +7 -7
index b9e848a22290..05eb0e994e68 100644
@@ -46,6 +46,13 @@ struct btrfs_ref;
 struct btrfs_bio;
 struct btrfs_ioctl_encoded_io_args;
 
+/* fs_info */
+struct reloc_control;
+struct btrfs_device;
+struct btrfs_fs_devices;
+struct btrfs_balance_control;
+struct btrfs_delayed_root;
+
 #define BTRFS_OLDEST_GENERATION	0ULL
 
 #define BTRFS_EMPTY_DIR_SIZE 0
@@ -208,13 +215,6 @@ struct btrfs_discard_ctl {
 	atomic64_t discard_bytes_saved;
 };
 
-/* fs_info */
-struct reloc_control;
-struct btrfs_device;
-struct btrfs_fs_devices;
-struct btrfs_balance_control;
-struct btrfs_delayed_root;
-
 /*
  * Exclusive operations (device replace, resize, device add/remove, balance)
  */
Signature · 1 line
2.26.3
#27 lore raw

PATCH 9/15 btrfs: move btrfs_csum_ptr to inode.c

In reply to Josef Bacik

This helper is only used in inode.c, move it locally to that file instead of defining it in ctree.h.

---
 fs/btrfs/ctree.h | 8 --------
 fs/btrfs/inode.c | 8 ++++++++
 2 files changed, 8 insertions(+), 8 deletions(-)
fs/btrfs/ctree.h +0 -8
index 05eb0e994e68..0da52e8b78e9 100644
@@ -1173,14 +1173,6 @@ int btrfs_get_extent_inline_ref_type(const struct extent_buffer *eb,
 				     enum btrfs_inline_ref_type is_data);
 u64 hash_extent_data_ref(u64 root_objectid, u64 owner, u64 offset);
 
-static inline u8 *btrfs_csum_ptr(const struct btrfs_fs_info *fs_info, u8 *csums,
-				 u64 offset)
-{
-	u64 offset_in_sectors = offset >> fs_info->sectorsize_bits;
-
-	return csums + offset_in_sectors * fs_info->csum_size;
-}
-
 /*
  * Take the number of bytes to be checksummed and figure out how many leaves
  * it would require to store the csums for that many bytes.
fs/btrfs/inode.c +8 -0
index ca6fa9b01785..62dc3dcf835b 100644
@@ -3459,6 +3459,14 @@ int btrfs_check_sector_csum(struct btrfs_fs_info *fs_info, struct page *page,
 	return 0;
 }
 
+static inline u8 *btrfs_csum_ptr(const struct btrfs_fs_info *fs_info, u8 *csums,
+				 u64 offset)
+{
+	u64 offset_in_sectors = offset >> fs_info->sectorsize_bits;
+
+	return csums + offset_in_sectors * fs_info->csum_size;
+}
+
 /*
  * check_data_csum - verify checksum of one sector of uncompressed data
  * @inode:	inode
Signature · 1 line
2.26.3
#30 lore raw

PATCH 10/15 btrfs: move the fs_info related helpers closer to fs_info in ctree.h

In reply to Josef Bacik

This is purely cosmetic, to make it straightforward to copy and paste the definition and helpers from ctree.h into fs.h. These are helpers that act directly on the fs_info, and were scattered throughout ctree.h. Move them directly below the fs_info definition to make it easier to move them later. This includes the exclop prototypes, which shares an enum that's used in struct btrfs_fs_info as well.

---
 fs/btrfs/ctree.h | 187 ++++++++++++++++++++++++-----------------------
 1 file changed, 94 insertions(+), 93 deletions(-)
fs/btrfs/ctree.h +94 -93
index 0da52e8b78e9..57d53ec3cdd0 100644
@@ -126,8 +126,7 @@ struct btrfs_path {
 	 */
 	unsigned int search_for_extension:1;
 };
-#define BTRFS_MAX_EXTENT_ITEM_SIZE(r) ((BTRFS_LEAF_DATA_SIZE(r->fs_info) >> 4) - \
-					sizeof(struct btrfs_item))
+
 struct btrfs_dev_replace {
 	u64 replace_state;	/* see #define above */
 	time64_t time_started;	/* seconds since 1-Jan-1970 */
@@ -705,6 +704,99 @@ static inline struct btrfs_fs_info *btrfs_sb(struct super_block *sb)
 	return sb->s_fs_info;
 }
 
+/*
+ * Take the number of bytes to be checksummed and figure out how many leaves
+ * it would require to store the csums for that many bytes.
+ */
+static inline u64 btrfs_csum_bytes_to_leaves(
+			const struct btrfs_fs_info *fs_info, u64 csum_bytes)
+{
+	const u64 num_csums = csum_bytes >> fs_info->sectorsize_bits;
+
+	return DIV_ROUND_UP_ULL(num_csums, fs_info->csums_per_leaf);
+}
+
+/*
+ * Use this if we would be adding new items, as we could split nodes as we cow
+ * down the tree.
+ */
+static inline u64 btrfs_calc_insert_metadata_size(struct btrfs_fs_info *fs_info,
+						  unsigned num_items)
+{
+	return (u64)fs_info->nodesize * BTRFS_MAX_LEVEL * 2 * num_items;
+}
+
+/*
+ * Doing a truncate or a modification won't result in new nodes or leaves, just
+ * what we need for COW.
+ */
+static inline u64 btrfs_calc_metadata_size(struct btrfs_fs_info *fs_info,
+						 unsigned num_items)
+{
+	return (u64)fs_info->nodesize * BTRFS_MAX_LEVEL * num_items;
+}
+
+static inline u32 BTRFS_LEAF_DATA_SIZE(const struct btrfs_fs_info *info)
+{
+	return info->nodesize - sizeof(struct btrfs_header);
+}
+
+static inline u32 BTRFS_MAX_ITEM_SIZE(const struct btrfs_fs_info *info)
+{
+	return BTRFS_LEAF_DATA_SIZE(info) - sizeof(struct btrfs_item);
+}
+
+static inline u32 BTRFS_NODEPTRS_PER_BLOCK(const struct btrfs_fs_info *info)
+{
+	return BTRFS_LEAF_DATA_SIZE(info) / sizeof(struct btrfs_key_ptr);
+}
+
+#define BTRFS_FILE_EXTENT_INLINE_DATA_START		\
+		(offsetof(struct btrfs_file_extent_item, disk_bytenr))
+static inline u32 BTRFS_MAX_INLINE_DATA_SIZE(const struct btrfs_fs_info *info)
+{
+	return BTRFS_MAX_ITEM_SIZE(info) -
+	       BTRFS_FILE_EXTENT_INLINE_DATA_START;
+}
+
+static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
+{
+	return BTRFS_MAX_ITEM_SIZE(info) - sizeof(struct btrfs_dir_item);
+}
+
+#define BTRFS_BYTES_TO_BLKS(fs_info, bytes) \
+				((bytes) >> (fs_info)->sectorsize_bits)
+
+#define BTRFS_MAX_EXTENT_ITEM_SIZE(r) ((BTRFS_LEAF_DATA_SIZE(r->fs_info) >> 4) - \
+					sizeof(struct btrfs_item))
+
+static inline bool btrfs_is_zoned(const struct btrfs_fs_info *fs_info)
+{
+	return fs_info->zone_size > 0;
+}
+
+/*
+ * Count how many fs_info->max_extent_size cover the @size
+ */
+static inline u32 count_max_extents(struct btrfs_fs_info *fs_info, u64 size)
+{
+#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
+	if (!fs_info)
+		return div_u64(size + BTRFS_MAX_EXTENT_SIZE - 1, BTRFS_MAX_EXTENT_SIZE);
+#endif
+
+	return div_u64(size + fs_info->max_extent_size - 1, fs_info->max_extent_size);
+}
+
+bool btrfs_exclop_start(struct btrfs_fs_info *fs_info,
+			enum btrfs_exclusive_operation type);
+bool btrfs_exclop_start_try_lock(struct btrfs_fs_info *fs_info,
+				 enum btrfs_exclusive_operation type);
+void btrfs_exclop_start_unlock(struct btrfs_fs_info *fs_info);
+void btrfs_exclop_finish(struct btrfs_fs_info *fs_info);
+void btrfs_exclop_balance(struct btrfs_fs_info *fs_info,
+			  enum btrfs_exclusive_operation op);
+
 /*
  * The state of btrfs root
  */
@@ -1097,39 +1189,6 @@ struct btrfs_file_private {
 	void *filldir_buf;
 };
 
-
-static inline u32 BTRFS_LEAF_DATA_SIZE(const struct btrfs_fs_info *info)
-{
-
-	return info->nodesize - sizeof(struct btrfs_header);
-}
-
-static inline u32 BTRFS_MAX_ITEM_SIZE(const struct btrfs_fs_info *info)
-{
-	return BTRFS_LEAF_DATA_SIZE(info) - sizeof(struct btrfs_item);
-}
-
-static inline u32 BTRFS_NODEPTRS_PER_BLOCK(const struct btrfs_fs_info *info)
-{
-	return BTRFS_LEAF_DATA_SIZE(info) / sizeof(struct btrfs_key_ptr);
-}
-
-#define BTRFS_FILE_EXTENT_INLINE_DATA_START		\
-		(offsetof(struct btrfs_file_extent_item, disk_bytenr))
-static inline u32 BTRFS_MAX_INLINE_DATA_SIZE(const struct btrfs_fs_info *info)
-{
-	return BTRFS_MAX_ITEM_SIZE(info) -
-	       BTRFS_FILE_EXTENT_INLINE_DATA_START;
-}
-
-static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
-{
-	return BTRFS_MAX_ITEM_SIZE(info) - sizeof(struct btrfs_dir_item);
-}
-
-#define BTRFS_BYTES_TO_BLKS(fs_info, bytes) \
-				((bytes) >> (fs_info)->sectorsize_bits)
-
 static inline u32 btrfs_crc32c(u32 crc, const void *address, unsigned length)
 {
 	return crc32c(crc, address, length);
@@ -1173,37 +1232,6 @@ int btrfs_get_extent_inline_ref_type(const struct extent_buffer *eb,
 				     enum btrfs_inline_ref_type is_data);
 u64 hash_extent_data_ref(u64 root_objectid, u64 owner, u64 offset);
 
-/*
- * Take the number of bytes to be checksummed and figure out how many leaves
- * it would require to store the csums for that many bytes.
- */
-static inline u64 btrfs_csum_bytes_to_leaves(
-			const struct btrfs_fs_info *fs_info, u64 csum_bytes)
-{
-	const u64 num_csums = csum_bytes >> fs_info->sectorsize_bits;
-
-	return DIV_ROUND_UP_ULL(num_csums, fs_info->csums_per_leaf);
-}
-
-/*
- * Use this if we would be adding new items, as we could split nodes as we cow
- * down the tree.
- */
-static inline u64 btrfs_calc_insert_metadata_size(struct btrfs_fs_info *fs_info,
-						  unsigned num_items)
-{
-	return (u64)fs_info->nodesize * BTRFS_MAX_LEVEL * 2 * num_items;
-}
-
-/*
- * Doing a truncate or a modification won't result in new nodes or leaves, just
- * what we need for COW.
- */
-static inline u64 btrfs_calc_metadata_size(struct btrfs_fs_info *fs_info,
-						 unsigned num_items)
-{
-	return (u64)fs_info->nodesize * BTRFS_MAX_LEVEL * num_items;
-}
 
 int btrfs_add_excluded_extent(struct btrfs_fs_info *fs_info,
 			      u64 start, u64 num_bytes);
@@ -1737,15 +1765,6 @@ void btrfs_get_block_group_info(struct list_head *groups_list,
 				struct btrfs_ioctl_space_info *space);
 void btrfs_update_ioctl_balance_args(struct btrfs_fs_info *fs_info,
 			       struct btrfs_ioctl_balance_args *bargs);
-bool btrfs_exclop_start(struct btrfs_fs_info *fs_info,
-			enum btrfs_exclusive_operation type);
-bool btrfs_exclop_start_try_lock(struct btrfs_fs_info *fs_info,
-				 enum btrfs_exclusive_operation type);
-void btrfs_exclop_start_unlock(struct btrfs_fs_info *fs_info);
-void btrfs_exclop_finish(struct btrfs_fs_info *fs_info);
-void btrfs_exclop_balance(struct btrfs_fs_info *fs_info,
-			  enum btrfs_exclusive_operation op);
-
 
 /* file.c */
 int __init btrfs_auto_defrag_init(void);
@@ -1943,24 +1962,6 @@ static inline int btrfs_get_verity_descriptor(struct inode *inode, void *buf,
 void btrfs_test_destroy_inode(struct inode *inode);
 #endif
 
-static inline bool btrfs_is_zoned(const struct btrfs_fs_info *fs_info)
-{
-	return fs_info->zone_size > 0;
-}
-
-/*
- * Count how many fs_info->max_extent_size cover the @size
- */
-static inline u32 count_max_extents(struct btrfs_fs_info *fs_info, u64 size)
-{
-#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
-	if (!fs_info)
-		return div_u64(size + BTRFS_MAX_EXTENT_SIZE - 1, BTRFS_MAX_EXTENT_SIZE);
-#endif
-
-	return div_u64(size + fs_info->max_extent_size - 1, fs_info->max_extent_size);
-}
-
 static inline bool btrfs_is_data_reloc_root(const struct btrfs_root *root)
 {
 	return root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID;
Signature · 1 line
2.26.3
#33 lore raw

PATCH 11/15 btrfs: move btrfs_ordered_sum_size into file-item.c

In reply to Josef Bacik

This is defined in ordered-data.h, but is only used in file-item.c. Move this to file-item.c as it doesn't need to be global.

---
 fs/btrfs/file-item.c    | 12 ++++++++++++
 fs/btrfs/ordered-data.h | 12 ------------
 2 files changed, 12 insertions(+), 12 deletions(-)
fs/btrfs/file-item.c +12 -0
index 7bd6e1b91495..615e65b15463 100644
@@ -132,6 +132,18 @@ static inline u32 max_ordered_sum_bytes(struct btrfs_fs_info *fs_info,
 	return ncsums * fs_info->sectorsize;
 }
 
+/*
+ * calculates the total size you need to allocate for an ordered sum
+ * structure spanning 'bytes' in the file
+ */
+static inline int btrfs_ordered_sum_size(struct btrfs_fs_info *fs_info,
+					 unsigned long bytes)
+{
+	int num_sectors = (int)DIV_ROUND_UP(bytes, fs_info->sectorsize);
+
+	return sizeof(struct btrfs_ordered_sum) + num_sectors * fs_info->csum_size;
+}
+
 int btrfs_insert_hole_extent(struct btrfs_trans_handle *trans,
 			     struct btrfs_root *root,
 			     u64 objectid, u64 pos, u64 num_bytes)
fs/btrfs/ordered-data.h +0 -12
index 87792f85e2c4..ac6b8ef133aa 100644
@@ -160,18 +160,6 @@ struct btrfs_ordered_extent {
 	struct block_device *bdev;
 };
 
-/*
- * calculates the total size you need to allocate for an ordered sum
- * structure spanning 'bytes' in the file
- */
-static inline int btrfs_ordered_sum_size(struct btrfs_fs_info *fs_info,
-					 unsigned long bytes)
-{
-	int num_sectors = (int)DIV_ROUND_UP(bytes, fs_info->sectorsize);
-
-	return sizeof(struct btrfs_ordered_sum) + num_sectors * fs_info->csum_size;
-}
-
 static inline void
 btrfs_ordered_inode_tree_init(struct btrfs_ordered_inode_tree *t)
 {
Signature · 1 line
2.26.3
#36 lore raw

PATCH 12/15 btrfs: delete btrfs_inode_sectorsize helper

In reply to Josef Bacik

This is defined in btrfs_inode.h, and dereferences btrfs_root and btrfs_fs_info, both of which aren't defined in btrfs_inode.h. Additionally, in many places we already have root or fs_info, so this helper often makes the code harder to read. So delete the helper and simply open code it in the few places that we use it.

---
 fs/btrfs/btrfs_inode.h |  5 -----
 fs/btrfs/extent_io.c   |  4 ++--
 fs/btrfs/file.c        | 11 +++++------
 3 files changed, 7 insertions(+), 13 deletions(-)
fs/btrfs/btrfs_inode.h +0 -5
index 890c9f979a3d..b24f78145fa6 100644
@@ -251,11 +251,6 @@ struct btrfs_inode {
 	struct inode vfs_inode;
 };
 
-static inline u32 btrfs_inode_sectorsize(const struct btrfs_inode *inode)
-{
-	return inode->root->fs_info->sectorsize;
-}
-
 static inline struct btrfs_inode *BTRFS_I(const struct inode *inode)
 {
 	return container_of(inode, struct btrfs_inode, vfs_inode);
fs/btrfs/extent_io.c +2 -2
index b1d57727be02..f5eb6c66911c 100644
@@ -3925,8 +3925,8 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo,
 		goto out;
 	}
 
-	lockstart = round_down(start, btrfs_inode_sectorsize(inode));
-	lockend = round_up(start + len, btrfs_inode_sectorsize(inode));
+	lockstart = round_down(start, root->fs_info->sectorsize);
+	lockend = round_up(start + len, root->fs_info->sectorsize);
 	prev_extent_end = lockstart;
 
 	lock_extent(&inode->io_tree, lockstart, lockend, &cached_state);
fs/btrfs/file.c +5 -6
index c395bf8e7522..c418468428ad 100644
@@ -3010,9 +3010,8 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
 	if (ret)
 		goto out_only_mutex;
 
-	lockstart = round_up(offset, btrfs_inode_sectorsize(BTRFS_I(inode)));
-	lockend = round_down(offset + len,
-			     btrfs_inode_sectorsize(BTRFS_I(inode))) - 1;
+	lockstart = round_up(offset, fs_info->sectorsize);
+	lockend = round_down(offset + len, fs_info->sectorsize) - 1;
 	same_block = (BTRFS_BYTES_TO_BLKS(fs_info, offset))
 		== (BTRFS_BYTES_TO_BLKS(fs_info, offset + len - 1));
 	/*
@@ -3214,7 +3213,7 @@ enum {
 static int btrfs_zero_range_check_range_boundary(struct btrfs_inode *inode,
 						 u64 offset)
 {
-	const u64 sectorsize = btrfs_inode_sectorsize(inode);
+	const u64 sectorsize = inode->root->fs_info->sectorsize;
 	struct extent_map *em;
 	int ret;
 
@@ -3244,7 +3243,7 @@ static int btrfs_zero_range(struct inode *inode,
 	struct extent_changeset *data_reserved = NULL;
 	int ret;
 	u64 alloc_hint = 0;
-	const u64 sectorsize = btrfs_inode_sectorsize(BTRFS_I(inode));
+	const u64 sectorsize = fs_info->sectorsize;
 	u64 alloc_start = round_down(offset, sectorsize);
 	u64 alloc_end = round_up(offset + len, sectorsize);
 	u64 bytes_to_reserve = 0;
@@ -3430,7 +3429,7 @@ static long btrfs_fallocate(struct file *file, int mode,
 	u64 data_space_reserved = 0;
 	u64 qgroup_reserved = 0;
 	struct extent_map *em;
-	int blocksize = btrfs_inode_sectorsize(BTRFS_I(inode));
+	int blocksize = BTRFS_I(inode)->root->fs_info->sectorsize;
 	int ret;
 
 	/* Do not allow fallocate in ZONED mode */
Signature · 1 line
2.26.3
#39 lore raw

PATCH 13/15 btrfs: delete btrfs_insert_inode_hash helper

In reply to Josef Bacik

This exists to insert the btree_inode in the super blocks inode hash table. Since it's only used for the btree inode move the code to where we use it in disk-io.c and remove the helper.

---
 fs/btrfs/btrfs_inode.h | 7 -------
 fs/btrfs/disk-io.c     | 4 +++-
 2 files changed, 3 insertions(+), 8 deletions(-)
fs/btrfs/btrfs_inode.h +0 -7
index b24f78145fa6..44edc6a3db6b 100644
@@ -268,13 +268,6 @@ static inline unsigned long btrfs_inode_hash(u64 objectid,
 	return (unsigned long)h;
 }
 
-static inline void btrfs_insert_inode_hash(struct inode *inode)
-{
-	unsigned long h = btrfs_inode_hash(inode->i_ino, BTRFS_I(inode)->root);
-
-	__insert_inode_hash(inode, h);
-}
-
 #if BITS_PER_LONG == 32
 
 /*
fs/btrfs/disk-io.c +3 -1
index 124c210c4e02..0f925b896fca 100644
@@ -2227,6 +2227,8 @@ static void btrfs_init_balance(struct btrfs_fs_info *fs_info)
 static void btrfs_init_btree_inode(struct btrfs_fs_info *fs_info)
 {
 	struct inode *inode = fs_info->btree_inode;
+	unsigned long hash = btrfs_inode_hash(BTRFS_BTREE_INODE_OBJECTID,
+					      fs_info->tree_root);
 
 	inode->i_ino = BTRFS_BTREE_INODE_OBJECTID;
 	set_nlink(inode, 1);
@@ -2248,7 +2250,7 @@ static void btrfs_init_btree_inode(struct btrfs_fs_info *fs_info)
 	BTRFS_I(inode)->location.type = 0;
 	BTRFS_I(inode)->location.offset = 0;
 	set_bit(BTRFS_INODE_DUMMY, &BTRFS_I(inode)->runtime_flags);
-	btrfs_insert_inode_hash(inode);
+	__insert_inode_hash(inode, hash);
 }
 
 static void btrfs_init_dev_replace_locks(struct btrfs_fs_info *fs_info)
Signature · 1 line
2.26.3
#42 lore raw

PATCH 14/15 btrfs: use a runtime flag to indicate an inode is a free space inode

In reply to Josef Bacik

We always check the root of an inode as well as it's inode number to determine if it's a free space inode. This is problematic as the helper is in a header file where it doesn't have the fs_info definition. To avoid this and make the check a little cleaner simply add a flag to the runtime_flags to indicate that the inode is a free space inode, set that when we create the inode, and then change the helper to check for this flag.

---
 fs/btrfs/btrfs_inode.h | 10 +++-------
 fs/btrfs/inode.c       |  5 +++++
 2 files changed, 8 insertions(+), 7 deletions(-)
fs/btrfs/btrfs_inode.h +3 -7
index 44edc6a3db6b..530a0ebfab3f 100644
@@ -65,6 +65,8 @@ enum {
 	 * on the same file.
 	 */
 	BTRFS_INODE_VERITY_IN_PROGRESS,
+	/* Set when this inode is a free space inode. */
+	BTRFS_INODE_FREE_SPACE_INODE,
 };
 
 /* in memory btrfs inode */
@@ -301,13 +303,7 @@ static inline void btrfs_i_size_write(struct btrfs_inode *inode, u64 size)
 
 static inline bool btrfs_is_free_space_inode(struct btrfs_inode *inode)
 {
-	struct btrfs_root *root = inode->root;
-
-	if (root == root->fs_info->tree_root &&
-	    btrfs_ino(inode) != BTRFS_BTREE_INODE_OBJECTID)
-		return true;
-
-	return false;
+	return test_bit(BTRFS_INODE_FREE_SPACE_INODE, &inode->runtime_flags);
 }
 
 static inline bool is_data_inode(struct inode *inode)
fs/btrfs/inode.c +5 -0
index 62dc3dcf835b..1f38d9b98132 100644
@@ -5731,6 +5731,11 @@ static int btrfs_init_locked_inode(struct inode *inode, void *p)
 	BTRFS_I(inode)->location.offset = 0;
 	BTRFS_I(inode)->root = btrfs_grab_root(args->root);
 	BUG_ON(args->root && !BTRFS_I(inode)->root);
+
+	if (args->root && args->root == args->root->fs_info->tree_root &&
+	    args->ino != BTRFS_BTREE_INODE_OBJECTID)
+		set_bit(BTRFS_INODE_FREE_SPACE_INODE,
+			&BTRFS_I(inode)->runtime_flags);
 	return 0;
 }
 
Signature · 1 line
2.26.3
#45 lore raw

PATCH 15/15 btrfs: add struct declarations in dev-replace.h

In reply to Josef Bacik

dev-replace.h just has function prototypes for device replace, however if you happen to include it in the wrong order you'll get compile errors because of different structures not being defined. Since these are just pointer args to functions we can declare them at the top in order to reduce the pain of using the header.

---
 fs/btrfs/dev-replace.h | 4 ++++
 1 file changed, 4 insertions(+)
fs/btrfs/dev-replace.h +4 -0
index 3911049a5f23..6084b313056a 100644
@@ -7,6 +7,10 @@
 #define BTRFS_DEV_REPLACE_H
 
 struct btrfs_ioctl_dev_replace_args;
+struct btrfs_fs_info;
+struct btrfs_trans_handle;
+struct btrfs_dev_replace;
+struct btrfs_block_group;
 
 int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info);
 int btrfs_run_dev_replace(struct btrfs_trans_handle *trans);
Signature · 1 line
2.26.3
Reviewed-by on v1 1/15
#2 lore raw

Re: [PATCH 01/15] btrfs: move btrfs_caching_type to block-group.h

In reply to Josef Bacik
Quoted 3 lines · Josef Bacik

This is a block group related definition, move it into block-group.h.

Quoted 41 lines
---
  fs/btrfs/block-group.h | 7 +++++++
  fs/btrfs/ctree.h       | 7 -------
  2 files changed, 7 insertions(+), 7 deletions(-)
fs/btrfs/block-group.h +7 -0
index e34cb80ffb25..558fa0a21fb4 100644
@@ -57,6 +57,13 @@ enum btrfs_block_group_flags {
  	BLOCK_GROUP_FLAG_ZONED_DATA_RELOC,
  };
 
+enum btrfs_caching_type {
+	BTRFS_CACHE_NO,
+	BTRFS_CACHE_STARTED,
+	BTRFS_CACHE_FINISHED,
+	BTRFS_CACHE_ERROR,
+};
+
  struct btrfs_caching_control {
  	struct list_head list;
  	struct mutex mutex;
fs/btrfs/ctree.h +0 -7
index 8271b3dccf16..725c187d5c4b 100644
@@ -180,13 +180,6 @@ struct btrfs_free_cluster {
  	struct list_head block_group_list;
  };
 
-enum btrfs_caching_type {
-	BTRFS_CACHE_NO,
-	BTRFS_CACHE_STARTED,
-	BTRFS_CACHE_FINISHED,
-	BTRFS_CACHE_ERROR,
-};
-
  /*
   * Tree to record all locked full stripes of a RAID5/6 block group
   */
Reviewed-by on v1 2/15
#5 lore raw

Re: [PATCH 02/15] btrfs: move btrfs_full_stripe_locks_tree into block-group.h

In reply to Josef Bacik
Quoted 5 lines · Josef Bacik

This is actually embedded in struct btrfs_block_group, so move this definition to block-group.h, and then open-code the init of the tree where we init the rest of the block group instead of using a helper.

Quoted 71 lines
---
  fs/btrfs/block-group.c |  3 ++-
  fs/btrfs/block-group.h |  8 ++++++++
  fs/btrfs/ctree.h       | 14 --------------
  3 files changed, 10 insertions(+), 15 deletions(-)
fs/btrfs/block-group.c +2 -1
index 20da92ae5c6b..e21382a13fe4 100644
@@ -1940,7 +1940,8 @@ static struct btrfs_block_group *btrfs_create_block_group_cache(
  	btrfs_init_free_space_ctl(cache, cache->free_space_ctl);
  	atomic_set(&cache->frozen, 0);
  	mutex_init(&cache->free_space_lock);
-	btrfs_init_full_stripe_locks_tree(&cache->full_stripe_locks_root);
+	cache->full_stripe_locks_root.root = RB_ROOT;
+	mutex_init(&cache->full_stripe_locks_root.lock);
 
  	return cache;
  }
fs/btrfs/block-group.h +8 -0
index 558fa0a21fb4..6c970a486b68 100644
@@ -76,6 +76,14 @@ struct btrfs_caching_control {
  /* Once caching_thread() finds this much free space, it will wake up waiters. */
  #define CACHING_CTL_WAKE_UP SZ_2M
 
+/*
+ * Tree to record all locked full stripes of a RAID5/6 block group
+ */
+struct btrfs_full_stripe_locks_tree {
+	struct rb_root root;
+	struct mutex lock;
+};
+
  struct btrfs_block_group {
  	struct btrfs_fs_info *fs_info;
  	struct inode *inode;
fs/btrfs/ctree.h +0 -14
index 725c187d5c4b..12d626e78182 100644
@@ -180,14 +180,6 @@ struct btrfs_free_cluster {
  	struct list_head block_group_list;
  };
 
-/*
- * Tree to record all locked full stripes of a RAID5/6 block group
- */
-struct btrfs_full_stripe_locks_tree {
-	struct rb_root root;
-	struct mutex lock;
-};
-
  /* Discard control. */
  /*
   * Async discard uses multiple lists to differentiate the discard filter
@@ -1944,12 +1936,6 @@ int btrfs_scrub_cancel(struct btrfs_fs_info *info);
  int btrfs_scrub_cancel_dev(struct btrfs_device *dev);
  int btrfs_scrub_progress(struct btrfs_fs_info *fs_info, u64 devid,
  			 struct btrfs_scrub_progress *progress);
-static inline void btrfs_init_full_stripe_locks_tree(
-			struct btrfs_full_stripe_locks_tree *locks_root)
-{
-	locks_root->root = RB_ROOT;
-	mutex_init(&locks_root->lock);
-}
 
  /* dev-replace.c */
  void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info);
Reviewed-by on v1 10/15
#31 lore raw

Re: [PATCH 10/15] btrfs: move the fs_info related helpers closer to fs_info in ctree.h

In reply to Josef Bacik
Quoted 8 lines · Josef Bacik

This is purely cosmetic, to make it straightforward to copy and paste the definition and helpers from ctree.h into fs.h. These are helpers that act directly on the fs_info, and were scattered throughout ctree.h. Move them directly below the fs_info definition to make it easier to move them later. This includes the exclop prototypes, which shares an enum that's used in struct btrfs_fs_info as well.

Reviewed-by on v1 12/15
#37 lore raw

Re: [PATCH 12/15] btrfs: delete btrfs_inode_sectorsize helper

In reply to Josef Bacik
Quoted 7 lines · Josef Bacik

This is defined in btrfs_inode.h, and dereferences btrfs_root and btrfs_fs_info, both of which aren't defined in btrfs_inode.h. Additionally, in many places we already have root or fs_info, so this helper often makes the code harder to read. So delete the helper and simply open code it in the few places that we use it.

Reviewed-by on v1 14/15
#43 lore raw

Re: [PATCH 14/15] btrfs: use a runtime flag to indicate an inode is a free space inode

In reply to Josef Bacik
Quoted 9 lines · Josef Bacik

We always check the root of an inode as well as it's inode number to determine if it's a free space inode. This is problematic as the helper is in a header file where it doesn't have the fs_info definition. To avoid this and make the check a little cleaner simply add a flag to the runtime_flags to indicate that the inode is a free space inode, set that when we create the inode, and then change the helper to check for this flag.

Reviewed-by on v1 15/15
#46 lore raw

Re: [PATCH 15/15] btrfs: add struct declarations in dev-replace.h

In reply to Josef Bacik
Quoted 7 lines · Josef Bacik

dev-replace.h just has function prototypes for device replace, however if you happen to include it in the wrong order you'll get compile errors because of different structures not being defined. Since these are just pointer args to functions we can declare them at the top in order to reduce the pain of using the header.

#20 lore raw

Re: [PATCH 06/15] btrfs: move static_assert() for btrfs_super_block into fs.c

In reply to Josef Bacik
Quoted 1 line · Josef Bacik

We shouldn't have static_assert()'s in header files in general,

Why? Since we have the _Static_assert support in all compilers we can do the header compile-time checks.

Quoted 14 lines

but
especially since btrfs_super_block isn't defined in ctree.h.

---
 fs/btrfs/ctree.h | 1 -
 fs/btrfs/fs.c    | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/ctree.h +0 -0
index a790c58b4c73..3cb4e0aca058 100644

fs/btrfs/ctree.h struct btrfs_ioctl_encoded_io_args; · line 61

Quoted 7 lines
fs/btrfs/ctree.h +2 -1
@@ -56,7 +56,6 @@ struct btrfs_ioctl_encoded_io_args;
 
 #define BTRFS_SUPER_INFO_OFFSET			SZ_64K
 #define BTRFS_SUPER_INFO_SIZE			4096
-static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE);
 
+
+static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE);

This can be dropped as the same assert is right after the super block definition and this is IMO the intended usage pattern. This catches any accidental changes to the structure.

#23 lore raw

Re: [PATCH 07/15] btrfs: move btrfs_swapfile_pin into volumes.h

In reply to Josef Bacik
Quoted 4 lines · Josef Bacik

This isn't a great spot for this, but one of the swapfile helper functions is in volumes.c, so move the struct to volumes.h. In the future when we have better separation of code there will be a more natural spot for this.

Some if the swapfile is in inode and it shares several callbacks for the inode ops so that's probably the right place but to move things out of ctree.h it can be in volumes.h as we don't have inode.h yet.

#48 lore raw
In reply to Josef Bacik
Quoted 12 lines · Josef Bacik

Part of the cleaning up of ctree.h is being able to move btrfs_fs_info out of it. This is actually pretty difficult because we essentially rely on ctree.h being included before everything else, so all other header files have fs_info defined for their helpers.

This series starts this work. There are a variety of other small moves as well, but the bulk is trying to pull any helpers that access fs_info members inside of their header files into their respective c files, or alternatively reworking the code to drop the dependency. Thanks,

Josef

Quoted 16 lines

Josef Bacik (15):
btrfs: move btrfs_caching_type to block-group.h
btrfs: move btrfs_full_stripe_locks_tree into block-group.h
btrfs: move btrfs_init_async_reclaim_work prototype to space-info.h
btrfs: move btrfs_pinned_by_swapfile prototype into volumes.h
btrfs: remove temporary btrfs_map_token declaration in ctree.h
btrfs: move static_assert() for btrfs_super_block into fs.c
btrfs: move btrfs_swapfile_pin into volumes.h
btrfs: move fs_info struct declarations to the top of ctree.h
btrfs: move btrfs_csum_ptr to inode.c
btrfs: move the fs_info related helpers closer to fs_info in ctree.h
btrfs: move btrfs_ordered_sum_size into file-item.c
btrfs: delete btrfs_inode_sectorsize helper
btrfs: delete btrfs_insert_inode_hash helper
btrfs: use a runtime flag to indicate an inode is a free space inode
btrfs: add struct declarations in dev-replace.h

All are safe changes, I've added it to misc-next, except the static_assert patch (6/15) that would need to be slightly changed.

#16 lore raw

Re: [PATCH 05/15] btrfs: remove temporary btrfs_map_token declaration in ctree.h

In reply to Josef Bacik
Quoted 13 lines · Josef Bacik

This was added while I was moving this code to its new home, it can be removed now.

---
 fs/btrfs/ctree.h | 2 --
 1 file changed, 2 deletions(-)
fs/btrfs/ctree.h +0 -0
index 36a473f05831..a790c58b4c73 100644

fs/btrfs/ctree.h struct btrfs_ref; · line 49

Quoted 4 lines
fs/btrfs/ctree.h +0 -1
@@ -46,8 +46,6 @@ struct btrfs_ref;
 struct btrfs_bio;
 struct btrfs_ioctl_encoded_io_args;
 
-struct btrfs_map_token;

This patch was not applied as this line is not in current misc-next and it probably depends on some other patchset.