qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, kraxel@redhat.com, hch@lst.de
Subject: [Qemu-devel] [PATCH v2 03/13] raw-posix: Fix test for host CD-ROM
Date: Tue,  6 Jul 2010 14:08:46 +0200	[thread overview]
Message-ID: <1278418136-24556-4-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1278418136-24556-1-git-send-email-armbru@redhat.com>

raw_pread_aligned() retries up to two times if the block device backs
a virtual CD-ROM (a drive with media=cdrom and if=ide, scsi, xen or
none).  This makes no sense.  Whether retrying reads can correct read
errors can only depend on what we're reading, not on how the result
gets used.  We need to check what whether we're reading from a
physical CD-ROM or floppy here.

I doubt retrying is useful even then.  Left for another day.

Impact:

* Virtual CD-ROM backed by host_cdrom behaves the same.

* Virtual CD-ROM backed by file or host_device no longer retries.

* A drive backed by host_cdrom now retries even if it's not a virtual
  CD-ROM.

* Any drive backed by host_floppy now retries.

While there, clean up gratuitous use of goto.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 block/raw-posix.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index 3f0701b..291699f 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;
         }
     }
 
@@ -260,13 +259,13 @@ static int raw_pread_aligned(BlockDriverState *bs, int64_t offset,
                       bs->total_sectors, ret, errno, strerror(errno));
 
     /* Try harder for CDrom. */
-    if (bs->type == BDRV_TYPE_CDROM) {
+    if (s->type != FTYPE_FILE) {
         ret = pread(s->fd, buf, count, offset);
         if (ret == count)
-            goto label__raw_read__success;
+            return ret;
         ret = pread(s->fd, buf, count, offset);
         if (ret == count)
-            goto label__raw_read__success;
+            return ret;
 
         DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
                           "] retry read failed %d : %d = %s\n",
@@ -274,8 +273,6 @@ static int raw_pread_aligned(BlockDriverState *bs, int64_t offset,
                           bs->total_sectors, ret, errno, strerror(errno));
     }
 
-label__raw_read__success:
-
     return  (ret < 0) ? -errno : ret;
 }
 
@@ -298,15 +295,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;
 }
 
-- 
1.6.6.1

  parent reply	other threads:[~2010-07-06 12:23 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-06 12:08 [Qemu-devel] [PATCH v2 00/13] Still more block related fixes and cleanups Markus Armbruster
2010-07-06 12:08 ` [Qemu-devel] [PATCH v2 01/13] blockdev: Clean up how readonly persists across virtual media change Markus Armbruster
2010-07-07  1:19   ` [Qemu-devel] " Christoph Hellwig
2010-07-06 12:08 ` [Qemu-devel] [PATCH v2 02/13] block migration: Fix test for read-only drive Markus Armbruster
2010-07-07  1:19   ` [Qemu-devel] " Christoph Hellwig
2010-07-06 12:08 ` Markus Armbruster [this message]
2010-07-07  1:23   ` [Qemu-devel] Re: [PATCH v2 03/13] raw-posix: Fix test for host CD-ROM Christoph Hellwig
2010-07-07  9:34     ` Markus Armbruster
2010-07-07 10:06       ` Kevin Wolf
2010-07-06 12:08 ` [Qemu-devel] [PATCH v2 04/13] fdc: Reject unimplemented error actions Markus Armbruster
2010-07-07  1:23   ` [Qemu-devel] " Christoph Hellwig
2010-07-06 12:08 ` [Qemu-devel] [PATCH v2 05/13] qdev: Don't hw_error() in qdev_init_nofail() Markus Armbruster
2010-07-07  1:24   ` [Qemu-devel] " Christoph Hellwig
2010-07-06 12:08 ` [Qemu-devel] [PATCH v2 06/13] scsi: Reject unimplemented error actions Markus Armbruster
2010-07-07  1:26   ` [Qemu-devel] " Christoph Hellwig
2010-07-07  9:41     ` Markus Armbruster
2010-07-06 12:08 ` [Qemu-devel] [PATCH v2 07/13] error: New qemu_opts_loc_restore() Markus Armbruster
2010-07-07  1:26   ` [Qemu-devel] " Christoph Hellwig
2010-07-06 12:08 ` [Qemu-devel] [PATCH v2 08/13] scsi: Error locations for -drive if=scsi device initialization Markus Armbruster
2010-07-06 12:08 ` [Qemu-devel] [PATCH v2 09/13] ide: Improve error messages Markus Armbruster
2010-07-07  1:26   ` [Qemu-devel] " Christoph Hellwig
2010-07-06 12:08 ` [Qemu-devel] [PATCH v2 10/13] ide: Replace IDEState members is_cdrom, is_cf by drive_kind Markus Armbruster
2010-07-07  1:27   ` [Qemu-devel] " Christoph Hellwig
2010-07-06 12:08 ` [Qemu-devel] [PATCH v2 11/13] ide: Make ide_init_drive() return success Markus Armbruster
2010-07-07  1:28   ` [Qemu-devel] " Christoph Hellwig
2010-07-06 12:08 ` [Qemu-devel] [PATCH v2 12/13] ide: Reject readonly drives unless CD-ROM Markus Armbruster
2010-07-07  1:28   ` [Qemu-devel] " Christoph Hellwig
2010-07-06 12:08 ` [Qemu-devel] [PATCH v2 13/13] ide: Reject invalid CHS geometry Markus Armbruster
2010-07-07  1:28   ` [Qemu-devel] " Christoph Hellwig
2010-07-06 14:06 ` [Qemu-devel] Re: [PATCH v2 00/13] Still more block related fixes and cleanups Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1278418136-24556-4-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=hch@lst.de \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).