aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/block/virtio_blk.c37
-rw-r--r--include/linux/virtio_blk.h4
2 files changed, 3 insertions, 38 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 55635d1f697d..51042f0ba7e1 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -182,34 +182,6 @@ static void do_virtblk_request(struct request_queue *q)
182 vblk->vq->vq_ops->kick(vblk->vq); 182 vblk->vq->vq_ops->kick(vblk->vq);
183} 183}
184 184
185/* return ATA identify data
186 */
187static int virtblk_identify(struct gendisk *disk, void *argp)
188{
189 struct virtio_blk *vblk = disk->private_data;
190 void *opaque;
191 int err = -ENOMEM;
192
193 opaque = kmalloc(VIRTIO_BLK_ID_BYTES, GFP_KERNEL);
194 if (!opaque)
195 goto out;
196
197 err = virtio_config_buf(vblk->vdev, VIRTIO_BLK_F_IDENTIFY,
198 offsetof(struct virtio_blk_config, identify), opaque,
199 VIRTIO_BLK_ID_BYTES);
200
201 if (err)
202 goto out_kfree;
203
204 if (copy_to_user(argp, opaque, VIRTIO_BLK_ID_BYTES))
205 err = -EFAULT;
206
207out_kfree:
208 kfree(opaque);
209out:
210 return err;
211}
212
213static void virtblk_prepare_flush(struct request_queue *q, struct request *req) 185static void virtblk_prepare_flush(struct request_queue *q, struct request *req)
214{ 186{
215 req->cmd_type = REQ_TYPE_LINUX_BLOCK; 187 req->cmd_type = REQ_TYPE_LINUX_BLOCK;
@@ -221,10 +193,6 @@ static int virtblk_ioctl(struct block_device *bdev, fmode_t mode,
221{ 193{
222 struct gendisk *disk = bdev->bd_disk; 194 struct gendisk *disk = bdev->bd_disk;
223 struct virtio_blk *vblk = disk->private_data; 195 struct virtio_blk *vblk = disk->private_data;
224 void __user *argp = (void __user *)data;
225
226 if (cmd == HDIO_GET_IDENTITY)
227 return virtblk_identify(disk, argp);
228 196
229 /* 197 /*
230 * Only allow the generic SCSI ioctls if the host can support it. 198 * Only allow the generic SCSI ioctls if the host can support it.
@@ -232,7 +200,8 @@ static int virtblk_ioctl(struct block_device *bdev, fmode_t mode,
232 if (!virtio_has_feature(vblk->vdev, VIRTIO_BLK_F_SCSI)) 200 if (!virtio_has_feature(vblk->vdev, VIRTIO_BLK_F_SCSI))
233 return -ENOTTY; 201 return -ENOTTY;
234 202
235 return scsi_cmd_ioctl(disk->queue, disk, mode, cmd, argp); 203 return scsi_cmd_ioctl(disk->queue, disk, mode, cmd,
204 (void __user *)data);
236} 205}
237 206
238/* We provide getgeo only to please some old bootloader/partitioning tools */ 207/* We provide getgeo only to please some old bootloader/partitioning tools */
@@ -443,7 +412,7 @@ static struct virtio_device_id id_table[] = {
443static unsigned int features[] = { 412static unsigned int features[] = {
444 VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX, 413 VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX,
445 VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE, 414 VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE,
446 VIRTIO_BLK_F_SCSI, VIRTIO_BLK_F_IDENTIFY, VIRTIO_BLK_F_FLUSH 415 VIRTIO_BLK_F_SCSI, VIRTIO_BLK_F_FLUSH
447}; 416};
448 417
449/* 418/*
diff --git a/include/linux/virtio_blk.h b/include/linux/virtio_blk.h
index 1e19470d2da2..fd294c56d571 100644
--- a/include/linux/virtio_blk.h
+++ b/include/linux/virtio_blk.h
@@ -14,11 +14,8 @@
14#define VIRTIO_BLK_F_RO 5 /* Disk is read-only */ 14#define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
15#define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/ 15#define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/
16#define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */ 16#define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */
17#define VIRTIO_BLK_F_IDENTIFY 8 /* ATA IDENTIFY supported */
18#define VIRTIO_BLK_F_FLUSH 9 /* Cache flush command support */ 17#define VIRTIO_BLK_F_FLUSH 9 /* Cache flush command support */
19 18
20#define VIRTIO_BLK_ID_BYTES (sizeof(__u16[256])) /* IDENTIFY DATA */
21
22struct virtio_blk_config { 19struct virtio_blk_config {
23 /* The capacity (in 512-byte sectors). */ 20 /* The capacity (in 512-byte sectors). */
24 __u64 capacity; 21 __u64 capacity;
@@ -34,7 +31,6 @@ struct virtio_blk_config {
34 } geometry; 31 } geometry;
35 /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */ 32 /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
36 __u32 blk_size; 33 __u32 blk_size;
37 __u8 identify[VIRTIO_BLK_ID_BYTES];
38} __attribute__((packed)); 34} __attribute__((packed));
39 35
40/* 36/*