From patchwork Wed Oct 23 08:51:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Yuan X-Patchwork-Id: 285559 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 964C52C019B for ; Wed, 23 Oct 2013 19:53:42 +1100 (EST) Received: from localhost ([::1]:48269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYuCC-0004GN-4W for incoming@patchwork.ozlabs.org; Wed, 23 Oct 2013 04:53:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYuAt-0002dB-Eo for qemu-devel@nongnu.org; Wed, 23 Oct 2013 04:52:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VYuAl-0005lR-0K for qemu-devel@nongnu.org; Wed, 23 Oct 2013 04:52:19 -0400 Received: from mail-pb0-x231.google.com ([2607:f8b0:400e:c01::231]:51337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYuAk-0005lN-Ov for qemu-devel@nongnu.org; Wed, 23 Oct 2013 04:52:10 -0400 Received: by mail-pb0-f49.google.com with SMTP id xb12so620052pbc.36 for ; Wed, 23 Oct 2013 01:52:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xTNFjmrt1CsXdfY1Igmr3gT+PRckYB3EN1nQAE7P9zc=; b=eLXzLrxUJBR4uYXBJEExvuYoFo/Clve7yRn5Jp3mzvPQ+qUYnY562J2j94GaQDvnOk e0vh2+25r3CxB9gphbl3zXrW7oFi8uFCbRvekMJYDmCvrUzJhXbe/J9izVJn3ty6bTHU mTKqNpNYPKBQY4kxLdlyf7yCHeixrg7rhcYnRzZpv2txibtrijNUCZTaOmGSA3Lxa7Dx t1fTtAy/uLCbmKC9yUicag5OzQ7wf7c0ZkbkgV7yi5AUmZTub9Hjrq6FnZPOR4UKAexG 78fE6awv+Joflo9IVy+QnoXZ2WSN++/FgJdRXGyXPj0jyGXxzA8MxAfDgpcWfYggf/SU fgvQ== X-Received: by 10.67.5.132 with SMTP id cm4mr173175pad.186.1382518329803; Wed, 23 Oct 2013 01:52:09 -0700 (PDT) Received: from ubuntu-precise.hz.ali.com ([182.92.247.6]) by mx.google.com with ESMTPSA id lm2sm39497922pab.2.2013.10.23.01.52.06 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Oct 2013 01:52:08 -0700 (PDT) From: Liu Yuan To: qemu-devel@nongnu.org Date: Wed, 23 Oct 2013 16:51:52 +0800 Message-Id: <1382518312-16578-3-git-send-email-namei.unix@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1382518312-16578-1-git-send-email-namei.unix@gmail.com> References: <1382518312-16578-1-git-send-email-namei.unix@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c01::231 Cc: Kevin Wolf , sheepdog@lists.wpkg.org, Stefan Hajnoczi Subject: [Qemu-devel] [PATCH v2 2/2] sheepdog: pass copy_policy in the request X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Cc: Stefan Hajnoczi Signed-off-by: Liu Yuan --- 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));