* [PATCH 14/22] Staging: hv: Cleanup storvsc_remove()
From: K. Y. Srinivasan @ 2011-04-04 22:48 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1301957291-8035-1-git-send-email-kys@microsoft.com>
storvsc_remove() cannot fail, clean it up accordingly.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/storvsc_drv.c | 14 ++------------
1 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index ae61735..f819c6a 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -404,7 +404,6 @@ static int storvsc_probe(struct device *device)
*/
static int storvsc_remove(struct device *device)
{
- int ret;
struct hv_driver *drv =
drv_to_hv_drv(device->driver);
struct storvsc_driver_object *storvsc_drv_obj = drv->priv;
@@ -413,20 +412,11 @@ static int storvsc_remove(struct device *device)
struct host_device_context *host_device_ctx =
(struct host_device_context *)host->hostdata;
-
- if (!storvsc_drv_obj->base.dev_rm)
- return -1;
-
/*
* Call to the vsc driver to let it know that the device is being
* removed
*/
- ret = storvsc_drv_obj->base.dev_rm(device_obj);
- if (ret != 0) {
- /* TODO: */
- DPRINT_ERR(STORVSC, "unable to remove vsc device (ret %d)",
- ret);
- }
+ storvsc_drv_obj->base.dev_rm(device_obj);
if (host_device_ctx->request_pool) {
kmem_cache_destroy(host_device_ctx->request_pool);
@@ -438,7 +428,7 @@ static int storvsc_remove(struct device *device)
DPRINT_INFO(STORVSC, "releasing host adapter (%p)...", host);
scsi_host_put(host);
- return ret;
+ return 0;
}
/*
--
1.7.4.1
^ permalink raw reply related
* [PATCH 13/22] Staging: hv: Cleanup blkvsc_remove()
From: K. Y. Srinivasan @ 2011-04-04 22:48 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1301957291-8035-1-git-send-email-kys@microsoft.com>
blkvsc_remove() cannot fail. Clean it up accordingly.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 15 +++------------
1 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 32d542d..c0a7acd 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -555,22 +555,12 @@ static int blkvsc_remove(struct device *device)
struct hv_device *device_obj = device_to_hv_device(device);
struct block_device_context *blkdev = dev_get_drvdata(device);
unsigned long flags;
- int ret;
-
-
- if (!storvsc_drv_obj->base.dev_rm)
- return -1;
/*
* Call to the vsc driver to let it know that the device is being
* removed
*/
- ret = storvsc_drv_obj->base.dev_rm(device_obj);
- if (ret != 0) {
- /* TODO: */
- DPRINT_ERR(BLKVSC_DRV,
- "unable to remove blkvsc device (ret %d)", ret);
- }
+ storvsc_drv_obj->base.dev_rm(device_obj);
/* Get to a known state */
spin_lock_irqsave(&blkdev->lock, flags);
@@ -603,7 +593,8 @@ static int blkvsc_remove(struct device *device)
kfree(blkdev);
- return ret;
+ return 0;
+
}
static void blkvsc_shutdown(struct device *device)
--
1.7.4.1
^ permalink raw reply related
* [PATCH 12/22] Staging: hv: Get rid of some DPRINT_DBG() calls
From: K. Y. Srinivasan @ 2011-04-04 22:48 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
In-Reply-To: <1301957291-8035-1-git-send-email-kys@microsoft.com>
Get rid of some of the DPRINT_DBG() statements.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 84 ---------------------------------------
1 files changed, 0 insertions(+), 84 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 1f4dd69..32d542d 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -220,14 +220,6 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
struct vmscsi_request *vm_srb;
int ret;
- DPRINT_DBG(BLKVSC_DRV, "blkvsc_submit_request() - "
- "req %p type %s start_sector %lu count %ld offset %d "
- "len %d\n", blkvsc_req,
- (blkvsc_req->write) ? "WRITE" : "READ",
- (unsigned long) blkvsc_req->sector_start,
- blkvsc_req->sector_count,
- blkvsc_req->request.data_buffer.offset,
- blkvsc_req->request.data_buffer.len);
storvsc_req = &blkvsc_req->request;
vm_srb = &storvsc_req->vstor_packet.vm_srb;
@@ -260,8 +252,6 @@ static int blkvsc_open(struct block_device *bdev, fmode_t mode)
{
struct block_device_context *blkdev = bdev->bd_disk->private_data;
- DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users,
- blkdev->gd->disk_name);
mutex_lock(&blkvsc_mutex);
spin_lock(&blkdev->lock);
@@ -351,8 +341,6 @@ static void blkvsc_cmd_completion(struct hv_storvsc_request *request)
struct scsi_sense_hdr sense_hdr;
struct vmscsi_request *vm_srb;
- DPRINT_DBG(BLKVSC_DRV, "blkvsc_cmd_completion() - req %p\n",
- blkvsc_req);
vm_srb = &blkvsc_req->request.vstor_packet.vm_srb;
blkdev->num_outstanding_reqs--;
@@ -495,7 +483,6 @@ static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev)
int ret = 0;
- DPRINT_DBG(BLKVSC_DRV, "blkvsc_cancel_pending_reqs()");
/* Flush the pending list first */
list_for_each_entry_safe(pend_req, tmp, &blkdev->pending_list,
@@ -508,11 +495,6 @@ static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev)
list_for_each_entry_safe(comp_req, tmp2,
&pend_req->group->blkvsc_req_list,
req_entry) {
- DPRINT_DBG(BLKVSC_DRV, "completing blkvsc_req %p "
- "sect_start %lu sect_count %ld\n",
- comp_req,
- (unsigned long) comp_req->sector_start,
- comp_req->sector_count);
if (comp_req == pend_req)
break;
@@ -536,9 +518,6 @@ static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev)
kmem_cache_free(blkdev->request_pool, comp_req);
}
- DPRINT_DBG(BLKVSC_DRV, "cancelling pending request - %p\n",
- pend_req);
-
list_del(&pend_req->pend_entry);
list_del(&pend_req->req_entry);
@@ -551,9 +530,6 @@ static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev)
* All the sectors have been xferred ie the
* request is done
*/
- DPRINT_DBG(BLKVSC_DRV,
- "blkvsc_cancel_pending_reqs() - "
- "req %p COMPLETED\n", pend_req->req);
kmem_cache_free(blkdev->request_pool,
pend_req->group);
}
@@ -581,7 +557,6 @@ static int blkvsc_remove(struct device *device)
unsigned long flags;
int ret;
- DPRINT_DBG(BLKVSC_DRV, "blkvsc_remove()\n");
if (!storvsc_drv_obj->base.dev_rm)
return -1;
@@ -639,9 +614,6 @@ static void blkvsc_shutdown(struct device *device)
if (!blkdev)
return;
- DPRINT_DBG(BLKVSC_DRV, "blkvsc_shutdown - users %d disk %s\n",
- blkdev->users, blkdev->gd->disk_name);
-
spin_lock_irqsave(&blkdev->lock, flags);
blkdev->shutting_down = 1;
@@ -669,9 +641,6 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode)
{
struct block_device_context *blkdev = disk->private_data;
- DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users,
- blkdev->gd->disk_name);
-
mutex_lock(&blkvsc_mutex);
spin_lock(&blkdev->lock);
if (blkdev->users == 1) {
@@ -709,9 +678,6 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
int pending = 0;
struct blkvsc_request_group *group = NULL;
- DPRINT_DBG(BLKVSC_DRV, "blkdev %p req %p sect %lu\n", blkdev, req,
- (unsigned long)blk_rq_pos(req));
-
/* Create a group to tie req to list of blkvsc_reqs */
group = kmem_cache_zalloc(blkdev->request_pool, GFP_ATOMIC);
if (!group)
@@ -729,11 +695,6 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
* Map this bio into an existing or new storvsc request
*/
bio_for_each_segment(bvec, bio, seg_idx) {
- DPRINT_DBG(BLKVSC_DRV, "bio_for_each_segment() "
- "- req %p bio %p bvec %p seg_idx %d "
- "databuf_idx %d\n", req, bio, bvec,
- seg_idx, databuf_idx);
-
/* Get a new storvsc request */
/* 1st-time */
if ((!blkvsc_req) ||
@@ -826,10 +787,6 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
/* Handle the last one */
if (blkvsc_req) {
- DPRINT_DBG(BLKVSC_DRV, "blkdev %p req %p group %p count %d\n",
- blkdev, req, blkvsc_req->group,
- blkvsc_req->group->outstanding);
-
blkvsc_req->sector_start = start_sector;
sector_div(blkvsc_req->sector_start,
(blkdev->sector_size >> 9));
@@ -842,13 +799,6 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
list_for_each_entry(blkvsc_req, &group->blkvsc_req_list, req_entry) {
if (pending) {
- DPRINT_DBG(BLKVSC_DRV, "adding blkvsc_req to "
- "pending_list - blkvsc_req %p start_sect %lu"
- " sect_count %ld (%lu %ld)\n", blkvsc_req,
- (unsigned long)blkvsc_req->sector_start,
- blkvsc_req->sector_count,
- (unsigned long)start_sector,
- (unsigned long)num_sectors);
list_add_tail(&blkvsc_req->pend_entry,
&blkdev->pending_list);
@@ -861,13 +811,6 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
&blkdev->pending_list);
}
- DPRINT_DBG(BLKVSC_DRV, "submitted blkvsc_req %p "
- "start_sect %lu sect_count %ld (%lu %ld) "
- "ret %d\n", blkvsc_req,
- (unsigned long)blkvsc_req->sector_start,
- blkvsc_req->sector_count,
- (unsigned long)start_sector,
- num_sectors, ret);
}
}
@@ -882,8 +825,6 @@ static int blkvsc_do_pending_reqs(struct block_device_context *blkdev)
/* Flush the pending list first */
list_for_each_entry_safe(pend_req, tmp, &blkdev->pending_list,
pend_entry) {
- DPRINT_DBG(BLKVSC_DRV, "working off pending_list - %p\n",
- pend_req);
ret = blkvsc_submit_request(pend_req,
blkvsc_request_completion);
@@ -903,9 +844,7 @@ static void blkvsc_request(struct request_queue *queue)
struct request *req;
int ret = 0;
- DPRINT_DBG(BLKVSC_DRV, "- enter\n");
while ((req = blk_peek_request(queue)) != NULL) {
- DPRINT_DBG(BLKVSC_DRV, "- req %p\n", req);
blkdev = req->rq_disk->private_data;
if (blkdev->shutting_down || req->cmd_type != REQ_TYPE_FS) {
@@ -916,8 +855,6 @@ static void blkvsc_request(struct request_queue *queue)
ret = blkvsc_do_pending_reqs(blkdev);
if (ret != 0) {
- DPRINT_DBG(BLKVSC_DRV,
- "- stop queue - pending_list not empty\n");
blk_stop_queue(queue);
break;
}
@@ -926,11 +863,9 @@ static void blkvsc_request(struct request_queue *queue)
ret = blkvsc_do_request(blkdev, req);
if (ret > 0) {
- DPRINT_DBG(BLKVSC_DRV, "- stop queue - no room\n");
blk_stop_queue(queue);
break;
} else if (ret < 0) {
- DPRINT_DBG(BLKVSC_DRV, "- stop queue - no mem\n");
blk_requeue_request(queue, req);
blk_stop_queue(queue);
break;
@@ -1040,7 +975,6 @@ static int blkvsc_probe(struct device *device)
static int ide0_registered;
static int ide1_registered;
- DPRINT_DBG(BLKVSC_DRV, "blkvsc_probe - enter");
if (!storvsc_drv_obj->base.dev_add) {
DPRINT_ERR(BLKVSC_DRV, "OnDeviceAdd() not set");
@@ -1194,17 +1128,6 @@ static void blkvsc_request_completion(struct hv_storvsc_request *request)
struct vmscsi_request *vm_srb;
- DPRINT_DBG(BLKVSC_DRV, "blkdev %p blkvsc_req %p group %p type %s "
- "sect_start %lu sect_count %ld len %d group outstd %d "
- "total outstd %d\n",
- blkdev, blkvsc_req, blkvsc_req->group,
- (blkvsc_req->write) ? "WRITE" : "READ",
- (unsigned long)blkvsc_req->sector_start,
- blkvsc_req->sector_count,
- blkvsc_req->request.data_buffer.len,
- blkvsc_req->group->outstanding,
- blkdev->num_outstanding_reqs);
-
spin_lock_irqsave(&blkdev->lock, flags);
blkdev->num_outstanding_reqs--;
@@ -1219,11 +1142,6 @@ static void blkvsc_request_completion(struct hv_storvsc_request *request)
list_for_each_entry_safe(comp_req, tmp,
&blkvsc_req->group->blkvsc_req_list,
req_entry) {
- DPRINT_DBG(BLKVSC_DRV, "completing blkvsc_req %p "
- "sect_start %lu sect_count %ld\n",
- comp_req,
- (unsigned long)comp_req->sector_start,
- comp_req->sector_count);
list_del(&comp_req->req_entry);
@@ -1236,8 +1154,6 @@ static void blkvsc_request_completion(struct hv_storvsc_request *request)
* All the sectors have been xferred ie the
* request is done
*/
- DPRINT_DBG(BLKVSC_DRV, "req %p COMPLETED\n",
- comp_req->req);
kmem_cache_free(blkdev->request_pool,
comp_req->group);
}
--
1.7.4.1
^ permalink raw reply related
* [PATCH 11/22] Staging: hv: Get rid of some DPRINT_INFO() statements
From: K. Y. Srinivasan @ 2011-04-04 22:48 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1301957291-8035-1-git-send-email-kys@microsoft.com>
Get rid of some of the DPRINT_INFO() statements.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 69b6290..1f4dd69 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -330,7 +330,6 @@ static int blkvsc_ioctl(struct block_device *bd, fmode_t mode,
switch (cmd) {
case HDIO_GET_IDENTITY:
- DPRINT_INFO(BLKVSC_DRV, "HDIO_GET_IDENTITY\n");
if (copy_to_user((void __user *)arg, blkdev->device_id,
blkdev->device_id_len))
ret = -EFAULT;
@@ -1262,8 +1261,6 @@ static int __init blkvsc_init(void)
BUILD_BUG_ON(sizeof(sector_t) != 8);
- DPRINT_INFO(BLKVSC_DRV, "Blkvsc initializing....");
-
ret = blkvsc_drv_init();
return ret;
--
1.7.4.1
^ permalink raw reply related
* [PATCH 10/22] Staging: hv: Simplify blkvsc_init_rw
From: K. Y. Srinivasan @ 2011-04-04 22:47 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
In-Reply-To: <1301957291-8035-1-git-send-email-kys@microsoft.com>
Simplyfify blkvsc_init_rw() by using a single scsi command independent of
the start sector
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 58 +++++++++------------------------------
1 files changed, 13 insertions(+), 45 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index da7fd38..69b6290 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -304,53 +304,21 @@ static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req)
blkvsc_req->cmd_len = 16;
- if (blkvsc_req->sector_start > 0xffffffff) {
- if (rq_data_dir(blkvsc_req->req)) {
- blkvsc_req->write = 1;
- blkvsc_req->cmnd[0] = WRITE_16;
- } else {
- blkvsc_req->write = 0;
- blkvsc_req->cmnd[0] = READ_16;
- }
-
- blkvsc_req->cmnd[1] |=
- (blkvsc_req->req->cmd_flags & REQ_FUA) ? 0x8 : 0;
-
- *(unsigned long long *)&blkvsc_req->cmnd[2] =
- cpu_to_be64(blkvsc_req->sector_start);
- *(unsigned int *)&blkvsc_req->cmnd[10] =
- cpu_to_be32(blkvsc_req->sector_count);
- } else if ((blkvsc_req->sector_count > 0xff) ||
- (blkvsc_req->sector_start > 0x1fffff)) {
- if (rq_data_dir(blkvsc_req->req)) {
- blkvsc_req->write = 1;
- blkvsc_req->cmnd[0] = WRITE_10;
- } else {
- blkvsc_req->write = 0;
- blkvsc_req->cmnd[0] = READ_10;
- }
-
- blkvsc_req->cmnd[1] |=
- (blkvsc_req->req->cmd_flags & REQ_FUA) ? 0x8 : 0;
-
- *(unsigned int *)&blkvsc_req->cmnd[2] =
- cpu_to_be32(blkvsc_req->sector_start);
- *(unsigned short *)&blkvsc_req->cmnd[7] =
- cpu_to_be16(blkvsc_req->sector_count);
+ if (rq_data_dir(blkvsc_req->req)) {
+ blkvsc_req->write = 1;
+ blkvsc_req->cmnd[0] = WRITE_16;
} else {
- if (rq_data_dir(blkvsc_req->req)) {
- blkvsc_req->write = 1;
- blkvsc_req->cmnd[0] = WRITE_6;
- } else {
- blkvsc_req->write = 0;
- blkvsc_req->cmnd[0] = READ_6;
- }
-
- *(unsigned int *)&blkvsc_req->cmnd[1] =
- cpu_to_be32(blkvsc_req->sector_start) >> 8;
- blkvsc_req->cmnd[1] &= 0x1f;
- blkvsc_req->cmnd[4] = (unsigned char)blkvsc_req->sector_count;
+ blkvsc_req->write = 0;
+ blkvsc_req->cmnd[0] = READ_16;
}
+
+ blkvsc_req->cmnd[1] |=
+ (blkvsc_req->req->cmd_flags & REQ_FUA) ? 0x8 : 0;
+
+ *(unsigned long long *)&blkvsc_req->cmnd[2] =
+ cpu_to_be64(blkvsc_req->sector_start);
+ *(unsigned int *)&blkvsc_req->cmnd[10] =
+ cpu_to_be32(blkvsc_req->sector_count);
}
--
1.7.4.1
^ permalink raw reply related
* [PATCH 09/22] Staging: hv: Get rid of the function blkvsc_revalidate_disk()
From: K. Y. Srinivasan @ 2011-04-04 22:47 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1301957291-8035-1-git-send-email-kys@microsoft.com>
The block driver in Hyper-V does not support removable media, get rid of the
blkvsc_revalidate_disk().
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 17 -----------------
1 files changed, 0 insertions(+), 17 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 1ea5f9c..da7fd38 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -721,22 +721,6 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode)
}
-static int blkvsc_revalidate_disk(struct gendisk *gd)
-{
- struct block_device_context *blkdev = gd->private_data;
-
- DPRINT_DBG(BLKVSC_DRV, "- enter\n");
-
- if (blkdev->device_type == DVD_TYPE) {
- blkvsc_do_operation(blkdev, DO_CAPACITY);
- set_capacity(blkdev->gd, blkdev->capacity *
- (blkdev->sector_size/512));
- blk_queue_logical_block_size(gd->queue, blkdev->sector_size);
- }
- return 0;
-}
-
-
/*
* We break the request into 1 or more blkvsc_requests and submit
* them. If we cant submit them all, we put them on the
@@ -996,7 +980,6 @@ static const struct block_device_operations block_ops = {
.owner = THIS_MODULE,
.open = blkvsc_open,
.release = blkvsc_release,
- .revalidate_disk = blkvsc_revalidate_disk,
.getgeo = blkvsc_getgeo,
.ioctl = blkvsc_ioctl,
};
--
1.7.4.1
^ permalink raw reply related
* [PATCH 08/22] Staging hv: Get rid of the state media_not_present
From: K. Y. Srinivasan @ 2011-04-04 22:47 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1301957291-8035-1-git-send-email-kys@microsoft.com>
The block driver in Hyper-V does not handle removable media, get rid of the
media_not_present state.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 9 +--------
1 files changed, 1 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 0715cba..1ea5f9c 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -103,7 +103,6 @@ struct block_device_context {
unsigned int device_id_len;
int num_outstanding_reqs;
int shutting_down;
- int media_not_present;
unsigned int sector_size;
sector_t capacity;
unsigned int port;
@@ -445,7 +444,6 @@ static int blkvsc_do_operation(struct block_device_context *blkdev,
case DO_CAPACITY:
blkdev->sector_size = 0;
blkdev->capacity = 0;
- blkdev->media_not_present = 0; /* assume a disk is present */
blkvsc_req->cmnd[0] = READ_CAPACITY;
blkvsc_req->cmd_len = 16;
@@ -472,10 +470,6 @@ static int blkvsc_do_operation(struct block_device_context *blkdev,
scsi_normalize_sense(blkvsc_req->sense_buffer,
SCSI_SENSE_BUFFERSIZE, &sense_hdr);
- if (sense_hdr.asc == 0x3A)
- /* Medium not present */
- blkdev->media_not_present = 1;
-
return 0;
}
@@ -963,8 +957,7 @@ static void blkvsc_request(struct request_queue *queue)
DPRINT_DBG(BLKVSC_DRV, "- req %p\n", req);
blkdev = req->rq_disk->private_data;
- if (blkdev->shutting_down || req->cmd_type != REQ_TYPE_FS ||
- blkdev->media_not_present) {
+ if (blkdev->shutting_down || req->cmd_type != REQ_TYPE_FS) {
__blk_end_request_cur(req, 0);
continue;
}
--
1.7.4.1
^ permalink raw reply related
* [PATCH 07/22] Staging: hv: Get rid of the function blkvsc_do_flush()
From: K. Y. Srinivasan @ 2011-04-04 22:47 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
In-Reply-To: <1301957291-8035-1-git-send-email-kys@microsoft.com>
Get rid of the function blkvsc_do_flush() and instead use the common function
to force a device flush.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 52 ++++++++++----------------------------
1 files changed, 14 insertions(+), 38 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 4da42c9..0715cba 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -49,6 +49,7 @@ enum blkvsc_device_type {
enum blkvsc_op_type {
DO_INQUIRY,
DO_CAPACITY,
+ DO_FLUSH,
};
/*
@@ -450,6 +451,13 @@ static int blkvsc_do_operation(struct block_device_context *blkdev,
blkvsc_req->cmd_len = 16;
blkvsc_req->request.data_buffer.len = 8;
break;
+
+ case DO_FLUSH:
+ blkvsc_req->cmnd[0] = SYNCHRONIZE_CACHE;
+ blkvsc_req->cmd_len = 10;
+ blkvsc_req->request.data_buffer.pfn_array[0] = 0;
+ blkvsc_req->request.data_buffer.len = 0;
+ break;
default:
ret = -EINVAL;
goto cleanup;
@@ -501,6 +509,9 @@ static int blkvsc_do_operation(struct block_device_context *blkdev,
(buf[4] << 24) | (buf[5] << 16) |
(buf[6] << 8) | buf[7];
break;
+ default:
+ break;
+
}
cleanup:
@@ -514,41 +525,6 @@ cleanup:
return ret;
}
-static int blkvsc_do_flush(struct block_device_context *blkdev)
-{
- struct blkvsc_request *blkvsc_req;
-
- DPRINT_DBG(BLKVSC_DRV, "blkvsc_do_flush()\n");
-
- if (blkdev->device_type != HARDDISK_TYPE)
- return 0;
-
- blkvsc_req = kmem_cache_zalloc(blkdev->request_pool, GFP_KERNEL);
- if (!blkvsc_req)
- return -ENOMEM;
-
- memset(blkvsc_req, 0, sizeof(struct blkvsc_request));
- init_completion(&blkvsc_req->request.wait_event);
- blkvsc_req->dev = blkdev;
- blkvsc_req->req = NULL;
- blkvsc_req->write = 0;
-
- blkvsc_req->request.data_buffer.pfn_array[0] = 0;
- blkvsc_req->request.data_buffer.offset = 0;
- blkvsc_req->request.data_buffer.len = 0;
-
- blkvsc_req->cmnd[0] = SYNCHRONIZE_CACHE;
- blkvsc_req->cmd_len = 10;
-
- blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion);
-
- wait_for_completion_interruptible(&blkvsc_req->request.wait_event);
-
- kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
-
- return 0;
-}
-
static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev)
{
@@ -675,7 +651,7 @@ static int blkvsc_remove(struct device *device)
udelay(100);
}
- blkvsc_do_flush(blkdev);
+ blkvsc_do_operation(blkdev, DO_FLUSH);
spin_lock_irqsave(&blkdev->lock, flags);
@@ -719,7 +695,7 @@ static void blkvsc_shutdown(struct device *device)
udelay(100);
}
- blkvsc_do_flush(blkdev);
+ blkvsc_do_operation(blkdev, DO_FLUSH);
spin_lock_irqsave(&blkdev->lock, flags);
@@ -739,7 +715,7 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode)
spin_lock(&blkdev->lock);
if (blkdev->users == 1) {
spin_unlock(&blkdev->lock);
- blkvsc_do_flush(blkdev);
+ blkvsc_do_operation(blkdev, DO_FLUSH);
spin_lock(&blkdev->lock);
}
--
1.7.4.1
^ permalink raw reply related
* [PATCH 06/22] Staging: hv: Get rid of blkvsc_do_read_capacity16()
From: K. Y. Srinivasan @ 2011-04-04 22:47 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1301957291-8035-1-git-send-email-kys@microsoft.com>
Get rid of blkvsc_do_read_capacity16() and instead use the common function
for retrieving capacity.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 81 +--------------------------------------
1 files changed, 2 insertions(+), 79 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 925b898..4da42c9 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -751,82 +751,6 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode)
}
-static int blkvsc_do_read_capacity16(struct block_device_context *blkdev)
-{
- struct blkvsc_request *blkvsc_req;
- struct page *page_buf;
- unsigned char *buf;
- struct scsi_sense_hdr sense_hdr;
- struct vmscsi_request *vm_srb;
-
- DPRINT_DBG(BLKVSC_DRV, "blkvsc_do_read_capacity16()\n");
-
- blkdev->sector_size = 0;
- blkdev->capacity = 0;
- blkdev->media_not_present = 0; /* assume a disk is present */
-
- blkvsc_req = kmem_cache_zalloc(blkdev->request_pool, GFP_KERNEL);
- if (!blkvsc_req)
- return -ENOMEM;
-
- memset(blkvsc_req, 0, sizeof(struct blkvsc_request));
- vm_srb = &blkvsc_req->request.vstor_packet.vm_srb;
- page_buf = alloc_page(GFP_KERNEL);
- if (!page_buf) {
- kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
- return -ENOMEM;
- }
-
- init_completion(&blkvsc_req->request.wait_event);
- blkvsc_req->dev = blkdev;
- blkvsc_req->req = NULL;
- blkvsc_req->write = 0;
-
- blkvsc_req->request.data_buffer.pfn_array[0] =
- page_to_pfn(page_buf);
- blkvsc_req->request.data_buffer.offset = 0;
- blkvsc_req->request.data_buffer.len = 12;
-
- blkvsc_req->cmnd[0] = 0x9E; /* READ_CAPACITY16; */
- blkvsc_req->cmd_len = 16;
-
- /*
- * Set this here since the completion routine may be invoked
- * and completed before we return
- */
-
- blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion);
-
- DPRINT_DBG(BLKVSC_DRV, "waiting %p to complete\n",
- blkvsc_req);
-
- wait_for_completion_interruptible(&blkvsc_req->request.wait_event);
-
- /* check error */
- if (vm_srb->scsi_status) {
- scsi_normalize_sense(blkvsc_req->sense_buffer,
- SCSI_SENSE_BUFFERSIZE, &sense_hdr);
- if (sense_hdr.asc == 0x3A) {
- /* Medium not present */
- blkdev->media_not_present = 1;
- }
- return 0;
- }
- buf = kmap(page_buf);
-
- /* be to le */
- blkdev->capacity = be64_to_cpu(*(unsigned long long *) &buf[0]) + 1;
- blkdev->sector_size = be32_to_cpu(*(unsigned int *)&buf[8]);
-
- kunmap(page_buf);
-
- __free_page(page_buf);
-
- kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
-
- return 0;
-}
-
static int blkvsc_revalidate_disk(struct gendisk *gd)
{
struct block_device_context *blkdev = gd->private_data;
@@ -1310,9 +1234,8 @@ static int blkvsc_probe(struct device *device)
set_disk_ro(blkdev->gd, 1);
blkdev->gd->flags |= GENHD_FL_REMOVABLE;
blkvsc_do_operation(blkdev, DO_CAPACITY);
- } else {
- blkvsc_do_read_capacity16(blkdev);
- }
+ } else
+ blkvsc_do_operation(blkdev, DO_CAPACITY);
set_capacity(blkdev->gd, blkdev->capacity * (blkdev->sector_size/512));
blk_queue_logical_block_size(blkdev->gd->queue, blkdev->sector_size);
--
1.7.4.1
^ permalink raw reply related
* [PATCH 05/22] Staging: hv: Get rid of blkvsc_do_read_capacity()
From: K. Y. Srinivasan @ 2011-04-04 22:47 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
In-Reply-To: <1301957291-8035-1-git-send-email-kys@microsoft.com>
Now that we have a common function for some of the operations on the device,
use that and get rid of the function blkvsc_do_read_capacity().
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 117 +++++++++++++--------------------------
1 files changed, 39 insertions(+), 78 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 8094c5e..925b898 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -48,6 +48,7 @@ enum blkvsc_device_type {
enum blkvsc_op_type {
DO_INQUIRY,
+ DO_CAPACITY,
};
/*
@@ -405,6 +406,9 @@ static int blkvsc_do_operation(struct block_device_context *blkdev,
struct page *page_buf;
unsigned char *buf;
unsigned char device_type;
+ struct scsi_sense_hdr sense_hdr;
+ struct vmscsi_request *vm_srb;
+
int ret = 0;
blkvsc_req = kmem_cache_zalloc(blkdev->request_pool, GFP_KERNEL);
@@ -417,6 +421,7 @@ static int blkvsc_do_operation(struct block_device_context *blkdev,
return -ENOMEM;
}
+ vm_srb = &blkvsc_req->request.vstor_packet.vm_srb;
init_completion(&blkvsc_req->request.wait_event);
blkvsc_req->dev = blkdev;
blkvsc_req->req = NULL;
@@ -436,6 +441,15 @@ static int blkvsc_do_operation(struct block_device_context *blkdev,
blkvsc_req->request.data_buffer.len = 64;
break;
+ case DO_CAPACITY:
+ blkdev->sector_size = 0;
+ blkdev->capacity = 0;
+ blkdev->media_not_present = 0; /* assume a disk is present */
+
+ blkvsc_req->cmnd[0] = READ_CAPACITY;
+ blkvsc_req->cmd_len = 16;
+ blkvsc_req->request.data_buffer.len = 8;
+ break;
default:
ret = -EINVAL;
goto cleanup;
@@ -445,6 +459,18 @@ static int blkvsc_do_operation(struct block_device_context *blkdev,
wait_for_completion_interruptible(&blkvsc_req->request.wait_event);
+ /* check error */
+ if (vm_srb->scsi_status) {
+ scsi_normalize_sense(blkvsc_req->sense_buffer,
+ SCSI_SENSE_BUFFERSIZE, &sense_hdr);
+
+ if (sense_hdr.asc == 0x3A)
+ /* Medium not present */
+ blkdev->media_not_present = 1;
+
+ return 0;
+ }
+
buf = kmap(page_buf);
switch (op) {
@@ -464,6 +490,17 @@ static int blkvsc_do_operation(struct block_device_context *blkdev,
memcpy(blkdev->device_id, &buf[8], blkdev->device_id_len);
break;
+
+ case DO_CAPACITY:
+ /* be to le */
+ blkdev->capacity =
+ ((buf[0] << 24) | (buf[1] << 16) |
+ (buf[2] << 8) | buf[3]) + 1;
+
+ blkdev->sector_size =
+ (buf[4] << 24) | (buf[5] << 16) |
+ (buf[6] << 8) | buf[7];
+ break;
}
cleanup:
@@ -714,82 +751,6 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode)
}
-/* Do a scsi READ_CAPACITY cmd here to get the size of the disk */
-static int blkvsc_do_read_capacity(struct block_device_context *blkdev)
-{
- struct blkvsc_request *blkvsc_req;
- struct page *page_buf;
- unsigned char *buf;
- struct scsi_sense_hdr sense_hdr;
- struct vmscsi_request *vm_srb;
-
- DPRINT_DBG(BLKVSC_DRV, "blkvsc_do_read_capacity()\n");
-
- blkdev->sector_size = 0;
- blkdev->capacity = 0;
- blkdev->media_not_present = 0; /* assume a disk is present */
-
- blkvsc_req = kmem_cache_zalloc(blkdev->request_pool, GFP_KERNEL);
- if (!blkvsc_req)
- return -ENOMEM;
-
- memset(blkvsc_req, 0, sizeof(struct blkvsc_request));
- page_buf = alloc_page(GFP_KERNEL);
- if (!page_buf) {
- kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
- return -ENOMEM;
- }
-
- vm_srb = &blkvsc_req->request.vstor_packet.vm_srb;
- init_completion(&blkvsc_req->request.wait_event);
- blkvsc_req->dev = blkdev;
- blkvsc_req->req = NULL;
- blkvsc_req->write = 0;
-
- blkvsc_req->request.data_buffer.pfn_array[0] =
- page_to_pfn(page_buf);
- blkvsc_req->request.data_buffer.offset = 0;
- blkvsc_req->request.data_buffer.len = 8;
-
- blkvsc_req->cmnd[0] = READ_CAPACITY;
- blkvsc_req->cmd_len = 16;
-
- blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion);
-
- DPRINT_DBG(BLKVSC_DRV, "waiting %p to complete\n",
- blkvsc_req);
-
- wait_for_completion_interruptible(&blkvsc_req->request.wait_event);
-
- /* check error */
- if (vm_srb->scsi_status) {
- scsi_normalize_sense(blkvsc_req->sense_buffer,
- SCSI_SENSE_BUFFERSIZE, &sense_hdr);
-
- if (sense_hdr.asc == 0x3A) {
- /* Medium not present */
- blkdev->media_not_present = 1;
- }
- return 0;
- }
- buf = kmap(page_buf);
-
- /* be to le */
- blkdev->capacity = ((buf[0] << 24) | (buf[1] << 16) |
- (buf[2] << 8) | buf[3]) + 1;
- blkdev->sector_size = (buf[4] << 24) | (buf[5] << 16) |
- (buf[6] << 8) | buf[7];
-
- kunmap(page_buf);
-
- __free_page(page_buf);
-
- kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
-
- return 0;
-}
-
-
static int blkvsc_do_read_capacity16(struct block_device_context *blkdev)
{
struct blkvsc_request *blkvsc_req;
@@ -873,7 +834,7 @@ static int blkvsc_revalidate_disk(struct gendisk *gd)
DPRINT_DBG(BLKVSC_DRV, "- enter\n");
if (blkdev->device_type == DVD_TYPE) {
- blkvsc_do_read_capacity(blkdev);
+ blkvsc_do_operation(blkdev, DO_CAPACITY);
set_capacity(blkdev->gd, blkdev->capacity *
(blkdev->sector_size/512));
blk_queue_logical_block_size(gd->queue, blkdev->sector_size);
@@ -1348,7 +1309,7 @@ static int blkvsc_probe(struct device *device)
if (blkdev->device_type == DVD_TYPE) {
set_disk_ro(blkdev->gd, 1);
blkdev->gd->flags |= GENHD_FL_REMOVABLE;
- blkvsc_do_read_capacity(blkdev);
+ blkvsc_do_operation(blkdev, DO_CAPACITY);
} else {
blkvsc_do_read_capacity16(blkdev);
}
--
1.7.4.1
^ permalink raw reply related
* [PATCH 04/22] Staging: hv: Introduce a common function for issuing commands to the device
From: K. Y. Srinivasan @ 2011-04-04 22:47 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1301957291-8035-1-git-send-email-kys@microsoft.com>
There are multiple functions to either get info about the device
(INQUIRY, CAPACITY etc) or to FLUSH the device cache. The majority of the
code for these functions is identical. Introduce a common function for
doing all these operations.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 163 ++++++++++++++++++++------------------
1 files changed, 86 insertions(+), 77 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index ad09917..8094c5e 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -46,6 +46,10 @@ enum blkvsc_device_type {
DVD_TYPE,
};
+enum blkvsc_op_type {
+ DO_INQUIRY,
+};
+
/*
* This request ties the struct request and struct
* blkvsc_request/hv_storvsc_request together A struct request may be
@@ -393,6 +397,86 @@ static void blkvsc_cmd_completion(struct hv_storvsc_request *request)
complete(&blkvsc_req->request.wait_event);
}
+
+static int blkvsc_do_operation(struct block_device_context *blkdev,
+ enum blkvsc_op_type op)
+{
+ struct blkvsc_request *blkvsc_req;
+ struct page *page_buf;
+ unsigned char *buf;
+ unsigned char device_type;
+ int ret = 0;
+
+ blkvsc_req = kmem_cache_zalloc(blkdev->request_pool, GFP_KERNEL);
+ if (!blkvsc_req)
+ return -ENOMEM;
+
+ page_buf = alloc_page(GFP_KERNEL);
+ if (!page_buf) {
+ kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
+ return -ENOMEM;
+ }
+
+ init_completion(&blkvsc_req->request.wait_event);
+ blkvsc_req->dev = blkdev;
+ blkvsc_req->req = NULL;
+ blkvsc_req->write = 0;
+
+ blkvsc_req->request.data_buffer.pfn_array[0] =
+ page_to_pfn(page_buf);
+ blkvsc_req->request.data_buffer.offset = 0;
+
+ switch (op) {
+ case DO_INQUIRY:
+ blkvsc_req->cmnd[0] = INQUIRY;
+ blkvsc_req->cmnd[1] = 0x1; /* Get product data */
+ blkvsc_req->cmnd[2] = 0x83; /* mode page 83 */
+ blkvsc_req->cmnd[4] = 64;
+ blkvsc_req->cmd_len = 6;
+ blkvsc_req->request.data_buffer.len = 64;
+ break;
+
+ default:
+ ret = -EINVAL;
+ goto cleanup;
+ }
+
+ blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion);
+
+ wait_for_completion_interruptible(&blkvsc_req->request.wait_event);
+
+ buf = kmap(page_buf);
+
+ switch (op) {
+ case DO_INQUIRY:
+ device_type = buf[0] & 0x1F;
+
+ if (device_type == 0x0)
+ blkdev->device_type = HARDDISK_TYPE;
+ else if (device_type == 0x5)
+ blkdev->device_type = DVD_TYPE;
+ else
+ blkdev->device_type = UNKNOWN_DEV_TYPE;
+
+ blkdev->device_id_len = buf[7];
+ if (blkdev->device_id_len > 64)
+ blkdev->device_id_len = 64;
+
+ memcpy(blkdev->device_id, &buf[8], blkdev->device_id_len);
+ break;
+ }
+
+cleanup:
+
+ kunmap(page_buf);
+
+ __free_page(page_buf);
+
+ kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
+
+ return ret;
+}
+
static int blkvsc_do_flush(struct block_device_context *blkdev)
{
struct blkvsc_request *blkvsc_req;
@@ -798,82 +882,6 @@ static int blkvsc_revalidate_disk(struct gendisk *gd)
}
-/* Do a scsi INQUIRY cmd here to get the device type (ie disk or dvd) */
-static int blkvsc_do_inquiry(struct block_device_context *blkdev)
-{
- struct blkvsc_request *blkvsc_req;
- struct page *page_buf;
- unsigned char *buf;
- unsigned char device_type;
-
- DPRINT_DBG(BLKVSC_DRV, "blkvsc_do_inquiry()\n");
-
- blkvsc_req = kmem_cache_zalloc(blkdev->request_pool, GFP_KERNEL);
- if (!blkvsc_req)
- return -ENOMEM;
-
- memset(blkvsc_req, 0, sizeof(struct blkvsc_request));
- page_buf = alloc_page(GFP_KERNEL);
- if (!page_buf) {
- kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
- return -ENOMEM;
- }
-
- init_completion(&blkvsc_req->request.wait_event);
- blkvsc_req->dev = blkdev;
- blkvsc_req->req = NULL;
- blkvsc_req->write = 0;
-
- blkvsc_req->request.data_buffer.pfn_array[0] =
- page_to_pfn(page_buf);
- blkvsc_req->request.data_buffer.offset = 0;
- blkvsc_req->request.data_buffer.len = 64;
-
- blkvsc_req->cmnd[0] = INQUIRY;
- blkvsc_req->cmnd[1] = 0x1; /* Get product data */
- blkvsc_req->cmnd[2] = 0x83; /* mode page 83 */
- blkvsc_req->cmnd[4] = 64;
- blkvsc_req->cmd_len = 6;
-
- blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion);
-
- DPRINT_DBG(BLKVSC_DRV, "waiting %p to complete\n",
- blkvsc_req);
-
- wait_for_completion_interruptible(&blkvsc_req->request.wait_event);
-
- buf = kmap(page_buf);
-
- /* be to le */
- device_type = buf[0] & 0x1F;
-
- if (device_type == 0x0) {
- blkdev->device_type = HARDDISK_TYPE;
- } else if (device_type == 0x5) {
- blkdev->device_type = DVD_TYPE;
- } else {
- /* TODO: this is currently unsupported device type */
- blkdev->device_type = UNKNOWN_DEV_TYPE;
- }
-
- DPRINT_DBG(BLKVSC_DRV, "device type %d\n", device_type);
-
- blkdev->device_id_len = buf[7];
- if (blkdev->device_id_len > 64)
- blkdev->device_id_len = 64;
-
- memcpy(blkdev->device_id, &buf[8], blkdev->device_id_len);
-
- kunmap(page_buf);
-
- __free_page(page_buf);
-
- kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
-
- return 0;
-}
-
-
/*
* We break the request into 1 or more blkvsc_requests and submit
* them. If we cant submit them all, we put them on the
@@ -1126,6 +1134,7 @@ static void blkvsc_request(struct request_queue *queue)
}
+
/* The one and only one */
static struct storvsc_driver_object g_blkvsc_drv;
@@ -1335,7 +1344,7 @@ static int blkvsc_probe(struct device *device)
blkdev->gd->driverfs_dev = &(blkdev->device_ctx->device);
sprintf(blkdev->gd->disk_name, "hd%c", 'a' + devnum);
- blkvsc_do_inquiry(blkdev);
+ blkvsc_do_operation(blkdev, DO_INQUIRY);
if (blkdev->device_type == DVD_TYPE) {
set_disk_ro(blkdev->gd, 1);
blkdev->gd->flags |= GENHD_FL_REMOVABLE;
--
1.7.4.1
^ permalink raw reply related
* [PATCH 03/22] Staging: hv: Simplify the code for blkvsc_getgeo()
From: K. Y. Srinivasan @ 2011-04-04 22:47 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
In-Reply-To: <1301957291-8035-1-git-send-email-kys@microsoft.com>
We are making up the geometry anyway, keep it simple.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 84 +++++---------------------------------
1 files changed, 11 insertions(+), 73 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 12a9083..ad09917 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -277,82 +277,20 @@ static int blkvsc_open(struct block_device *bdev, fmode_t mode)
static int blkvsc_getgeo(struct block_device *bd, struct hd_geometry *hg)
{
- sector_t total_sectors = get_capacity(bd->bd_disk);
- sector_t cylinder_times_heads = 0;
- sector_t temp = 0;
+ sector_t nsect = get_capacity(bd->bd_disk);
+ sector_t cylinders = nsect;
- int sectors_per_track = 0;
- int heads = 0;
- int cylinders = 0;
- int rem = 0;
-
- if (total_sectors > (65535 * 16 * 255))
- total_sectors = (65535 * 16 * 255);
-
- if (total_sectors >= (65535 * 16 * 63)) {
- sectors_per_track = 255;
- heads = 16;
-
- cylinder_times_heads = total_sectors;
- /* sector_div stores the quotient in cylinder_times_heads */
- rem = sector_div(cylinder_times_heads, sectors_per_track);
- } else {
- sectors_per_track = 17;
-
- cylinder_times_heads = total_sectors;
- /* sector_div stores the quotient in cylinder_times_heads */
- rem = sector_div(cylinder_times_heads, sectors_per_track);
-
- temp = cylinder_times_heads + 1023;
- /* sector_div stores the quotient in temp */
- rem = sector_div(temp, 1024);
-
- heads = temp;
-
- if (heads < 4)
- heads = 4;
-
-
- if (cylinder_times_heads >= (heads * 1024) || (heads > 16)) {
- sectors_per_track = 31;
- heads = 16;
-
- cylinder_times_heads = total_sectors;
- /*
- * sector_div stores the quotient in
- * cylinder_times_heads
- */
- rem = sector_div(cylinder_times_heads,
- sectors_per_track);
- }
-
- if (cylinder_times_heads >= (heads * 1024)) {
- sectors_per_track = 63;
- heads = 16;
-
- cylinder_times_heads = total_sectors;
- /*
- * sector_div stores the quotient in
- * cylinder_times_heads
- */
- rem = sector_div(cylinder_times_heads,
- sectors_per_track);
- }
- }
-
- temp = cylinder_times_heads;
- /* sector_div stores the quotient in temp */
- rem = sector_div(temp, heads);
- cylinders = temp;
-
- hg->heads = heads;
- hg->sectors = sectors_per_track;
+ /*
+ * We are making up these values; let us keep it simple.
+ */
+ hg->heads = 0xff;
+ hg->sectors = 0x3f;
+ sector_div(cylinders, hg->heads * hg->sectors);
hg->cylinders = cylinders;
-
- DPRINT_INFO(BLKVSC_DRV, "CHS (%d, %d, %d)", cylinders, heads,
- sectors_per_track);
-
+ if ((sector_t)(hg->cylinders + 1) * hg->heads * hg->sectors < nsect)
+ hg->cylinders = 0xffff;
return 0;
+
}
--
1.7.4.1
^ permalink raw reply related
* [PATCH 02/22] Staging: hv: Enable blkvsc_ioctl()
From: K. Y. Srinivasan @ 2011-04-04 22:47 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1301957291-8035-1-git-send-email-kys@microsoft.com>
We can support HDIO_GET_IDENTITY ioctl, enable blkvsc_ioctl().
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 1203049..12a9083 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -412,23 +412,18 @@ static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req)
static int blkvsc_ioctl(struct block_device *bd, fmode_t mode,
- unsigned cmd, unsigned long argument)
+ unsigned cmd, unsigned long arg)
{
- int ret;
+ struct block_device_context *blkdev = bd->bd_disk->private_data;
+ int ret = 0;
switch (cmd) {
- /*
- * TODO: I think there is certain format for HDIO_GET_IDENTITY rather
- * than just a GUID. Commented it out for now.
- */
-#if 0
case HDIO_GET_IDENTITY:
DPRINT_INFO(BLKVSC_DRV, "HDIO_GET_IDENTITY\n");
if (copy_to_user((void __user *)arg, blkdev->device_id,
blkdev->device_id_len))
ret = -EFAULT;
break;
-#endif
default:
ret = -EINVAL;
break;
--
1.7.4.1
^ permalink raw reply related
* [PATCH 01/22] Staging: hv: Get rid of blkvsc_media_changed()
From: K. Y. Srinivasan @ 2011-04-04 22:47 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1301957186-7853-1-git-send-email-kys@microsoft.com>
We don't support removable media in Hyper-V block driver.
Get rid of blkvsc_media_changed() as it is efectively "dead code".
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 7 -------
1 files changed, 0 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 9faccbe..1203049 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -251,12 +251,6 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
return ret;
}
-static int blkvsc_media_changed(struct gendisk *gd)
-{
- DPRINT_DBG(BLKVSC_DRV, "- enter\n");
- return 1;
-}
-
static int blkvsc_open(struct block_device *bdev, fmode_t mode)
{
struct block_device_context *blkdev = bdev->bd_disk->private_data;
@@ -1206,7 +1200,6 @@ static const struct block_device_operations block_ops = {
.owner = THIS_MODULE,
.open = blkvsc_open,
.release = blkvsc_release,
- .media_changed = blkvsc_media_changed,
.revalidate_disk = blkvsc_revalidate_disk,
.getgeo = blkvsc_getgeo,
.ioctl = blkvsc_ioctl,
--
1.7.4.1
^ permalink raw reply related
* [PATCH 00/22] Staging: hv: Cleanup storage drivers - Phase IV
From: K. Y. Srinivasan @ 2011-04-04 22:46 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: K. Y. Srinivasan
More cleanup. In this patch-set we deal with the following issues:
1) While a Linux guest on Hyper-V can be assigned removable media
devices (DVD, floppy etc), these devices are not handled by the
Hyper-V block driver. So, we cleanup all the dead code
dealing with removable media devices.
2) There were multiple functions to retrieve information about
the device. Since much of the code in these functions were
identical, we have consolidated these functions into a single
function.
3) Enable the ioctl code for handling HDIO_GET_IDENTITY
4) Cleanup the code for getting the geometry.
5) Cleanup code for retreiving device capacity; this has also fixed
a bug with regards to presenting physical disks to the guest
as an IDE disk.
6) General cleanup: simplify blkvsc_init_rw(), get rid of
unnecessary DPRINT*() calls, get rid of unnecessary code,
cleanup blkvsc_open().
7) Remove all IDE details from blkvsc_drv.c.
Regards,
K. Y
^ permalink raw reply
* Re: [PATCH RESEND] net: convert xen-netfront to hw_features
From: David Miller @ 2011-04-04 18:08 UTC (permalink / raw)
To: Ian.Campbell
Cc: Jeremy.Fitzhardinge, konrad.wilk, netdev, virtualization,
xen-devel, mirq-linux
In-Reply-To: <1301920159.23887.96.camel@zakaz.uk.xensource.com>
From: Ian Campbell <Ian.Campbell@eu.citrix.com>
Date: Mon, 4 Apr 2011 13:29:19 +0100
>>From 0b56469abe56efae415b4603ef508ce9aec0e4c1 Mon Sep 17 00:00:00 2001
> From: Ian Campbell <ian.campbell@citrix.com>
> Date: Mon, 4 Apr 2011 10:58:50 +0100
> Subject: [PATCH] xen: netfront: assume all hw features are available until backend connection setup
>
> We need to assume that all features will be available when registering the
> netdev otherwise they are ommitted from the initial set of
> dev->wanted_features. When we connect to the backed we reduce the set as
> necessary due to the call to netdev_update_features() in xennet_connect().
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
I've applied this, thanks Ian.
^ permalink raw reply
* Re: [PATCH] virtio: Decrement avail idx on buffer detach
From: Amit Shah @ 2011-04-04 15:01 UTC (permalink / raw)
To: Rusty Russell; +Cc: Virtualization List
In-Reply-To: <87bp0mbk3j.fsf@rustcorp.com.au>
On (Mon) 04 Apr 2011 [16:04:40], Rusty Russell wrote:
> On Mon, 28 Mar 2011 19:57:06 +0530, Amit Shah <amit.shah@redhat.com> wrote:
> > On (Thu) 17 Mar 2011 [17:56:59], Amit Shah wrote:
> > > On (Thu) 17 Mar 2011 [15:26:28], Rusty Russell wrote:
> > > > On Wed, 16 Mar 2011 19:12:10 +0530, Amit Shah <amit.shah@redhat.com> wrote:
> > > > > When detaching a buffer from a vq, the avail.idx value should be
> > > > > decremented as well.
> > > > >
> > > > > This was noticed by hot-unplugging a virtio console port and then
> > > > > plugging in a new one on the same number (re-using the vqs which were
> > > > > just 'disowned'). qemu reported
> > > > >
> > > > > 'Guest moved used index from 0 to 256'
> > > > >
> > > > > when any IO was attempted on the new port.
> > > >
> > > > Yech... detach_unused_buf cannot be used on a live virtqueue; it assumes
> > > > we will reset the vq (usually by resetting the entire device).
> > > >
> > > > You've partially violated that assumption by reusing the vq after
> > > > calling detach_unused_buf. So I'm not entirely sure this is the only
> > > > bug lurking; safer would be to re-initialize the vq somehow when you
> > > > plug back in...
> > >
> > > Right; and then that will need host changes too (re-init the vqs on
> > > the host side), which then gets us into compat problems...
> >
> > Rusty, any thoughts on this?
>
> Yes... I've applied your patch for the moment, and will send to Linus
> with cc' stable.
OK, thanks!
Amit
^ permalink raw reply
* Re: [PATCH RESEND] net: convert xen-netfront to hw_features
From: Ian Campbell @ 2011-04-04 12:29 UTC (permalink / raw)
To: David Miller
Cc: Jeremy Fitzhardinge, konrad.wilk@oracle.com,
netdev@vger.kernel.org, virtualization@lists.linux-foundation.org,
xen-devel@lists.xensource.com, mirq-linux@rere.qmqm.pl
In-Reply-To: <20110401.205455.70198735.davem@davemloft.net>
On Sat, 2011-04-02 at 04:54 +0100, David Miller wrote:
> From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> Date: Thu, 31 Mar 2011 13:01:35 +0200 (CEST)
>
> > Not tested in any way. The original code for offload setting seems broken
> > as it resets the features on every netback reconnect.
> >
> > This will set GSO_ROBUST at device creation time (earlier than connect time).
> >
> > RX checksum offload is forced on - so advertise as it is.
> >
> > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
>
> Applied.
Thanks, but unfortunately the patch results in the features all being
disabled by default, since they are not set in the initial dev->features
and the initial dev->wanted_features is based on features & hw_features.
The ndo_fix_features hook only clears features and doesn't add new
features (nor should it AFAICT).
Features cannot be negotiated with the backend until xennet_connect().
The carrier is not enabled until the end of that function, therefore I
think it is safe to start with a full set of features in dev->features
and rely on the call to netdev_update_features() in xennet_connect() to
clear those which turn out to be unavailable.
The following works for me, I guess the alternative is for
xennet_connect() to expand dev->features based on what it detects? Or is
there a mechanism for a driver to inform the core that a new hardware
feature has become available (I doubt that really happens on physical
h/w so I guess not).
Ian.
8<-----------------
From 0b56469abe56efae415b4603ef508ce9aec0e4c1 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ian.campbell@citrix.com>
Date: Mon, 4 Apr 2011 10:58:50 +0100
Subject: [PATCH] xen: netfront: assume all hw features are available until backend connection setup
We need to assume that all features will be available when registering the
netdev otherwise they are ommitted from the initial set of
dev->wanted_features. When we connect to the backed we reduce the set as
necessary due to the call to netdev_update_features() in xennet_connect().
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: mirq-linux@rere.qmqm.pl
Cc: netdev@vger.kernel.org <netdev@vger.kernel.org>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: konrad.wilk@oracle.com
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: xen-devel@lists.xensource.com
---
drivers/net/xen-netfront.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 0cfe4cc..db9a763 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1251,6 +1251,14 @@ static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev
NETIF_F_GSO_ROBUST;
netdev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO;
+ /*
+ * Assume that all hw features are available for now. This set
+ * will be adjusted by the call to netdev_update_features() in
+ * xennet_connect() which is the earliest point where we can
+ * negotiate with the backend regarding supported features.
+ */
+ netdev->features |= netdev->hw_features;
+
SET_ETHTOOL_OPS(netdev, &xennet_ethtool_ops);
SET_NETDEV_DEV(netdev, &dev->dev);
--
1.7.2.5
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization
^ permalink raw reply related
* [PATCH] xen: drop anti-dependency on X86_VISWS (Was: Re: [PATCH] xen: netfront: fix declaration order)
From: Ian Campbell @ 2011-04-04 9:55 UTC (permalink / raw)
To: David Miller
Cc: Randy Dunlap, Jeremy Fitzhardinge, eric.dumazet@gmail.com,
konrad.wilk@oracle.com, netdev@vger.kernel.org,
mirq-linux@rere.qmqm.pl, xen-devel@lists.xensource.com,
H. Peter Anvin, linux-visws-devel, Thomas Gleixner,
virtualization@lists.linux-foundation.org, AndreyPanin,
Ingo Molnar
In-Reply-To: <20110403.172407.91341067.davem@davemloft.net>
On Mon, 2011-04-04 at 01:24 +0100, David Miller wrote:
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Sun, 03 Apr 2011 13:07:19 +0200
>
> > [PATCH] xen: netfront: fix declaration order
> >
> > Must declare xennet_fix_features() and xennet_set_features() before
> > using them.
> >
> > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> > Cc: Michał Mirosław <mirq-linux@rere.qmqm.pl>
>
> Ugh, it makes no sense that XEN won't make it into the x86_32
> allmodconfig build. Those dependencies in arch/x86/xen/Kconfig
> are terrible.
You mean the "!X86_VISWS" I presume? It doesn't make sense to me either.
Or at least I'm not sure why this single X86_32_NON_STANDARD machine is
more special than the others to require an anti-dependency like this.
It seems to have originally appeared from f0f32fccbffa on
CONFIG_PARAVIRT due to a conflict around ARCH_SETUP() and subsequently
got pushed down to CONFIG_XEN. However ARCH_SETUP doesn't exist any more
and I think the subarch stuff has been much improved since then so there
should be no conflict any more.
I dropped the dependency and, with a bit of fiddling, was able to build
a kernel with both CONFIG_X86_VISWS and CONFIG_XEN which booted as a Xen
domU.
tglx, Andrey, to get VISWS to build I had to comment out some code in
arch/x86/platform/visws/visws_quirks.c which seems to have been missed
during some irq_chip update or something?
CC arch/x86/platform/visws/visws_quirks.o
arch/x86/platform/visws/visws_quirks.c: In function 'startup_piix4_master_irq':
arch/x86/platform/visws/visws_quirks.c:474: warning: no return statement in function returning non-void
arch/x86/platform/visws/visws_quirks.c: At top level:
arch/x86/platform/visws/visws_quirks.c:495: error: unknown field 'mask' specified in initializer
arch/x86/platform/visws/visws_quirks.c:495: warning: initialization from incompatible pointer type
arch/x86/platform/visws/visws_quirks.c: In function 'set_piix4_virtual_irq_type':
arch/x86/platform/visws/visws_quirks.c:583: error: 'struct irq_chip' has no member named 'enable'
arch/x86/platform/visws/visws_quirks.c:583: error: 'struct irq_chip' has no member named 'unmask'
arch/x86/platform/visws/visws_quirks.c:584: error: 'struct irq_chip' has no member named 'disable'
arch/x86/platform/visws/visws_quirks.c:584: error: 'struct irq_chip' has no member named 'mask'
arch/x86/platform/visws/visws_quirks.c:585: error: 'struct irq_chip' has no member named 'unmask'
arch/x86/platform/visws/visws_quirks.c:585: error: 'struct irq_chip' has no member named 'unmask'
arch/x86/platform/visws/visws_quirks.c: In function 'visws_pre_intr_init':
arch/x86/platform/visws/visws_quirks.c:602: error: expected expression before '>' token
make[4]: *** [arch/x86/platform/visws/visws_quirks.o] Error 1
Ian
8<--------
From db0ae26f479306ee8ebcfe2a08aa56a6dfe63987 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ian.campbell@citrix.com>
Date: Mon, 4 Apr 2011 10:27:47 +0100
Subject: [PATCH] xen: drop anti-dependency on X86_VISWS
This seems to have been added in f0f32fccbffa to avoid a conflict arising from
the long deceased ARCH_SETUP() macro and subsequently pushed down to the XEN
option.
As far as I can tell the conflict is no longer present and by dropping the
dependency I was able to build a kernel which has both CONFIG_XEN and
CONFIG_X86_VISWS enabled and boot it on Xen. I didn't try it on the VISWS
platform.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: konrad.wilk@oracle.com
Cc: xen-devel@lists.xensource.com
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Andrey Panin <pazke@donpac.ru>
Cc: linux-visws-devel@lists.sf.net
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
---
arch/x86/xen/Kconfig | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
index 1c7121b..65d7b13 100644
--- a/arch/x86/xen/Kconfig
+++ b/arch/x86/xen/Kconfig
@@ -6,7 +6,7 @@ config XEN
bool "Xen guest support"
select PARAVIRT
select PARAVIRT_CLOCK
- depends on X86_64 || (X86_32 && X86_PAE && !X86_VISWS)
+ depends on X86_64 || (X86_32 && X86_PAE)
depends on X86_CMPXCHG && X86_TSC
help
This is the Linux Xen port. Enabling this will allow the
--
1.7.2.5
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization
^ permalink raw reply related
* Re: Signed bit field; int have_hotplug_status_watch:1
From: Ian Campbell @ 2011-04-04 8:26 UTC (permalink / raw)
To: Dr. David Alan Gilbert
Cc: netdev, Jeremy Fitzhardinge, xen-devel, konrad.wilk@oracle.com,
virtualization@lists.linux-foundation.org
In-Reply-To: <20110403213241.GA25913@gallifrey>
On Sun, 2011-04-03 at 22:32 +0100, Dr. David Alan Gilbert wrote:
> Hi Ian,
> I've been going through some sparse scans of the kernel and
> it threw up:
>
> CHECK drivers/net/xen-netback/xenbus.c
> drivers/net/xen-netback/xenbus.c:29:40: error: dubious one-bit signed bitfield
>
> int have_hotplug_status_watch:1;
>
> from your patch f942dc2552b8bfdee607be867b12a8971bb9cd85
>
> It does look like that should be an unsigned (given it's assigned
> 0 and 1)
I agree.
8<----------------------------------
From 38fdb7199a0c3c5eb18ec27d2380e21116c97e29 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ian.campbell@citrix.com>
Date: Mon, 4 Apr 2011 09:18:35 +0100
Subject: [PATCH] xen: netback: use unsigned type for one-bit bitfield.
Fixes error from sparse:
CHECK drivers/net/xen-netback/xenbus.c
drivers/net/xen-netback/xenbus.c:29:40: error: dubious one-bit signed bitfield
int have_hotplug_status_watch:1;
Reported-by: Dr. David Alan Gilbert <linux@treblig.org>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: netdev@vger.kernel.org
Cc: xen-devel@lists.xensource.com
---
drivers/net/xen-netback/xenbus.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 22b8c35..1ce729d 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -26,7 +26,7 @@ struct backend_info {
struct xenvif *vif;
enum xenbus_state frontend_state;
struct xenbus_watch hotplug_status_watch;
- int have_hotplug_status_watch:1;
+ u8 have_hotplug_status_watch:1;
};
static int connect_rings(struct backend_info *);
--
1.7.2.5
^ permalink raw reply related
* Re: [PATCH] virtio: Decrement avail idx on buffer detach
From: Rusty Russell @ 2011-04-04 6:34 UTC (permalink / raw)
To: Amit Shah; +Cc: Virtualization List
In-Reply-To: <20110328142706.GA2949@amit-x200.redhat.com>
On Mon, 28 Mar 2011 19:57:06 +0530, Amit Shah <amit.shah@redhat.com> wrote:
> On (Thu) 17 Mar 2011 [17:56:59], Amit Shah wrote:
> > On (Thu) 17 Mar 2011 [15:26:28], Rusty Russell wrote:
> > > On Wed, 16 Mar 2011 19:12:10 +0530, Amit Shah <amit.shah@redhat.com> wrote:
> > > > When detaching a buffer from a vq, the avail.idx value should be
> > > > decremented as well.
> > > >
> > > > This was noticed by hot-unplugging a virtio console port and then
> > > > plugging in a new one on the same number (re-using the vqs which were
> > > > just 'disowned'). qemu reported
> > > >
> > > > 'Guest moved used index from 0 to 256'
> > > >
> > > > when any IO was attempted on the new port.
> > >
> > > Yech... detach_unused_buf cannot be used on a live virtqueue; it assumes
> > > we will reset the vq (usually by resetting the entire device).
> > >
> > > You've partially violated that assumption by reusing the vq after
> > > calling detach_unused_buf. So I'm not entirely sure this is the only
> > > bug lurking; safer would be to re-initialize the vq somehow when you
> > > plug back in...
> >
> > Right; and then that will need host changes too (re-init the vqs on
> > the host side), which then gets us into compat problems...
>
> Rusty, any thoughts on this?
>
> Amit
>
Yes... I've applied your patch for the moment, and will send to Linus
with cc' stable.
Thanks,
Rusty.
^ permalink raw reply
* Re: [PATCH] xen: netfront: fix declaration order
From: David Miller @ 2011-04-04 0:24 UTC (permalink / raw)
To: eric.dumazet
Cc: xen-devel, Ian.Campbell, konrad.wilk, netdev, mirq-linux,
jeremy.fitzhardinge, virtualization
In-Reply-To: <1301828839.2837.143.camel@edumazet-laptop>
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Sun, 03 Apr 2011 13:07:19 +0200
> [PATCH] xen: netfront: fix declaration order
>
> Must declare xennet_fix_features() and xennet_set_features() before
> using them.
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> Cc: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Ugh, it makes no sense that XEN won't make it into the x86_32
allmodconfig build. Those dependencies in arch/x86/xen/Kconfig
are terrible.
For if it did, I would have caught this immediately.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* Signed bit field; int have_hotplug_status_watch:1
From: Dr. David Alan Gilbert @ 2011-04-03 21:32 UTC (permalink / raw)
To: Ian.Campbell, virtualization; +Cc: jeremy.fitzhardinge, konrad.wilk
Hi Ian,
I've been going through some sparse scans of the kernel and
it threw up:
CHECK drivers/net/xen-netback/xenbus.c
drivers/net/xen-netback/xenbus.c:29:40: error: dubious one-bit signed bitfield
int have_hotplug_status_watch:1;
from your patch f942dc2552b8bfdee607be867b12a8971bb9cd85
It does look like that should be an unsigned (given it's assigned
0 and 1)
Dave
--
-----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert | Running GNU/Linux | Happy \
\ gro.gilbert @ treblig.org | | In Hex /
\ _________________________|_____ http://www.treblig.org |_______/
^ permalink raw reply
* Re: [PATCH] xen: netfront: fix declaration order
From: Michał Mirosław @ 2011-04-03 17:35 UTC (permalink / raw)
To: Eric Dumazet
Cc: jeremy.fitzhardinge, Ian.Campbell, konrad.wilk, netdev,
virtualization, xen-devel, David Miller
In-Reply-To: <1301828839.2837.143.camel@edumazet-laptop>
On Sun, Apr 03, 2011 at 01:07:19PM +0200, Eric Dumazet wrote:
> Le vendredi 01 avril 2011 à 20:54 -0700, David Miller a écrit :
> > From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > Date: Thu, 31 Mar 2011 13:01:35 +0200 (CEST)
> >
> > > Not tested in any way. The original code for offload setting seems broken
> > > as it resets the features on every netback reconnect.
> > >
> > > This will set GSO_ROBUST at device creation time (earlier than connect time).
> > >
> > > RX checksum offload is forced on - so advertise as it is.
> > >
> > > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > Applied.
> Hmm... I had to apply following patch to make it actually compile.
> [PATCH] xen: netfront: fix declaration order
>
> Must declare xennet_fix_features() and xennet_set_features() before
> using them.
Hmm. Sorry for that. Looks like x86 allyesconfig doesn't include this
driver in the build. :/
There really needs to be something like CONFIG_LINT...
Best Regards,
Michał Mirosław
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* [PATCH] xen: netfront: fix declaration order
From: Eric Dumazet @ 2011-04-03 11:07 UTC (permalink / raw)
To: David Miller
Cc: xen-devel, Ian.Campbell, konrad.wilk, netdev, mirq-linux,
jeremy.fitzhardinge, virtualization
In-Reply-To: <20110401.205455.70198735.davem@davemloft.net>
Le vendredi 01 avril 2011 à 20:54 -0700, David Miller a écrit :
> From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> Date: Thu, 31 Mar 2011 13:01:35 +0200 (CEST)
>
> > Not tested in any way. The original code for offload setting seems broken
> > as it resets the features on every netback reconnect.
> >
> > This will set GSO_ROBUST at device creation time (earlier than connect time).
> >
> > RX checksum offload is forced on - so advertise as it is.
> >
> > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
>
> Applied.
Hmm... I had to apply following patch to make it actually compile.
Thanks
[PATCH] xen: netfront: fix declaration order
Must declare xennet_fix_features() and xennet_set_features() before
using them.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
drivers/net/xen-netfront.c | 72 +++++++++++++++++------------------
1 file changed, 36 insertions(+), 36 deletions(-)
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index f6e7e27..0cfe4cc 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1140,6 +1140,42 @@ static void xennet_uninit(struct net_device *dev)
gnttab_free_grant_references(np->gref_rx_head);
}
+static u32 xennet_fix_features(struct net_device *dev, u32 features)
+{
+ struct netfront_info *np = netdev_priv(dev);
+ int val;
+
+ if (features & NETIF_F_SG) {
+ if (xenbus_scanf(XBT_NIL, np->xbdev->otherend, "feature-sg",
+ "%d", &val) < 0)
+ val = 0;
+
+ if (!val)
+ features &= ~NETIF_F_SG;
+ }
+
+ if (features & NETIF_F_TSO) {
+ if (xenbus_scanf(XBT_NIL, np->xbdev->otherend,
+ "feature-gso-tcpv4", "%d", &val) < 0)
+ val = 0;
+
+ if (!val)
+ features &= ~NETIF_F_TSO;
+ }
+
+ return features;
+}
+
+static int xennet_set_features(struct net_device *dev, u32 features)
+{
+ if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) {
+ netdev_info(dev, "Reducing MTU because no SG offload");
+ dev->mtu = ETH_DATA_LEN;
+ }
+
+ return 0;
+}
+
static const struct net_device_ops xennet_netdev_ops = {
.ndo_open = xennet_open,
.ndo_uninit = xennet_uninit,
@@ -1513,42 +1549,6 @@ again:
return err;
}
-static u32 xennet_fix_features(struct net_device *dev, u32 features)
-{
- struct netfront_info *np = netdev_priv(dev);
- int val;
-
- if (features & NETIF_F_SG) {
- if (xenbus_scanf(XBT_NIL, np->xbdev->otherend, "feature-sg",
- "%d", &val) < 0)
- val = 0;
-
- if (!val)
- features &= ~NETIF_F_SG;
- }
-
- if (features & NETIF_F_TSO) {
- if (xenbus_scanf(XBT_NIL, np->xbdev->otherend,
- "feature-gso-tcpv4", "%d", &val) < 0)
- val = 0;
-
- if (!val)
- features &= ~NETIF_F_TSO;
- }
-
- return features;
-}
-
-static int xennet_set_features(struct net_device *dev, u32 features)
-{
- if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) {
- netdev_info(dev, "Reducing MTU because no SG offload");
- dev->mtu = ETH_DATA_LEN;
- }
-
- return 0;
-}
-
static int xennet_connect(struct net_device *dev)
{
struct netfront_info *np = netdev_priv(dev);
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox