qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/2] sheepdog: make use of copy_policy
@ 2013-10-23  8:51 Liu Yuan
  2013-10-23  8:51 ` [Qemu-devel] [PATCH v2 1/2] sheepdog: explicitly set copies as type uint8_t Liu Yuan
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Liu Yuan @ 2013-10-23  8:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: sheepdog

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(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH v2 1/2] sheepdog: explicitly set copies as type uint8_t
  2013-10-23  8:51 [Qemu-devel] [PATCH v2 0/2] sheepdog: make use of copy_policy Liu Yuan
@ 2013-10-23  8:51 ` Liu Yuan
  2013-10-23  8:51 ` [Qemu-devel] [PATCH v2 2/2] sheepdog: pass copy_policy in the request Liu Yuan
  2013-10-25 18:03 ` [Qemu-devel] [sheepdog] [PATCH v2 0/2] sheepdog: make use of copy_policy MORITA Kazutaka
  2 siblings, 0 replies; 5+ messages in thread
From: Liu Yuan @ 2013-10-23  8:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, sheepdog, Stefan Hajnoczi

'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.

Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
---
 block/sheepdog.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/block/sheepdog.c b/block/sheepdog.c
index 5f81c93..b8a2985 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -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)
 {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH v2 2/2] sheepdog: pass copy_policy in the request
  2013-10-23  8:51 [Qemu-devel] [PATCH v2 0/2] sheepdog: make use of copy_policy Liu Yuan
  2013-10-23  8:51 ` [Qemu-devel] [PATCH v2 1/2] sheepdog: explicitly set copies as type uint8_t Liu Yuan
@ 2013-10-23  8:51 ` Liu Yuan
  2013-10-25 18:03 ` [Qemu-devel] [sheepdog] [PATCH v2 0/2] sheepdog: make use of copy_policy MORITA Kazutaka
  2 siblings, 0 replies; 5+ messages in thread
From: Liu Yuan @ 2013-10-23  8:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, sheepdog, Stefan Hajnoczi

Currently 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.

Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
---
 block/sheepdog.c |   20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/block/sheepdog.c b/block/sheepdog.c
index b8a2985..9f0757b 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -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));
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [sheepdog] [PATCH v2 0/2] sheepdog: make use of copy_policy
  2013-10-23  8:51 [Qemu-devel] [PATCH v2 0/2] sheepdog: make use of copy_policy Liu Yuan
  2013-10-23  8:51 ` [Qemu-devel] [PATCH v2 1/2] sheepdog: explicitly set copies as type uint8_t Liu Yuan
  2013-10-23  8:51 ` [Qemu-devel] [PATCH v2 2/2] sheepdog: pass copy_policy in the request Liu Yuan
@ 2013-10-25 18:03 ` MORITA Kazutaka
  2013-10-28 16:40   ` Kevin Wolf
  2 siblings, 1 reply; 5+ messages in thread
From: MORITA Kazutaka @ 2013-10-25 18:03 UTC (permalink / raw)
  To: Liu Yuan; +Cc: Kevin Wolf, sheepdog, qemu-devel, Stefan Hajnoczi

At Wed, 23 Oct 2013 16:51:50 +0800,
Liu Yuan wrote:
> 
> 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(-)

Acked-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [sheepdog] [PATCH v2 0/2] sheepdog: make use of copy_policy
  2013-10-25 18:03 ` [Qemu-devel] [sheepdog] [PATCH v2 0/2] sheepdog: make use of copy_policy MORITA Kazutaka
@ 2013-10-28 16:40   ` Kevin Wolf
  0 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2013-10-28 16:40 UTC (permalink / raw)
  To: MORITA Kazutaka; +Cc: Liu Yuan, sheepdog, qemu-devel, Stefan Hajnoczi

Am 25.10.2013 um 20:03 hat MORITA Kazutaka geschrieben:
> At Wed, 23 Oct 2013 16:51:50 +0800,
> Liu Yuan wrote:
> > 
> > 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(-)
> 
> Acked-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>

Thanks, applied both patches to the block branch.

Kevin

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-10-28 16:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-23  8:51 [Qemu-devel] [PATCH v2 0/2] sheepdog: make use of copy_policy Liu Yuan
2013-10-23  8:51 ` [Qemu-devel] [PATCH v2 1/2] sheepdog: explicitly set copies as type uint8_t Liu Yuan
2013-10-23  8:51 ` [Qemu-devel] [PATCH v2 2/2] sheepdog: pass copy_policy in the request Liu Yuan
2013-10-25 18:03 ` [Qemu-devel] [sheepdog] [PATCH v2 0/2] sheepdog: make use of copy_policy MORITA Kazutaka
2013-10-28 16:40   ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).