Patchwork [4/9] block: vhdx - log support struct and defines

login
register
mail settings
Submitter Jeff Cody
Date July 24, 2013, 5:54 p.m.
Message ID <803cc31a021f57b4310f133ea5b03e2af7ef7f04.1374687002.git.jcody@redhat.com>
Download mbox | patch
Permalink /patch/261482/
State New
Headers show

Comments

Jeff Cody - July 24, 2013, 5:54 p.m.
This adds some magic number defines, and internal structure
definitions for VHDX log replay support.

Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 block/vhdx.h | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
Fam Zheng - July 30, 2013, 3:15 a.m.
On Wed, 07/24 13:54, Jeff Cody wrote:
> This adds some magic number defines, and internal structure
> definitions for VHDX log replay support.
> 
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
>  block/vhdx.h | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/block/vhdx.h b/block/vhdx.h
> index c8d8593..2db6615 100644
> --- a/block/vhdx.h
> +++ b/block/vhdx.h
> @@ -151,7 +151,10 @@ typedef struct QEMU_PACKED VHDXRegionTableEntry {
>  
>  
>  /* ---- LOG ENTRY STRUCTURES ---- */
> +#define VHDX_LOG_MIN_SIZE (1024*1024)
> +#define VHDX_LOG_SECTOR_SIZE 4096
>  #define VHDX_LOG_HDR_SIZE 64
> +#define VHDX_LOG_SIGNATURE 0x65676f6c
>  typedef struct QEMU_PACKED VHDXLogEntryHeader {
>      uint32_t    signature;              /* "loge" in ASCII */
>      uint32_t    checksum;               /* CRC-32C hash of the 64KB table */
> @@ -174,7 +177,8 @@ typedef struct QEMU_PACKED VHDXLogEntryHeader {
>  } VHDXLogEntryHeader;
>  
>  #define VHDX_LOG_DESC_SIZE 32
> -
> +#define VHDX_LOG_DESC_SIGNATURE 0x63736564
> +#define VHDX_LOG_ZERO_SIGNATURE 0x6f72657a

Are these macros really used? I see "desc" and "zero" used to compare
signatures.

Thanks

Fam
Jeff Cody - July 30, 2013, 1:42 p.m.
On Tue, Jul 30, 2013 at 11:15:02AM +0800, Fam Zheng wrote:
> On Wed, 07/24 13:54, Jeff Cody wrote:
> > This adds some magic number defines, and internal structure
> > definitions for VHDX log replay support.
> > 
> > Signed-off-by: Jeff Cody <jcody@redhat.com>
> > ---
> >  block/vhdx.h | 21 ++++++++++++++++++++-
> >  1 file changed, 20 insertions(+), 1 deletion(-)
> > 
> > diff --git a/block/vhdx.h b/block/vhdx.h
> > index c8d8593..2db6615 100644
> > --- a/block/vhdx.h
> > +++ b/block/vhdx.h
> > @@ -151,7 +151,10 @@ typedef struct QEMU_PACKED VHDXRegionTableEntry {
> >  
> >  
> >  /* ---- LOG ENTRY STRUCTURES ---- */
> > +#define VHDX_LOG_MIN_SIZE (1024*1024)
> > +#define VHDX_LOG_SECTOR_SIZE 4096
> >  #define VHDX_LOG_HDR_SIZE 64
> > +#define VHDX_LOG_SIGNATURE 0x65676f6c
> >  typedef struct QEMU_PACKED VHDXLogEntryHeader {
> >      uint32_t    signature;              /* "loge" in ASCII */
> >      uint32_t    checksum;               /* CRC-32C hash of the 64KB table */
> > @@ -174,7 +177,8 @@ typedef struct QEMU_PACKED VHDXLogEntryHeader {
> >  } VHDXLogEntryHeader;
> >  
> >  #define VHDX_LOG_DESC_SIZE 32
> > -
> > +#define VHDX_LOG_DESC_SIGNATURE 0x63736564
> > +#define VHDX_LOG_ZERO_SIGNATURE 0x6f72657a
> 
> Are these macros really used? I see "desc" and "zero" used to compare
> signatures.
>

They are used in the log write patch (when creating new log sectors).
Right now, we only create data sectors (nothing uses the zero sectors
yet), so only the _DESC_SIGNATURE is used.

Thanks,
Jeff

Patch

diff --git a/block/vhdx.h b/block/vhdx.h
index c8d8593..2db6615 100644
--- a/block/vhdx.h
+++ b/block/vhdx.h
@@ -151,7 +151,10 @@  typedef struct QEMU_PACKED VHDXRegionTableEntry {
 
 
 /* ---- LOG ENTRY STRUCTURES ---- */
+#define VHDX_LOG_MIN_SIZE (1024*1024)
+#define VHDX_LOG_SECTOR_SIZE 4096
 #define VHDX_LOG_HDR_SIZE 64
+#define VHDX_LOG_SIGNATURE 0x65676f6c
 typedef struct QEMU_PACKED VHDXLogEntryHeader {
     uint32_t    signature;              /* "loge" in ASCII */
     uint32_t    checksum;               /* CRC-32C hash of the 64KB table */
@@ -174,7 +177,8 @@  typedef struct QEMU_PACKED VHDXLogEntryHeader {
 } VHDXLogEntryHeader;
 
 #define VHDX_LOG_DESC_SIZE 32
-
+#define VHDX_LOG_DESC_SIGNATURE 0x63736564
+#define VHDX_LOG_ZERO_SIGNATURE 0x6f72657a
 typedef struct QEMU_PACKED VHDXLogDescriptor {
     uint32_t    signature;              /* "zero" or "desc" in ASCII */
     union  {
@@ -194,6 +198,7 @@  typedef struct QEMU_PACKED VHDXLogDescriptor {
                                            vhdx_log_entry_header */
 } VHDXLogDescriptor;
 
+#define VHDX_LOG_DATA_SIGNATURE 0x61746164
 typedef struct QEMU_PACKED VHDXLogDataSector {
     uint32_t    data_signature;         /* "data" in ASCII */
     uint32_t    sequence_high;          /* 4 MSB of 8 byte sequence_number */
@@ -318,6 +323,18 @@  typedef struct VHDXMetadataEntries {
     uint16_t present;
 } VHDXMetadataEntries;
 
+typedef struct VHDXLogEntries {
+    uint64_t offset;
+    uint64_t length;
+    uint32_t head;
+    uint32_t tail;
+} VHDXLogEntries;
+
+typedef struct VHDXLogEntryInfo {
+    uint64_t sector_start;
+    uint32_t desc_count;
+} VHDXLogEntryInfo;
+
 typedef struct BDRVVHDXState {
     CoMutex lock;
 
@@ -351,6 +368,8 @@  typedef struct BDRVVHDXState {
 
     MSGUID session_guid;
 
+    VHDXLogEntries log;
+
     VHDXParentLocatorHeader parent_header;
     VHDXParentLocatorEntry *parent_entries;