sheepdog: make use of copy_policy
v2 cover sheepdog: make use of copy_policy
v2:
- merge the reserved bits
This patch set makes use of copy_policy in struct SheepdogInode in order to support recently introduced erasure coding volume in sheepdog.
Thanks
Yuan
Liu Yuan (2):
sheepdog: explicitly set copies as type uint8_t
sheepdog: pass copy_policy in the request
block/sheepdog.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v2 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 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
block/sheepdog.c +9 -7
@@ -125,8 +125,8 @@ typedef struct SheepdogObjReq {uint32_t data_length;uint64_t oid;uint64_t cow_oid; -uint32_t copies; -uint32_t rsvd; +uint8_t copies; +uint8_t reserved[7 ];uint64_t offset; } SheepdogObjReq;
@@ -138,7 +138,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 +152,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 +1083,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 +1131,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 +1139,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
PATCH v2 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[7 ]; +uint8_t copy_policy; +uint8_t reserved[6 ];uint64_t offset; } SheepdogObjReq;
@@ -139,7 +140,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;
@@ -153,7 +155,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;
@@ -1346,7 +1349,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;
@@ -1376,6 +1380,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);
@@ -1528,7 +1533,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; }
@@ -1718,7 +1724,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; }
@@ -2008,7 +2014,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
At Wed, 23 Oct 2013 16:51:50 +0800,
Quoted 10 lines · Liu Yuan
v2:
- merge the reserved bitsThis patch set makes use of
copy_policyin struct SheepdogInode in order to support recently introduced erasure coding volume in sheepdog.Thanks
Yuan
Quoted 6 lines
Liu Yuan (2):
sheepdog: explicitly set copies as typeuint8_t
sheepdog: passcopy_policyin the requestblock/sheepdog.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)
Kevin Wolf
AppliedAm 25.10.2013 um 20:03 hat MORITA Kazutaka geschrieben:
Quoted 12 lines
At Wed, 23 Oct 2013 16:51:50 +0800,
Quoted 10 lines · Liu Yuan
v2:
- merge the reserved bitsThis patch set makes use of
copy_policyin struct SheepdogInode in order to support recently introduced erasure coding volume in sheepdog.Thanks
Yuan
Quoted 8 lines
Quoted 6 lines
Liu Yuan (2):
sheepdog: explicitly set copies as typeuint8_t
sheepdog: passcopy_policyin the requestblock/sheepdog.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)Acked-by MORITA Kazutaka <[email protected]>
Thanks, applied both patches to the block branch.
Kevin