g/c vbd active.
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Tue, 23 Aug 2005 18:09:54 +0000 (18:09 +0000)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Tue, 23 Aug 2005 18:09:54 +0000 (18:09 +0000)
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
linux-2.6-xen-sparse/drivers/xen/blkback/common.h
linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
linux-2.6-xen-sparse/drivers/xen/blkback/vbd.c
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c

index 4af91f8aa6d2cb7cda8403be1558107a89fb7f14..784fd9a020169d862c852ccf35c24eb2614d0ee8 100644 (file)
@@ -35,8 +35,6 @@ struct vbd {
     unsigned char  type;        /* VDISK_xxx */
     blkif_pdev_t   pdevice;     /* phys device that this vbd maps to */
     struct block_device *bdev;
-
-    int active;
 }; 
 
 typedef struct blkif_st {
@@ -83,11 +81,9 @@ int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn);
             free_blkif_callback(_b);             \
     } while (0)
 
-/* Creates inactive vbd. */
+/* Create a vbd. */
 int vbd_create(blkif_t *blkif, blkif_vdev_t vdevice, blkif_pdev_t pdevice,
               int readonly);
-int vbd_is_active(struct vbd *vbd);
-void vbd_activate(struct vbd *vbd);
 void vbd_free(struct vbd *vbd);
 
 unsigned long vbd_size(struct vbd *vbd);
index 3f5eda76b31d69e67e7a6591888f7171f04bbd0d..014e9ea34c44cfd9d2a7dd2824d0bf3a437a7724 100644 (file)
@@ -116,8 +116,7 @@ static void free_blkif(void *arg)
     op.u.close.dom = blkif->domid;
     HYPERVISOR_event_channel_op(&op);
 
-    if (vbd_is_active(&blkif->vbd))
-       vbd_free(&blkif->vbd);
+    vbd_free(&blkif->vbd);
 
     if (blkif->evtchn)
         unbind_evtchn_from_irqhandler(blkif->evtchn, blkif);
index a8df6b955832a5ac4406b39c748c41317929132f..f3b73cdec08af40a46b513f20744ac076bcba5bd 100644 (file)
@@ -32,11 +32,6 @@ unsigned long vbd_secsize(struct vbd *vbd)
        return bdev_hardsect_size(vbd->bdev);
 }
 
-int vbd_is_active(struct vbd *vbd)
-{
-       return vbd->active;
-}
-
 int vbd_create(blkif_t *blkif, blkif_vdev_t handle,
               blkif_pdev_t pdevice, int readonly)
 {
@@ -46,7 +41,6 @@ int vbd_create(blkif_t *blkif, blkif_vdev_t handle,
     vbd->handle   = handle; 
     vbd->readonly = readonly;
     vbd->type     = 0;
-    vbd->active   = 0;
 
     vbd->pdevice  = pdevice;
 
@@ -62,7 +56,7 @@ int vbd_create(blkif_t *blkif, blkif_vdev_t handle,
     if ( (vbd->bdev->bd_disk == NULL) )
     {
         DPRINTK("vbd_creat: device %08x doesn't exist.\n", vbd->pdevice);
-        bdev_put(vbd->bdev);
+       vbd_free(vbd);
         return -ENOENT;
     }
 
@@ -76,19 +70,11 @@ int vbd_create(blkif_t *blkif, blkif_vdev_t handle,
     return 0;
 }
 
-void vbd_activate(struct vbd *vbd)
-{
-    BUG_ON(vbd_is_active(vbd));
-
-    /* Now we're active. */
-    vbd->active = 1;
-}
-
 void vbd_free(struct vbd *vbd)
 {
-    if (vbd_is_active(vbd))
-       vbd->active = 0;
-    bdev_put(vbd->bdev);
+    if (vbd->bdev)
+       bdev_put(vbd->bdev);
+    vbd->bdev = NULL;
 }
 
 int vbd_translate(struct phys_req *req, blkif_t *blkif, int operation)
index 1ff4d2900921d879242d94a8ab2cb6d827e281c8..3163ee56663f7882bd39c7bd2e72e18716dbe362 100644 (file)
@@ -69,7 +69,7 @@ static void frontend_changed(struct xenbus_watch *watch, const char *node)
                device_unregister(&be->dev->dev);
                return;
        }
-       if (vbd_is_active(&be->blkif->vbd))
+       if (be->blkif->status == CONNECTED)
                return;
 
        err = xenbus_gather(be->frontpath, "grant-id", "%lu", &sharedmfn,
@@ -82,9 +82,8 @@ static void frontend_changed(struct xenbus_watch *watch, const char *node)
        }
 
        /* Domains must use same shared frame for all vbds. */
-       if (be->blkif->status == CONNECTED &&
-           (evtchn != be->blkif->remote_evtchn ||
-            sharedmfn != be->blkif->shmem_frame)) {
+       if (evtchn != be->blkif->remote_evtchn ||
+           sharedmfn != be->blkif->shmem_frame) {
                xenbus_dev_error(be->dev, err,
                                 "Shared frame/evtchn %li/%u not same as"
                                 " old %li/%u",
@@ -125,20 +124,15 @@ static void frontend_changed(struct xenbus_watch *watch, const char *node)
                goto abort;
        }
 
-       /* First vbd?  We need to map the shared frame, irq etc. */
-       if (be->blkif->status != CONNECTED) {
-               err = blkif_map(be->blkif, sharedmfn, evtchn);
-               if (err) {
-                       xenbus_dev_error(be->dev, err,
-                                        "mapping shared-frame %lu port %u",
-                                        sharedmfn, evtchn);
-                       goto abort;
-               }
+       /* Map the shared frame, irq etc. */
+       err = blkif_map(be->blkif, sharedmfn, evtchn);
+       if (err) {
+               xenbus_dev_error(be->dev, err,
+                                "mapping shared-frame %lu port %u",
+                                sharedmfn, evtchn);
+               goto abort;
        }
 
-       /* We're ready, activate. */
-       vbd_activate(&be->blkif->vbd);
-
        xenbus_transaction_end(0);
        xenbus_dev_ok(be->dev);