Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 249144
b: refs/heads/master
c: 1f91bca
h: refs/heads/master
v: v3
  • Loading branch information
K. Y. Srinivasan authored and Greg Kroah-Hartman committed Apr 25, 2011
1 parent 0829e4c commit 6388cc8
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 487ae7cd557f52d46f7a0fb5dcc05976952e9853
refs/heads/master: 1f91bca8dbf046ad6cb57fa203b7ca735f8c7e4a
68 changes: 68 additions & 0 deletions trunk/drivers/staging/hv/storvsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* Authors:
* Haiyang Zhang <haiyangz@microsoft.com>
* Hank Janssen <hjanssen@microsoft.com>
*
* 4/3/2011: K. Y. Srinivasan - Significant restructuring and cleanup.
*/
#include <linux/kernel.h>
#include <linux/sched.h>
Expand Down Expand Up @@ -592,6 +594,72 @@ int stor_vsc_on_io_request(struct hv_device *device,
return ret;
}

/*
* The channel properties uniquely specify how the device is to be
* presented to the guest. Map this information for use by the block
* driver. For Linux guests on Hyper-V, we emulate a scsi HBA in the guest
* (storvsc_drv) and so scsi devices in the guest are handled by
* native upper level Linux drivers. Consequently, Hyper-V
* block driver, while being a generic block driver, presently does not
* deal with anything other than devices that would need to be presented
* to the guest as an IDE disk.
*
* This function maps the channel properties as embedded in the input
* parameter device_info onto information necessary to register the
* corresponding block device.
*
* Currently, there is no way to stop the emulation of the block device
* on the host side. And so, to prevent the native IDE drivers in Linux
* from taking over these devices (to be managedby Hyper-V block
* driver), we will take over if need be the major of the IDE controllers.
*
*/

int stor_vsc_get_major_info(struct storvsc_device_info *device_info,
struct storvsc_major_info *major_info)
{
static bool ide0_registered;
static bool ide1_registered;

/*
* For now we only support IDE disks.
*/
major_info->devname = "ide";
major_info->diskname = "hd";

if (device_info->path_id) {
major_info->major = 22;
if (!ide1_registered)
major_info->do_register = true;
else {
major_info->do_register = false;
ide1_registered = true;
}
if (device_info->target_id)
major_info->index = 3;
else
major_info->index = 2;

return 0;
} else {
major_info->major = 3;
if (!ide0_registered)
major_info->do_register = true;
else {
major_info->do_register = false;
ide0_registered = true;
}
if (device_info->target_id)
major_info->index = 1;
else
major_info->index = 0;

return 0;
}

return -ENODEV;
}

/*
* stor_vsc_on_cleanup - Perform any cleanup when the driver is removed
*/
Expand Down
10 changes: 10 additions & 0 deletions trunk/drivers/staging/hv/storvsc_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ struct storvsc_device_info {
unsigned char target_id;
};

struct storvsc_major_info {
int major;
int index;
bool do_register;
char *devname;
char *diskname;
};

/* A storvsc device is a device object that contains a vmbus channel */
struct storvsc_device {
struct hv_device *device;
Expand Down Expand Up @@ -155,5 +163,7 @@ int stor_vsc_on_io_request(struct hv_device *device,
struct hv_storvsc_request *request);
void stor_vsc_on_cleanup(struct hv_driver *driver);

int stor_vsc_get_major_info(struct storvsc_device_info *device_info,
struct storvsc_major_info *major_info);

#endif /* _STORVSC_API_H_ */

0 comments on commit 6388cc8

Please sign in to comment.