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 {
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);
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)
{
vbd->handle = handle;
vbd->readonly = readonly;
vbd->type = 0;
- vbd->active = 0;
vbd->pdevice = pdevice;
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;
}
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)
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,
}
/* 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",
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);