From patchwork Wed Oct 16 07:38:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Yuan X-Patchwork-Id: 283871 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 3B8E52C00E4 for ; Wed, 16 Oct 2013 18:39:37 +1100 (EST) Received: from localhost ([::1]:45724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWLhf-0001x7-4U for incoming@patchwork.ozlabs.org; Wed, 16 Oct 2013 03:39:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWLh8-0001rr-QC for qemu-devel@nongnu.org; Wed, 16 Oct 2013 03:39:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VWLh0-0000Fh-Cv for qemu-devel@nongnu.org; Wed, 16 Oct 2013 03:39:02 -0400 Received: from mail-pb0-x22f.google.com ([2607:f8b0:400e:c01::22f]:60466) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWLh0-0000Fb-59 for qemu-devel@nongnu.org; Wed, 16 Oct 2013 03:38:54 -0400 Received: by mail-pb0-f47.google.com with SMTP id rr4so454288pbb.20 for ; Wed, 16 Oct 2013 00:38:53 -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=LIO9J1EJPVHujw2nQUFJU0W3Y6YEzodtyzJVJSg6iV0=; b=GRf0o5Np3axy21WOzJjLKTWUndjZZck3CGZwi1HplZ6rclO4eGnQkgoDrUBXI+AKLO yJyJ8mimP588jA9/pm7ql0yVJ+ab+aqNvHW/FgorDYzzkBA3oL2nPn5Tj9afPlGJldr9 kT1/pG4mAI/OydkbSS5vDO50BKwC036gUKobqNdL7APgBnzgPGDXDBceUAFuXclHB4JS J8t/cZGoGIAdUU54skqTJYaLMruocPAcUAUYNBssclW5/uIzoI0gWkY142lmHxPb2LXt 3tDgpyQy0i5Na42wsrAfo+BPASW0Bn9N42UfgwCX2zRNOXF1HkH4t4phgbdDOMGLFfDl EDRw== X-Received: by 10.67.5.132 with SMTP id cm4mr325749pad.186.1381909133202; Wed, 16 Oct 2013 00:38:53 -0700 (PDT) Received: from ubuntu-precise.taobao.ali.com ([182.92.247.2]) by mx.google.com with ESMTPSA id ja5sm89326469pbc.14.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Oct 2013 00:38:52 -0700 (PDT) From: Liu Yuan To: qemu-devel@nongnu.org Date: Wed, 16 Oct 2013 15:38:37 +0800 Message-Id: <1381909118-10667-2-git-send-email-namei.unix@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1381909118-10667-1-git-send-email-namei.unix@gmail.com> References: <1381909118-10667-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::22f Cc: Kevin Wolf , sheepdog@lists.wpkg.org, Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 1/2] sheepdog: explicitly set copies as type uint8_t 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 '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 Cc: Stefan Hajnoczi Signed-off-by: Liu Yuan --- block/sheepdog.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index 5f81c93..ca4f98b 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -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) {