On Wed, Nov 20, 2013 at 04:22:02PM +0100, Heinz Graalfs wrote: > Add virtblk_notify() as virtio_driver's notify() callback. > > When a transport driver is notified that a device disappeared it > should invoke this callback to prevent further request queueing. > > Subsequent block layer calls of virtio_blk's request function will > fail, resulting in appropriate I/O errors. > > Signed-off-by: Heinz Graalfs <graalfs@xxxxxxxxxxxxxxxxxx> > --- > drivers/block/virtio_blk.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c > index 2d43be4..7fc1d62 100644 > --- a/drivers/block/virtio_blk.c > +++ b/drivers/block/virtio_blk.c > @@ -901,6 +901,19 @@ static void virtblk_remove(struct virtio_device *vdev) > ida_simple_remove(&vd_index_ida, index); > } > > +static int virtblk_notify(struct virtio_device *vdev, int event) > +{ > + struct virtio_blk *vblk = vdev->priv; > + > + if (event == VDEV_GONE) { > + queue_flag_set_unlocked(QUEUE_FLAG_DYING, vblk->disk->queue); > + queue_flag_set_unlocked(QUEUE_FLAG_NOMERGES, vblk->disk->queue); > + queue_flag_set_unlocked(QUEUE_FLAG_NOXMERGES, > + vblk->disk->queue); > + } > + return NOTIFY_DONE; > +} > + But what serializes with the block layer? And is unlocked really safe here? Don't we need to take the queue lock? > #ifdef CONFIG_PM > static int virtblk_freeze(struct virtio_device *vdev) > { > @@ -961,6 +974,7 @@ static struct virtio_driver virtio_blk = { > .probe = virtblk_probe, > .remove = virtblk_remove, > .config_changed = virtblk_config_changed, > + .notify = virtblk_notify, > #ifdef CONFIG_PM > .freeze = virtblk_freeze, > .restore = virtblk_restore, > -- > 1.8.3.1 _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization