diff mbox series

[08/24] metadump: Introduce struct metadump_ops

Message ID 20230523090050.373545-9-chandan.babu@oracle.com (mailing list archive)
State Superseded
Headers show
Series Metadump v2 | expand

Commit Message

Chandan Babu R May 23, 2023, 9 a.m. UTC
We will need two sets of functions to implement two versions of metadump. This
commit adds the definition for 'struct metadump_ops' to hold pointers to
version specific metadump functions.

Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
---
 db/metadump.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Darrick J. Wong May 23, 2023, 5:15 p.m. UTC | #1
On Tue, May 23, 2023 at 02:30:34PM +0530, Chandan Babu R wrote:
> We will need two sets of functions to implement two versions of metadump. This
> commit adds the definition for 'struct metadump_ops' to hold pointers to
> version specific metadump functions.
> 
> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
> ---
>  db/metadump.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/db/metadump.c b/db/metadump.c
> index 212b484a2..56d8c3bdf 100644
> --- a/db/metadump.c
> +++ b/db/metadump.c
> @@ -40,6 +40,14 @@ static const cmdinfo_t	metadump_cmd =
>  		N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] filename"),
>  		N_("dump metadata to a file"), metadump_help };
>  
> +struct metadump_ops {
> +	int (*init_metadump)(void);
> +	int (*write_metadump)(enum typnm type, char *data, int64_t off,
> +		int len);
> +	int (*end_write_metadump)(void);
> +	void (*release_metadump)(void);

Needs comments describing what each of these do.  Does each
->write_metadump have to have a ->end_write_metadump?

You could probably remove the _metadump suffix too.

--D

> +};
> +
>  static struct metadump {
>  	int			version;
>  	int			show_progress;
> @@ -54,6 +62,7 @@ static struct metadump {
>  	xfs_ino_t		cur_ino;
>  	/* Metadump file */
>  	FILE			*outf;
> +	struct metadump_ops	*mdops;
>  	/* header + index + buffers */
>  	struct xfs_metablock	*metablock;
>  	__be64			*block_index;
> -- 
> 2.39.1
>
Chandan Babu R May 25, 2023, 8:48 a.m. UTC | #2
On Tue, May 23, 2023 at 10:15:25 AM -0700, Darrick J. Wong wrote:
> On Tue, May 23, 2023 at 02:30:34PM +0530, Chandan Babu R wrote:
>> We will need two sets of functions to implement two versions of metadump. This
>> commit adds the definition for 'struct metadump_ops' to hold pointers to
>> version specific metadump functions.
>> 
>> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
>> ---
>>  db/metadump.c | 9 +++++++++
>>  1 file changed, 9 insertions(+)
>> 
>> diff --git a/db/metadump.c b/db/metadump.c
>> index 212b484a2..56d8c3bdf 100644
>> --- a/db/metadump.c
>> +++ b/db/metadump.c
>> @@ -40,6 +40,14 @@ static const cmdinfo_t	metadump_cmd =
>>  		N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] filename"),
>>  		N_("dump metadata to a file"), metadump_help };
>>  
>> +struct metadump_ops {
>> +	int (*init_metadump)(void);
>> +	int (*write_metadump)(enum typnm type, char *data, int64_t off,
>> +		int len);
>> +	int (*end_write_metadump)(void);
>> +	void (*release_metadump)(void);
>
> Needs comments describing what each of these do.

Sure. I will add the comments to describe each function pointer.

> Does each ->write_metadump have to have a ->end_write_metadump?

No. The v1 format code collects metadata blocks in memory and writes them to
the disk after sufficient number of blocks have been collected. We might not
have reached this limit for the final set of 512 byte metadata blocks. Hence,
a write operation has to be explicitly issued for such metadata blocks.

>
> You could probably remove the _metadump suffix too.

Yes, I will remove them.
diff mbox series

Patch

diff --git a/db/metadump.c b/db/metadump.c
index 212b484a2..56d8c3bdf 100644
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -40,6 +40,14 @@  static const cmdinfo_t	metadump_cmd =
 		N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] filename"),
 		N_("dump metadata to a file"), metadump_help };
 
+struct metadump_ops {
+	int (*init_metadump)(void);
+	int (*write_metadump)(enum typnm type, char *data, int64_t off,
+		int len);
+	int (*end_write_metadump)(void);
+	void (*release_metadump)(void);
+};
+
 static struct metadump {
 	int			version;
 	int			show_progress;
@@ -54,6 +62,7 @@  static struct metadump {
 	xfs_ino_t		cur_ino;
 	/* Metadump file */
 	FILE			*outf;
+	struct metadump_ops	*mdops;
 	/* header + index + buffers */
 	struct xfs_metablock	*metablock;
 	__be64			*block_index;