From patchwork Wed Jun 30 11:55:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 57394 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EE07AB6F05 for ; Wed, 30 Jun 2010 21:59:13 +1000 (EST) Received: from localhost ([127.0.0.1]:52067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTvwd-0002Ni-2R for incoming@patchwork.ozlabs.org; Wed, 30 Jun 2010 07:59:11 -0400 Received: from [140.186.70.92] (port=56917 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTvtP-0000mr-VM for qemu-devel@nongnu.org; Wed, 30 Jun 2010 07:55:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OTvtL-0000ZO-HE for qemu-devel@nongnu.org; Wed, 30 Jun 2010 07:55:51 -0400 Received: from oxygen.pond.sub.org ([213.239.205.148]:57037) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OTvtL-0000Yh-8n for qemu-devel@nongnu.org; Wed, 30 Jun 2010 07:55:47 -0400 Received: from blackfin.pond.sub.org (pD951BCA6.dip.t-dialin.net [217.81.188.166]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 6079A2DD3B5; Wed, 30 Jun 2010 13:55:44 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id CB54D41E; Wed, 30 Jun 2010 13:55:42 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 30 Jun 2010 13:55:34 +0200 Message-Id: <1277898942-6501-4-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1277898942-6501-1-git-send-email-armbru@redhat.com> References: <1277898942-6501-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: kwolf@redhat.com, kraxel@redhat.com, hch@lst.de Subject: [Qemu-devel] [PATCH 03/11] raw-posix: Don't "try harder" for BDRV_TYPE_CDROM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org raw_pread_aligned() retries up to two times if the block device backs a virtual CD-ROM. This makes no sense. Whether retrying reads can correct read errors may depend on what we're reading, not on how the result gets used. Also clean up gratuitous use of goto. This reverts what's left of commit 8c05dbf9. Signed-off-by: Markus Armbruster --- block/raw-posix.c | 26 +++----------------------- 1 files changed, 3 insertions(+), 23 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 3f0701b..2a847aa 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -242,15 +242,14 @@ static int raw_pread_aligned(BlockDriverState *bs, int64_t offset, ret = pread(s->fd, buf, count, offset); if (ret == count) - goto label__raw_read__success; + return ret; /* Allow reads beyond the end (needed for pwrite) */ if ((ret == 0) && bs->growable) { int64_t size = raw_getlength(bs); if (offset >= size) { memset(buf, 0, count); - ret = count; - goto label__raw_read__success; + return count; } } @@ -259,23 +258,6 @@ static int raw_pread_aligned(BlockDriverState *bs, int64_t offset, s->fd, bs->filename, offset, buf, count, bs->total_sectors, ret, errno, strerror(errno)); - /* Try harder for CDrom. */ - if (bs->type == BDRV_TYPE_CDROM) { - ret = pread(s->fd, buf, count, offset); - if (ret == count) - goto label__raw_read__success; - ret = pread(s->fd, buf, count, offset); - if (ret == count) - goto label__raw_read__success; - - DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64 - "] retry read failed %d : %d = %s\n", - s->fd, bs->filename, offset, buf, count, - bs->total_sectors, ret, errno, strerror(errno)); - } - -label__raw_read__success: - return (ret < 0) ? -errno : ret; } @@ -298,15 +280,13 @@ static int raw_pwrite_aligned(BlockDriverState *bs, int64_t offset, ret = pwrite(s->fd, buf, count, offset); if (ret == count) - goto label__raw_write__success; + return ret; DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %" PRId64 ", %p, %d) [%" PRId64 "] write failed %d : %d = %s\n", s->fd, bs->filename, offset, buf, count, bs->total_sectors, ret, errno, strerror(errno)); -label__raw_write__success: - return (ret < 0) ? -errno : ret; }