make use of copy_policy
This patch set makes use of copy_policy in struct SheepdogInode in order to support recently introduced erasure coding in sheepdog.
Thanks
Yuan
PATCH 1/2 sheepdog: explicitly set copies as type uint8_t
'copies' is actually uint8_t since day one, but request headers and some helper functions parameterize it as uint32_t for unknown reasons and effectively reserve 24 bytes for possible future use. This patch explicitly set the correct for copies and reserve the left bytes.
This is a preparation patch that allow passing copy_policy in request header.
--- block/sheepdog.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
block/sheepdog.c +9 -6
@@ -125,7 +125,8 @@ typedef struct SheepdogObjReq {uint32_t data_length;uint64_t oid;uint64_t cow_oid; -uint32_t copies; +uint8_t copies; +uint8_t reserved[3 ];uint32_t rsvd;uint64_t offset; } SheepdogObjReq;
@@ -138,7 +139,8 @@ typedef struct SheepdogObjRsp {uint32_t id;uint32_t data_length;uint32_t result; -uint32_t copies; +uint8_t copies; +uint8_t reserved[3 ];uint32_t pad[6 ]; } SheepdogObjRsp;
@@ -151,7 +153,8 @@ typedef struct SheepdogVdiReq {uint32_t data_length;uint64_t vdi_size;uint32_t vdi_id; -uint32_t copies; +uint8_t copies; +uint8_t reserved[3 ];uint32_t snapid;uint32_t pad[3 ]; } SheepdogVdiReq;
@@ -1081,7 +1084,7 @@ static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,return 0 ; } -static int read_write_object (int fd,char *buf,uint64_t oid,int copies, +static int read_write_object (int fd,char *buf,uint64_t oid,uint8_t copies,unsigned int datalen,uint64_t offset,bool write,bool create,uint32_t cache_flags) {
@@ -1129,7 +1132,7 @@ static int read_write_object(int fd, char *buf, uint64_t oid, int copies, } } -static int read_object (int fd,char *buf,uint64_t oid,int copies, +static int read_object (int fd,char *buf,uint64_t oid,uint8_t copies,unsigned int datalen,uint64_t offset,uint32_t cache_flags) {
@@ -1137,7 +1140,7 @@ static int read_object(int fd, char *buf, uint64_t oid, int copies, false, cache_flags); } -static int write_object (int fd,char *buf,uint64_t oid,int copies, +static int write_object (int fd,char *buf,uint64_t oid,uint8_t copies,unsigned int datalen,uint64_t offset,bool create,uint32_t cache_flags) {
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [sheepdog] [PATCH 1/2] sheepdog: explicitly set copies as type uint8_t
At Wed, 16 Oct 2013 15:38:37 +0800,
Quoted 20 lines · Liu Yuan
'copies' is actually
uint8_tsince day one, but request headers and some helper functions parameterize it asuint32_tfor unknown reasons and effectively reserve 24 bytes for possible future use. This patch explicitly set the correct for copies and reserve the left bytes.This is a preparation patch that allow passing
copy_policyin request header.Cc Kevin Wolf <[email protected]>Cc Stefan Hajnoczi <[email protected]>Signed-off-by Liu Yuan <[email protected]>--- block/sheepdog.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)block/sheepdog.c +0
-0
block/sheepdog.c typedef struct SheepdogObjReq { · line 132
Quoted 9 lines
block/sheepdog.c +2
-1@@ -125,7 +125,8 @@ typedef struct SheepdogObjReq {uint32_t data_length;uint64_t oid;uint64_t cow_oid; -uint32_t copies; +uint8_t copies; +uint8_t reserved[3 ];uint32_t rsvd;uint64_t offset; } SheepdogObjReq;
Having both 'reserved' and 'rsvd' looks confusing. I'd suggest merging them into 'uint8_t reserved[7]'.
Thanks,
Kazutaka
PATCH 2/2 sheepdog: pass copy_policy in the request
In reply to Liu YuanCurrently copy_policy isn't used. Recent sheepdog supports erasure coding, which make use of copy_policy internally, but require client explicitly passing copy_policy from base inode to newly creately inode for snapshot related operations.
If connected sheep daemon doesn't utilize copy_policy, passing it to sheep daemon is just one extra null effect operation. So no compatibility problem.
With this patch, sheepdog can provide erasure coded volume for QEMU VM.
--- block/sheepdog.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
block/sheepdog.c +13 -7
@@ -126,7 +126,8 @@ typedef struct SheepdogObjReq {uint64_t oid;uint64_t cow_oid;uint8_t copies; -uint8_t reserved[3 ]; +uint8_t copy_policy; +uint8_t reserved[2 ];uint32_t rsvd;uint64_t offset; } SheepdogObjReq;
@@ -140,7 +141,8 @@ typedef struct SheepdogObjRsp {uint32_t data_length;uint32_t result;uint8_t copies; -uint8_t reserved[3 ]; +uint8_t copy_policy; +uint8_t reserved[2 ];uint32_t pad[6 ]; } SheepdogObjRsp;
@@ -154,7 +156,8 @@ typedef struct SheepdogVdiReq {uint64_t vdi_size;uint32_t vdi_id;uint8_t copies; -uint8_t reserved[3 ]; +uint8_t copy_policy; +uint8_t reserved[2 ];uint32_t snapid;uint32_t pad[3 ]; } SheepdogVdiReq;
@@ -1347,7 +1350,8 @@ out: }static int do_sd_create (BDRVSheepdogState *s,char *filename,int64_t vdi_size, -uint32_t base_vid,uint32_t *vdi_id,int snapshot) +uint32_t base_vid,uint32_t *vdi_id,int snapshot, +uint8_t copy_policy) {SheepdogVdiReq hdr;SheepdogVdiRsp *rsp = (SheepdogVdiRsp *)&hdr;
@@ -1377,6 +1381,7 @@ static int do_sd_create(BDRVSheepdogState *s, char *filename, int64_t vdi_size, hdr.data_length = wlen; hdr.vdi_size = vdi_size; + hdr.copy_policy = copy_policy; ret =do_req (fd, (SheepdogReq *)&hdr, buf, &wlen, &rlen);
@@ -1529,7 +1534,8 @@ static int sd_create(const char *filename, QEMUOptionParameter *options,bdrv_unref (bs); } - ret =do_sd_create (s, vdi, vdi_size, base_vid, &vid,0 ); +/* TODO: allow users to specify copy number */ + ret =do_sd_create (s, vdi, vdi_size, base_vid, &vid,0 ,0 );if (!prealloc || ret) { goto out; }
@@ -1719,7 +1725,7 @@ static int sd_create_branch(BDRVSheepdogState *s)*/ deleted =sd_delete (s); ret =do_sd_create (s, s->name, s->inode.vdi_size, s->inode.vdi_id, &vid, - !deleted); + !deleted, s->inode.copy_policy);if (ret) { goto out; }
@@ -2009,7 +2015,7 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) } ret =do_sd_create (s, s->name, s->inode.vdi_size, s->inode.vdi_id, &new_vid, -1 ); +1 , s->inode.copy_policy);if (ret <0 ) {error_report ("failed to create inode for snapshot. %s" ,strerror (errno));
Signature · 1 line
1.7.9.5
Quoted 5 lines · Liu Yuan
This patch set makes use of
copy_policyin struct SheepdogInode in order to support recently introduced erasure coding in sheepdog.Thanks
Yuan
Ping ?