* [PATCH v2 01/12] btrfs: move btrfs_crc32c_final into free-space-cache.c
2023-08-25 20:19 [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Josef Bacik
@ 2023-08-25 20:19 ` Josef Bacik
2023-08-25 20:19 ` [PATCH v2 02/12] btrfs: remove btrfs_crc32c wrapper Josef Bacik
` (12 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Josef Bacik @ 2023-08-25 20:19 UTC (permalink / raw)
To: linux-btrfs, kernel-team
This is the only place this helper is used, take it out of ctree.h and
move it into free-space-cache.c.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/ctree.h | 5 -----
fs/btrfs/free-space-cache.c | 5 +++++
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 9419f4e37a58..c80d9879d931 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -475,11 +475,6 @@ static inline u32 btrfs_crc32c(u32 crc, const void *address, unsigned length)
return crc32c(crc, address, length);
}
-static inline void btrfs_crc32c_final(u32 crc, u8 *result)
-{
- put_unaligned_le32(~crc, result);
-}
-
static inline u64 btrfs_name_hash(const char *name, int len)
{
return crc32c((u32)~1, name, len);
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 27fad70451aa..759b92db35d7 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -57,6 +57,11 @@ static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
struct btrfs_free_space *info, u64 offset,
u64 bytes, bool update_stats);
+static inline void btrfs_crc32c_final(u32 crc, u8 *result)
+{
+ put_unaligned_le32(~crc, result);
+}
+
static void __btrfs_remove_free_space_cache(struct btrfs_free_space_ctl *ctl)
{
struct btrfs_free_space *info;
--
2.41.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH v2 02/12] btrfs: remove btrfs_crc32c wrapper
2023-08-25 20:19 [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Josef Bacik
2023-08-25 20:19 ` [PATCH v2 01/12] btrfs: move btrfs_crc32c_final into free-space-cache.c Josef Bacik
@ 2023-08-25 20:19 ` Josef Bacik
2023-08-25 20:19 ` [PATCH v2 03/12] btrfs: move btrfs_extref_hash into inode-item.h Josef Bacik
` (11 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Josef Bacik @ 2023-08-25 20:19 UTC (permalink / raw)
To: linux-btrfs, kernel-team
This simply sends the same arguments into crc32c(), and is just used in
a few places. Remove this wrapper and directly call crc32c() in these
instances.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/ctree.h | 5 -----
fs/btrfs/extent-tree.c | 6 +++---
fs/btrfs/free-space-cache.c | 4 ++--
fs/btrfs/send.c | 6 +++---
4 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index c80d9879d931..bffee2ab5783 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -470,11 +470,6 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
#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);
-}
-
static inline u64 btrfs_name_hash(const char *name, int len)
{
return crc32c((u32)~1, name, len);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index f356f08b55cb..e4d337b78e76 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -399,11 +399,11 @@ u64 hash_extent_data_ref(u64 root_objectid, u64 owner, u64 offset)
__le64 lenum;
lenum = cpu_to_le64(root_objectid);
- high_crc = btrfs_crc32c(high_crc, &lenum, sizeof(lenum));
+ high_crc = crc32c(high_crc, &lenum, sizeof(lenum));
lenum = cpu_to_le64(owner);
- low_crc = btrfs_crc32c(low_crc, &lenum, sizeof(lenum));
+ low_crc = crc32c(low_crc, &lenum, sizeof(lenum));
lenum = cpu_to_le64(offset);
- low_crc = btrfs_crc32c(low_crc, &lenum, sizeof(lenum));
+ low_crc = crc32c(low_crc, &lenum, sizeof(lenum));
return ((u64)high_crc << 31) ^ (u64)low_crc;
}
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 759b92db35d7..dfeed8256c02 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -545,7 +545,7 @@ static void io_ctl_set_crc(struct btrfs_io_ctl *io_ctl, int index)
if (index == 0)
offset = sizeof(u32) * io_ctl->num_pages;
- crc = btrfs_crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset);
+ crc = crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset);
btrfs_crc32c_final(crc, (u8 *)&crc);
io_ctl_unmap_page(io_ctl);
tmp = page_address(io_ctl->pages[0]);
@@ -567,7 +567,7 @@ static int io_ctl_check_crc(struct btrfs_io_ctl *io_ctl, int index)
val = *tmp;
io_ctl_map_page(io_ctl, 0);
- crc = btrfs_crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset);
+ crc = crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset);
btrfs_crc32c_final(crc, (u8 *)&crc);
if (val != crc) {
btrfs_err_rl(io_ctl->fs_info,
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 3a566150c531..3b929f0e8f04 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -796,7 +796,7 @@ static int send_cmd(struct send_ctx *sctx)
put_unaligned_le32(sctx->send_size - sizeof(*hdr), &hdr->len);
put_unaligned_le32(0, &hdr->crc);
- crc = btrfs_crc32c(0, (unsigned char *)sctx->send_buf, sctx->send_size);
+ crc = crc32c(0, (unsigned char *)sctx->send_buf, sctx->send_size);
put_unaligned_le32(crc, &hdr->crc);
ret = write_buf(sctx->send_filp, sctx->send_buf, sctx->send_size,
@@ -5669,8 +5669,8 @@ static int send_encoded_extent(struct send_ctx *sctx, struct btrfs_path *path,
hdr = (struct btrfs_cmd_header *)sctx->send_buf;
hdr->len = cpu_to_le32(sctx->send_size + disk_num_bytes - sizeof(*hdr));
hdr->crc = 0;
- crc = btrfs_crc32c(0, sctx->send_buf, sctx->send_size);
- crc = btrfs_crc32c(crc, sctx->send_buf + data_offset, disk_num_bytes);
+ crc = crc32c(0, sctx->send_buf, sctx->send_size);
+ crc = crc32c(crc, sctx->send_buf + data_offset, disk_num_bytes);
hdr->crc = cpu_to_le32(crc);
ret = write_buf(sctx->send_filp, sctx->send_buf, sctx->send_size,
--
2.41.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH v2 03/12] btrfs: move btrfs_extref_hash into inode-item.h
2023-08-25 20:19 [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Josef Bacik
2023-08-25 20:19 ` [PATCH v2 01/12] btrfs: move btrfs_crc32c_final into free-space-cache.c Josef Bacik
2023-08-25 20:19 ` [PATCH v2 02/12] btrfs: remove btrfs_crc32c wrapper Josef Bacik
@ 2023-08-25 20:19 ` Josef Bacik
2023-08-25 20:19 ` [PATCH v2 04/12] btrfs: move btrfs_name_hash to dir-item.h Josef Bacik
` (10 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Josef Bacik @ 2023-08-25 20:19 UTC (permalink / raw)
To: linux-btrfs, kernel-team
Ideally this would be un-inlined, but that is a cleanup for later. For
now move this into inode-item.h, which is where the extref code lives.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/ctree.h | 9 ---------
fs/btrfs/inode-item.h | 9 +++++++++
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index bffee2ab5783..7b8e52fd6d99 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -475,15 +475,6 @@ static inline u64 btrfs_name_hash(const char *name, int len)
return crc32c((u32)~1, name, len);
}
-/*
- * Figure the key offset of an extended inode ref
- */
-static inline u64 btrfs_extref_hash(u64 parent_objectid, const char *name,
- int len)
-{
- return (u64) crc32c(parent_objectid, name, len);
-}
-
static inline gfp_t btrfs_alloc_write_mask(struct address_space *mapping)
{
return mapping_gfp_constraint(mapping, ~__GFP_FS);
diff --git a/fs/btrfs/inode-item.h b/fs/btrfs/inode-item.h
index ede43b6c6559..2ee425a08e63 100644
--- a/fs/btrfs/inode-item.h
+++ b/fs/btrfs/inode-item.h
@@ -107,4 +107,13 @@ struct btrfs_inode_extref *btrfs_find_name_in_ext_backref(
struct extent_buffer *leaf, int slot, u64 ref_objectid,
const struct fscrypt_str *name);
+/*
+ * Figure the key offset of an extended inode ref
+ */
+static inline u64 btrfs_extref_hash(u64 parent_objectid, const char *name,
+ int len)
+{
+ return (u64) crc32c(parent_objectid, name, len);
+}
+
#endif
--
2.41.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH v2 04/12] btrfs: move btrfs_name_hash to dir-item.h
2023-08-25 20:19 [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Josef Bacik
` (2 preceding siblings ...)
2023-08-25 20:19 ` [PATCH v2 03/12] btrfs: move btrfs_extref_hash into inode-item.h Josef Bacik
@ 2023-08-25 20:19 ` Josef Bacik
2023-08-25 20:19 ` [PATCH v2 05/12] btrfs: include asm/unaligned.h in accessors.h Josef Bacik
` (9 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Josef Bacik @ 2023-08-25 20:19 UTC (permalink / raw)
To: linux-btrfs, kernel-team
This is related to the name hashing for dir items, move it into
dir-item.h.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/ctree.h | 5 -----
fs/btrfs/dir-item.h | 5 +++++
fs/btrfs/props.c | 1 +
fs/btrfs/tree-checker.c | 1 +
4 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 7b8e52fd6d99..9c2e96b8711f 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -470,11 +470,6 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
#define BTRFS_BYTES_TO_BLKS(fs_info, bytes) \
((bytes) >> (fs_info)->sectorsize_bits)
-static inline u64 btrfs_name_hash(const char *name, int len)
-{
- return crc32c((u32)~1, name, len);
-}
-
static inline gfp_t btrfs_alloc_write_mask(struct address_space *mapping)
{
return mapping_gfp_constraint(mapping, ~__GFP_FS);
diff --git a/fs/btrfs/dir-item.h b/fs/btrfs/dir-item.h
index aab4b7cc7fa0..951b4dda46fe 100644
--- a/fs/btrfs/dir-item.h
+++ b/fs/btrfs/dir-item.h
@@ -39,4 +39,9 @@ struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_fs_info *fs_info,
const char *name,
int name_len);
+static inline u64 btrfs_name_hash(const char *name, int len)
+{
+ return crc32c((u32)~1, name, len);
+}
+
#endif
diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
index 0755af0e53e3..f9bf591a0718 100644
--- a/fs/btrfs/props.c
+++ b/fs/btrfs/props.c
@@ -15,6 +15,7 @@
#include "fs.h"
#include "accessors.h"
#include "super.h"
+#include "dir-item.h"
#define BTRFS_PROP_HANDLERS_HT_BITS 8
static DEFINE_HASHTABLE(prop_handlers_ht, BTRFS_PROP_HANDLERS_HT_BITS);
diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index ab08a0b01311..8ad92aa43924 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -29,6 +29,7 @@
#include "accessors.h"
#include "file-item.h"
#include "inode-item.h"
+#include "dir-item.h"
/*
* Error message should follow the following format:
--
2.41.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH v2 05/12] btrfs: include asm/unaligned.h in accessors.h
2023-08-25 20:19 [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Josef Bacik
` (3 preceding siblings ...)
2023-08-25 20:19 ` [PATCH v2 04/12] btrfs: move btrfs_name_hash to dir-item.h Josef Bacik
@ 2023-08-25 20:19 ` Josef Bacik
2023-08-25 20:19 ` [PATCH v2 06/12] btrfs: include linux/crc32c in dir-item and inode-item Josef Bacik
` (8 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Josef Bacik @ 2023-08-25 20:19 UTC (permalink / raw)
To: linux-btrfs, kernel-team
We use the unaligned helpers directly in accessors.h, add the include
here.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/accessors.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/btrfs/accessors.h b/fs/btrfs/accessors.h
index 8cfc8214109c..f958eccff477 100644
--- a/fs/btrfs/accessors.h
+++ b/fs/btrfs/accessors.h
@@ -4,6 +4,7 @@
#define BTRFS_ACCESSORS_H
#include <linux/stddef.h>
+#include <asm/unaligned.h>
struct btrfs_map_token {
struct extent_buffer *eb;
--
2.41.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH v2 06/12] btrfs: include linux/crc32c in dir-item and inode-item
2023-08-25 20:19 [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Josef Bacik
` (4 preceding siblings ...)
2023-08-25 20:19 ` [PATCH v2 05/12] btrfs: include asm/unaligned.h in accessors.h Josef Bacik
@ 2023-08-25 20:19 ` Josef Bacik
2023-08-25 20:19 ` [PATCH v2 07/12] btrfs: include linux/iomap.h in file.c Josef Bacik
` (7 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Josef Bacik @ 2023-08-25 20:19 UTC (permalink / raw)
To: linux-btrfs, kernel-team
Now these are holding the crc32c wrappers, add the required include so
that we have our necessary dependencies.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/dir-item.h | 2 ++
fs/btrfs/inode-item.h | 1 +
2 files changed, 3 insertions(+)
diff --git a/fs/btrfs/dir-item.h b/fs/btrfs/dir-item.h
index 951b4dda46fe..5db2ea0dfd76 100644
--- a/fs/btrfs/dir-item.h
+++ b/fs/btrfs/dir-item.h
@@ -3,6 +3,8 @@
#ifndef BTRFS_DIR_ITEM_H
#define BTRFS_DIR_ITEM_H
+#include <linux/crc32c.h>
+
int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir,
const struct fscrypt_str *name);
int btrfs_insert_dir_item(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/inode-item.h b/fs/btrfs/inode-item.h
index 2ee425a08e63..63dfd227e7ce 100644
--- a/fs/btrfs/inode-item.h
+++ b/fs/btrfs/inode-item.h
@@ -4,6 +4,7 @@
#define BTRFS_INODE_ITEM_H
#include <linux/types.h>
+#include <linux/crc32c.h>
struct btrfs_trans_handle;
struct btrfs_root;
--
2.41.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH v2 07/12] btrfs: include linux/iomap.h in file.c
2023-08-25 20:19 [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Josef Bacik
` (5 preceding siblings ...)
2023-08-25 20:19 ` [PATCH v2 06/12] btrfs: include linux/crc32c in dir-item and inode-item Josef Bacik
@ 2023-08-25 20:19 ` Josef Bacik
2023-08-25 20:19 ` [PATCH v2 08/12] btrfs: add fscrypt related dependencies to respective headers Josef Bacik
` (6 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Josef Bacik @ 2023-08-25 20:19 UTC (permalink / raw)
To: linux-btrfs, kernel-team
We use the iomap code in file.c, include it so we have our dependencies.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/file.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 6edad7b9a5d3..ee9621e622d0 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -17,6 +17,7 @@
#include <linux/uio.h>
#include <linux/iversion.h>
#include <linux/fsverity.h>
+#include <linux/iomap.h>
#include "ctree.h"
#include "disk-io.h"
#include "transaction.h"
--
2.41.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH v2 08/12] btrfs: add fscrypt related dependencies to respective headers
2023-08-25 20:19 [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Josef Bacik
` (6 preceding siblings ...)
2023-08-25 20:19 ` [PATCH v2 07/12] btrfs: include linux/iomap.h in file.c Josef Bacik
@ 2023-08-25 20:19 ` Josef Bacik
2023-08-25 20:19 ` [PATCH v2 09/12] btrfs: add btrfs_delayed_ref_head declaration to extent-tree.h Josef Bacik
` (5 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Josef Bacik @ 2023-08-25 20:19 UTC (permalink / raw)
To: linux-btrfs, kernel-team
These headers have struct fscrypt_str as function arguments, so add
struct fscrypt_str to the theader, and include linux/fscrypt.h in
btrfs_inode.h as it also needs the definition of struct fscrypt_name for
the new inode args.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/btrfs_inode.h | 1 +
fs/btrfs/dir-item.h | 2 ++
fs/btrfs/inode-item.h | 1 +
fs/btrfs/root-tree.h | 2 ++
4 files changed, 6 insertions(+)
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index bda1fdbba666..bca97a6bb246 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -8,6 +8,7 @@
#include <linux/hash.h>
#include <linux/refcount.h>
+#include <linux/fscrypt.h>
#include "extent_map.h"
#include "extent_io.h"
#include "ordered-data.h"
diff --git a/fs/btrfs/dir-item.h b/fs/btrfs/dir-item.h
index 5db2ea0dfd76..e40a226373d7 100644
--- a/fs/btrfs/dir-item.h
+++ b/fs/btrfs/dir-item.h
@@ -5,6 +5,8 @@
#include <linux/crc32c.h>
+struct fscrypt_str;
+
int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir,
const struct fscrypt_str *name);
int btrfs_insert_dir_item(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/inode-item.h b/fs/btrfs/inode-item.h
index 63dfd227e7ce..a4a142f1b5e3 100644
--- a/fs/btrfs/inode-item.h
+++ b/fs/btrfs/inode-item.h
@@ -13,6 +13,7 @@ struct btrfs_key;
struct btrfs_inode_extref;
struct btrfs_inode;
struct extent_buffer;
+struct fscrypt_str;
/*
* Return this if we need to call truncate_block for the last bit of the
diff --git a/fs/btrfs/root-tree.h b/fs/btrfs/root-tree.h
index cbbaca32126e..eb15768b9170 100644
--- a/fs/btrfs/root-tree.h
+++ b/fs/btrfs/root-tree.h
@@ -3,6 +3,8 @@
#ifndef BTRFS_ROOT_TREE_H
#define BTRFS_ROOT_TREE_H
+struct fscrypt_str;
+
int btrfs_subvolume_reserve_metadata(struct btrfs_root *root,
struct btrfs_block_rsv *rsv,
int nitems, bool use_global_rsv);
--
2.41.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH v2 09/12] btrfs: add btrfs_delayed_ref_head declaration to extent-tree.h
2023-08-25 20:19 [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Josef Bacik
` (7 preceding siblings ...)
2023-08-25 20:19 ` [PATCH v2 08/12] btrfs: add fscrypt related dependencies to respective headers Josef Bacik
@ 2023-08-25 20:19 ` Josef Bacik
2023-08-25 20:19 ` [PATCH v2 10/12] btrfs: include trace header in where necessary Josef Bacik
` (4 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Josef Bacik @ 2023-08-25 20:19 UTC (permalink / raw)
To: linux-btrfs, kernel-team
extent-tree.h uses btrfs_delayed_ref_head in a function argument but
doesn't pull it's declaration from anywhere, add it to the top of the
header.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/extent-tree.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/btrfs/extent-tree.h b/fs/btrfs/extent-tree.h
index 88c249c37516..ab2016db17e8 100644
--- a/fs/btrfs/extent-tree.h
+++ b/fs/btrfs/extent-tree.h
@@ -7,6 +7,7 @@
#include "block-group.h"
struct btrfs_free_cluster;
+struct btrfs_delayed_ref_head;
enum btrfs_extent_allocation_policy {
BTRFS_EXTENT_ALLOC_CLUSTERED,
--
2.41.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH v2 10/12] btrfs: include trace header in where necessary
2023-08-25 20:19 [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Josef Bacik
` (8 preceding siblings ...)
2023-08-25 20:19 ` [PATCH v2 09/12] btrfs: add btrfs_delayed_ref_head declaration to extent-tree.h Josef Bacik
@ 2023-08-25 20:19 ` Josef Bacik
2023-08-25 20:19 ` [PATCH v2 11/12] btrfs: include linux/security.h in super.c Josef Bacik
` (3 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Josef Bacik @ 2023-08-25 20:19 UTC (permalink / raw)
To: linux-btrfs, kernel-team
If we no longer include the tracepoints from ctree.h we fail to compile
because we have the dependency in some of the header files and source
files. Add the include where we have these dependencies to allow us to
remove the include from ctree.h.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/async-thread.c | 1 +
fs/btrfs/btrfs_inode.h | 1 +
fs/btrfs/locking.c | 1 +
fs/btrfs/space-info.h | 1 +
4 files changed, 4 insertions(+)
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index ce083e99ef68..714ca74b66bf 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -9,6 +9,7 @@
#include <linux/list.h>
#include <linux/spinlock.h>
#include <linux/freezer.h>
+#include <trace/events/btrfs.h>
#include "async-thread.h"
#include "ctree.h"
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index bca97a6bb246..b675dc09845d 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -9,6 +9,7 @@
#include <linux/hash.h>
#include <linux/refcount.h>
#include <linux/fscrypt.h>
+#include <trace/events/btrfs.h>
#include "extent_map.h"
#include "extent_io.h"
#include "ordered-data.h"
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c
index 7979449a58d6..79a125c0f4a2 100644
--- a/fs/btrfs/locking.c
+++ b/fs/btrfs/locking.c
@@ -8,6 +8,7 @@
#include <linux/spinlock.h>
#include <linux/page-flags.h>
#include <asm/bug.h>
+#include <trace/events/btrfs.h>
#include "misc.h"
#include "ctree.h"
#include "extent_io.h"
diff --git a/fs/btrfs/space-info.h b/fs/btrfs/space-info.h
index 0bb9d14e60a8..ac0ce83f1477 100644
--- a/fs/btrfs/space-info.h
+++ b/fs/btrfs/space-info.h
@@ -3,6 +3,7 @@
#ifndef BTRFS_SPACE_INFO_H
#define BTRFS_SPACE_INFO_H
+#include <trace/events/btrfs.h>
#include "volumes.h"
/*
--
2.41.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH v2 11/12] btrfs: include linux/security.h in super.c
2023-08-25 20:19 [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Josef Bacik
` (9 preceding siblings ...)
2023-08-25 20:19 ` [PATCH v2 10/12] btrfs: include trace header in where necessary Josef Bacik
@ 2023-08-25 20:19 ` Josef Bacik
2023-08-25 20:19 ` [PATCH v2 12/12] btrfs: remove extraneous includes from ctree.h Josef Bacik
` (2 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Josef Bacik @ 2023-08-25 20:19 UTC (permalink / raw)
To: linux-btrfs, kernel-team
We use some of the security related code in here, include it in super.c
so we can remove the include from ctree.h.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/super.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index cffdd6f7f8e8..0c215ca05c8a 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 <linux/security.h>
#include "messages.h"
#include "delayed-inode.h"
#include "ctree.h"
--
2.41.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH v2 12/12] btrfs: remove extraneous includes from ctree.h
2023-08-25 20:19 [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Josef Bacik
` (10 preceding siblings ...)
2023-08-25 20:19 ` [PATCH v2 11/12] btrfs: include linux/security.h in super.c Josef Bacik
@ 2023-08-25 20:19 ` Josef Bacik
2023-09-05 13:44 ` David Sterba
2023-08-28 16:25 ` [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Johannes Thumshirn
2023-09-05 14:38 ` David Sterba
13 siblings, 1 reply; 17+ messages in thread
From: Josef Bacik @ 2023-08-25 20:19 UTC (permalink / raw)
To: linux-btrfs, kernel-team
We don't need any of these includes in the ctree.h header file for the
header file itself, remove them to clean up ctree.h a little bit.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/ctree.h | 28 ----------------------------
1 file changed, 28 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 9c2e96b8711f..da9e07bf76ea 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -6,36 +6,8 @@
#ifndef BTRFS_CTREE_H
#define BTRFS_CTREE_H
-#include <linux/mm.h>
-#include <linux/sched/signal.h>
-#include <linux/highmem.h>
-#include <linux/fs.h>
-#include <linux/rwsem.h>
-#include <linux/semaphore.h>
-#include <linux/completion.h>
-#include <linux/backing-dev.h>
-#include <linux/wait.h>
-#include <linux/slab.h>
-#include <trace/events/btrfs.h>
-#include <asm/unaligned.h>
#include <linux/pagemap.h>
-#include <linux/btrfs.h>
-#include <linux/btrfs_tree.h>
-#include <linux/workqueue.h>
-#include <linux/security.h>
-#include <linux/sizes.h>
-#include <linux/dynamic_debug.h>
-#include <linux/refcount.h>
-#include <linux/crc32c.h>
-#include <linux/iomap.h>
-#include <linux/fscrypt.h>
-#include "extent-io-tree.h"
-#include "extent_io.h"
-#include "extent_map.h"
-#include "async-thread.h"
-#include "block-rsv.h"
#include "locking.h"
-#include "misc.h"
#include "fs.h"
struct btrfs_trans_handle;
--
2.41.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH v2 12/12] btrfs: remove extraneous includes from ctree.h
2023-08-25 20:19 ` [PATCH v2 12/12] btrfs: remove extraneous includes from ctree.h Josef Bacik
@ 2023-09-05 13:44 ` David Sterba
0 siblings, 0 replies; 17+ messages in thread
From: David Sterba @ 2023-09-05 13:44 UTC (permalink / raw)
To: Josef Bacik; +Cc: linux-btrfs, kernel-team
On Fri, Aug 25, 2023 at 04:19:30PM -0400, Josef Bacik wrote:
> We don't need any of these includes in the ctree.h header file for the
> header file itself, remove them to clean up ctree.h a little bit.
While the include reduction is nice, we still don't have the includes
for everything ctree.h uses, e.g. spinlock_t, mutex, pid_t, rb_tree and
maybe more. It's not critical as long as it compiles and we have the
includes entangled too much so incremental updates work better. The tool
include-what-you-use can print the recommendeations for adding and
removing includes but it can get confused by direct includes by command
line -include. I did a pass for btrfs-progs, desiable for kernel too.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 00/12] btrfs: ctree.[ch] cleanups
2023-08-25 20:19 [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Josef Bacik
` (11 preceding siblings ...)
2023-08-25 20:19 ` [PATCH v2 12/12] btrfs: remove extraneous includes from ctree.h Josef Bacik
@ 2023-08-28 16:25 ` Johannes Thumshirn
2023-09-05 13:45 ` David Sterba
2023-09-05 14:38 ` David Sterba
13 siblings, 1 reply; 17+ messages in thread
From: Johannes Thumshirn @ 2023-08-28 16:25 UTC (permalink / raw)
To: Josef Bacik, linux-btrfs@vger.kernel.org, kernel-team@fb.com
On 25.08.23 22:21, Josef Bacik wrote:
> v1->v2:
> - added "btrfs: include linux/security.h in super.c" to deal with a compile
> error after removing it from ctree.h in certain configs.
>
> --- Original email ---
> Hello,
>
> While refreshing my ctree sync patches for btrfs-progs I ran into some oddness
> around our crc32c related helpers that made the sync awkward. This moves those
> helpers around to other locations to make it easier to sync ctree.c into
> btrfs-progs.
>
> I also got a little distracted by the massive amount of includes we have in
> ctree.h, so I moved code around to trim this down to the bare minimum we need
> currently.
>
> There's no functional change here, just moving things about and renaming things.
> Thanks,
>
> Josef
>
I'd fold 6/12 into the patches moving the hash functions, but otherwise
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
for the series
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH v2 00/12] btrfs: ctree.[ch] cleanups
2023-08-28 16:25 ` [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Johannes Thumshirn
@ 2023-09-05 13:45 ` David Sterba
0 siblings, 0 replies; 17+ messages in thread
From: David Sterba @ 2023-09-05 13:45 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: Josef Bacik, linux-btrfs@vger.kernel.org, kernel-team@fb.com
On Mon, Aug 28, 2023 at 04:25:47PM +0000, Johannes Thumshirn wrote:
> On 25.08.23 22:21, Josef Bacik wrote:
> > v1->v2:
> > - added "btrfs: include linux/security.h in super.c" to deal with a compile
> > error after removing it from ctree.h in certain configs.
> >
> > --- Original email ---
> > Hello,
> >
> > While refreshing my ctree sync patches for btrfs-progs I ran into some oddness
> > around our crc32c related helpers that made the sync awkward. This moves those
> > helpers around to other locations to make it easier to sync ctree.c into
> > btrfs-progs.
> >
> > I also got a little distracted by the massive amount of includes we have in
> > ctree.h, so I moved code around to trim this down to the bare minimum we need
> > currently.
> >
> > There's no functional change here, just moving things about and renaming things.
> > Thanks,
> >
> > Josef
> >
>
> I'd fold 6/12 into the patches moving the hash functions, but otherwise
Agreed, updating includes as a collateral change is acceptable, though
in this series the point was to get the includes ready before the final
change to ctree.h. I'll fold the patch as you suggest, thanks.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 00/12] btrfs: ctree.[ch] cleanups
2023-08-25 20:19 [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Josef Bacik
` (12 preceding siblings ...)
2023-08-28 16:25 ` [PATCH v2 00/12] btrfs: ctree.[ch] cleanups Johannes Thumshirn
@ 2023-09-05 14:38 ` David Sterba
13 siblings, 0 replies; 17+ messages in thread
From: David Sterba @ 2023-09-05 14:38 UTC (permalink / raw)
To: Josef Bacik; +Cc: linux-btrfs, kernel-team
On Fri, Aug 25, 2023 at 04:19:18PM -0400, Josef Bacik wrote:
> v1->v2:
> - added "btrfs: include linux/security.h in super.c" to deal with a compile
> error after removing it from ctree.h in certain configs.
>
> --- Original email ---
> Hello,
>
> While refreshing my ctree sync patches for btrfs-progs I ran into some oddness
> around our crc32c related helpers that made the sync awkward. This moves those
> helpers around to other locations to make it easier to sync ctree.c into
> btrfs-progs.
>
> I also got a little distracted by the massive amount of includes we have in
> ctree.h, so I moved code around to trim this down to the bare minimum we need
> currently.
>
> There's no functional change here, just moving things about and renaming things.
> Thanks,
>
> Josef
>
>
> Josef Bacik (12):
> btrfs: move btrfs_crc32c_final into free-space-cache.c
> btrfs: remove btrfs_crc32c wrapper
> btrfs: move btrfs_extref_hash into inode-item.h
> btrfs: move btrfs_name_hash to dir-item.h
> btrfs: include asm/unaligned.h in accessors.h
> btrfs: include linux/crc32c in dir-item and inode-item
> btrfs: include linux/iomap.h in file.c
> btrfs: add fscrypt related dependencies to respective headers
> btrfs: add btrfs_delayed_ref_head declaration to extent-tree.h
> btrfs: include trace header in where necessary
> btrfs: include linux/security.h in super.c
> btrfs: remove extraneous includes from ctree.h
With patch 6 folded to 3 and 4 added to misc-next, thanks.
^ permalink raw reply [flat|nested] 17+ messages in thread