qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: anthony@codemonkey.ws
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 10/11] ide: Handle flush failure
Date: Fri, 22 Oct 2010 15:43:55 +0200	[thread overview]
Message-ID: <1287755036-27688-11-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1287755036-27688-1-git-send-email-kwolf@redhat.com>

Instead of always assuming success for bdrv_aio_flush, actually do something
with the error. This respects the werror option and accordingly ignores the
error, reports it to the guest or stops the VM and retries after cont.

Ignoring the error is trivial, obviously. For stopping the VM and retrying
later old code can be reused, but we need to introduce a new status for "retry
a flush". For reporting to the guest, fortunately the same action is required
as for a failed read/write (status = DRDY | ERR, error = ABRT), so this code
can be reused as well.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 hw/ide/core.c     |   10 +++++++++-
 hw/ide/internal.h |    3 ++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/hw/ide/core.c b/hw/ide/core.c
index 6d8606e..bc3e916 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -65,6 +65,7 @@ static void ide_dma_start(IDEState *s, BlockDriverCompletionFunc *dma_cb);
 static void ide_dma_restart(IDEState *s, int is_read);
 static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret);
 static int ide_handle_rw_error(IDEState *s, int error, int op);
+static void ide_flush_cache(IDEState *s);
 
 static void padstr(char *str, const char *src, int len)
 {
@@ -688,6 +689,8 @@ static void ide_dma_restart_bh(void *opaque)
         } else {
             ide_sector_write(bmdma_active_if(bm));
         }
+    } else if (bm->status & BM_STATUS_RETRY_FLUSH) {
+        ide_flush_cache(bmdma_active_if(bm));
     }
 }
 
@@ -795,7 +798,12 @@ static void ide_flush_cb(void *opaque, int ret)
 {
     IDEState *s = opaque;
 
-    /* XXX: how do we signal I/O errors here? */
+    if (ret < 0) {
+        /* XXX: What sector number to set here? */
+        if (ide_handle_rw_error(s, -ret, BM_STATUS_RETRY_FLUSH)) {
+            return;
+        }
+    }
 
     s->status = READY_STAT | SEEK_STAT;
     ide_set_irq(s->bus);
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index 4165543..d652e06 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -472,7 +472,8 @@ struct IDEDeviceInfo {
 #define BM_STATUS_INT    0x04
 #define BM_STATUS_DMA_RETRY  0x08
 #define BM_STATUS_PIO_RETRY  0x10
-#define BM_STATUS_RETRY_READ 0x20
+#define BM_STATUS_RETRY_READ  0x20
+#define BM_STATUS_RETRY_FLUSH 0x40
 
 #define BM_CMD_START     0x01
 #define BM_CMD_READ      0x08
-- 
1.7.2.3

  parent reply	other threads:[~2010-10-22 13:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22 13:43 [Qemu-devel] [PULL 00/11] Block patches Kevin Wolf
2010-10-22 13:43 ` [Qemu-devel] [PATCH 01/11] qcow2: Support exact L1 table growth Kevin Wolf
2010-10-22 13:43 ` [Qemu-devel] [PATCH 02/11] qcow2: Simplify image creation Kevin Wolf
2010-10-22 13:43 ` [Qemu-devel] [PATCH 03/11] qcow2: Remove old image creation function Kevin Wolf
2010-10-22 13:43 ` [Qemu-devel] [PATCH 04/11] ide: set WCACHE supported in IDENTIFY data Kevin Wolf
2010-10-22 13:43 ` [Qemu-devel] [PATCH 05/11] Copy snapshots out of QCOW2 disk Kevin Wolf
2010-10-22 13:43 ` [Qemu-devel] [PATCH 06/11] qemu-io: New command map Kevin Wolf
2010-10-22 13:43 ` [Qemu-devel] [PATCH 07/11] block: Use GCC_FMT_ATTR and fix a format error Kevin Wolf
2010-10-22 13:43 ` [Qemu-devel] [PATCH 08/11] qemu-img: Fix qemu-img convert -obacking_file Kevin Wolf
2010-10-22 13:43 ` [Qemu-devel] [PATCH 09/11] ide: Factor ide_flush_cache out Kevin Wolf
2010-10-22 13:43 ` Kevin Wolf [this message]
2010-10-22 13:43 ` [Qemu-devel] [PATCH 11/11] virtio-blk: Respect werror option for flushes 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=1287755036-27688-11-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=anthony@codemonkey.ws \
    --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).