diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-10-02 11:25:48 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-10-09 06:24:47 -0400 |
commit | 865b58c05b841964f48f574c2027311bd04db8a1 (patch) | |
tree | 2559fdb2e8b8191caf97900be89758230f394607 /drivers/scsi | |
parent | 9da5f5ac6affad8dd8cd80f5cca26e4335e1728b (diff) |
[SCSI] virtio-scsi: support online resizing of disks
Support the LUN parameter change event. Currently, the host fires this event
when the capacity of a disk is changed from the virtual machine monitor.
The resize then appears in the kernel log like this:
sd 0:0:0:0: [sda] 46137344 512-byte logical blocks: (23.6 GB/22.0 GIb)
sda: detected capacity change from 22548578304 to 23622320128
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/virtio_scsi.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index a7cf726bc747..595af1ae4421 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c | |||
@@ -279,6 +279,31 @@ static void virtscsi_handle_transport_reset(struct virtio_scsi *vscsi, | |||
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | static void virtscsi_handle_param_change(struct virtio_scsi *vscsi, | ||
283 | struct virtio_scsi_event *event) | ||
284 | { | ||
285 | struct scsi_device *sdev; | ||
286 | struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev); | ||
287 | unsigned int target = event->lun[1]; | ||
288 | unsigned int lun = (event->lun[2] << 8) | event->lun[3]; | ||
289 | u8 asc = event->reason & 255; | ||
290 | u8 ascq = event->reason >> 8; | ||
291 | |||
292 | sdev = scsi_device_lookup(shost, 0, target, lun); | ||
293 | if (!sdev) { | ||
294 | pr_err("SCSI device %d 0 %d %d not found\n", | ||
295 | shost->host_no, target, lun); | ||
296 | return; | ||
297 | } | ||
298 | |||
299 | /* Handle "Parameters changed", "Mode parameters changed", and | ||
300 | "Capacity data has changed". */ | ||
301 | if (asc == 0x2a && (ascq == 0x00 || ascq == 0x01 || ascq == 0x09)) | ||
302 | scsi_rescan_device(&sdev->sdev_gendev); | ||
303 | |||
304 | scsi_device_put(sdev); | ||
305 | } | ||
306 | |||
282 | static void virtscsi_handle_event(struct work_struct *work) | 307 | static void virtscsi_handle_event(struct work_struct *work) |
283 | { | 308 | { |
284 | struct virtio_scsi_event_node *event_node = | 309 | struct virtio_scsi_event_node *event_node = |
@@ -297,6 +322,9 @@ static void virtscsi_handle_event(struct work_struct *work) | |||
297 | case VIRTIO_SCSI_T_TRANSPORT_RESET: | 322 | case VIRTIO_SCSI_T_TRANSPORT_RESET: |
298 | virtscsi_handle_transport_reset(vscsi, event); | 323 | virtscsi_handle_transport_reset(vscsi, event); |
299 | break; | 324 | break; |
325 | case VIRTIO_SCSI_T_PARAM_CHANGE: | ||
326 | virtscsi_handle_param_change(vscsi, event); | ||
327 | break; | ||
300 | default: | 328 | default: |
301 | pr_err("Unsupport virtio scsi event %x\n", event->event); | 329 | pr_err("Unsupport virtio scsi event %x\n", event->event); |
302 | } | 330 | } |
@@ -737,7 +765,8 @@ static struct virtio_device_id id_table[] = { | |||
737 | }; | 765 | }; |
738 | 766 | ||
739 | static unsigned int features[] = { | 767 | static unsigned int features[] = { |
740 | VIRTIO_SCSI_F_HOTPLUG | 768 | VIRTIO_SCSI_F_HOTPLUG, |
769 | VIRTIO_SCSI_F_CHANGE, | ||
741 | }; | 770 | }; |
742 | 771 | ||
743 | static struct virtio_driver virtio_scsi_driver = { | 772 | static struct virtio_driver virtio_scsi_driver = { |