All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 02/13] btrfs-progs: store LEAF_DATA_SIZE in the mkfs_config
Date: Tue, 22 Feb 2022 17:26:12 -0500	[thread overview]
Message-ID: <3dfc516330a61f54ec9dbc2b59ad38d96992e59a.1645568701.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1645568701.git.josef@toxicpanda.com>

We use __BTRFS_LEAF_DATA_SIZE() in a few places for mkfs.  With extent
tree v2 we'll be increasing the size of btrfs_header, so it'll be kind
of annoying to add flags to all callers of __BTRFS_LEAF_DATA_SIZE, so
simply calculate it once and put it in the mkfs_config and use that.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 mkfs/common.c | 9 ++++-----
 mkfs/common.h | 1 +
 mkfs/main.c   | 1 +
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/mkfs/common.c b/mkfs/common.c
index 9608d27f..aee4b9fb 100644
--- a/mkfs/common.c
+++ b/mkfs/common.c
@@ -93,7 +93,7 @@ static int btrfs_create_tree_root(int fd, struct btrfs_mkfs_config *cfg,
 
 	btrfs_set_disk_key_type(&disk_key, BTRFS_ROOT_ITEM_KEY);
 	btrfs_set_disk_key_offset(&disk_key, 0);
-	itemoff = __BTRFS_LEAF_DATA_SIZE(cfg->nodesize) - sizeof(root_item);
+	itemoff = cfg->leaf_data_size - sizeof(root_item);
 
 	for (i = 0; i < blocks_nr; i++) {
 		blk = blocks[i];
@@ -148,7 +148,7 @@ static int create_free_space_tree(int fd, struct btrfs_mkfs_config *cfg,
 {
 	struct btrfs_free_space_info *info;
 	struct btrfs_disk_key disk_key;
-	int itemoff = __BTRFS_LEAF_DATA_SIZE(cfg->nodesize);
+	int itemoff = cfg->leaf_data_size;
 	int nritems = 0;
 	int ret;
 
@@ -427,7 +427,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
 		cfg->nodesize - sizeof(struct btrfs_header));
 	nritems = 0;
 	item_size = sizeof(*dev_item);
-	itemoff = __BTRFS_LEAF_DATA_SIZE(cfg->nodesize) - item_size;
+	itemoff = cfg->leaf_data_size - item_size;
 
 	/* first device 1 (there is no device 0) */
 	btrfs_set_disk_key_objectid(&disk_key, BTRFS_DEV_ITEMS_OBJECTID);
@@ -515,8 +515,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) -
-		sizeof(struct btrfs_dev_extent);
+	itemoff = cfg->leaf_data_size - sizeof(struct btrfs_dev_extent);
 
 	btrfs_set_disk_key_objectid(&disk_key, 1);
 	btrfs_set_disk_key_offset(&disk_key, system_group_offset);
diff --git a/mkfs/common.h b/mkfs/common.h
index 66c9d9d0..428cd366 100644
--- a/mkfs/common.h
+++ b/mkfs/common.h
@@ -76,6 +76,7 @@ struct btrfs_mkfs_config {
 	u32 nodesize;
 	u32 sectorsize;
 	u32 stripesize;
+	u32 leaf_data_size;
 	/* Bitfield of incompat features, BTRFS_FEATURE_INCOMPAT_* */
 	u64 features;
 	/* Bitfield of BTRFS_RUNTIME_FEATURE_* */
diff --git a/mkfs/main.c b/mkfs/main.c
index f9e8be74..3dd06979 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -1413,6 +1413,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
 	mkfs_cfg.features = features;
 	mkfs_cfg.runtime_features = runtime_features;
 	mkfs_cfg.csum_type = csum_type;
+	mkfs_cfg.leaf_data_size = __BTRFS_LEAF_DATA_SIZE(nodesize);
 	if (zoned)
 		mkfs_cfg.zone_size = zone_size(file);
 	else
-- 
2.26.3


  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 ` Josef Bacik [this message]
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 ` [PATCH 05/13] btrfs-progs: reduce usage of __BTRFS_LEAF_DATA_SIZE Josef Bacik
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=3dfc516330a61f54ec9dbc2b59ad38d96992e59a.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.