diff mbox series

[V2,10/23] metadump: Define metadump v2 ondisk format structures and macros

Message ID 20230606092806.1604491-11-chandan.babu@oracle.com (mailing list archive)
State Superseded, archived
Headers show
Series Metadump v2 | expand

Commit Message

Chandan Babu R June 6, 2023, 9:27 a.m. UTC
The corresponding metadump file's disk layout is as shown below,

     |------------------------------|
     | struct xfs_metadump_header   |
     |------------------------------|
     | struct xfs_meta_extent 0     |
     | Extent 0's data              |
     | struct xfs_meta_extent 1     |
     | Extent 1's data              |
     | ...                          |
     | struct xfs_meta_extent (n-1) |
     | Extent (n-1)'s data          |
     |------------------------------|

The "struct xfs_metadump_header" is followed by alternating series of "struct
xfs_meta_extent" and the extent itself.

Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
---
 include/xfs_metadump.h | 58 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

Comments

Darrick J. Wong July 12, 2023, 5:18 p.m. UTC | #1
On Tue, Jun 06, 2023 at 02:57:53PM +0530, Chandan Babu R wrote:
> The corresponding metadump file's disk layout is as shown below,
> 
>      |------------------------------|
>      | struct xfs_metadump_header   |
>      |------------------------------|
>      | struct xfs_meta_extent 0     |
>      | Extent 0's data              |
>      | struct xfs_meta_extent 1     |
>      | Extent 1's data              |
>      | ...                          |
>      | struct xfs_meta_extent (n-1) |
>      | Extent (n-1)'s data          |
>      |------------------------------|
> 
> The "struct xfs_metadump_header" is followed by alternating series of "struct
> xfs_meta_extent" and the extent itself.
> 
> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
> ---
>  include/xfs_metadump.h | 58 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 58 insertions(+)
> 
> diff --git a/include/xfs_metadump.h b/include/xfs_metadump.h
> index a4dca25c..518cb302 100644
> --- a/include/xfs_metadump.h
> +++ b/include/xfs_metadump.h
> @@ -8,7 +8,9 @@
>  #define _XFS_METADUMP_H_
>  
>  #define	XFS_MD_MAGIC_V1		0x5846534d	/* 'XFSM' */
> +#define	XFS_MD_MAGIC_V2		0x584D4432	/* 'XMD2' */
>  
> +/* Metadump v1 */
>  typedef struct xfs_metablock {
>  	__be32		mb_magic;
>  	__be16		mb_count;
> @@ -23,4 +25,60 @@ typedef struct xfs_metablock {
>  #define XFS_METADUMP_FULLBLOCKS	(1 << 2)
>  #define XFS_METADUMP_DIRTYLOG	(1 << 3)
>  
> +/*
> + * Metadump v2
> + *
> + * The following diagram depicts the ondisk layout of the metadump v2 format.
> + *
> + * |------------------------------|
> + * | struct xfs_metadump_header   |
> + * |------------------------------|
> + * | struct xfs_meta_extent 0     |
> + * | Extent 0's data              |
> + * | struct xfs_meta_extent 1     |
> + * | Extent 1's data              |
> + * | ...                          |
> + * | struct xfs_meta_extent (n-1) |
> + * | Extent (n-1)'s data          |
> + * |------------------------------|
> + *
> + * The "struct xfs_metadump_header" is followed by alternating series of "struct
> + * xfs_meta_extent" and the extent itself.
> + */
> +struct xfs_metadump_header {
> +	__be32		xmh_magic;
> +	__be32		xmh_version;
> +	__be32		xmh_compat_flags;
> +	__be32		xmh_incompat_flags;
> +	__be64		xmh_reserved;
> +} __packed;
> +
> +#define XFS_MD2_INCOMPAT_OBFUSCATED	(1 << 0)
> +#define XFS_MD2_INCOMPAT_FULLBLOCKS	(1 << 1)
> +#define XFS_MD2_INCOMPAT_DIRTYLOG	(1 << 2)
> +#define XFS_MD2_INCOMPAT_EXTERNALLOG	(1 << 3)

Please document the meaning of these four flags.

/*
 * User-supplied directory entry and extended attribute names have been
 * obscured, and extended attribute values are zeroed to protect privacy.
 */
#define XFS_MD2_INCOMPAT_OBFUSCATED	(1 << 0)

/* Full blocks have been dumped. */
#define XFS_MD2_INCOMPAT_FULLBLOCKS	(1 << 1)

/* Log was dirty. */
#define XFS_MD2_INCOMPAT_DIRTYLOG	(1 << 2)

/* Dump contains external log contents. */
#define XFS_MD2_INCOMPAT_EXTERNALLOG	(1 << 3)

Otherwise looks fine to me.

--D

> +
> +struct xfs_meta_extent {
> +	/*
> +	 * Lowest 54 bits are used to store 512 byte addresses.
> +	 * Next 2 bits is used for indicating the device.
> +	 * 00 - Data device
> +	 * 01 - External log
> +	 */
> +	__be64 xme_addr;
> +	/* In units of 512 byte blocks */
> +	__be32 xme_len;
> +} __packed;
> +
> +#define XME_ADDR_DEVICE_SHIFT	54
> +
> +#define XME_ADDR_DADDR_MASK	((1ULL << XME_ADDR_DEVICE_SHIFT) - 1)
> +
> +/* Extent was copied from the data device */
> +#define XME_ADDR_DATA_DEVICE	(0ULL << XME_ADDR_DEVICE_SHIFT)
> +/* Extent was copied from the log device */
> +#define XME_ADDR_LOG_DEVICE	(1ULL << XME_ADDR_DEVICE_SHIFT)
> +
> +#define XME_ADDR_DEVICE_MASK	(3ULL << XME_ADDR_DEVICE_SHIFT)
> +
>  #endif /* _XFS_METADUMP_H_ */
> -- 
> 2.39.1
>
Chandan Babu R July 13, 2023, 4:37 a.m. UTC | #2
On Wed, Jul 12, 2023 at 10:18:42 AM -0700, Darrick J. Wong wrote:
> On Tue, Jun 06, 2023 at 02:57:53PM +0530, Chandan Babu R wrote:
>> The corresponding metadump file's disk layout is as shown below,
>> 
>>      |------------------------------|
>>      | struct xfs_metadump_header   |
>>      |------------------------------|
>>      | struct xfs_meta_extent 0     |
>>      | Extent 0's data              |
>>      | struct xfs_meta_extent 1     |
>>      | Extent 1's data              |
>>      | ...                          |
>>      | struct xfs_meta_extent (n-1) |
>>      | Extent (n-1)'s data          |
>>      |------------------------------|
>> 
>> The "struct xfs_metadump_header" is followed by alternating series of "struct
>> xfs_meta_extent" and the extent itself.
>> 
>> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
>> ---
>>  include/xfs_metadump.h | 58 ++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 58 insertions(+)
>> 
>> diff --git a/include/xfs_metadump.h b/include/xfs_metadump.h
>> index a4dca25c..518cb302 100644
>> --- a/include/xfs_metadump.h
>> +++ b/include/xfs_metadump.h
>> @@ -8,7 +8,9 @@
>>  #define _XFS_METADUMP_H_
>>  
>>  #define	XFS_MD_MAGIC_V1		0x5846534d	/* 'XFSM' */
>> +#define	XFS_MD_MAGIC_V2		0x584D4432	/* 'XMD2' */
>>  
>> +/* Metadump v1 */
>>  typedef struct xfs_metablock {
>>  	__be32		mb_magic;
>>  	__be16		mb_count;
>> @@ -23,4 +25,60 @@ typedef struct xfs_metablock {
>>  #define XFS_METADUMP_FULLBLOCKS	(1 << 2)
>>  #define XFS_METADUMP_DIRTYLOG	(1 << 3)
>>  
>> +/*
>> + * Metadump v2
>> + *
>> + * The following diagram depicts the ondisk layout of the metadump v2 format.
>> + *
>> + * |------------------------------|
>> + * | struct xfs_metadump_header   |
>> + * |------------------------------|
>> + * | struct xfs_meta_extent 0     |
>> + * | Extent 0's data              |
>> + * | struct xfs_meta_extent 1     |
>> + * | Extent 1's data              |
>> + * | ...                          |
>> + * | struct xfs_meta_extent (n-1) |
>> + * | Extent (n-1)'s data          |
>> + * |------------------------------|
>> + *
>> + * The "struct xfs_metadump_header" is followed by alternating series of "struct
>> + * xfs_meta_extent" and the extent itself.
>> + */
>> +struct xfs_metadump_header {
>> +	__be32		xmh_magic;
>> +	__be32		xmh_version;
>> +	__be32		xmh_compat_flags;
>> +	__be32		xmh_incompat_flags;
>> +	__be64		xmh_reserved;
>> +} __packed;
>> +
>> +#define XFS_MD2_INCOMPAT_OBFUSCATED	(1 << 0)
>> +#define XFS_MD2_INCOMPAT_FULLBLOCKS	(1 << 1)
>> +#define XFS_MD2_INCOMPAT_DIRTYLOG	(1 << 2)
>> +#define XFS_MD2_INCOMPAT_EXTERNALLOG	(1 << 3)
>
> Please document the meaning of these four flags.
>
> /*
>  * User-supplied directory entry and extended attribute names have been
>  * obscured, and extended attribute values are zeroed to protect privacy.
>  */
> #define XFS_MD2_INCOMPAT_OBFUSCATED	(1 << 0)
>
> /* Full blocks have been dumped. */
> #define XFS_MD2_INCOMPAT_FULLBLOCKS	(1 << 1)
>
> /* Log was dirty. */
> #define XFS_MD2_INCOMPAT_DIRTYLOG	(1 << 2)
>
> /* Dump contains external log contents. */
> #define XFS_MD2_INCOMPAT_EXTERNALLOG	(1 << 3)
>
> Otherwise looks fine to me.
>

Sure. I will add the required comments.
diff mbox series

Patch

diff --git a/include/xfs_metadump.h b/include/xfs_metadump.h
index a4dca25c..518cb302 100644
--- a/include/xfs_metadump.h
+++ b/include/xfs_metadump.h
@@ -8,7 +8,9 @@ 
 #define _XFS_METADUMP_H_
 
 #define	XFS_MD_MAGIC_V1		0x5846534d	/* 'XFSM' */
+#define	XFS_MD_MAGIC_V2		0x584D4432	/* 'XMD2' */
 
+/* Metadump v1 */
 typedef struct xfs_metablock {
 	__be32		mb_magic;
 	__be16		mb_count;
@@ -23,4 +25,60 @@  typedef struct xfs_metablock {
 #define XFS_METADUMP_FULLBLOCKS	(1 << 2)
 #define XFS_METADUMP_DIRTYLOG	(1 << 3)
 
+/*
+ * Metadump v2
+ *
+ * The following diagram depicts the ondisk layout of the metadump v2 format.
+ *
+ * |------------------------------|
+ * | struct xfs_metadump_header   |
+ * |------------------------------|
+ * | struct xfs_meta_extent 0     |
+ * | Extent 0's data              |
+ * | struct xfs_meta_extent 1     |
+ * | Extent 1's data              |
+ * | ...                          |
+ * | struct xfs_meta_extent (n-1) |
+ * | Extent (n-1)'s data          |
+ * |------------------------------|
+ *
+ * The "struct xfs_metadump_header" is followed by alternating series of "struct
+ * xfs_meta_extent" and the extent itself.
+ */
+struct xfs_metadump_header {
+	__be32		xmh_magic;
+	__be32		xmh_version;
+	__be32		xmh_compat_flags;
+	__be32		xmh_incompat_flags;
+	__be64		xmh_reserved;
+} __packed;
+
+#define XFS_MD2_INCOMPAT_OBFUSCATED	(1 << 0)
+#define XFS_MD2_INCOMPAT_FULLBLOCKS	(1 << 1)
+#define XFS_MD2_INCOMPAT_DIRTYLOG	(1 << 2)
+#define XFS_MD2_INCOMPAT_EXTERNALLOG	(1 << 3)
+
+struct xfs_meta_extent {
+	/*
+	 * Lowest 54 bits are used to store 512 byte addresses.
+	 * Next 2 bits is used for indicating the device.
+	 * 00 - Data device
+	 * 01 - External log
+	 */
+	__be64 xme_addr;
+	/* In units of 512 byte blocks */
+	__be32 xme_len;
+} __packed;
+
+#define XME_ADDR_DEVICE_SHIFT	54
+
+#define XME_ADDR_DADDR_MASK	((1ULL << XME_ADDR_DEVICE_SHIFT) - 1)
+
+/* Extent was copied from the data device */
+#define XME_ADDR_DATA_DEVICE	(0ULL << XME_ADDR_DEVICE_SHIFT)
+/* Extent was copied from the log device */
+#define XME_ADDR_LOG_DEVICE	(1ULL << XME_ADDR_DEVICE_SHIFT)
+
+#define XME_ADDR_DEVICE_MASK	(3ULL << XME_ADDR_DEVICE_SHIFT)
+
 #endif /* _XFS_METADUMP_H_ */