diff mbox series

[04/13] btrfs-progs: convert: use cfg->leaf_data_size

Message ID c0abc5a5a87e6e8f22d225185a0fd23cafe0325e.1645568701.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: cleanup btrfs_item* accessors | expand

Commit Message

Josef Bacik Feb. 22, 2022, 10:26 p.m. UTC
The mkfs_config can hold the BTRFS_LEAF_DATA_SIZE, so calculate this at
config creation time and then use that value throughout convert instead
of calling __BTRFS_LEAF_DATA_SIZE.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 convert/common.c | 8 ++++----
 convert/main.c   | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

Comments

Nikolay Borisov March 9, 2022, 11:48 a.m. UTC | #1
On 23.02.22 г. 0:26 ч., Josef Bacik wrote:
> The mkfs_config can hold the BTRFS_LEAF_DATA_SIZE, so calculate this at
> config creation time and then use that value throughout convert instead
> of calling __BTRFS_LEAF_DATA_SIZE.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

nit: IMO this patch should be squashed into the patch 02.
David Sterba March 9, 2022, 2:18 p.m. UTC | #2
On Wed, Mar 09, 2022 at 01:48:08PM +0200, Nikolay Borisov wrote:
> 
> 
> On 23.02.22 г. 0:26 ч., Josef Bacik wrote:
> > The mkfs_config can hold the BTRFS_LEAF_DATA_SIZE, so calculate this at
> > config creation time and then use that value throughout convert instead
> > of calling __BTRFS_LEAF_DATA_SIZE.
> > 
> > Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> 
> nit: IMO this patch should be squashed into the patch 02.

I don't mind the patch granularity, both ways it's reviewable and clear.
diff mbox series

Patch

diff --git a/convert/common.c b/convert/common.c
index 00a7e553..356c2b4c 100644
--- a/convert/common.c
+++ b/convert/common.c
@@ -238,7 +238,7 @@  static int setup_temp_root_tree(int fd, struct btrfs_mkfs_config *cfg,
 				u64 dev_bytenr, u64 fs_bytenr, u64 csum_bytenr)
 {
 	struct extent_buffer *buf = NULL;
-	u32 itemoff = __BTRFS_LEAF_DATA_SIZE(cfg->nodesize);
+	u32 itemoff = cfg->leaf_data_size;
 	int slot = 0;
 	int ret;
 
@@ -419,7 +419,7 @@  static int setup_temp_chunk_tree(int fd, struct btrfs_mkfs_config *cfg,
 				 u64 chunk_bytenr)
 {
 	struct extent_buffer *buf = NULL;
-	u32 itemoff = __BTRFS_LEAF_DATA_SIZE(cfg->nodesize);
+	u32 itemoff = cfg->leaf_data_size;
 	int slot = 0;
 	int ret;
 
@@ -490,7 +490,7 @@  static int setup_temp_dev_tree(int fd, struct btrfs_mkfs_config *cfg,
 			       u64 dev_bytenr)
 {
 	struct extent_buffer *buf = NULL;
-	u32 itemoff = __BTRFS_LEAF_DATA_SIZE(cfg->nodesize);
+	u32 itemoff = cfg->leaf_data_size;
 	int slot = 0;
 	int ret;
 
@@ -688,7 +688,7 @@  static int setup_temp_extent_tree(int fd, struct btrfs_mkfs_config *cfg,
 				  u64 fs_bytenr, u64 csum_bytenr)
 {
 	struct extent_buffer *buf = NULL;
-	u32 itemoff = __BTRFS_LEAF_DATA_SIZE(cfg->nodesize);
+	u32 itemoff = cfg->leaf_data_size;
 	int slot = 0;
 	int ret;
 
diff --git a/convert/main.c b/convert/main.c
index 333d5be1..b72d1e51 100644
--- a/convert/main.c
+++ b/convert/main.c
@@ -1228,6 +1228,7 @@  static int do_convert(const char *devname, u32 convert_flags, u32 nodesize,
 	mkfs_cfg.sectorsize = blocksize;
 	mkfs_cfg.stripesize = blocksize;
 	mkfs_cfg.features = features;
+	mkfs_cfg.leaf_data_size = __BTRFS_LEAF_DATA_SIZE(nodesize);
 
 	printf("Create initial btrfs filesystem\n");
 	ret = make_convert_btrfs(fd, &mkfs_cfg, &cctx);