From: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
To: rusty@rustcorp.com.au, virtualization@lists.linux-foundation.org
Cc: borntraeger@de.ibm.com, mst@redhat.com
Subject: [PATCH v2 RFC 2/3] virtio_blk: add virtblk_notify() as virtio_driver's notify() callback
Date: Thu, 21 Nov 2013 15:45:32 +0100 [thread overview]
Message-ID: <1385045133-2165-3-git-send-email-graalfs@linux.vnet.ibm.com> (raw)
In-Reply-To: <1385045133-2165-1-git-send-email-graalfs@linux.vnet.ibm.com>
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@linux.vnet.ibm.com>
---
drivers/block/virtio_blk.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 2d43be4..04fd635 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -11,6 +11,7 @@
#include <linux/string_helpers.h>
#include <scsi/scsi_cmnd.h>
#include <linux/idr.h>
+#include <linux/notifier.h>
#define PART_BITS 4
@@ -901,6 +902,21 @@ 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;
+ unsigned long flags;
+
+ if (event == VDEV_GONE) {
+ spin_lock_irqsave(vblk->disk->queue->queue_lock, flags);
+ queue_flag_set(QUEUE_FLAG_DYING, vblk->disk->queue);
+ queue_flag_set(QUEUE_FLAG_NOMERGES, vblk->disk->queue);
+ queue_flag_set(QUEUE_FLAG_NOXMERGES, vblk->disk->queue);
+ spin_unlock_irqrestore(vblk->disk->queue->queue_lock, flags);
+ }
+ return NOTIFY_DONE;
+}
+
#ifdef CONFIG_PM
static int virtblk_freeze(struct virtio_device *vdev)
{
@@ -961,6 +977,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
next prev parent reply other threads:[~2013-11-21 14:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-21 14:45 [PATCH v2 RFC 0/3] virtio: add new notify() callback to virtio_driver Heinz Graalfs
2013-11-21 14:45 ` [PATCH v2 RFC 1/3] virtio: add " Heinz Graalfs
2013-11-21 15:18 ` Michael S. Tsirkin
2013-11-21 14:45 ` Heinz Graalfs [this message]
2013-11-21 14:45 ` [PATCH v2 RFC 3/3] virtio_ccw: invoke virtio_driver's notify() on CIO_GONE notification Heinz Graalfs
2013-11-21 15:15 ` Michael S. Tsirkin
2013-11-21 17:12 ` Heinz Graalfs
2013-11-21 18:31 ` Michael S. Tsirkin
2013-11-27 10:32 ` Heinz Graalfs
2013-11-27 10:42 ` Michael S. Tsirkin
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=1385045133-2165-3-git-send-email-graalfs@linux.vnet.ibm.com \
--to=graalfs@linux.vnet.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=mst@redhat.com \
--cc=rusty@rustcorp.com.au \
--cc=virtualization@lists.linux-foundation.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).