All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@eu.citrix.com>
To: xen-devel@lists.xensource.com
Subject: Re: [PATCH] minios: blkfront_aio_poll may reenter
Date: Sat, 5 Apr 2008 14:31:08 +0200	[thread overview]
Message-ID: <20080405123108.GF4005@implementation> (raw)
In-Reply-To: <20080326121038.GG5636@implementation.uk.xensource.com>

Hello,

That patch didn't get apply, is there any problem with it?

Samuel


minios: blkfront_aio_poll may reenter
if the callback calls blkfront_sync for instance.
In such a case, we would see responses and hence release grants several
times. We thus need to be more synchronous and stop when we detect that
we have re-entered.
This fixes HVM restore with stubdomains.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>

diff -r 91c4e704169d extras/mini-os/blkfront.c
--- a/extras/mini-os/blkfront.c	Wed Mar 26 11:28:47 2008 +0000
+++ b/extras/mini-os/blkfront.c	Wed Mar 26 12:07:07 2008 +0000
@@ -319,6 +319,7 @@ int blkfront_aio_poll(struct blkfront_de
 {
     RING_IDX rp, cons;
     struct blkif_response *rsp;
+    int more;
 
 moretodo:
 #ifdef HAVE_LIBC
@@ -334,6 +335,7 @@ moretodo:
     while ((cons != rp))
     {
 	rsp = RING_GET_RESPONSE(&dev->ring, cons);
+	nr_consumed++;
 
         if (rsp->status != BLKIF_RSP_OKAY)
             printk("block error %d for op %d\n", rsp->status, rsp->operation);
@@ -343,29 +345,30 @@ moretodo:
         case BLKIF_OP_WRITE:
         {
             struct blkfront_aiocb *aiocbp = (void*) (uintptr_t) rsp->id;
+            int status = rsp->status;
             int j;
 
             for (j = 0; j < aiocbp->n; j++)
                 gnttab_end_access(aiocbp->gref[j]);
 
+            dev->ring.rsp_cons = ++cons;
             /* Nota: callback frees aiocbp itself */
-            aiocbp->aio_cb(aiocbp, rsp->status ? -EIO : 0);
+            aiocbp->aio_cb(aiocbp, status ? -EIO : 0);
+            if (dev->ring.rsp_cons != cons)
+                /* We reentered, we must not continue here */
+                goto out;
             break;
         }
+        default:
+            printk("unrecognized block operation %d response\n", rsp->operation);
         case BLKIF_OP_WRITE_BARRIER:
         case BLKIF_OP_FLUSH_DISKCACHE:
-            break;
-        default:
-            printk("unrecognized block operation %d response\n", rsp->operation);
+            dev->ring.rsp_cons = ++cons;
             break;
         }
+    }
 
-	nr_consumed++;
-	++cons;
-    }
-    dev->ring.rsp_cons = cons;
-
-    int more;
+out:
     RING_FINAL_CHECK_FOR_RESPONSES(&dev->ring, more);
     if (more) goto moretodo;
 
diff -r 91c4e704169d extras/mini-os/minios.mk
--- a/extras/mini-os/minios.mk	Wed Mar 26 11:28:47 2008 +0000
+++ b/extras/mini-os/minios.mk	Wed Mar 26 12:07:07 2008 +0000
@@ -16,10 +16,10 @@ DEF_LDFLAGS =
 
 ifeq ($(debug),y)
 DEF_CFLAGS += -g
-#DEF_CFLAGS += MM_DEBUG
-#DEF_CFLAGS += FS_DEBUG
-#DEF_CFLAGS += LIBC_DEBUG
-#DEF_CFLAGS += GNT_DEBUG
+#DEF_CFLAGS += -DMM_DEBUG
+#DEF_CFLAGS += -DFS_DEBUG
+#DEF_CFLAGS += -DLIBC_DEBUG
+DEF_CFLAGS += -DGNT_DEBUG
 else
 DEF_CFLAGS += -O3
 endif

  reply	other threads:[~2008-04-05 12:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-26 12:10 [PATCH] minios: blkfront_aio_poll may reenter Samuel Thibault
2008-04-05 12:31 ` Samuel Thibault [this message]
2008-04-05 12:40   ` Samuel Thibault

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=20080405123108.GF4005@implementation \
    --to=samuel.thibault@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.