xen_disk: move sanity check to the correct place
authorGerd Hoffmann <kraxel@redhat.com>
Thu, 11 Jun 2009 09:32:48 +0000 (11:32 +0200)
committerBlue Swirl <blauwirbel@gmail.com>
Sat, 13 Jun 2009 13:11:07 +0000 (16:11 +0300)
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/xen_disk.c

index f95e373..659a839 100644 (file)
@@ -179,10 +179,6 @@ static int ioreq_parse(struct ioreq *ioreq)
     switch (ioreq->req.operation) {
     case BLKIF_OP_READ:
        ioreq->prot = PROT_WRITE; /* to memory */
-        if (ioreq->req.operation != BLKIF_OP_READ && blkdev->mode[0] != 'w') {
-           xen_be_printf(&blkdev->xendev, 0, "error: write req for ro device\n");
-           goto err;
-       }
        break;
     case BLKIF_OP_WRITE_BARRIER:
        if (!syncwrite)
@@ -199,6 +195,11 @@ static int ioreq_parse(struct ioreq *ioreq)
        goto err;
     };
 
+    if (ioreq->req.operation != BLKIF_OP_READ && blkdev->mode[0] != 'w') {
+        xen_be_printf(&blkdev->xendev, 0, "error: write req for ro device\n");
+        goto err;
+    }
+
     ioreq->start = ioreq->req.sector_number * blkdev->file_blk;
     for (i = 0; i < ioreq->req.nr_segments; i++) {
        if (i == BLKIF_MAX_SEGMENTS_PER_REQUEST) {