WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [QEMU] Enhance raw io reliability

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [QEMU] Enhance raw io reliability
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 11 Sep 2007 21:10:12 -0700
Delivery-date: Tue, 11 Sep 2007 21:10:30 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1189526523 -3600
# Node ID 5352a7cc4f2ab3e5b79cfb8d8a25a670946d41dd
# Parent  2e4912a256a43e5e2d85212b980883ddbb538511
[QEMU] Enhance raw io reliability

For raw block device only :
log any I/O error and perform automatic read retry for CDrom
(improves MediaCheck with old installers).

Signed-off-by: Ben Guthro <bguthro@xxxxxxxxxxxxxxx>
Signed-off-by: Josh Nicholas <jnicholas@xxxxxxxxxxxxxxx>
---
 tools/ioemu/block-raw.c |   94 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 92 insertions(+), 2 deletions(-)

diff -r 2e4912a256a4 -r 5352a7cc4f2a tools/ioemu/block-raw.c
--- a/tools/ioemu/block-raw.c   Tue Sep 11 17:00:25 2007 +0100
+++ b/tools/ioemu/block-raw.c   Tue Sep 11 17:02:03 2007 +0100
@@ -59,6 +59,13 @@
 
 //#define DEBUG_FLOPPY
 
+#define DEBUG_BLOCK
+#ifdef  DEBUG_BLOCK
+#define DEBUG_BLOCK_PRINT( formatCstr, args... ) fprintf( logfile, formatCstr, 
##args ); fflush( logfile )
+#else
+#define DEBUG_BLOCK_PRINT( formatCstr, args... )
+#endif
+
 #define FTYPE_FILE   0
 #define FTYPE_CD     1
 #define FTYPE_FD     2
@@ -70,6 +77,7 @@ typedef struct BDRVRawState {
 typedef struct BDRVRawState {
     int fd;
     int type;
+    unsigned int lseek_err_cnt;
 #if defined(__linux__)
     /* linux floppy specific */
     int fd_open_flags;
@@ -87,6 +95,8 @@ static int raw_open(BlockDriverState *bs
     BDRVRawState *s = bs->opaque;
     int fd, open_flags, ret;
 
+    s->lseek_err_cnt = 0;
+
     open_flags = O_BINARY;
     if ((flags & BDRV_O_ACCESS) == O_RDWR) {
         open_flags |= O_RDWR;
@@ -137,8 +147,58 @@ static int raw_pread(BlockDriverState *b
     if (ret < 0)
         return ret;
 
-    lseek(s->fd, offset, SEEK_SET);
+    if (lseek(s->fd, offset, SEEK_SET) == (off_t)-1) {
+        ++(s->lseek_err_cnt);
+        if(s->lseek_err_cnt <= 10) {
+                DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %ld, %p, %d) [%ld] lseek 
failed : %d = %s\n", 
+                        s->fd, 
+                        bs->filename, 
+                        offset, 
+                        buf, 
+                        count, 
+                        bs->total_sectors, errno, strerror(errno) );
+       }
+       return -1;
+    }
+    s->lseek_err_cnt=0;
+
     ret = read(s->fd, buf, count);
+    if (ret == count) 
+        goto label__raw_read__success;
+    
+    DEBUG_BLOCK_PRINT("raw_read(%d:%s, %ld, %p, %d) [%ld] read failed %d : %d 
= %s\n", 
+        s->fd, 
+        bs->filename, 
+        offset, 
+        buf, 
+        count, 
+        bs->total_sectors, 
+        ret, errno, strerror(errno) );
+    
+    if (bs->type == BDRV_TYPE_CDROM) {  // Try harder for CDrom
+        lseek(s->fd, offset, SEEK_SET);
+        ret = read(s->fd, buf, count);
+        if (ret == count) 
+            goto label__raw_read__success;
+        lseek(s->fd, offset, SEEK_SET);
+        ret = read(s->fd, buf, count);
+        if (ret == count)
+            goto label__raw_read__success;
+        
+        DEBUG_BLOCK_PRINT("raw_read(%d:%s, %ld, %p, %d) [%ld] retry read 
failed %d : %d = %s\n", 
+            s->fd, 
+            bs->filename, 
+            offset, 
+            buf, 
+            count, 
+            bs->total_sectors, 
+            ret, errno, strerror(errno) );
+    }
+    
+    return -1;
+    
+label__raw_read__success:
+
     return ret;
 }
 
@@ -152,8 +212,38 @@ static int raw_pwrite(BlockDriverState *
     if (ret < 0)
         return ret;
 
-    lseek(s->fd, offset, SEEK_SET);
+    if (lseek(s->fd, offset, SEEK_SET) == (off_t)-1) {
+        ++(s->lseek_err_cnt);
+        if(s->lseek_err_cnt) {
+                DEBUG_BLOCK_PRINT("raw_write(%d:%s, %ld, %p, %d) [%ld] lseek 
failed : %d = %s\n", 
+                        s->fd, 
+                        bs->filename, 
+                        offset, 
+                        buf, 
+                        count, 
+                        bs->total_sectors, errno, strerror(errno) );
+        }
+        return -1;
+    }
+    s->lseek_err_cnt = 0;
+
     ret = write(s->fd, buf, count);
+    if (ret == count) 
+        goto label__raw_write__success;
+    
+    DEBUG_BLOCK_PRINT("raw_write(%d:%s, %ld, %p, %d) [%ld] write failed %d : 
%d = %s\n", 
+        s->fd, 
+        bs->filename, 
+        offset, 
+        buf, 
+        count, 
+        bs->total_sectors, 
+        ret, errno, strerror(errno) );
+    
+    return -1;
+    
+label__raw_write__success:
+
     return ret;
 }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [QEMU] Enhance raw io reliability, Xen patchbot-unstable <=