From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 05/13] btrfs-progs: reduce usage of __BTRFS_LEAF_DATA_SIZE
Date: Tue, 22 Feb 2022 17:26:15 -0500 [thread overview]
Message-ID: <dc71da10bbb0a0cfd5cb3da856e69014e362dfa0.1645568701.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1645568701.git.josef@toxicpanda.com>
This helper only takes the nodesize, but in the future it'll take a bool
to indicate if we're extent tree v2. The remaining users are all where
we only have extent_buffer, but we should always have a valid
eb->fs_info in these cases, so add BUG_ON()'s for the !eb->fs_info case
and then convert these callers to use BTRFS_LEAF_DATA_SIZE which takes
the fs_info.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
kernel-shared/ctree.c | 5 +++--
kernel-shared/ctree.h | 5 +++--
kernel-shared/print-tree.c | 2 +-
mkfs/common.c | 2 +-
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c
index 950923d0..10b22b2c 100644
--- a/kernel-shared/ctree.c
+++ b/kernel-shared/ctree.c
@@ -1949,8 +1949,9 @@ int btrfs_leaf_free_space(struct extent_buffer *leaf)
u32 leaf_data_size;
int ret;
- BUG_ON(leaf->fs_info && leaf->fs_info->nodesize != leaf->len);
- leaf_data_size = __BTRFS_LEAF_DATA_SIZE(leaf->len);
+ BUG_ON(!leaf->fs_info);
+ BUG_ON(leaf->fs_info->nodesize != leaf->len);
+ leaf_data_size = BTRFS_LEAF_DATA_SIZE(leaf->fs_info);
ret = leaf_data_size - leaf_space_used(leaf, 0 ,nritems);
if (ret < 0) {
printk("leaf free space ret %d, leaf data size %u, used %d nritems %d\n",
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index 31169f33..d9677bce 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -1328,8 +1328,9 @@ static inline u32 BTRFS_NODEPTRS_PER_BLOCK(const struct btrfs_fs_info *info)
static inline u32 BTRFS_NODEPTRS_PER_EXTENT_BUFFER(const struct extent_buffer *eb)
{
- BUG_ON(eb->fs_info && eb->fs_info->nodesize != eb->len);
- return __BTRFS_LEAF_DATA_SIZE(eb->len) / sizeof(struct btrfs_key_ptr);
+ BUG_ON(!eb->fs_info);
+ BUG_ON(eb->fs_info->nodesize != eb->len);
+ return BTRFS_LEAF_DATA_SIZE(eb->fs_info) / sizeof(struct btrfs_key_ptr);
}
#define BTRFS_FILE_EXTENT_INLINE_DATA_START \
diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
index bd75ae51..7308599f 100644
--- a/kernel-shared/print-tree.c
+++ b/kernel-shared/print-tree.c
@@ -1288,7 +1288,7 @@ void btrfs_print_leaf(struct extent_buffer *eb, unsigned int mode)
{
struct btrfs_item *item;
struct btrfs_disk_key disk_key;
- u32 leaf_data_size = __BTRFS_LEAF_DATA_SIZE(eb->len);
+ u32 leaf_data_size = BTRFS_LEAF_DATA_SIZE(eb->fs_info);
u32 i;
u32 nr;
const bool print_csum_items = (mode & BTRFS_PRINT_TREE_CSUM_ITEMS);
diff --git a/mkfs/common.c b/mkfs/common.c
index aee4b9fb..f3e689cb 100644
--- a/mkfs/common.c
+++ b/mkfs/common.c
@@ -326,7 +326,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
memset(buf->data + sizeof(struct btrfs_header), 0,
cfg->nodesize - sizeof(struct btrfs_header));
nritems = 0;
- itemoff = __BTRFS_LEAF_DATA_SIZE(cfg->nodesize);
+ itemoff = cfg->leaf_data_size;
for (i = 0; i < blocks_nr; i++) {
blk = blocks[i];
--
2.26.3
next prev parent reply other threads:[~2022-02-22 22:26 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-22 22:26 [PATCH 00/13] btrfs-progs: cleanup btrfs_item* accessors Josef Bacik
2022-02-22 22:26 ` [PATCH 01/13] btrfs-progs: turn on more compiler warnings and use -Wall Josef Bacik
2022-03-08 16:51 ` David Sterba
2022-03-08 18:15 ` David Sterba
2022-03-08 18:26 ` David Sterba
2022-02-22 22:26 ` [PATCH 02/13] btrfs-progs: store LEAF_DATA_SIZE in the mkfs_config Josef Bacik
2022-02-22 22:26 ` [PATCH 03/13] btrfs-progs: store BTRFS_LEAF_DATA_SIZE in the fs_info Josef Bacik
2022-02-22 22:26 ` [PATCH 04/13] btrfs-progs: convert: use cfg->leaf_data_size Josef Bacik
2022-03-09 11:48 ` Nikolay Borisov
2022-03-09 14:18 ` David Sterba
2022-02-22 22:26 ` Josef Bacik [this message]
2022-02-22 22:26 ` [PATCH 06/13] btrfs-progs: btrfs_item_size_nr/btrfs_item_offset_nr everywhere Josef Bacik
2022-03-09 11:45 ` Nikolay Borisov
2022-03-09 12:27 ` Nikolay Borisov
2022-02-22 22:26 ` [PATCH 07/13] btrfs-progs: add btrfs_set_item_*_nr() helpers Josef Bacik
2022-02-22 22:26 ` [PATCH 08/13] btrfs-progs: change btrfs_file_extent_inline_item_len to take a slot Josef Bacik
2022-02-22 22:26 ` [PATCH 09/13] btrfs-progs: rename btrfs_item_end_nr to btrfs_item_end Josef Bacik
2022-02-22 22:26 ` [PATCH 10/13] btrfs-progs: remove the _nr from the item helpers Josef Bacik
2022-02-22 22:26 ` [PATCH 11/13] btrfs-progs: replace btrfs_item_nr_offset(0) Josef Bacik
2022-03-09 12:42 ` Nikolay Borisov
2022-02-22 22:26 ` [PATCH 12/13] btrfs-progs: rework the btrfs_node accessors to match the item accessors Josef Bacik
2022-02-22 22:26 ` [PATCH 13/13] btrfs-progs: make all of the item/key_ptr offset helpers take an eb Josef Bacik
2022-03-09 12:46 ` [PATCH 00/13] btrfs-progs: cleanup btrfs_item* accessors Nikolay Borisov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dc71da10bbb0a0cfd5cb3da856e69014e362dfa0.1645568701.git.josef@toxicpanda.com \
--to=josef@toxicpanda.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox