2 * Copyright (c) 2009, Microsoft Corporation.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307 USA.
18 * Haiyang Zhang <haiyangz@microsoft.com>
19 * Hank Janssen <hjanssen@microsoft.com>
21 #include <linux/init.h>
22 #include <linux/module.h>
23 #include <linux/device.h>
24 #include <linux/blkdev.h>
25 #include <linux/major.h>
26 #include <linux/delay.h>
27 #include <linux/hdreg.h>
28 #include <linux/mutex.h>
29 #include <linux/slab.h>
30 #include <scsi/scsi.h>
31 #include <scsi/scsi_cmnd.h>
32 #include <scsi/scsi_eh.h>
33 #include <scsi/scsi_dbg.h>
36 #include "version_info.h"
38 #include "storvsc_api.h"
41 #define BLKVSC_MINORS 64
43 enum blkvsc_device_type
{
50 * This request ties the struct request and struct
51 * blkvsc_request/hv_storvsc_request together A struct request may be
52 * represented by 1 or more struct blkvsc_request
54 struct blkvsc_request_group
{
57 struct list_head blkvsc_req_list
; /* list of blkvsc_requests */
60 struct blkvsc_request
{
61 /* blkvsc_request_group.blkvsc_req_list */
62 struct list_head req_entry
;
64 /* block_device_context.pending_list */
65 struct list_head pend_entry
;
67 /* This may be null if we generate a request internally */
70 struct block_device_context
*dev
;
72 /* The group this request is part of. Maybe null */
73 struct blkvsc_request_group
*group
;
75 wait_queue_head_t wevent
;
79 sector_t sector_start
;
80 unsigned long sector_count
;
82 unsigned char sense_buffer
[SCSI_SENSE_BUFFERSIZE
];
83 unsigned char cmd_len
;
84 unsigned char cmnd
[MAX_COMMAND_SIZE
];
86 struct hv_storvsc_request request
;
88 * !!!DO NOT ADD ANYTHING BELOW HERE!!! Otherwise, memory can overlap,
89 * because - The extension buffer falls right here and is pointed to by
91 * Which sounds like a horrible idea, who designed this?
95 /* Per device structure */
96 struct block_device_context
{
97 /* point back to our device context */
98 struct hv_device
*device_ctx
;
99 struct kmem_cache
*request_pool
;
102 enum blkvsc_device_type device_type
;
103 struct list_head pending_list
;
105 unsigned char device_id
[64];
106 unsigned int device_id_len
;
107 int num_outstanding_reqs
;
109 int media_not_present
;
110 unsigned int sector_size
;
114 unsigned char target
;
120 static DEFINE_MUTEX(blkvsc_mutex
);
121 static int blkvsc_probe(struct device
*dev
);
122 static int blkvsc_remove(struct device
*device
);
123 static void blkvsc_shutdown(struct device
*device
);
125 static int blkvsc_open(struct block_device
*bdev
, fmode_t mode
);
126 static int blkvsc_release(struct gendisk
*disk
, fmode_t mode
);
127 static unsigned int blkvsc_check_events(struct gendisk
*gd
,
128 unsigned int clearing
);
129 static int blkvsc_revalidate_disk(struct gendisk
*gd
);
130 static int blkvsc_getgeo(struct block_device
*bd
, struct hd_geometry
*hg
);
131 static int blkvsc_ioctl(struct block_device
*bd
, fmode_t mode
,
132 unsigned cmd
, unsigned long argument
);
133 static void blkvsc_request(struct request_queue
*queue
);
134 static void blkvsc_request_completion(struct hv_storvsc_request
*request
);
135 static int blkvsc_do_request(struct block_device_context
*blkdev
,
136 struct request
*req
);
137 static int blkvsc_submit_request(struct blkvsc_request
*blkvsc_req
,
138 void (*request_completion
)(struct hv_storvsc_request
*));
139 static void blkvsc_init_rw(struct blkvsc_request
*blkvsc_req
);
140 static void blkvsc_cmd_completion(struct hv_storvsc_request
*request
);
141 static int blkvsc_do_inquiry(struct block_device_context
*blkdev
);
142 static int blkvsc_do_read_capacity(struct block_device_context
*blkdev
);
143 static int blkvsc_do_read_capacity16(struct block_device_context
*blkdev
);
144 static int blkvsc_do_flush(struct block_device_context
*blkdev
);
145 static int blkvsc_cancel_pending_reqs(struct block_device_context
*blkdev
);
146 static int blkvsc_do_pending_reqs(struct block_device_context
*blkdev
);
148 static int blkvsc_ringbuffer_size
= BLKVSC_RING_BUFFER_SIZE
;
149 module_param(blkvsc_ringbuffer_size
, int, S_IRUGO
);
150 MODULE_PARM_DESC(ring_size
, "Ring buffer size (in bytes)");
152 /* The one and only one */
153 static struct storvsc_driver_object g_blkvsc_drv
;
155 static const struct block_device_operations block_ops
= {
156 .owner
= THIS_MODULE
,
158 .release
= blkvsc_release
,
159 .check_events
= blkvsc_check_events
,
160 .revalidate_disk
= blkvsc_revalidate_disk
,
161 .getgeo
= blkvsc_getgeo
,
162 .ioctl
= blkvsc_ioctl
,
166 * blkvsc_drv_init - BlkVsc driver initialization.
168 static int blkvsc_drv_init(int (*drv_init
)(struct hv_driver
*drv
))
170 struct storvsc_driver_object
*storvsc_drv_obj
= &g_blkvsc_drv
;
171 struct hv_driver
*drv
= &g_blkvsc_drv
.base
;
174 storvsc_drv_obj
->ring_buffer_size
= blkvsc_ringbuffer_size
;
176 drv
->priv
= storvsc_drv_obj
;
178 /* Callback to client driver to complete the initialization */
179 drv_init(&storvsc_drv_obj
->base
);
181 drv
->driver
.name
= storvsc_drv_obj
->base
.name
;
183 drv
->driver
.probe
= blkvsc_probe
;
184 drv
->driver
.remove
= blkvsc_remove
;
185 drv
->driver
.shutdown
= blkvsc_shutdown
;
187 /* The driver belongs to vmbus */
188 ret
= vmbus_child_driver_register(&drv
->driver
);
193 static int blkvsc_drv_exit_cb(struct device
*dev
, void *data
)
195 struct device
**curr
= (struct device
**)data
;
197 return 1; /* stop iterating */
200 static void blkvsc_drv_exit(void)
202 struct storvsc_driver_object
*storvsc_drv_obj
= &g_blkvsc_drv
;
203 struct hv_driver
*drv
= &g_blkvsc_drv
.base
;
204 struct device
*current_dev
;
211 ret
= driver_for_each_device(&drv
->driver
, NULL
,
212 (void *) ¤t_dev
,
216 DPRINT_WARN(BLKVSC_DRV
,
217 "driver_for_each_device returned %d", ret
);
220 if (current_dev
== NULL
)
223 /* Initiate removal from the top-down */
224 device_unregister(current_dev
);
227 if (storvsc_drv_obj
->base
.cleanup
)
228 storvsc_drv_obj
->base
.cleanup(&storvsc_drv_obj
->base
);
230 vmbus_child_driver_unregister(&drv
->driver
);
236 * blkvsc_probe - Add a new device for this driver
238 static int blkvsc_probe(struct device
*device
)
240 struct hv_driver
*drv
=
241 drv_to_hv_drv(device
->driver
);
242 struct storvsc_driver_object
*storvsc_drv_obj
=
244 struct hv_device
*device_obj
= device_to_hv_device(device
);
246 struct block_device_context
*blkdev
= NULL
;
247 struct storvsc_device_info device_info
;
251 static int ide0_registered
;
252 static int ide1_registered
;
254 DPRINT_DBG(BLKVSC_DRV
, "blkvsc_probe - enter");
256 if (!storvsc_drv_obj
->base
.dev_add
) {
257 DPRINT_ERR(BLKVSC_DRV
, "OnDeviceAdd() not set");
262 blkdev
= kzalloc(sizeof(struct block_device_context
), GFP_KERNEL
);
268 INIT_LIST_HEAD(&blkdev
->pending_list
);
270 /* Initialize what we can here */
271 spin_lock_init(&blkdev
->lock
);
273 /* ASSERT(sizeof(struct blkvsc_request_group) <= */
274 /* sizeof(struct blkvsc_request)); */
276 blkdev
->request_pool
= kmem_cache_create(dev_name(&device_obj
->device
),
277 sizeof(struct blkvsc_request
) +
278 storvsc_drv_obj
->request_ext_size
, 0,
279 SLAB_HWCACHE_ALIGN
, NULL
);
280 if (!blkdev
->request_pool
) {
286 /* Call to the vsc driver to add the device */
287 ret
= storvsc_drv_obj
->base
.dev_add(device_obj
, &device_info
);
289 DPRINT_ERR(BLKVSC_DRV
, "unable to add blkvsc device");
293 blkdev
->device_ctx
= device_obj
;
294 /* this identified the device 0 or 1 */
295 blkdev
->target
= device_info
.target_id
;
296 /* this identified the ide ctrl 0 or 1 */
297 blkdev
->path
= device_info
.path_id
;
299 dev_set_drvdata(device
, blkdev
);
301 /* Calculate the major and device num */
302 if (blkdev
->path
== 0) {
304 devnum
= blkdev
->path
+ blkdev
->target
; /* 0 or 1 */
306 if (!ide0_registered
) {
307 ret
= register_blkdev(major
, "ide");
309 DPRINT_ERR(BLKVSC_DRV
,
310 "register_blkdev() failed! ret %d",
317 } else if (blkdev
->path
== 1) {
319 devnum
= blkdev
->path
+ blkdev
->target
+ 1; /* 2 or 3 */
321 if (!ide1_registered
) {
322 ret
= register_blkdev(major
, "ide");
324 DPRINT_ERR(BLKVSC_DRV
,
325 "register_blkdev() failed! ret %d",
333 DPRINT_ERR(BLKVSC_DRV
, "invalid pathid");
338 DPRINT_INFO(BLKVSC_DRV
, "blkvsc registered for major %d!!", major
);
340 blkdev
->gd
= alloc_disk(BLKVSC_MINORS
);
342 DPRINT_ERR(BLKVSC_DRV
, "register_blkdev() failed! ret %d", ret
);
347 blkdev
->gd
->queue
= blk_init_queue(blkvsc_request
, &blkdev
->lock
);
349 blk_queue_max_segment_size(blkdev
->gd
->queue
, PAGE_SIZE
);
350 blk_queue_max_segments(blkdev
->gd
->queue
, MAX_MULTIPAGE_BUFFER_COUNT
);
351 blk_queue_segment_boundary(blkdev
->gd
->queue
, PAGE_SIZE
-1);
352 blk_queue_bounce_limit(blkdev
->gd
->queue
, BLK_BOUNCE_ANY
);
353 blk_queue_dma_alignment(blkdev
->gd
->queue
, 511);
355 blkdev
->gd
->major
= major
;
356 if (devnum
== 1 || devnum
== 3)
357 blkdev
->gd
->first_minor
= BLKVSC_MINORS
;
359 blkdev
->gd
->first_minor
= 0;
360 blkdev
->gd
->fops
= &block_ops
;
361 blkdev
->gd
->events
= DISK_EVENT_MEDIA_CHANGE
;
362 blkdev
->gd
->private_data
= blkdev
;
363 blkdev
->gd
->driverfs_dev
= &(blkdev
->device_ctx
->device
);
364 sprintf(blkdev
->gd
->disk_name
, "hd%c", 'a' + devnum
);
366 blkvsc_do_inquiry(blkdev
);
367 if (blkdev
->device_type
== DVD_TYPE
) {
368 set_disk_ro(blkdev
->gd
, 1);
369 blkdev
->gd
->flags
|= GENHD_FL_REMOVABLE
;
370 blkvsc_do_read_capacity(blkdev
);
372 blkvsc_do_read_capacity16(blkdev
);
375 set_capacity(blkdev
->gd
, blkdev
->capacity
* (blkdev
->sector_size
/512));
376 blk_queue_logical_block_size(blkdev
->gd
->queue
, blkdev
->sector_size
);
378 add_disk(blkdev
->gd
);
380 DPRINT_INFO(BLKVSC_DRV
, "%s added!! capacity %lu sector_size %d",
381 blkdev
->gd
->disk_name
, (unsigned long)blkdev
->capacity
,
382 blkdev
->sector_size
);
387 storvsc_drv_obj
->base
.dev_rm(device_obj
);
391 if (blkdev
->request_pool
) {
392 kmem_cache_destroy(blkdev
->request_pool
);
393 blkdev
->request_pool
= NULL
;
402 static void blkvsc_shutdown(struct device
*device
)
404 struct block_device_context
*blkdev
= dev_get_drvdata(device
);
410 DPRINT_DBG(BLKVSC_DRV
, "blkvsc_shutdown - users %d disk %s\n",
411 blkdev
->users
, blkdev
->gd
->disk_name
);
413 spin_lock_irqsave(&blkdev
->lock
, flags
);
415 blkdev
->shutting_down
= 1;
417 blk_stop_queue(blkdev
->gd
->queue
);
419 spin_unlock_irqrestore(&blkdev
->lock
, flags
);
421 while (blkdev
->num_outstanding_reqs
) {
422 DPRINT_INFO(STORVSC
, "waiting for %d requests to complete...",
423 blkdev
->num_outstanding_reqs
);
427 blkvsc_do_flush(blkdev
);
429 spin_lock_irqsave(&blkdev
->lock
, flags
);
431 blkvsc_cancel_pending_reqs(blkdev
);
433 spin_unlock_irqrestore(&blkdev
->lock
, flags
);
436 static int blkvsc_do_flush(struct block_device_context
*blkdev
)
438 struct blkvsc_request
*blkvsc_req
;
440 DPRINT_DBG(BLKVSC_DRV
, "blkvsc_do_flush()\n");
442 if (blkdev
->device_type
!= HARDDISK_TYPE
)
445 blkvsc_req
= kmem_cache_alloc(blkdev
->request_pool
, GFP_KERNEL
);
449 memset(blkvsc_req
, 0, sizeof(struct blkvsc_request
));
450 init_waitqueue_head(&blkvsc_req
->wevent
);
451 blkvsc_req
->dev
= blkdev
;
452 blkvsc_req
->req
= NULL
;
453 blkvsc_req
->write
= 0;
455 blkvsc_req
->request
.data_buffer
.pfn_array
[0] = 0;
456 blkvsc_req
->request
.data_buffer
.offset
= 0;
457 blkvsc_req
->request
.data_buffer
.len
= 0;
459 blkvsc_req
->cmnd
[0] = SYNCHRONIZE_CACHE
;
460 blkvsc_req
->cmd_len
= 10;
463 * Set this here since the completion routine may be invoked and
464 * completed before we return
466 blkvsc_req
->cond
= 0;
467 blkvsc_submit_request(blkvsc_req
, blkvsc_cmd_completion
);
469 wait_event_interruptible(blkvsc_req
->wevent
, blkvsc_req
->cond
);
471 kmem_cache_free(blkvsc_req
->dev
->request_pool
, blkvsc_req
);
476 /* Do a scsi INQUIRY cmd here to get the device type (ie disk or dvd) */
477 static int blkvsc_do_inquiry(struct block_device_context
*blkdev
)
479 struct blkvsc_request
*blkvsc_req
;
480 struct page
*page_buf
;
482 unsigned char device_type
;
484 DPRINT_DBG(BLKVSC_DRV
, "blkvsc_do_inquiry()\n");
486 blkvsc_req
= kmem_cache_alloc(blkdev
->request_pool
, GFP_KERNEL
);
490 memset(blkvsc_req
, 0, sizeof(struct blkvsc_request
));
491 page_buf
= alloc_page(GFP_KERNEL
);
493 kmem_cache_free(blkvsc_req
->dev
->request_pool
, blkvsc_req
);
497 init_waitqueue_head(&blkvsc_req
->wevent
);
498 blkvsc_req
->dev
= blkdev
;
499 blkvsc_req
->req
= NULL
;
500 blkvsc_req
->write
= 0;
502 blkvsc_req
->request
.data_buffer
.pfn_array
[0] = page_to_pfn(page_buf
);
503 blkvsc_req
->request
.data_buffer
.offset
= 0;
504 blkvsc_req
->request
.data_buffer
.len
= 64;
506 blkvsc_req
->cmnd
[0] = INQUIRY
;
507 blkvsc_req
->cmnd
[1] = 0x1; /* Get product data */
508 blkvsc_req
->cmnd
[2] = 0x83; /* mode page 83 */
509 blkvsc_req
->cmnd
[4] = 64;
510 blkvsc_req
->cmd_len
= 6;
513 * Set this here since the completion routine may be invoked and
514 * completed before we return
516 blkvsc_req
->cond
= 0;
518 blkvsc_submit_request(blkvsc_req
, blkvsc_cmd_completion
);
520 DPRINT_DBG(BLKVSC_DRV
, "waiting %p to complete - cond %d\n",
521 blkvsc_req
, blkvsc_req
->cond
);
523 wait_event_interruptible(blkvsc_req
->wevent
, blkvsc_req
->cond
);
525 buf
= kmap(page_buf
);
527 /* print_hex_dump_bytes("", DUMP_PREFIX_NONE, buf, 64); */
529 device_type
= buf
[0] & 0x1F;
531 if (device_type
== 0x0) {
532 blkdev
->device_type
= HARDDISK_TYPE
;
533 } else if (device_type
== 0x5) {
534 blkdev
->device_type
= DVD_TYPE
;
536 /* TODO: this is currently unsupported device type */
537 blkdev
->device_type
= UNKNOWN_DEV_TYPE
;
540 DPRINT_DBG(BLKVSC_DRV
, "device type %d\n", device_type
);
542 blkdev
->device_id_len
= buf
[7];
543 if (blkdev
->device_id_len
> 64)
544 blkdev
->device_id_len
= 64;
546 memcpy(blkdev
->device_id
, &buf
[8], blkdev
->device_id_len
);
547 /* printk_hex_dump_bytes("", DUMP_PREFIX_NONE, blkdev->device_id,
548 * blkdev->device_id_len); */
552 __free_page(page_buf
);
554 kmem_cache_free(blkvsc_req
->dev
->request_pool
, blkvsc_req
);
559 /* Do a scsi READ_CAPACITY cmd here to get the size of the disk */
560 static int blkvsc_do_read_capacity(struct block_device_context
*blkdev
)
562 struct blkvsc_request
*blkvsc_req
;
563 struct page
*page_buf
;
565 struct scsi_sense_hdr sense_hdr
;
567 DPRINT_DBG(BLKVSC_DRV
, "blkvsc_do_read_capacity()\n");
569 blkdev
->sector_size
= 0;
570 blkdev
->capacity
= 0;
571 blkdev
->media_not_present
= 0; /* assume a disk is present */
573 blkvsc_req
= kmem_cache_alloc(blkdev
->request_pool
, GFP_KERNEL
);
577 memset(blkvsc_req
, 0, sizeof(struct blkvsc_request
));
578 page_buf
= alloc_page(GFP_KERNEL
);
580 kmem_cache_free(blkvsc_req
->dev
->request_pool
, blkvsc_req
);
584 init_waitqueue_head(&blkvsc_req
->wevent
);
585 blkvsc_req
->dev
= blkdev
;
586 blkvsc_req
->req
= NULL
;
587 blkvsc_req
->write
= 0;
589 blkvsc_req
->request
.data_buffer
.pfn_array
[0] = page_to_pfn(page_buf
);
590 blkvsc_req
->request
.data_buffer
.offset
= 0;
591 blkvsc_req
->request
.data_buffer
.len
= 8;
593 blkvsc_req
->cmnd
[0] = READ_CAPACITY
;
594 blkvsc_req
->cmd_len
= 16;
597 * Set this here since the completion routine may be invoked
598 * and completed before we return
600 blkvsc_req
->cond
= 0;
602 blkvsc_submit_request(blkvsc_req
, blkvsc_cmd_completion
);
604 DPRINT_DBG(BLKVSC_DRV
, "waiting %p to complete - cond %d\n",
605 blkvsc_req
, blkvsc_req
->cond
);
607 wait_event_interruptible(blkvsc_req
->wevent
, blkvsc_req
->cond
);
610 if (blkvsc_req
->request
.status
) {
611 scsi_normalize_sense(blkvsc_req
->sense_buffer
,
612 SCSI_SENSE_BUFFERSIZE
, &sense_hdr
);
614 if (sense_hdr
.asc
== 0x3A) {
615 /* Medium not present */
616 blkdev
->media_not_present
= 1;
620 buf
= kmap(page_buf
);
623 blkdev
->capacity
= ((buf
[0] << 24) | (buf
[1] << 16) |
624 (buf
[2] << 8) | buf
[3]) + 1;
625 blkdev
->sector_size
= (buf
[4] << 24) | (buf
[5] << 16) |
626 (buf
[6] << 8) | buf
[7];
630 __free_page(page_buf
);
632 kmem_cache_free(blkvsc_req
->dev
->request_pool
, blkvsc_req
);
637 static int blkvsc_do_read_capacity16(struct block_device_context
*blkdev
)
639 struct blkvsc_request
*blkvsc_req
;
640 struct page
*page_buf
;
642 struct scsi_sense_hdr sense_hdr
;
644 DPRINT_DBG(BLKVSC_DRV
, "blkvsc_do_read_capacity16()\n");
646 blkdev
->sector_size
= 0;
647 blkdev
->capacity
= 0;
648 blkdev
->media_not_present
= 0; /* assume a disk is present */
650 blkvsc_req
= kmem_cache_alloc(blkdev
->request_pool
, GFP_KERNEL
);
654 memset(blkvsc_req
, 0, sizeof(struct blkvsc_request
));
655 page_buf
= alloc_page(GFP_KERNEL
);
657 kmem_cache_free(blkvsc_req
->dev
->request_pool
, blkvsc_req
);
661 init_waitqueue_head(&blkvsc_req
->wevent
);
662 blkvsc_req
->dev
= blkdev
;
663 blkvsc_req
->req
= NULL
;
664 blkvsc_req
->write
= 0;
666 blkvsc_req
->request
.data_buffer
.pfn_array
[0] = page_to_pfn(page_buf
);
667 blkvsc_req
->request
.data_buffer
.offset
= 0;
668 blkvsc_req
->request
.data_buffer
.len
= 12;
670 blkvsc_req
->cmnd
[0] = 0x9E; /* READ_CAPACITY16; */
671 blkvsc_req
->cmd_len
= 16;
674 * Set this here since the completion routine may be invoked
675 * and completed before we return
677 blkvsc_req
->cond
= 0;
679 blkvsc_submit_request(blkvsc_req
, blkvsc_cmd_completion
);
681 DPRINT_DBG(BLKVSC_DRV
, "waiting %p to complete - cond %d\n",
682 blkvsc_req
, blkvsc_req
->cond
);
684 wait_event_interruptible(blkvsc_req
->wevent
, blkvsc_req
->cond
);
687 if (blkvsc_req
->request
.status
) {
688 scsi_normalize_sense(blkvsc_req
->sense_buffer
,
689 SCSI_SENSE_BUFFERSIZE
, &sense_hdr
);
690 if (sense_hdr
.asc
== 0x3A) {
691 /* Medium not present */
692 blkdev
->media_not_present
= 1;
696 buf
= kmap(page_buf
);
699 blkdev
->capacity
= be64_to_cpu(*(unsigned long long *) &buf
[0]) + 1;
700 blkdev
->sector_size
= be32_to_cpu(*(unsigned int *)&buf
[8]);
703 blkdev
->capacity
= ((buf
[0] << 24) | (buf
[1] << 16) |
704 (buf
[2] << 8) | buf
[3]) + 1;
705 blkdev
->sector_size
= (buf
[4] << 24) | (buf
[5] << 16) |
706 (buf
[6] << 8) | buf
[7];
711 __free_page(page_buf
);
713 kmem_cache_free(blkvsc_req
->dev
->request_pool
, blkvsc_req
);
719 * blkvsc_remove() - Callback when our device is removed
721 static int blkvsc_remove(struct device
*device
)
723 struct hv_driver
*drv
=
724 drv_to_hv_drv(device
->driver
);
725 struct storvsc_driver_object
*storvsc_drv_obj
=
727 struct hv_device
*device_obj
= device_to_hv_device(device
);
728 struct block_device_context
*blkdev
= dev_get_drvdata(device
);
732 DPRINT_DBG(BLKVSC_DRV
, "blkvsc_remove()\n");
734 if (!storvsc_drv_obj
->base
.dev_rm
)
738 * Call to the vsc driver to let it know that the device is being
741 ret
= storvsc_drv_obj
->base
.dev_rm(device_obj
);
744 DPRINT_ERR(BLKVSC_DRV
,
745 "unable to remove blkvsc device (ret %d)", ret
);
748 /* Get to a known state */
749 spin_lock_irqsave(&blkdev
->lock
, flags
);
751 blkdev
->shutting_down
= 1;
753 blk_stop_queue(blkdev
->gd
->queue
);
755 spin_unlock_irqrestore(&blkdev
->lock
, flags
);
757 while (blkdev
->num_outstanding_reqs
) {
758 DPRINT_INFO(STORVSC
, "waiting for %d requests to complete...",
759 blkdev
->num_outstanding_reqs
);
763 blkvsc_do_flush(blkdev
);
765 spin_lock_irqsave(&blkdev
->lock
, flags
);
767 blkvsc_cancel_pending_reqs(blkdev
);
769 spin_unlock_irqrestore(&blkdev
->lock
, flags
);
771 blk_cleanup_queue(blkdev
->gd
->queue
);
773 del_gendisk(blkdev
->gd
);
775 kmem_cache_destroy(blkdev
->request_pool
);
782 static void blkvsc_init_rw(struct blkvsc_request
*blkvsc_req
)
784 /* ASSERT(blkvsc_req->req); */
785 /* ASSERT(blkvsc_req->sector_count <= (MAX_MULTIPAGE_BUFFER_COUNT*8)); */
787 blkvsc_req
->cmd_len
= 16;
789 if (blkvsc_req
->sector_start
> 0xffffffff) {
790 if (rq_data_dir(blkvsc_req
->req
)) {
791 blkvsc_req
->write
= 1;
792 blkvsc_req
->cmnd
[0] = WRITE_16
;
794 blkvsc_req
->write
= 0;
795 blkvsc_req
->cmnd
[0] = READ_16
;
798 blkvsc_req
->cmnd
[1] |=
799 (blkvsc_req
->req
->cmd_flags
& REQ_FUA
) ? 0x8 : 0;
801 *(unsigned long long *)&blkvsc_req
->cmnd
[2] =
802 cpu_to_be64(blkvsc_req
->sector_start
);
803 *(unsigned int *)&blkvsc_req
->cmnd
[10] =
804 cpu_to_be32(blkvsc_req
->sector_count
);
805 } else if ((blkvsc_req
->sector_count
> 0xff) ||
806 (blkvsc_req
->sector_start
> 0x1fffff)) {
807 if (rq_data_dir(blkvsc_req
->req
)) {
808 blkvsc_req
->write
= 1;
809 blkvsc_req
->cmnd
[0] = WRITE_10
;
811 blkvsc_req
->write
= 0;
812 blkvsc_req
->cmnd
[0] = READ_10
;
815 blkvsc_req
->cmnd
[1] |=
816 (blkvsc_req
->req
->cmd_flags
& REQ_FUA
) ? 0x8 : 0;
818 *(unsigned int *)&blkvsc_req
->cmnd
[2] =
819 cpu_to_be32(blkvsc_req
->sector_start
);
820 *(unsigned short *)&blkvsc_req
->cmnd
[7] =
821 cpu_to_be16(blkvsc_req
->sector_count
);
823 if (rq_data_dir(blkvsc_req
->req
)) {
824 blkvsc_req
->write
= 1;
825 blkvsc_req
->cmnd
[0] = WRITE_6
;
827 blkvsc_req
->write
= 0;
828 blkvsc_req
->cmnd
[0] = READ_6
;
831 *(unsigned int *)&blkvsc_req
->cmnd
[1] =
832 cpu_to_be32(blkvsc_req
->sector_start
) >> 8;
833 blkvsc_req
->cmnd
[1] &= 0x1f;
834 blkvsc_req
->cmnd
[4] = (unsigned char)blkvsc_req
->sector_count
;
838 static int blkvsc_submit_request(struct blkvsc_request
*blkvsc_req
,
839 void (*request_completion
)(struct hv_storvsc_request
*))
841 struct block_device_context
*blkdev
= blkvsc_req
->dev
;
842 struct hv_device
*device_ctx
= blkdev
->device_ctx
;
843 struct hv_driver
*drv
=
844 drv_to_hv_drv(device_ctx
->device
.driver
);
845 struct storvsc_driver_object
*storvsc_drv_obj
=
847 struct hv_storvsc_request
*storvsc_req
;
850 DPRINT_DBG(BLKVSC_DRV
, "blkvsc_submit_request() - "
851 "req %p type %s start_sector %lu count %ld offset %d "
852 "len %d\n", blkvsc_req
,
853 (blkvsc_req
->write
) ? "WRITE" : "READ",
854 (unsigned long) blkvsc_req
->sector_start
,
855 blkvsc_req
->sector_count
,
856 blkvsc_req
->request
.data_buffer
.offset
,
857 blkvsc_req
->request
.data_buffer
.len
);
859 for (i
= 0; i
< (blkvsc_req
->request
.data_buffer
.len
>> 12); i
++) {
860 DPRINT_DBG(BLKVSC_DRV
, "blkvsc_submit_request() - "
861 "req %p pfn[%d] %llx\n",
863 blkvsc_req
->request
.data_buffer
.pfn_array
[i
]);
867 storvsc_req
= &blkvsc_req
->request
;
868 storvsc_req
->extension
= (void *)((unsigned long)blkvsc_req
+
869 sizeof(struct blkvsc_request
));
871 storvsc_req
->type
= blkvsc_req
->write
? WRITE_TYPE
: READ_TYPE
;
873 storvsc_req
->on_io_completion
= request_completion
;
874 storvsc_req
->context
= blkvsc_req
;
876 storvsc_req
->host
= blkdev
->port
;
877 storvsc_req
->bus
= blkdev
->path
;
878 storvsc_req
->target_id
= blkdev
->target
;
879 storvsc_req
->lun_id
= 0; /* this is not really used at all */
881 storvsc_req
->cdb_len
= blkvsc_req
->cmd_len
;
882 storvsc_req
->cdb
= blkvsc_req
->cmnd
;
884 storvsc_req
->sense_buffer
= blkvsc_req
->sense_buffer
;
885 storvsc_req
->sense_buffer_size
= SCSI_SENSE_BUFFERSIZE
;
887 ret
= storvsc_drv_obj
->on_io_request(blkdev
->device_ctx
,
888 &blkvsc_req
->request
);
890 blkdev
->num_outstanding_reqs
++;
896 * We break the request into 1 or more blkvsc_requests and submit
897 * them. If we can't submit them all, we put them on the
898 * pending_list. The blkvsc_request() will work on the pending_list.
900 static int blkvsc_do_request(struct block_device_context
*blkdev
,
903 struct bio
*bio
= NULL
;
904 struct bio_vec
*bvec
= NULL
;
905 struct bio_vec
*prev_bvec
= NULL
;
906 struct blkvsc_request
*blkvsc_req
= NULL
;
907 struct blkvsc_request
*tmp
;
910 sector_t start_sector
;
911 unsigned long num_sectors
= 0;
914 struct blkvsc_request_group
*group
= NULL
;
916 DPRINT_DBG(BLKVSC_DRV
, "blkdev %p req %p sect %lu\n", blkdev
, req
,
917 (unsigned long)blk_rq_pos(req
));
919 /* Create a group to tie req to list of blkvsc_reqs */
920 group
= kmem_cache_alloc(blkdev
->request_pool
, GFP_ATOMIC
);
924 INIT_LIST_HEAD(&group
->blkvsc_req_list
);
925 group
->outstanding
= group
->status
= 0;
927 start_sector
= blk_rq_pos(req
);
929 /* foreach bio in the request */
931 for (bio
= req
->bio
; bio
; bio
= bio
->bi_next
) {
933 * Map this bio into an existing or new storvsc request
935 bio_for_each_segment(bvec
, bio
, seg_idx
) {
936 DPRINT_DBG(BLKVSC_DRV
, "bio_for_each_segment() "
937 "- req %p bio %p bvec %p seg_idx %d "
938 "databuf_idx %d\n", req
, bio
, bvec
,
939 seg_idx
, databuf_idx
);
941 /* Get a new storvsc request */
944 (databuf_idx
>= MAX_MULTIPAGE_BUFFER_COUNT
)
945 /* hole at the begin of page */
946 || (bvec
->bv_offset
!= 0) ||
947 /* hold at the end of page */
949 (prev_bvec
->bv_len
!= PAGE_SIZE
))) {
950 /* submit the prev one */
952 blkvsc_req
->sector_start
= start_sector
;
953 sector_div(blkvsc_req
->sector_start
, (blkdev
->sector_size
>> 9));
955 blkvsc_req
->sector_count
= num_sectors
/ (blkdev
->sector_size
>> 9);
956 blkvsc_init_rw(blkvsc_req
);
960 * Create new blkvsc_req to represent
963 blkvsc_req
= kmem_cache_alloc(blkdev
->request_pool
, GFP_ATOMIC
);
965 /* free up everything */
966 list_for_each_entry_safe(
968 &group
->blkvsc_req_list
,
970 list_del(&blkvsc_req
->req_entry
);
971 kmem_cache_free(blkdev
->request_pool
, blkvsc_req
);
974 kmem_cache_free(blkdev
->request_pool
, group
);
978 memset(blkvsc_req
, 0,
979 sizeof(struct blkvsc_request
));
981 blkvsc_req
->dev
= blkdev
;
982 blkvsc_req
->req
= req
;
983 blkvsc_req
->request
.data_buffer
.offset
985 blkvsc_req
->request
.data_buffer
.len
988 /* Add to the group */
989 blkvsc_req
->group
= group
;
990 blkvsc_req
->group
->outstanding
++;
991 list_add_tail(&blkvsc_req
->req_entry
,
992 &blkvsc_req
->group
->blkvsc_req_list
);
994 start_sector
+= num_sectors
;
999 /* Add the curr bvec/segment to the curr blkvsc_req */
1000 blkvsc_req
->request
.data_buffer
.
1001 pfn_array
[databuf_idx
]
1002 = page_to_pfn(bvec
->bv_page
);
1003 blkvsc_req
->request
.data_buffer
.len
1009 num_sectors
+= bvec
->bv_len
>> 9;
1011 } /* bio_for_each_segment */
1013 } /* rq_for_each_bio */
1016 /* Handle the last one */
1018 DPRINT_DBG(BLKVSC_DRV
, "blkdev %p req %p group %p count %d\n",
1019 blkdev
, req
, blkvsc_req
->group
,
1020 blkvsc_req
->group
->outstanding
);
1022 blkvsc_req
->sector_start
= start_sector
;
1023 sector_div(blkvsc_req
->sector_start
,
1024 (blkdev
->sector_size
>> 9));
1026 blkvsc_req
->sector_count
= num_sectors
/
1027 (blkdev
->sector_size
>> 9);
1029 blkvsc_init_rw(blkvsc_req
);
1032 list_for_each_entry(blkvsc_req
, &group
->blkvsc_req_list
, req_entry
) {
1034 DPRINT_DBG(BLKVSC_DRV
, "adding blkvsc_req to "
1035 "pending_list - blkvsc_req %p start_sect %lu"
1036 " sect_count %ld (%lu %ld)\n", blkvsc_req
,
1037 (unsigned long)blkvsc_req
->sector_start
,
1038 blkvsc_req
->sector_count
,
1039 (unsigned long)start_sector
,
1040 (unsigned long)num_sectors
);
1042 list_add_tail(&blkvsc_req
->pend_entry
,
1043 &blkdev
->pending_list
);
1045 ret
= blkvsc_submit_request(blkvsc_req
,
1046 blkvsc_request_completion
);
1049 list_add_tail(&blkvsc_req
->pend_entry
,
1050 &blkdev
->pending_list
);
1053 DPRINT_DBG(BLKVSC_DRV
, "submitted blkvsc_req %p "
1054 "start_sect %lu sect_count %ld (%lu %ld) "
1055 "ret %d\n", blkvsc_req
,
1056 (unsigned long)blkvsc_req
->sector_start
,
1057 blkvsc_req
->sector_count
,
1058 (unsigned long)start_sector
,
1066 static void blkvsc_cmd_completion(struct hv_storvsc_request
*request
)
1068 struct blkvsc_request
*blkvsc_req
=
1069 (struct blkvsc_request
*)request
->context
;
1070 struct block_device_context
*blkdev
=
1071 (struct block_device_context
*)blkvsc_req
->dev
;
1072 struct scsi_sense_hdr sense_hdr
;
1074 DPRINT_DBG(BLKVSC_DRV
, "blkvsc_cmd_completion() - req %p\n",
1077 blkdev
->num_outstanding_reqs
--;
1079 if (blkvsc_req
->request
.status
)
1080 if (scsi_normalize_sense(blkvsc_req
->sense_buffer
,
1081 SCSI_SENSE_BUFFERSIZE
, &sense_hdr
))
1082 scsi_print_sense_hdr("blkvsc", &sense_hdr
);
1084 blkvsc_req
->cond
= 1;
1085 wake_up_interruptible(&blkvsc_req
->wevent
);
1088 static void blkvsc_request_completion(struct hv_storvsc_request
*request
)
1090 struct blkvsc_request
*blkvsc_req
=
1091 (struct blkvsc_request
*)request
->context
;
1092 struct block_device_context
*blkdev
=
1093 (struct block_device_context
*)blkvsc_req
->dev
;
1094 unsigned long flags
;
1095 struct blkvsc_request
*comp_req
, *tmp
;
1097 /* ASSERT(blkvsc_req->group); */
1099 DPRINT_DBG(BLKVSC_DRV
, "blkdev %p blkvsc_req %p group %p type %s "
1100 "sect_start %lu sect_count %ld len %d group outstd %d "
1101 "total outstd %d\n",
1102 blkdev
, blkvsc_req
, blkvsc_req
->group
,
1103 (blkvsc_req
->write
) ? "WRITE" : "READ",
1104 (unsigned long)blkvsc_req
->sector_start
,
1105 blkvsc_req
->sector_count
,
1106 blkvsc_req
->request
.data_buffer
.len
,
1107 blkvsc_req
->group
->outstanding
,
1108 blkdev
->num_outstanding_reqs
);
1110 spin_lock_irqsave(&blkdev
->lock
, flags
);
1112 blkdev
->num_outstanding_reqs
--;
1113 blkvsc_req
->group
->outstanding
--;
1116 * Only start processing when all the blkvsc_reqs are
1117 * completed. This guarantees no out-of-order blkvsc_req
1118 * completion when calling end_that_request_first()
1120 if (blkvsc_req
->group
->outstanding
== 0) {
1121 list_for_each_entry_safe(comp_req
, tmp
,
1122 &blkvsc_req
->group
->blkvsc_req_list
,
1124 DPRINT_DBG(BLKVSC_DRV
, "completing blkvsc_req %p "
1125 "sect_start %lu sect_count %ld\n",
1127 (unsigned long)comp_req
->sector_start
,
1128 comp_req
->sector_count
);
1130 list_del(&comp_req
->req_entry
);
1132 if (!__blk_end_request(comp_req
->req
,
1133 (!comp_req
->request
.status
? 0 : -EIO
),
1134 comp_req
->sector_count
* blkdev
->sector_size
)) {
1136 * All the sectors have been xferred ie the
1139 DPRINT_DBG(BLKVSC_DRV
, "req %p COMPLETED\n",
1141 kmem_cache_free(blkdev
->request_pool
,
1145 kmem_cache_free(blkdev
->request_pool
, comp_req
);
1148 if (!blkdev
->shutting_down
) {
1149 blkvsc_do_pending_reqs(blkdev
);
1150 blk_start_queue(blkdev
->gd
->queue
);
1151 blkvsc_request(blkdev
->gd
->queue
);
1155 spin_unlock_irqrestore(&blkdev
->lock
, flags
);
1158 static int blkvsc_cancel_pending_reqs(struct block_device_context
*blkdev
)
1160 struct blkvsc_request
*pend_req
, *tmp
;
1161 struct blkvsc_request
*comp_req
, *tmp2
;
1165 DPRINT_DBG(BLKVSC_DRV
, "blkvsc_cancel_pending_reqs()");
1167 /* Flush the pending list first */
1168 list_for_each_entry_safe(pend_req
, tmp
, &blkdev
->pending_list
,
1171 * The pend_req could be part of a partially completed
1172 * request. If so, complete those req first until we
1175 list_for_each_entry_safe(comp_req
, tmp2
,
1176 &pend_req
->group
->blkvsc_req_list
,
1178 DPRINT_DBG(BLKVSC_DRV
, "completing blkvsc_req %p "
1179 "sect_start %lu sect_count %ld\n",
1181 (unsigned long) comp_req
->sector_start
,
1182 comp_req
->sector_count
);
1184 if (comp_req
== pend_req
)
1187 list_del(&comp_req
->req_entry
);
1189 if (comp_req
->req
) {
1190 ret
= __blk_end_request(comp_req
->req
,
1191 (!comp_req
->request
.status
? 0 : -EIO
),
1192 comp_req
->sector_count
*
1193 blkdev
->sector_size
);
1195 /* FIXME: shouldn't this do more than return? */
1200 kmem_cache_free(blkdev
->request_pool
, comp_req
);
1203 DPRINT_DBG(BLKVSC_DRV
, "cancelling pending request - %p\n",
1206 list_del(&pend_req
->pend_entry
);
1208 list_del(&pend_req
->req_entry
);
1210 if (comp_req
->req
) {
1211 if (!__blk_end_request(pend_req
->req
, -EIO
,
1212 pend_req
->sector_count
*
1213 blkdev
->sector_size
)) {
1215 * All the sectors have been xferred ie the
1218 DPRINT_DBG(BLKVSC_DRV
,
1219 "blkvsc_cancel_pending_reqs() - "
1220 "req %p COMPLETED\n", pend_req
->req
);
1221 kmem_cache_free(blkdev
->request_pool
,
1226 kmem_cache_free(blkdev
->request_pool
, pend_req
);
1233 static int blkvsc_do_pending_reqs(struct block_device_context
*blkdev
)
1235 struct blkvsc_request
*pend_req
, *tmp
;
1238 /* Flush the pending list first */
1239 list_for_each_entry_safe(pend_req
, tmp
, &blkdev
->pending_list
,
1241 DPRINT_DBG(BLKVSC_DRV
, "working off pending_list - %p\n",
1244 ret
= blkvsc_submit_request(pend_req
,
1245 blkvsc_request_completion
);
1249 list_del(&pend_req
->pend_entry
);
1255 static void blkvsc_request(struct request_queue
*queue
)
1257 struct block_device_context
*blkdev
= NULL
;
1258 struct request
*req
;
1261 DPRINT_DBG(BLKVSC_DRV
, "- enter\n");
1262 while ((req
= blk_peek_request(queue
)) != NULL
) {
1263 DPRINT_DBG(BLKVSC_DRV
, "- req %p\n", req
);
1265 blkdev
= req
->rq_disk
->private_data
;
1266 if (blkdev
->shutting_down
|| req
->cmd_type
!= REQ_TYPE_FS
||
1267 blkdev
->media_not_present
) {
1268 __blk_end_request_cur(req
, 0);
1272 ret
= blkvsc_do_pending_reqs(blkdev
);
1275 DPRINT_DBG(BLKVSC_DRV
,
1276 "- stop queue - pending_list not empty\n");
1277 blk_stop_queue(queue
);
1281 blk_start_request(req
);
1283 ret
= blkvsc_do_request(blkdev
, req
);
1285 DPRINT_DBG(BLKVSC_DRV
, "- stop queue - no room\n");
1286 blk_stop_queue(queue
);
1288 } else if (ret
< 0) {
1289 DPRINT_DBG(BLKVSC_DRV
, "- stop queue - no mem\n");
1290 blk_requeue_request(queue
, req
);
1291 blk_stop_queue(queue
);
1297 static int blkvsc_open(struct block_device
*bdev
, fmode_t mode
)
1299 struct block_device_context
*blkdev
= bdev
->bd_disk
->private_data
;
1301 DPRINT_DBG(BLKVSC_DRV
, "- users %d disk %s\n", blkdev
->users
,
1302 blkdev
->gd
->disk_name
);
1304 mutex_lock(&blkvsc_mutex
);
1305 spin_lock(&blkdev
->lock
);
1307 if (!blkdev
->users
&& blkdev
->device_type
== DVD_TYPE
) {
1308 spin_unlock(&blkdev
->lock
);
1309 check_disk_change(bdev
);
1310 spin_lock(&blkdev
->lock
);
1315 spin_unlock(&blkdev
->lock
);
1316 mutex_unlock(&blkvsc_mutex
);
1320 static int blkvsc_release(struct gendisk
*disk
, fmode_t mode
)
1322 struct block_device_context
*blkdev
= disk
->private_data
;
1324 DPRINT_DBG(BLKVSC_DRV
, "- users %d disk %s\n", blkdev
->users
,
1325 blkdev
->gd
->disk_name
);
1327 mutex_lock(&blkvsc_mutex
);
1328 spin_lock(&blkdev
->lock
);
1329 if (blkdev
->users
== 1) {
1330 spin_unlock(&blkdev
->lock
);
1331 blkvsc_do_flush(blkdev
);
1332 spin_lock(&blkdev
->lock
);
1337 spin_unlock(&blkdev
->lock
);
1338 mutex_unlock(&blkvsc_mutex
);
1342 static unsigned int blkvsc_check_events(struct gendisk
*gd
,
1343 unsigned int clearing
)
1345 DPRINT_DBG(BLKVSC_DRV
, "- enter\n");
1346 return DISK_EVENT_MEDIA_CHANGE
;
1349 static int blkvsc_revalidate_disk(struct gendisk
*gd
)
1351 struct block_device_context
*blkdev
= gd
->private_data
;
1353 DPRINT_DBG(BLKVSC_DRV
, "- enter\n");
1355 if (blkdev
->device_type
== DVD_TYPE
) {
1356 blkvsc_do_read_capacity(blkdev
);
1357 set_capacity(blkdev
->gd
, blkdev
->capacity
*
1358 (blkdev
->sector_size
/512));
1359 blk_queue_logical_block_size(gd
->queue
, blkdev
->sector_size
);
1364 static int blkvsc_getgeo(struct block_device
*bd
, struct hd_geometry
*hg
)
1366 sector_t total_sectors
= get_capacity(bd
->bd_disk
);
1367 sector_t cylinder_times_heads
= 0;
1370 int sectors_per_track
= 0;
1375 if (total_sectors
> (65535 * 16 * 255))
1376 total_sectors
= (65535 * 16 * 255);
1378 if (total_sectors
>= (65535 * 16 * 63)) {
1379 sectors_per_track
= 255;
1382 cylinder_times_heads
= total_sectors
;
1383 /* sector_div stores the quotient in cylinder_times_heads */
1384 rem
= sector_div(cylinder_times_heads
, sectors_per_track
);
1386 sectors_per_track
= 17;
1388 cylinder_times_heads
= total_sectors
;
1389 /* sector_div stores the quotient in cylinder_times_heads */
1390 rem
= sector_div(cylinder_times_heads
, sectors_per_track
);
1392 temp
= cylinder_times_heads
+ 1023;
1393 /* sector_div stores the quotient in temp */
1394 rem
= sector_div(temp
, 1024);
1402 if (cylinder_times_heads
>= (heads
* 1024) || (heads
> 16)) {
1403 sectors_per_track
= 31;
1406 cylinder_times_heads
= total_sectors
;
1408 * sector_div stores the quotient in
1409 * cylinder_times_heads
1411 rem
= sector_div(cylinder_times_heads
,
1415 if (cylinder_times_heads
>= (heads
* 1024)) {
1416 sectors_per_track
= 63;
1419 cylinder_times_heads
= total_sectors
;
1421 * sector_div stores the quotient in
1422 * cylinder_times_heads
1424 rem
= sector_div(cylinder_times_heads
,
1429 temp
= cylinder_times_heads
;
1430 /* sector_div stores the quotient in temp */
1431 rem
= sector_div(temp
, heads
);
1435 hg
->sectors
= sectors_per_track
;
1436 hg
->cylinders
= cylinders
;
1438 DPRINT_INFO(BLKVSC_DRV
, "CHS (%d, %d, %d)", cylinders
, heads
,
1444 static int blkvsc_ioctl(struct block_device
*bd
, fmode_t mode
,
1445 unsigned cmd
, unsigned long argument
)
1447 /* struct block_device_context *blkdev = bd->bd_disk->private_data; */
1452 * TODO: I think there is certain format for HDIO_GET_IDENTITY rather
1453 * than just a GUID. Commented it out for now.
1456 case HDIO_GET_IDENTITY
:
1457 DPRINT_INFO(BLKVSC_DRV
, "HDIO_GET_IDENTITY\n");
1458 if (copy_to_user((void __user
*)arg
, blkdev
->device_id
,
1459 blkdev
->device_id_len
))
1471 static int __init
blkvsc_init(void)
1475 BUILD_BUG_ON(sizeof(sector_t
) != 8);
1477 DPRINT_INFO(BLKVSC_DRV
, "Blkvsc initializing....");
1479 ret
= blkvsc_drv_init(blk_vsc_initialize
);
1484 static void __exit
blkvsc_exit(void)
1489 MODULE_LICENSE("GPL");
1490 MODULE_VERSION(HV_DRV_VERSION
);
1491 MODULE_DESCRIPTION("Microsoft Hyper-V virtual block driver");
1492 module_init(blkvsc_init
);
1493 module_exit(blkvsc_exit
);