diff mbox series

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

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

Commit Message

Anand Jain May 3, 2024, 9:08 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>
---
 convert/source-ext2.c | 4 ++++
 convert/source-fs.h   | 5 +++++
 2 files changed, 9 insertions(+)

Comments

David Sterba May 3, 2024, 11:49 a.m. UTC | #1
On Fri, May 03, 2024 at 05:08:53PM +0800, Anand Jain wrote:
> 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.

Even though there will be no more reiserfs development you should not
clutter the generic API for filesystems with ext2-specific members.

> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  convert/source-ext2.c | 4 ++++
>  convert/source-fs.h   | 5 +++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/convert/source-ext2.c b/convert/source-ext2.c
> index a3f61bb01171..625387e95857 100644
> --- a/convert/source-ext2.c
> +++ b/convert/source-ext2.c
> @@ -324,6 +324,10 @@ static int ext2_create_file_extents(struct btrfs_trans_handle *trans,
>  	init_blk_iterate_data(&data, trans, root, btrfs_inode, objectid,
>  			convert_flags & CONVERT_FLAG_DATACSUM);
>  
> +	data.ext2_fs = ext2_fs;
> +	data.ext2_ino = ext2_ino;
> +	data.ext2_inode = ext2_inode;
> +
>  	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-fs.h b/convert/source-fs.h
> index b26e1842941d..0e71e79eddcc 100644
> --- a/convert/source-fs.h
> +++ b/convert/source-fs.h
> @@ -20,6 +20,7 @@
>  #include "kerncompat.h"
>  #include <sys/types.h>
>  #include <pthread.h>
> +#include <ext2fs/ext2fs.h>
>  #include "kernel-shared/uapi/btrfs_tree.h"
>  #include "convert/common.h"
>  
> @@ -118,6 +119,10 @@ struct btrfs_convert_operations {
>  };
>  
>  struct blk_iterate_data {
> +	ext2_filsys ext2_fs;
> +	struct ext2_inode *ext2_inode;
> +	ext2_ino_t ext2_ino;

This should be a void pointer filled by the target filesystem
implementation that fills it with anything it needs.

> +
>  	struct btrfs_trans_handle *trans;
>  	struct btrfs_root *root;
>  	struct btrfs_root *convert_root;
> -- 
> 2.39.3
>
Anand Jain May 3, 2024, 1:09 p.m. UTC | #2
On 5/3/24 19:49, David Sterba wrote:
> On Fri, May 03, 2024 at 05:08:53PM +0800, Anand Jain wrote:
>> 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.
> 
> Even though there will be no more reiserfs development you should not
> clutter the generic API for filesystems with ext2-specific members.
> 
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>   convert/source-ext2.c | 4 ++++
>>   convert/source-fs.h   | 5 +++++
>>   2 files changed, 9 insertions(+)
>>
>> diff --git a/convert/source-ext2.c b/convert/source-ext2.c
>> index a3f61bb01171..625387e95857 100644
>> --- a/convert/source-ext2.c
>> +++ b/convert/source-ext2.c
>> @@ -324,6 +324,10 @@ static int ext2_create_file_extents(struct btrfs_trans_handle *trans,
>>   	init_blk_iterate_data(&data, trans, root, btrfs_inode, objectid,
>>   			convert_flags & CONVERT_FLAG_DATACSUM);
>>   
>> +	data.ext2_fs = ext2_fs;
>> +	data.ext2_ino = ext2_ino;
>> +	data.ext2_inode = ext2_inode;
>> +
>>   	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-fs.h b/convert/source-fs.h
>> index b26e1842941d..0e71e79eddcc 100644
>> --- a/convert/source-fs.h
>> +++ b/convert/source-fs.h
>> @@ -20,6 +20,7 @@
>>   #include "kerncompat.h"
>>   #include <sys/types.h>
>>   #include <pthread.h>
>> +#include <ext2fs/ext2fs.h>
>>   #include "kernel-shared/uapi/btrfs_tree.h"
>>   #include "convert/common.h"
>>   
>> @@ -118,6 +119,10 @@ struct btrfs_convert_operations {
>>   };
>>   
>>   struct blk_iterate_data {
>> +	ext2_filsys ext2_fs;
>> +	struct ext2_inode *ext2_inode;
>> +	ext2_ino_t ext2_ino;
> 
> This should be a void pointer filled by the target filesystem
> implementation that fills it with anything it needs.
> 

Thanks for the suggestions.

I hope the following will be better.

struct blk_iterate_data {

+ void *source_fs_data;

::
}


struct ext2_source_fs_data {
	ext2_filsys ext2_fs;
	struct ext2_inode *ext2_inode;
	ext2_ino_t ext2_ino;
}

do malloc() and free() in ext2_create_file_extents().


Thx
Anand

>> +
>>   	struct btrfs_trans_handle *trans;
>>   	struct btrfs_root *root;
>>   	struct btrfs_root *convert_root;
>> -- 
>> 2.39.3
>>
diff mbox series

Patch

diff --git a/convert/source-ext2.c b/convert/source-ext2.c
index a3f61bb01171..625387e95857 100644
--- a/convert/source-ext2.c
+++ b/convert/source-ext2.c
@@ -324,6 +324,10 @@  static int ext2_create_file_extents(struct btrfs_trans_handle *trans,
 	init_blk_iterate_data(&data, trans, root, btrfs_inode, objectid,
 			convert_flags & CONVERT_FLAG_DATACSUM);
 
+	data.ext2_fs = ext2_fs;
+	data.ext2_ino = ext2_ino;
+	data.ext2_inode = ext2_inode;
+
 	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-fs.h b/convert/source-fs.h
index b26e1842941d..0e71e79eddcc 100644
--- a/convert/source-fs.h
+++ b/convert/source-fs.h
@@ -20,6 +20,7 @@ 
 #include "kerncompat.h"
 #include <sys/types.h>
 #include <pthread.h>
+#include <ext2fs/ext2fs.h>
 #include "kernel-shared/uapi/btrfs_tree.h"
 #include "convert/common.h"
 
@@ -118,6 +119,10 @@  struct btrfs_convert_operations {
 };
 
 struct blk_iterate_data {
+	ext2_filsys ext2_fs;
+	struct ext2_inode *ext2_inode;
+	ext2_ino_t ext2_ino;
+
 	struct btrfs_trans_handle *trans;
 	struct btrfs_root *root;
 	struct btrfs_root *convert_root;