Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F162637925
D57247.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D57247.diff
View Options
diff --git a/sys/dev/virtio/scsi/virtio_scsi.h b/sys/dev/virtio/scsi/virtio_scsi.h
--- a/sys/dev/virtio/scsi/virtio_scsi.h
+++ b/sys/dev/virtio/scsi/virtio_scsi.h
@@ -162,6 +162,15 @@
#define VIRTIO_SCSI_T_ASYNC_NOTIFY 2
#define VIRTIO_SCSI_T_PARAM_CHANGE 3
+/*
+ * SCSI ASC/ASCQ Sense Codes
+ * https://www.t10.org/lists/asc-num.txt
+ */
+#define VIRTIO_SCSI_ASC(x) ((x) & 0xff)
+#define VIRTIO_SCSI_ASCQ(x) (((x) >> 8) & 0xff)
+#define VIRTIO_SCSI_CAPACITY_CHNG_ASC 0x2a
+#define VIRTIO_SCSI_CAPACITY_CHNG_ASCQ 0x09
+
/* Reasons of transport reset event */
#define VIRTIO_SCSI_EVT_RESET_HARD 0
#define VIRTIO_SCSI_EVT_RESET_RESCAN 1
diff --git a/sys/dev/virtio/scsi/virtio_scsi.c b/sys/dev/virtio/scsi/virtio_scsi.c
--- a/sys/dev/virtio/scsi/virtio_scsi.c
+++ b/sys/dev/virtio/scsi/virtio_scsi.c
@@ -1786,6 +1786,27 @@
}
}
+static void
+vtscsi_param_change_event(struct vtscsi_softc *sc,
+ struct virtio_scsi_event *event)
+{
+ target_id_t target_id;
+ lun_id_t lun_id;
+
+ vtscsi_get_request_lun(event->lun, &target_id, &lun_id);
+
+ if (VIRTIO_SCSI_ASC(event->reason) == VIRTIO_SCSI_CAPACITY_CHNG_ASC &&
+ VIRTIO_SCSI_ASCQ(event->reason) == VIRTIO_SCSI_CAPACITY_CHNG_ASCQ) {
+ /* Disk capacity has changed. */
+ vtscsi_announce(sc, AC_INQ_CHANGED, target_id, lun_id);
+ } else {
+ device_printf(sc->vtscsi_dev,
+ "unhandled PARAM_CHANGE event. ASC: %02x, ASCQ: %02x\n",
+ VIRTIO_SCSI_ASC(event->reason),
+ VIRTIO_SCSI_ASCQ(event->reason));
+ }
+}
+
static void
vtscsi_handle_event(struct vtscsi_softc *sc, struct virtio_scsi_event *event)
{
@@ -1796,6 +1817,9 @@
case VIRTIO_SCSI_T_TRANSPORT_RESET:
vtscsi_transport_reset_event(sc, event);
break;
+ case VIRTIO_SCSI_T_PARAM_CHANGE:
+ vtscsi_param_change_event(sc, event);
+ break;
default:
device_printf(sc->vtscsi_dev,
"unhandled event: %d\n", event->event);
diff --git a/sys/dev/virtio/scsi/virtio_scsivar.h b/sys/dev/virtio/scsi/virtio_scsivar.h
--- a/sys/dev/virtio/scsi/virtio_scsivar.h
+++ b/sys/dev/virtio/scsi/virtio_scsivar.h
@@ -139,6 +139,7 @@
/* Features desired/implemented by this driver. */
#define VTSCSI_FEATURES \
(VIRTIO_SCSI_F_HOTPLUG | \
+ VIRTIO_SCSI_F_CHANGE | \
VIRTIO_RING_F_INDIRECT_DESC)
#define VTSCSI_MTX(_sc) &(_sc)->vtscsi_mtx
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 16, 7:24 AM (14 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35129256
Default Alt Text
D57247.diff (2 KB)
Attached To
Mode
D57247: virtio-scsi: handle device capacity change event
Attached
Detach File
Event Timeline
Log In to Comment