virtio_blk.c (f4953fe6c4aeada2d5cafd78aa97587a46d2d8f9) | virtio_blk.c (8d85fce77edfc22f1d6dbf78e3af723b4b556f3d) |
---|---|
1//#define DEBUG 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> --- 682 unchanged lines hidden (view full) --- 691 692static const struct device_attribute dev_attr_cache_type_ro = 693 __ATTR(cache_type, S_IRUGO, 694 virtblk_cache_type_show, NULL); 695static const struct device_attribute dev_attr_cache_type_rw = 696 __ATTR(cache_type, S_IRUGO|S_IWUSR, 697 virtblk_cache_type_show, virtblk_cache_type_store); 698 | 1//#define DEBUG 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> --- 682 unchanged lines hidden (view full) --- 691 692static const struct device_attribute dev_attr_cache_type_ro = 693 __ATTR(cache_type, S_IRUGO, 694 virtblk_cache_type_show, NULL); 695static const struct device_attribute dev_attr_cache_type_rw = 696 __ATTR(cache_type, S_IRUGO|S_IWUSR, 697 virtblk_cache_type_show, virtblk_cache_type_store); 698 |
699static int __devinit virtblk_probe(struct virtio_device *vdev) | 699static int virtblk_probe(struct virtio_device *vdev) |
700{ 701 struct virtio_blk *vblk; 702 struct request_queue *q; 703 int err, index; 704 int pool_size; 705 706 u64 cap; 707 u32 v, blk_size, sg_elems, opt_io_size; --- 172 unchanged lines hidden (view full) --- 880out_free_vblk: 881 kfree(vblk); 882out_free_index: 883 ida_simple_remove(&vd_index_ida, index); 884out: 885 return err; 886} 887 | 700{ 701 struct virtio_blk *vblk; 702 struct request_queue *q; 703 int err, index; 704 int pool_size; 705 706 u64 cap; 707 u32 v, blk_size, sg_elems, opt_io_size; --- 172 unchanged lines hidden (view full) --- 880out_free_vblk: 881 kfree(vblk); 882out_free_index: 883 ida_simple_remove(&vd_index_ida, index); 884out: 885 return err; 886} 887 |
888static void __devexit virtblk_remove(struct virtio_device *vdev) | 888static void virtblk_remove(struct virtio_device *vdev) |
889{ 890 struct virtio_blk *vblk = vdev->priv; 891 int index = vblk->index; | 889{ 890 struct virtio_blk *vblk = vdev->priv; 891 int index = vblk->index; |
892 int refc; | |
893 894 /* Prevent config work handler from accessing the device. */ 895 mutex_lock(&vblk->config_lock); 896 vblk->config_enable = false; 897 mutex_unlock(&vblk->config_lock); 898 899 del_gendisk(vblk->disk); 900 blk_cleanup_queue(vblk->disk->queue); 901 902 /* Stop all the virtqueues. */ 903 vdev->config->reset(vdev); 904 905 flush_work(&vblk->config_work); 906 | 892 893 /* Prevent config work handler from accessing the device. */ 894 mutex_lock(&vblk->config_lock); 895 vblk->config_enable = false; 896 mutex_unlock(&vblk->config_lock); 897 898 del_gendisk(vblk->disk); 899 blk_cleanup_queue(vblk->disk->queue); 900 901 /* Stop all the virtqueues. */ 902 vdev->config->reset(vdev); 903 904 flush_work(&vblk->config_work); 905 |
907 refc = atomic_read(&disk_to_dev(vblk->disk)->kobj.kref.refcount); | |
908 put_disk(vblk->disk); 909 mempool_destroy(vblk->pool); 910 vdev->config->del_vqs(vdev); 911 kfree(vblk); | 906 put_disk(vblk->disk); 907 mempool_destroy(vblk->pool); 908 vdev->config->del_vqs(vdev); 909 kfree(vblk); |
912 913 /* Only free device id if we don't have any users */ 914 if (refc == 1) 915 ida_simple_remove(&vd_index_ida, index); | 910 ida_simple_remove(&vd_index_ida, index); |
916} 917 918#ifdef CONFIG_PM 919static int virtblk_freeze(struct virtio_device *vdev) 920{ 921 struct virtio_blk *vblk = vdev->priv; 922 923 /* Ensure we don't receive any more interrupts */ --- 37 unchanged lines hidden (view full) --- 961}; 962 963static unsigned int features[] = { 964 VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX, VIRTIO_BLK_F_GEOMETRY, 965 VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE, VIRTIO_BLK_F_SCSI, 966 VIRTIO_BLK_F_WCE, VIRTIO_BLK_F_TOPOLOGY, VIRTIO_BLK_F_CONFIG_WCE 967}; 968 | 911} 912 913#ifdef CONFIG_PM 914static int virtblk_freeze(struct virtio_device *vdev) 915{ 916 struct virtio_blk *vblk = vdev->priv; 917 918 /* Ensure we don't receive any more interrupts */ --- 37 unchanged lines hidden (view full) --- 956}; 957 958static unsigned int features[] = { 959 VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX, VIRTIO_BLK_F_GEOMETRY, 960 VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE, VIRTIO_BLK_F_SCSI, 961 VIRTIO_BLK_F_WCE, VIRTIO_BLK_F_TOPOLOGY, VIRTIO_BLK_F_CONFIG_WCE 962}; 963 |
969/* 970 * virtio_blk causes spurious section mismatch warning by 971 * simultaneously referring to a __devinit and a __devexit function. 972 * Use __refdata to avoid this warning. 973 */ 974static struct virtio_driver __refdata virtio_blk = { | 964static struct virtio_driver virtio_blk = { |
975 .feature_table = features, 976 .feature_table_size = ARRAY_SIZE(features), 977 .driver.name = KBUILD_MODNAME, 978 .driver.owner = THIS_MODULE, 979 .id_table = id_table, 980 .probe = virtblk_probe, | 965 .feature_table = features, 966 .feature_table_size = ARRAY_SIZE(features), 967 .driver.name = KBUILD_MODNAME, 968 .driver.owner = THIS_MODULE, 969 .id_table = id_table, 970 .probe = virtblk_probe, |
981 .remove = __devexit_p(virtblk_remove), | 971 .remove = virtblk_remove, |
982 .config_changed = virtblk_config_changed, 983#ifdef CONFIG_PM 984 .freeze = virtblk_freeze, 985 .restore = virtblk_restore, 986#endif 987}; 988 989static int __init init(void) --- 37 unchanged lines hidden --- | 972 .config_changed = virtblk_config_changed, 973#ifdef CONFIG_PM 974 .freeze = virtblk_freeze, 975 .restore = virtblk_restore, 976#endif 977}; 978 979static int __init init(void) --- 37 unchanged lines hidden --- |