[Sheepdog] [PATCH] sheepdog: implement SD_OP_FLUSH_VDI operation

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Sun Mar 25 22:53:54 CEST 2012


At Sat, 24 Mar 2012 16:49:35 +0800,
Liu Yuan wrote:
> 
> From: Liu Yuan <tailai.ly at taobao.com>
> 
> With this operation added, Guest can assure the data of
> reaching the sheepdog cluster storage by sending flush request.
> 
> Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
> ---
> Hi Kazum,
> 
> After your review, I'll send it to qemu community.
> 
>  block/sheepdog.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 44 insertions(+), 0 deletions(-)
> 
> diff --git a/block/sheepdog.c b/block/sheepdog.c
> index 00276f6f..04607c6 100644
> --- a/block/sheepdog.c
> +++ b/block/sheepdog.c
> @@ -32,9 +32,11 @@
>  #define SD_OP_RELEASE_VDI    0x13
>  #define SD_OP_GET_VDI_INFO   0x14
>  #define SD_OP_READ_VDIS      0x15
> +#define SD_OP_FLUSH_VDI      0x16
>  
>  #define SD_FLAG_CMD_WRITE    0x01
>  #define SD_FLAG_CMD_COW      0x02
> +#define SD_FLAG_CMD_CACHE    0x04
>  
>  #define SD_RES_SUCCESS       0x00 /* Success */
>  #define SD_RES_UNKNOWN       0x01 /* Unknown error */
> @@ -179,6 +181,8 @@ typedef struct SheepdogInode {
>      uint32_t data_vdi_id[MAX_DATA_OBJS];
>  } SheepdogInode;
>  
> +static int cache_enabled;
> +
>  /*
>   * 64 bit FNV-1a non-zero initial basis
>   */
> @@ -900,6 +904,9 @@ static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,
>          hdr.flags = SD_FLAG_CMD_WRITE | flags;
>      }
>  
> +    if (cache_enabled)
> +        hdr.flags |= SD_FLAG_CMD_CACHE;
> +

QEMU coding style uses {} even for one-line if statement bodies.  Try
qemu/scripts/checkpatch.

And we also need to set SD_FLAG_CMD_CACHE in read_write_object().


>      hdr.oid = oid;
>      hdr.cow_oid = old_oid;
>      hdr.copies = s->inode.nr_copies;
> @@ -1046,6 +1053,10 @@ static int sd_open(BlockDriverState *bs, const char *filename, int flags)
>          goto out;
>      }
>  
> +    if (flags & BDRV_O_CACHE_WB)
> +        if (!(flags & BDRV_O_NOCACHE))
> +            cache_enabled = 1;
> +

This must be set before reading a VDI object.

Thanks,

Kazutaka



More information about the sheepdog mailing list