2 #include <linux/spinlock.h>
3 #include <linux/slab.h>
4 #include <linux/blkdev.h>
5 #include <linux/hdreg.h>
6 #include <linux/module.h>
7 #include <linux/mutex.h>
8 #include <linux/virtio.h>
9 #include <linux/virtio_blk.h>
10 #include <linux/scatterlist.h>
11 #include <linux/string_helpers.h>
12 #include <scsi/scsi_cmnd.h>
13 #include <linux/idr.h>
14 #include <linux/blk-mq.h>
15 #include <linux/numa.h>
20 static DEFINE_IDA(vd_index_ida);
22 static struct workqueue_struct *virtblk_wq;
26 struct virtio_device *vdev;
30 /* The disk structure for the kernel. */
33 /* Block layer tags. */
34 struct blk_mq_tag_set tag_set;
36 /* Process context for config space updates */
37 struct work_struct config_work;
39 /* Lock for config space updates */
40 struct mutex config_lock;
42 /* enable config space updates */
45 /* What host tells us, plus 2 for header & tailer. */
46 unsigned int sg_elems;
48 /* Ida index - used to track minor number allocations. */
55 struct virtio_blk_outhdr out_hdr;
56 struct virtio_scsi_inhdr in_hdr;
58 struct scatterlist sg[];
61 static inline int virtblk_result(struct virtblk_req *vbr)
63 switch (vbr->status) {
66 case VIRTIO_BLK_S_UNSUPP:
73 static int __virtblk_add_req(struct virtqueue *vq,
74 struct virtblk_req *vbr,
75 struct scatterlist *data_sg,
78 struct scatterlist hdr, status, cmd, sense, inhdr, *sgs[6];
79 unsigned int num_out = 0, num_in = 0;
80 int type = vbr->out_hdr.type & ~VIRTIO_BLK_T_OUT;
82 sg_init_one(&hdr, &vbr->out_hdr, sizeof(vbr->out_hdr));
83 sgs[num_out++] = &hdr;
86 * If this is a packet command we need a couple of additional headers.
87 * Behind the normal outhdr we put a segment with the scsi command
88 * block, and before the normal inhdr we put the sense data and the
89 * inhdr with additional status information.
91 if (type == VIRTIO_BLK_T_SCSI_CMD) {
92 sg_init_one(&cmd, vbr->req->cmd, vbr->req->cmd_len);
93 sgs[num_out++] = &cmd;
97 if (vbr->out_hdr.type & VIRTIO_BLK_T_OUT)
98 sgs[num_out++] = data_sg;
100 sgs[num_out + num_in++] = data_sg;
103 if (type == VIRTIO_BLK_T_SCSI_CMD) {
104 sg_init_one(&sense, vbr->req->sense, SCSI_SENSE_BUFFERSIZE);
105 sgs[num_out + num_in++] = &sense;
106 sg_init_one(&inhdr, &vbr->in_hdr, sizeof(vbr->in_hdr));
107 sgs[num_out + num_in++] = &inhdr;
110 sg_init_one(&status, &vbr->status, sizeof(vbr->status));
111 sgs[num_out + num_in++] = &status;
113 return virtqueue_add_sgs(vq, sgs, num_out, num_in, vbr, GFP_ATOMIC);
116 static inline void virtblk_request_done(struct request *req)
118 struct virtblk_req *vbr = blk_mq_rq_to_pdu(req);
119 int error = virtblk_result(vbr);
121 if (req->cmd_type == REQ_TYPE_BLOCK_PC) {
122 req->resid_len = vbr->in_hdr.residual;
123 req->sense_len = vbr->in_hdr.sense_len;
124 req->errors = vbr->in_hdr.errors;
125 } else if (req->cmd_type == REQ_TYPE_SPECIAL) {
126 req->errors = (error != 0);
129 blk_mq_end_io(req, error);
132 static void virtblk_done(struct virtqueue *vq)
134 struct virtio_blk *vblk = vq->vdev->priv;
135 bool req_done = false;
136 struct virtblk_req *vbr;
140 spin_lock_irqsave(&vblk->vq_lock, flags);
142 virtqueue_disable_cb(vq);
143 while ((vbr = virtqueue_get_buf(vblk->vq, &len)) != NULL) {
144 blk_mq_complete_request(vbr->req);
147 if (unlikely(virtqueue_is_broken(vq)))
149 } while (!virtqueue_enable_cb(vq));
151 /* In case queue is stopped waiting for more buffers. */
153 blk_mq_start_stopped_hw_queues(vblk->disk->queue, true);
154 spin_unlock_irqrestore(&vblk->vq_lock, flags);
157 static int virtio_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req)
159 struct virtio_blk *vblk = hctx->queue->queuedata;
160 struct virtblk_req *vbr = blk_mq_rq_to_pdu(req);
163 const bool last = (req->cmd_flags & REQ_END) != 0;
166 BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
169 if (req->cmd_flags & REQ_FLUSH) {
170 vbr->out_hdr.type = VIRTIO_BLK_T_FLUSH;
171 vbr->out_hdr.sector = 0;
172 vbr->out_hdr.ioprio = req_get_ioprio(vbr->req);
174 switch (req->cmd_type) {
176 vbr->out_hdr.type = 0;
177 vbr->out_hdr.sector = blk_rq_pos(vbr->req);
178 vbr->out_hdr.ioprio = req_get_ioprio(vbr->req);
180 case REQ_TYPE_BLOCK_PC:
181 vbr->out_hdr.type = VIRTIO_BLK_T_SCSI_CMD;
182 vbr->out_hdr.sector = 0;
183 vbr->out_hdr.ioprio = req_get_ioprio(vbr->req);
185 case REQ_TYPE_SPECIAL:
186 vbr->out_hdr.type = VIRTIO_BLK_T_GET_ID;
187 vbr->out_hdr.sector = 0;
188 vbr->out_hdr.ioprio = req_get_ioprio(vbr->req);
191 /* We don't put anything else in the queue. */
196 num = blk_rq_map_sg(hctx->queue, vbr->req, vbr->sg);
198 if (rq_data_dir(vbr->req) == WRITE)
199 vbr->out_hdr.type |= VIRTIO_BLK_T_OUT;
201 vbr->out_hdr.type |= VIRTIO_BLK_T_IN;
204 spin_lock_irqsave(&vblk->vq_lock, flags);
205 err = __virtblk_add_req(vblk->vq, vbr, vbr->sg, num);
207 virtqueue_kick(vblk->vq);
208 blk_mq_stop_hw_queue(hctx);
209 spin_unlock_irqrestore(&vblk->vq_lock, flags);
210 /* Out of mem doesn't actually happen, since we fall back
211 * to direct descriptors */
212 if (err == -ENOMEM || err == -ENOSPC)
213 return BLK_MQ_RQ_QUEUE_BUSY;
214 return BLK_MQ_RQ_QUEUE_ERROR;
218 virtqueue_kick(vblk->vq);
220 spin_unlock_irqrestore(&vblk->vq_lock, flags);
221 return BLK_MQ_RQ_QUEUE_OK;
224 /* return id (s/n) string for *disk to *id_str
226 static int virtblk_get_id(struct gendisk *disk, char *id_str)
228 struct virtio_blk *vblk = disk->private_data;
233 bio = bio_map_kern(vblk->disk->queue, id_str, VIRTIO_BLK_ID_BYTES,
238 req = blk_make_request(vblk->disk->queue, bio, GFP_KERNEL);
244 req->cmd_type = REQ_TYPE_SPECIAL;
245 err = blk_execute_rq(vblk->disk->queue, vblk->disk, req, false);
246 blk_put_request(req);
251 static int virtblk_ioctl(struct block_device *bdev, fmode_t mode,
252 unsigned int cmd, unsigned long data)
254 struct gendisk *disk = bdev->bd_disk;
255 struct virtio_blk *vblk = disk->private_data;
258 * Only allow the generic SCSI ioctls if the host can support it.
260 if (!virtio_has_feature(vblk->vdev, VIRTIO_BLK_F_SCSI))
263 return scsi_cmd_blk_ioctl(bdev, mode, cmd,
264 (void __user *)data);
267 /* We provide getgeo only to please some old bootloader/partitioning tools */
268 static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo)
270 struct virtio_blk *vblk = bd->bd_disk->private_data;
272 /* see if the host passed in geometry config */
273 if (virtio_has_feature(vblk->vdev, VIRTIO_BLK_F_GEOMETRY)) {
274 virtio_cread(vblk->vdev, struct virtio_blk_config,
275 geometry.cylinders, &geo->cylinders);
276 virtio_cread(vblk->vdev, struct virtio_blk_config,
277 geometry.heads, &geo->heads);
278 virtio_cread(vblk->vdev, struct virtio_blk_config,
279 geometry.sectors, &geo->sectors);
281 /* some standard values, similar to sd */
283 geo->sectors = 1 << 5;
284 geo->cylinders = get_capacity(bd->bd_disk) >> 11;
289 static const struct block_device_operations virtblk_fops = {
290 .ioctl = virtblk_ioctl,
291 .owner = THIS_MODULE,
292 .getgeo = virtblk_getgeo,
295 static int index_to_minor(int index)
297 return index << PART_BITS;
300 static int minor_to_index(int minor)
302 return minor >> PART_BITS;
305 static ssize_t virtblk_serial_show(struct device *dev,
306 struct device_attribute *attr, char *buf)
308 struct gendisk *disk = dev_to_disk(dev);
311 /* sysfs gives us a PAGE_SIZE buffer */
312 BUILD_BUG_ON(PAGE_SIZE < VIRTIO_BLK_ID_BYTES);
314 buf[VIRTIO_BLK_ID_BYTES] = '\0';
315 err = virtblk_get_id(disk, buf);
319 if (err == -EIO) /* Unsupported? Make it empty. */
324 DEVICE_ATTR(serial, S_IRUGO, virtblk_serial_show, NULL);
326 static void virtblk_config_changed_work(struct work_struct *work)
328 struct virtio_blk *vblk =
329 container_of(work, struct virtio_blk, config_work);
330 struct virtio_device *vdev = vblk->vdev;
331 struct request_queue *q = vblk->disk->queue;
332 char cap_str_2[10], cap_str_10[10];
333 char *envp[] = { "RESIZE=1", NULL };
336 mutex_lock(&vblk->config_lock);
337 if (!vblk->config_enable)
340 /* Host must always specify the capacity. */
341 virtio_cread(vdev, struct virtio_blk_config, capacity, &capacity);
343 /* If capacity is too big, truncate with warning. */
344 if ((sector_t)capacity != capacity) {
345 dev_warn(&vdev->dev, "Capacity %llu too large: truncating\n",
346 (unsigned long long)capacity);
347 capacity = (sector_t)-1;
350 size = capacity * queue_logical_block_size(q);
351 string_get_size(size, STRING_UNITS_2, cap_str_2, sizeof(cap_str_2));
352 string_get_size(size, STRING_UNITS_10, cap_str_10, sizeof(cap_str_10));
354 dev_notice(&vdev->dev,
355 "new size: %llu %d-byte logical blocks (%s/%s)\n",
356 (unsigned long long)capacity,
357 queue_logical_block_size(q),
358 cap_str_10, cap_str_2);
360 set_capacity(vblk->disk, capacity);
361 revalidate_disk(vblk->disk);
362 kobject_uevent_env(&disk_to_dev(vblk->disk)->kobj, KOBJ_CHANGE, envp);
364 mutex_unlock(&vblk->config_lock);
367 static void virtblk_config_changed(struct virtio_device *vdev)
369 struct virtio_blk *vblk = vdev->priv;
371 queue_work(virtblk_wq, &vblk->config_work);
374 static int init_vq(struct virtio_blk *vblk)
378 /* We expect one virtqueue, for output. */
379 vblk->vq = virtio_find_single_vq(vblk->vdev, virtblk_done, "requests");
380 if (IS_ERR(vblk->vq))
381 err = PTR_ERR(vblk->vq);
387 * Legacy naming scheme used for virtio devices. We are stuck with it for
388 * virtio blk but don't ever use it for any new driver.
390 static int virtblk_name_format(char *prefix, int index, char *buf, int buflen)
392 const int base = 'z' - 'a' + 1;
393 char *begin = buf + strlen(prefix);
394 char *end = buf + buflen;
404 *--p = 'a' + (index % unit);
405 index = (index / unit) - 1;
406 } while (index >= 0);
408 memmove(begin, p, end - p);
409 memcpy(buf, prefix, strlen(prefix));
414 static int virtblk_get_cache_mode(struct virtio_device *vdev)
419 err = virtio_cread_feature(vdev, VIRTIO_BLK_F_CONFIG_WCE,
420 struct virtio_blk_config, wce,
423 writeback = virtio_has_feature(vdev, VIRTIO_BLK_F_WCE);
428 static void virtblk_update_cache_mode(struct virtio_device *vdev)
430 u8 writeback = virtblk_get_cache_mode(vdev);
431 struct virtio_blk *vblk = vdev->priv;
434 blk_queue_flush(vblk->disk->queue, REQ_FLUSH);
436 blk_queue_flush(vblk->disk->queue, 0);
438 revalidate_disk(vblk->disk);
441 static const char *const virtblk_cache_types[] = {
442 "write through", "write back"
446 virtblk_cache_type_store(struct device *dev, struct device_attribute *attr,
447 const char *buf, size_t count)
449 struct gendisk *disk = dev_to_disk(dev);
450 struct virtio_blk *vblk = disk->private_data;
451 struct virtio_device *vdev = vblk->vdev;
454 BUG_ON(!virtio_has_feature(vblk->vdev, VIRTIO_BLK_F_CONFIG_WCE));
455 for (i = ARRAY_SIZE(virtblk_cache_types); --i >= 0; )
456 if (sysfs_streq(buf, virtblk_cache_types[i]))
462 virtio_cwrite8(vdev, offsetof(struct virtio_blk_config, wce), i);
463 virtblk_update_cache_mode(vdev);
468 virtblk_cache_type_show(struct device *dev, struct device_attribute *attr,
471 struct gendisk *disk = dev_to_disk(dev);
472 struct virtio_blk *vblk = disk->private_data;
473 u8 writeback = virtblk_get_cache_mode(vblk->vdev);
475 BUG_ON(writeback >= ARRAY_SIZE(virtblk_cache_types));
476 return snprintf(buf, 40, "%s\n", virtblk_cache_types[writeback]);
479 static const struct device_attribute dev_attr_cache_type_ro =
480 __ATTR(cache_type, S_IRUGO,
481 virtblk_cache_type_show, NULL);
482 static const struct device_attribute dev_attr_cache_type_rw =
483 __ATTR(cache_type, S_IRUGO|S_IWUSR,
484 virtblk_cache_type_show, virtblk_cache_type_store);
486 static int virtblk_init_request(void *data, struct request *rq,
487 unsigned int hctx_idx, unsigned int request_idx,
488 unsigned int numa_node)
490 struct virtio_blk *vblk = data;
491 struct virtblk_req *vbr = blk_mq_rq_to_pdu(rq);
493 sg_init_table(vbr->sg, vblk->sg_elems);
497 static struct blk_mq_ops virtio_mq_ops = {
498 .queue_rq = virtio_queue_rq,
499 .map_queue = blk_mq_map_queue,
500 .complete = virtblk_request_done,
501 .init_request = virtblk_init_request,
504 static unsigned int virtblk_queue_depth;
505 module_param_named(queue_depth, virtblk_queue_depth, uint, 0444);
507 static int virtblk_probe(struct virtio_device *vdev)
509 struct virtio_blk *vblk;
510 struct request_queue *q;
514 u32 v, blk_size, sg_elems, opt_io_size;
516 u8 physical_block_exp, alignment_offset;
518 err = ida_simple_get(&vd_index_ida, 0, minor_to_index(1 << MINORBITS),
524 /* We need to know how many segments before we allocate. */
525 err = virtio_cread_feature(vdev, VIRTIO_BLK_F_SEG_MAX,
526 struct virtio_blk_config, seg_max,
529 /* We need at least one SG element, whatever they say. */
530 if (err || !sg_elems)
533 /* We need an extra sg elements at head and tail. */
535 vdev->priv = vblk = kmalloc(sizeof(*vblk), GFP_KERNEL);
542 vblk->sg_elems = sg_elems;
543 mutex_init(&vblk->config_lock);
545 INIT_WORK(&vblk->config_work, virtblk_config_changed_work);
546 vblk->config_enable = true;
551 spin_lock_init(&vblk->vq_lock);
553 /* FIXME: How many partitions? How long is a piece of string? */
554 vblk->disk = alloc_disk(1 << PART_BITS);
560 /* Default queue sizing is to fill the ring. */
561 if (!virtblk_queue_depth) {
562 virtblk_queue_depth = vblk->vq->num_free;
563 /* ... but without indirect descs, we use 2 descs per req */
564 if (!virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC))
565 virtblk_queue_depth /= 2;
568 memset(&vblk->tag_set, 0, sizeof(vblk->tag_set));
569 vblk->tag_set.ops = &virtio_mq_ops;
570 vblk->tag_set.nr_hw_queues = 1;
571 vblk->tag_set.queue_depth = virtblk_queue_depth;
572 vblk->tag_set.numa_node = NUMA_NO_NODE;
573 vblk->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
574 vblk->tag_set.cmd_size =
575 sizeof(struct virtblk_req) +
576 sizeof(struct scatterlist) * sg_elems;
577 vblk->tag_set.driver_data = vblk;
579 err = blk_mq_alloc_tag_set(&vblk->tag_set);
583 q = vblk->disk->queue = blk_mq_init_queue(&vblk->tag_set);
591 virtblk_name_format("vd", index, vblk->disk->disk_name, DISK_NAME_LEN);
593 vblk->disk->major = major;
594 vblk->disk->first_minor = index_to_minor(index);
595 vblk->disk->private_data = vblk;
596 vblk->disk->fops = &virtblk_fops;
597 vblk->disk->driverfs_dev = &vdev->dev;
600 /* configure queue flush support */
601 virtblk_update_cache_mode(vdev);
603 /* If disk is read-only in the host, the guest should obey */
604 if (virtio_has_feature(vdev, VIRTIO_BLK_F_RO))
605 set_disk_ro(vblk->disk, 1);
607 /* Host must always specify the capacity. */
608 virtio_cread(vdev, struct virtio_blk_config, capacity, &cap);
610 /* If capacity is too big, truncate with warning. */
611 if ((sector_t)cap != cap) {
612 dev_warn(&vdev->dev, "Capacity %llu too large: truncating\n",
613 (unsigned long long)cap);
616 set_capacity(vblk->disk, cap);
618 /* We can handle whatever the host told us to handle. */
619 blk_queue_max_segments(q, vblk->sg_elems-2);
621 /* No need to bounce any requests */
622 blk_queue_bounce_limit(q, BLK_BOUNCE_ANY);
624 /* No real sector limit. */
625 blk_queue_max_hw_sectors(q, -1U);
627 /* Host can optionally specify maximum segment size and number of
629 err = virtio_cread_feature(vdev, VIRTIO_BLK_F_SIZE_MAX,
630 struct virtio_blk_config, size_max, &v);
632 blk_queue_max_segment_size(q, v);
634 blk_queue_max_segment_size(q, -1U);
636 /* Host can optionally specify the block size of the device */
637 err = virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE,
638 struct virtio_blk_config, blk_size,
641 blk_queue_logical_block_size(q, blk_size);
643 blk_size = queue_logical_block_size(q);
645 /* Use topology information if available */
646 err = virtio_cread_feature(vdev, VIRTIO_BLK_F_TOPOLOGY,
647 struct virtio_blk_config, physical_block_exp,
648 &physical_block_exp);
649 if (!err && physical_block_exp)
650 blk_queue_physical_block_size(q,
651 blk_size * (1 << physical_block_exp));
653 err = virtio_cread_feature(vdev, VIRTIO_BLK_F_TOPOLOGY,
654 struct virtio_blk_config, alignment_offset,
656 if (!err && alignment_offset)
657 blk_queue_alignment_offset(q, blk_size * alignment_offset);
659 err = virtio_cread_feature(vdev, VIRTIO_BLK_F_TOPOLOGY,
660 struct virtio_blk_config, min_io_size,
662 if (!err && min_io_size)
663 blk_queue_io_min(q, blk_size * min_io_size);
665 err = virtio_cread_feature(vdev, VIRTIO_BLK_F_TOPOLOGY,
666 struct virtio_blk_config, opt_io_size,
668 if (!err && opt_io_size)
669 blk_queue_io_opt(q, blk_size * opt_io_size);
671 add_disk(vblk->disk);
672 err = device_create_file(disk_to_dev(vblk->disk), &dev_attr_serial);
676 if (virtio_has_feature(vdev, VIRTIO_BLK_F_CONFIG_WCE))
677 err = device_create_file(disk_to_dev(vblk->disk),
678 &dev_attr_cache_type_rw);
680 err = device_create_file(disk_to_dev(vblk->disk),
681 &dev_attr_cache_type_ro);
687 del_gendisk(vblk->disk);
688 blk_cleanup_queue(vblk->disk->queue);
690 blk_mq_free_tag_set(&vblk->tag_set);
692 put_disk(vblk->disk);
694 vdev->config->del_vqs(vdev);
698 ida_simple_remove(&vd_index_ida, index);
703 static void virtblk_remove(struct virtio_device *vdev)
705 struct virtio_blk *vblk = vdev->priv;
706 int index = vblk->index;
709 /* Prevent config work handler from accessing the device. */
710 mutex_lock(&vblk->config_lock);
711 vblk->config_enable = false;
712 mutex_unlock(&vblk->config_lock);
714 del_gendisk(vblk->disk);
715 blk_cleanup_queue(vblk->disk->queue);
717 blk_mq_free_tag_set(&vblk->tag_set);
719 /* Stop all the virtqueues. */
720 vdev->config->reset(vdev);
722 flush_work(&vblk->config_work);
724 refc = atomic_read(&disk_to_dev(vblk->disk)->kobj.kref.refcount);
725 put_disk(vblk->disk);
726 vdev->config->del_vqs(vdev);
729 /* Only free device id if we don't have any users */
731 ida_simple_remove(&vd_index_ida, index);
734 #ifdef CONFIG_PM_SLEEP
735 static int virtblk_freeze(struct virtio_device *vdev)
737 struct virtio_blk *vblk = vdev->priv;
739 /* Ensure we don't receive any more interrupts */
740 vdev->config->reset(vdev);
742 /* Prevent config work handler from accessing the device. */
743 mutex_lock(&vblk->config_lock);
744 vblk->config_enable = false;
745 mutex_unlock(&vblk->config_lock);
747 flush_work(&vblk->config_work);
749 blk_mq_stop_hw_queues(vblk->disk->queue);
751 vdev->config->del_vqs(vdev);
755 static int virtblk_restore(struct virtio_device *vdev)
757 struct virtio_blk *vblk = vdev->priv;
760 vblk->config_enable = true;
761 ret = init_vq(vdev->priv);
763 blk_mq_start_stopped_hw_queues(vblk->disk->queue, true);
769 static const struct virtio_device_id id_table[] = {
770 { VIRTIO_ID_BLOCK, VIRTIO_DEV_ANY_ID },
774 static unsigned int features[] = {
775 VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX, VIRTIO_BLK_F_GEOMETRY,
776 VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE, VIRTIO_BLK_F_SCSI,
777 VIRTIO_BLK_F_WCE, VIRTIO_BLK_F_TOPOLOGY, VIRTIO_BLK_F_CONFIG_WCE
780 static struct virtio_driver virtio_blk = {
781 .feature_table = features,
782 .feature_table_size = ARRAY_SIZE(features),
783 .driver.name = KBUILD_MODNAME,
784 .driver.owner = THIS_MODULE,
785 .id_table = id_table,
786 .probe = virtblk_probe,
787 .remove = virtblk_remove,
788 .config_changed = virtblk_config_changed,
789 #ifdef CONFIG_PM_SLEEP
790 .freeze = virtblk_freeze,
791 .restore = virtblk_restore,
795 static int __init init(void)
799 virtblk_wq = alloc_workqueue("virtio-blk", 0, 0);
803 major = register_blkdev(0, "virtblk");
806 goto out_destroy_workqueue;
809 error = register_virtio_driver(&virtio_blk);
811 goto out_unregister_blkdev;
814 out_unregister_blkdev:
815 unregister_blkdev(major, "virtblk");
816 out_destroy_workqueue:
817 destroy_workqueue(virtblk_wq);
821 static void __exit fini(void)
823 unregister_blkdev(major, "virtblk");
824 unregister_virtio_driver(&virtio_blk);
825 destroy_workqueue(virtblk_wq);
830 MODULE_DEVICE_TABLE(virtio, id_table);
831 MODULE_DESCRIPTION("Virtio block driver");
832 MODULE_LICENSE("GPL");