diff mbox series

[v2,2/4] btrfs-progs: convert: struct blk_iterate_data, add ext2-specific file inode pointers

Message ID b84b93b5359341d710367b1f4e0fe9a7d528dd4f.1714963428.git.anand.jain@oracle.com (mailing list archive)
State New
Headers show
Series btrfs-progs: add support ext4 unwritten file extent | expand

Commit Message

Anand Jain May 6, 2024, 3:04 a.m. UTC
To obtain the file data extent flags, we require the use of ext2 helper
functions, pass these pointer in the 'struct blk_iterate_data'. However,
this struct is a common function across both 'reiserfs' and 'ext4'
filesystems. Since there is no further development on 'convert-reiserfs',
this patch avoids creating a mess which won't be used.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2: split struct blk_iterate_data  containing the source private.

 convert/source-ext2.c | 7 +++++++
 convert/source-ext2.h | 6 ++++++
 convert/source-fs.h   | 2 ++
 3 files changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/convert/source-ext2.c b/convert/source-ext2.c
index a3f61bb01171..477c39d9d658 100644
--- a/convert/source-ext2.c
+++ b/convert/source-ext2.c
@@ -320,10 +320,17 @@  static int ext2_create_file_extents(struct btrfs_trans_handle *trans,
 	u32 sectorsize = root->fs_info->sectorsize;
 	u64 inode_size = btrfs_stack_inode_size(btrfs_inode);
 	struct blk_iterate_data data;
+	struct ext2_source_fs  source_fs;
 
 	init_blk_iterate_data(&data, trans, root, btrfs_inode, objectid,
 			convert_flags & CONVERT_FLAG_DATACSUM);
 
+	source_fs.ext2_fs = ext2_fs;
+	source_fs.ext2_ino = ext2_ino;
+	source_fs.ext2_inode = ext2_inode;
+
+	data.source_fs = &source_fs;
+
 	err = ext2fs_block_iterate2(ext2_fs, ext2_ino, BLOCK_FLAG_DATA_ONLY,
 				    NULL, ext2_block_iterate_proc, &data);
 	if (err)
diff --git a/convert/source-ext2.h b/convert/source-ext2.h
index d204aac504e7..026a7cad8ac8 100644
--- a/convert/source-ext2.h
+++ b/convert/source-ext2.h
@@ -76,6 +76,12 @@  struct dir_iterate_data {
 	int errcode;
 };
 
+struct ext2_source_fs {
+	ext2_filsys ext2_fs;
+	struct ext2_inode *ext2_inode;
+	ext2_ino_t ext2_ino;
+};
+
 #define EXT2_ACL_VERSION	0x0001
 
 #endif	/* BTRFSCONVERT_EXT2 */
diff --git a/convert/source-fs.h b/convert/source-fs.h
index b26e1842941d..25916c65681b 100644
--- a/convert/source-fs.h
+++ b/convert/source-fs.h
@@ -118,6 +118,8 @@  struct btrfs_convert_operations {
 };
 
 struct blk_iterate_data {
+	void *source_fs;
+
 	struct btrfs_trans_handle *trans;
 	struct btrfs_root *root;
 	struct btrfs_root *convert_root;