From patchwork Thu Apr 25 10:37:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MORITA Kazutaka X-Patchwork-Id: 239475 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 38E122C00F5 for ; Thu, 25 Apr 2013 20:32:56 +1000 (EST) Received: from localhost ([::1]:43520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVJTy-00026z-39 for incoming@patchwork.ozlabs.org; Thu, 25 Apr 2013 06:32:54 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVJTP-00026J-MS for qemu-devel@nongnu.org; Thu, 25 Apr 2013 06:32:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVJTO-00074p-7D for qemu-devel@nongnu.org; Thu, 25 Apr 2013 06:32:19 -0400 Received: from sh.osrg.net ([192.16.179.4]:56734) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVJTN-00073a-PX for qemu-devel@nongnu.org; Thu, 25 Apr 2013 06:32:18 -0400 Received: from fs.osrg.net (localns.osrg.net [10.0.0.11]) by sh.osrg.net (8.14.4/8.14.4/OSRG-NET) with ESMTP id r3PAW3KK011500; Thu, 25 Apr 2013 19:32:03 +0900 Received: from localhost (dfs1401.osrg.net [10.68.14.1]) by fs.osrg.net (Postfix) with ESMTP id 791FFF945; Thu, 25 Apr 2013 19:32:03 +0900 (JST) From: MORITA Kazutaka To: stefanha@redhat.com, kwolf@redhat.com Date: Thu, 25 Apr 2013 19:37:41 +0900 Message-Id: <1366886263-21263-2-git-send-email-morita.kazutaka@lab.ntt.co.jp> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1366886263-21263-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> References: <1366886263-21263-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> X-Dispatcher: imput version 20100215(IM150) Lines: 59 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (sh.osrg.net [192.16.179.4]); Thu, 25 Apr 2013 19:32:04 +0900 (JST) X-Virus-Scanned: clamav-milter 0.97.7 at sh X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 192.16.179.4 Cc: sheepdog@lists.wpkg.org, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 1/3] sheepdog: cleanup find_vdi_name 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 This makes 'filename' and 'tag' constant variables, and renames 'for_snapshot' to 'lock' to clear how it works. Signed-off-by: MORITA Kazutaka --- block/sheepdog.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index 9f30a87..4326664 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -941,8 +941,9 @@ static int parse_vdiname(BDRVSheepdogState *s, const char *filename, return ret; } -static int find_vdi_name(BDRVSheepdogState *s, char *filename, uint32_t snapid, - char *tag, uint32_t *vid, int for_snapshot) +static int find_vdi_name(BDRVSheepdogState *s, const char *filename, + uint32_t snapid, const char *tag, uint32_t *vid, + bool lock) { int ret, fd; SheepdogVdiReq hdr; @@ -963,10 +964,10 @@ static int find_vdi_name(BDRVSheepdogState *s, char *filename, uint32_t snapid, strncpy(buf + SD_MAX_VDI_LEN, tag, SD_MAX_VDI_TAG_LEN); memset(&hdr, 0, sizeof(hdr)); - if (for_snapshot) { - hdr.opcode = SD_OP_GET_VDI_INFO; - } else { + if (lock) { hdr.opcode = SD_OP_LOCK_VDI; + } else { + hdr.opcode = SD_OP_GET_VDI_INFO; } wlen = SD_MAX_VDI_LEN + SD_MAX_VDI_TAG_LEN; hdr.proto_ver = SD_PROTO_VER; @@ -1205,7 +1206,7 @@ static int sd_open(BlockDriverState *bs, QDict *options, int flags) goto out; } - ret = find_vdi_name(s, vdi, snapid, tag, &vid, 0); + ret = find_vdi_name(s, vdi, snapid, tag, &vid, true); if (ret) { goto out; } @@ -1921,7 +1922,7 @@ static int sd_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) pstrcpy(tag, sizeof(tag), s->name); } - ret = find_vdi_name(s, vdi, snapid, tag, &vid, 1); + ret = find_vdi_name(s, vdi, snapid, tag, &vid, false); if (ret) { error_report("Failed to find_vdi_name"); goto out;