* [PATCH 11/22] Staging: hv: Get rid of the forward declaration of blkvsc_shutdown()
From: K. Y. Srinivasan @ 2011-04-06 21:35 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1302125720-10808-1-git-send-email-kys@microsoft.com>
Get rid of the forward declaration of blkvsc_shutdown() by moving the
code around.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 70 +++++++++++++++++++--------------------
1 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index a98ed8f..1fb68b7 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -645,10 +645,42 @@ static int blkvsc_remove(struct device *device)
return ret;
}
+static void blkvsc_shutdown(struct device *device)
+{
+ struct block_device_context *blkdev = dev_get_drvdata(device);
+ unsigned long flags;
+
+ 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;
+
+ blk_stop_queue(blkdev->gd->queue);
+
+ spin_unlock_irqrestore(&blkdev->lock, flags);
+
+ while (blkdev->num_outstanding_reqs) {
+ DPRINT_INFO(STORVSC, "waiting for %d requests to complete...",
+ blkdev->num_outstanding_reqs);
+ udelay(100);
+ }
+
+ blkvsc_do_flush(blkdev);
+
+ spin_lock_irqsave(&blkdev->lock, flags);
+
+ blkvsc_cancel_pending_reqs(blkdev);
+
+ spin_unlock_irqrestore(&blkdev->lock, flags);
+}
+
/* Static decl */
static int blkvsc_probe(struct device *dev);
-static void blkvsc_shutdown(struct device *device);
-
static int blkvsc_release(struct gendisk *disk, fmode_t mode);
static int blkvsc_revalidate_disk(struct gendisk *gd);
static void blkvsc_request(struct request_queue *queue);
@@ -913,40 +945,6 @@ Cleanup:
return ret;
}
-static void blkvsc_shutdown(struct device *device)
-{
- struct block_device_context *blkdev = dev_get_drvdata(device);
- unsigned long flags;
-
- 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;
-
- blk_stop_queue(blkdev->gd->queue);
-
- spin_unlock_irqrestore(&blkdev->lock, flags);
-
- while (blkdev->num_outstanding_reqs) {
- DPRINT_INFO(STORVSC, "waiting for %d requests to complete...",
- blkdev->num_outstanding_reqs);
- udelay(100);
- }
-
- blkvsc_do_flush(blkdev);
-
- spin_lock_irqsave(&blkdev->lock, flags);
-
- blkvsc_cancel_pending_reqs(blkdev);
-
- spin_unlock_irqrestore(&blkdev->lock, flags);
-}
-
/* 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)
{
--
1.7.4.1
^ permalink raw reply related
* [PATCH 10/22] Staging: hv: Get rid of the forward declaration of blkvsc_remove()
From: K. Y. Srinivasan @ 2011-04-06 21:35 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
Cc: K. Y. Srinivasan, Haiyang Zhang, Abhishek Kane, Hank Janssen
In-Reply-To: <1302125720-10808-1-git-send-email-kys@microsoft.com>
Get rid of the forward declaration of blkvsc_remove() by moving the code around.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 130 +++++++++++++++++++-------------------
1 files changed, 65 insertions(+), 65 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 2829266..a98ed8f 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -580,9 +580,73 @@ out:
return ret;
}
+
+/*
+ * blkvsc_remove() - Callback when our device is removed
+ */
+static int blkvsc_remove(struct device *device)
+{
+ struct hv_driver *drv =
+ drv_to_hv_drv(device->driver);
+ struct storvsc_driver_object *storvsc_drv_obj =
+ drv->priv;
+ struct hv_device *device_obj = device_to_hv_device(device);
+ struct block_device_context *blkdev = dev_get_drvdata(device);
+ unsigned long flags;
+ int ret;
+
+ DPRINT_DBG(BLKVSC_DRV, "blkvsc_remove()\n");
+
+ 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);
+ }
+
+ /* Get to a known state */
+ spin_lock_irqsave(&blkdev->lock, flags);
+
+ blkdev->shutting_down = 1;
+
+ blk_stop_queue(blkdev->gd->queue);
+
+ spin_unlock_irqrestore(&blkdev->lock, flags);
+
+ while (blkdev->num_outstanding_reqs) {
+ DPRINT_INFO(STORVSC, "waiting for %d requests to complete...",
+ blkdev->num_outstanding_reqs);
+ udelay(100);
+ }
+
+ blkvsc_do_flush(blkdev);
+
+ spin_lock_irqsave(&blkdev->lock, flags);
+
+ blkvsc_cancel_pending_reqs(blkdev);
+
+ spin_unlock_irqrestore(&blkdev->lock, flags);
+
+ blk_cleanup_queue(blkdev->gd->queue);
+
+ del_gendisk(blkdev->gd);
+
+ kmem_cache_destroy(blkdev->request_pool);
+
+ kfree(blkdev);
+
+ return ret;
+}
+
/* Static decl */
static int blkvsc_probe(struct device *dev);
-static int blkvsc_remove(struct device *device);
static void blkvsc_shutdown(struct device *device);
static int blkvsc_release(struct gendisk *disk, fmode_t mode);
@@ -1120,70 +1184,6 @@ static int blkvsc_do_read_capacity16(struct block_device_context *blkdev)
}
/*
- * blkvsc_remove() - Callback when our device is removed
- */
-static int blkvsc_remove(struct device *device)
-{
- struct hv_driver *drv =
- drv_to_hv_drv(device->driver);
- struct storvsc_driver_object *storvsc_drv_obj =
- drv->priv;
- struct hv_device *device_obj = device_to_hv_device(device);
- struct block_device_context *blkdev = dev_get_drvdata(device);
- unsigned long flags;
- int ret;
-
- DPRINT_DBG(BLKVSC_DRV, "blkvsc_remove()\n");
-
- 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);
- }
-
- /* Get to a known state */
- spin_lock_irqsave(&blkdev->lock, flags);
-
- blkdev->shutting_down = 1;
-
- blk_stop_queue(blkdev->gd->queue);
-
- spin_unlock_irqrestore(&blkdev->lock, flags);
-
- while (blkdev->num_outstanding_reqs) {
- DPRINT_INFO(STORVSC, "waiting for %d requests to complete...",
- blkdev->num_outstanding_reqs);
- udelay(100);
- }
-
- blkvsc_do_flush(blkdev);
-
- spin_lock_irqsave(&blkdev->lock, flags);
-
- blkvsc_cancel_pending_reqs(blkdev);
-
- spin_unlock_irqrestore(&blkdev->lock, flags);
-
- blk_cleanup_queue(blkdev->gd->queue);
-
- del_gendisk(blkdev->gd);
-
- kmem_cache_destroy(blkdev->request_pool);
-
- kfree(blkdev);
-
- return ret;
-}
-
-/*
* We break the request into 1 or more blkvsc_requests and submit
* them. If we cant submit them all, we put them on the
* pending_list. The blkvsc_request() will work on the pending_list.
--
1.7.4.1
^ permalink raw reply related
* [PATCH 09/22] Staging: hv: Get rid of the forward declaration of blkvsc_cancel_pending_reqs()
From: K. Y. Srinivasan @ 2011-04-06 21:35 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1302125720-10808-1-git-send-email-kys@microsoft.com>
Get rid of the forward declaration of blkvsc_cancel_pending_reqs() by moving
the code around.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 159 +++++++++++++++++++--------------------
1 files changed, 79 insertions(+), 80 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 94f090e..2829266 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -501,6 +501,85 @@ static int blkvsc_do_flush(struct block_device_context *blkdev)
}
+static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev)
+{
+ struct blkvsc_request *pend_req, *tmp;
+ struct blkvsc_request *comp_req, *tmp2;
+ struct vmscsi_request *vm_srb;
+
+ 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,
+ pend_entry) {
+ /*
+ * The pend_req could be part of a partially completed
+ * request. If so, complete those req first until we
+ * hit the pend_req
+ */
+ 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;
+
+ list_del(&comp_req->req_entry);
+
+ if (comp_req->req) {
+ vm_srb =
+ &comp_req->request.vstor_packet.
+ vm_srb;
+ ret = __blk_end_request(comp_req->req,
+ (!vm_srb->scsi_status ? 0 : -EIO),
+ comp_req->sector_count *
+ blkdev->sector_size);
+
+ /* FIXME: shouldn't this do more than return? */
+ if (ret)
+ goto out;
+ }
+
+ 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);
+
+ if (comp_req->req) {
+ if (!__blk_end_request(pend_req->req, -EIO,
+ pend_req->sector_count *
+ blkdev->sector_size)) {
+ /*
+ * 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);
+ }
+ }
+
+ kmem_cache_free(blkdev->request_pool, pend_req);
+ }
+
+out:
+ return ret;
+}
+
/* Static decl */
static int blkvsc_probe(struct device *dev);
static int blkvsc_remove(struct device *device);
@@ -515,7 +594,6 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
static int blkvsc_do_inquiry(struct block_device_context *blkdev);
static int blkvsc_do_read_capacity(struct block_device_context *blkdev);
static int blkvsc_do_read_capacity16(struct block_device_context *blkdev);
-static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev);
static int blkvsc_do_pending_reqs(struct block_device_context *blkdev);
static int blkvsc_ringbuffer_size = BLKVSC_RING_BUFFER_SIZE;
@@ -1352,85 +1430,6 @@ static void blkvsc_request_completion(struct hv_storvsc_request *request)
spin_unlock_irqrestore(&blkdev->lock, flags);
}
-static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev)
-{
- struct blkvsc_request *pend_req, *tmp;
- struct blkvsc_request *comp_req, *tmp2;
- struct vmscsi_request *vm_srb;
-
- 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,
- pend_entry) {
- /*
- * The pend_req could be part of a partially completed
- * request. If so, complete those req first until we
- * hit the pend_req
- */
- 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;
-
- list_del(&comp_req->req_entry);
-
- if (comp_req->req) {
- vm_srb =
- &comp_req->request.vstor_packet.
- vm_srb;
- ret = __blk_end_request(comp_req->req,
- (!vm_srb->scsi_status ? 0 : -EIO),
- comp_req->sector_count *
- blkdev->sector_size);
-
- /* FIXME: shouldn't this do more than return? */
- if (ret)
- goto out;
- }
-
- 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);
-
- if (comp_req->req) {
- if (!__blk_end_request(pend_req->req, -EIO,
- pend_req->sector_count *
- blkdev->sector_size)) {
- /*
- * 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);
- }
- }
-
- kmem_cache_free(blkdev->request_pool, pend_req);
- }
-
-out:
- return ret;
-}
-
static int blkvsc_do_pending_reqs(struct block_device_context *blkdev)
{
struct blkvsc_request *pend_req, *tmp;
--
1.7.4.1
^ permalink raw reply related
* [PATCH 08/22] Staging: hv: Get rid of the forward declaration of blkvsc_do_flush()
From: K. Y. Srinivasan @ 2011-04-06 21:35 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1302125720-10808-1-git-send-email-kys@microsoft.com>
Get rid of the forward declaration of blkvsc_do_flush() by moving the code
around.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 71 +++++++++++++++++++--------------------
1 files changed, 35 insertions(+), 36 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 068daee..94f090e 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -465,6 +465,41 @@ static void blkvsc_cmd_completion(struct hv_storvsc_request *request)
complete(&blkvsc_req->request.wait_event);
}
+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 decl */
static int blkvsc_probe(struct device *dev);
@@ -480,7 +515,6 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
static int blkvsc_do_inquiry(struct block_device_context *blkdev);
static int blkvsc_do_read_capacity(struct block_device_context *blkdev);
static int blkvsc_do_read_capacity16(struct block_device_context *blkdev);
-static int blkvsc_do_flush(struct block_device_context *blkdev);
static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev);
static int blkvsc_do_pending_reqs(struct block_device_context *blkdev);
@@ -771,41 +805,6 @@ static void blkvsc_shutdown(struct device *device)
spin_unlock_irqrestore(&blkdev->lock, flags);
}
-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;
-}
-
/* 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)
{
--
1.7.4.1
^ permalink raw reply related
* [PATCH 07/22] Staging: hv: Get rid of the forward declaration of blkvsc_cmd_completion()
From: K. Y. Srinivasan @ 2011-04-06 21:35 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1302125720-10808-1-git-send-email-kys@microsoft.com>
Get rid of the forward declaration of blkvsc_cmd_completion() by moving the
code around.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 48 +++++++++++++++++++-------------------
1 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index a16f38c..068daee 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -442,6 +442,30 @@ static int blkvsc_ioctl(struct block_device *bd, fmode_t mode,
return ret;
}
+static void blkvsc_cmd_completion(struct hv_storvsc_request *request)
+{
+ struct blkvsc_request *blkvsc_req =
+ (struct blkvsc_request *)request->context;
+ struct block_device_context *blkdev =
+ (struct block_device_context *)blkvsc_req->dev;
+ 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--;
+
+ if (vm_srb->scsi_status)
+ if (scsi_normalize_sense(blkvsc_req->sense_buffer,
+ SCSI_SENSE_BUFFERSIZE, &sense_hdr))
+ scsi_print_sense_hdr("blkvsc", &sense_hdr);
+
+ complete(&blkvsc_req->request.wait_event);
+}
+
+
/* Static decl */
static int blkvsc_probe(struct device *dev);
static int blkvsc_remove(struct device *device);
@@ -453,7 +477,6 @@ static void blkvsc_request(struct request_queue *queue);
static void blkvsc_request_completion(struct hv_storvsc_request *request);
static int blkvsc_do_request(struct block_device_context *blkdev,
struct request *req);
-static void blkvsc_cmd_completion(struct hv_storvsc_request *request);
static int blkvsc_do_inquiry(struct block_device_context *blkdev);
static int blkvsc_do_read_capacity(struct block_device_context *blkdev);
static int blkvsc_do_read_capacity16(struct block_device_context *blkdev);
@@ -1257,29 +1280,6 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
return pending;
}
-static void blkvsc_cmd_completion(struct hv_storvsc_request *request)
-{
- struct blkvsc_request *blkvsc_req =
- (struct blkvsc_request *)request->context;
- struct block_device_context *blkdev =
- (struct block_device_context *)blkvsc_req->dev;
- 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--;
-
- if (vm_srb->scsi_status)
- if (scsi_normalize_sense(blkvsc_req->sense_buffer,
- SCSI_SENSE_BUFFERSIZE, &sense_hdr))
- scsi_print_sense_hdr("blkvsc", &sense_hdr);
-
- complete(&blkvsc_req->request.wait_event);
-}
-
static void blkvsc_request_completion(struct hv_storvsc_request *request)
{
struct blkvsc_request *blkvsc_req =
--
1.7.4.1
^ permalink raw reply related
* [PATCH 06/22] Staging: hv: Get rid of the forward declaration of blkvsc_ioctl()
From: K. Y. Srinivasan @ 2011-04-06 21:35 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
Cc: K. Y. Srinivasan, Haiyang Zhang, Abhishek Kane, Hank Janssen
In-Reply-To: <1302125720-10808-1-git-send-email-kys@microsoft.com>
Get rid of the forward declaration of blkvsc_ioctl() by moving the code around.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 56 ++++++++++++++++++--------------------
1 files changed, 27 insertions(+), 29 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 5f14bb6..a16f38c 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -415,6 +415,33 @@ 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)
+{
+/* struct block_device_context *blkdev = bd->bd_disk->private_data; */
+ int ret;
+
+ 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;
+ }
+
+ return ret;
+}
+
/* Static decl */
static int blkvsc_probe(struct device *dev);
static int blkvsc_remove(struct device *device);
@@ -422,8 +449,6 @@ static void blkvsc_shutdown(struct device *device);
static int blkvsc_release(struct gendisk *disk, fmode_t mode);
static int blkvsc_revalidate_disk(struct gendisk *gd);
-static int blkvsc_ioctl(struct block_device *bd, fmode_t mode,
- unsigned cmd, unsigned long argument);
static void blkvsc_request(struct request_queue *queue);
static void blkvsc_request_completion(struct hv_storvsc_request *request);
static int blkvsc_do_request(struct block_device_context *blkdev,
@@ -1508,33 +1533,6 @@ static int blkvsc_revalidate_disk(struct gendisk *gd)
return 0;
}
-static int blkvsc_ioctl(struct block_device *bd, fmode_t mode,
- unsigned cmd, unsigned long argument)
-{
-/* struct block_device_context *blkdev = bd->bd_disk->private_data; */
- int ret;
-
- 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;
- }
-
- return ret;
-}
-
static int __init blkvsc_init(void)
{
int ret;
--
1.7.4.1
^ permalink raw reply related
* [PATCH 05/22] Staging: hv: Get rid of the forward declaration of blkvsc_init_rw()
From: K. Y. Srinivasan @ 2011-04-06 21:35 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1302125720-10808-1-git-send-email-kys@microsoft.com>
Get rid of the forward declaration of blkvsc_init_rw() by moving the
code around.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 117 ++++++++++++++++++++-------------------
1 files changed, 59 insertions(+), 58 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 69048e3..5f14bb6 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -356,6 +356,65 @@ static int blkvsc_getgeo(struct block_device *bd, struct hd_geometry *hg)
return 0;
}
+
+static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req)
+{
+ /* ASSERT(blkvsc_req->req); */
+ /* ASSERT(blkvsc_req->sector_count <=
+ (MAX_MULTIPAGE_BUFFER_COUNT*8)); */
+
+ 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);
+ } 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;
+ }
+}
+
+
/* Static decl */
static int blkvsc_probe(struct device *dev);
static int blkvsc_remove(struct device *device);
@@ -369,7 +428,6 @@ static void blkvsc_request(struct request_queue *queue);
static void blkvsc_request_completion(struct hv_storvsc_request *request);
static int blkvsc_do_request(struct block_device_context *blkdev,
struct request *req);
-static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req);
static void blkvsc_cmd_completion(struct hv_storvsc_request *request);
static int blkvsc_do_inquiry(struct block_device_context *blkdev);
static int blkvsc_do_read_capacity(struct block_device_context *blkdev);
@@ -1000,63 +1058,6 @@ static int blkvsc_remove(struct device *device)
return ret;
}
-static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req)
-{
- /* ASSERT(blkvsc_req->req); */
- /* ASSERT(blkvsc_req->sector_count <= (MAX_MULTIPAGE_BUFFER_COUNT*8)); */
-
- 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);
- } 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;
- }
-}
-
-
/*
* We break the request into 1 or more blkvsc_requests and submit
* them. If we cant submit them all, we put them on the
--
1.7.4.1
^ permalink raw reply related
* [PATCH 04/22] Staging: hv: Get rid of the forward declaration of blkvsc_getgeo()
From: K. Y. Srinivasan @ 2011-04-06 21:35 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
Cc: K. Y. Srinivasan, Haiyang Zhang, Abhishek Kane, Hank Janssen
In-Reply-To: <1302125720-10808-1-git-send-email-kys@microsoft.com>
Get rid of the forward declaration of blkvsc_getgeo() by moving the code around.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 162 +++++++++++++++++++-------------------
1 files changed, 81 insertions(+), 81 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 173abe3..69048e3 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -275,6 +275,87 @@ static int blkvsc_open(struct block_device *bdev, fmode_t mode)
return 0;
}
+
+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;
+
+ 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;
+ hg->cylinders = cylinders;
+
+ DPRINT_INFO(BLKVSC_DRV, "CHS (%d, %d, %d)", cylinders, heads,
+ sectors_per_track);
+
+ return 0;
+}
+
/* Static decl */
static int blkvsc_probe(struct device *dev);
static int blkvsc_remove(struct device *device);
@@ -282,7 +363,6 @@ static void blkvsc_shutdown(struct device *device);
static int blkvsc_release(struct gendisk *disk, fmode_t mode);
static int blkvsc_revalidate_disk(struct gendisk *gd);
-static int blkvsc_getgeo(struct block_device *bd, struct hd_geometry *hg);
static int blkvsc_ioctl(struct block_device *bd, fmode_t mode,
unsigned cmd, unsigned long argument);
static void blkvsc_request(struct request_queue *queue);
@@ -1427,86 +1507,6 @@ static int blkvsc_revalidate_disk(struct gendisk *gd)
return 0;
}
-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;
-
- 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;
- hg->cylinders = cylinders;
-
- DPRINT_INFO(BLKVSC_DRV, "CHS (%d, %d, %d)", cylinders, heads,
- sectors_per_track);
-
- return 0;
-}
-
static int blkvsc_ioctl(struct block_device *bd, fmode_t mode,
unsigned cmd, unsigned long argument)
{
--
1.7.4.1
^ permalink raw reply related
* [PATCH 03/22] Staging: hv: Get rid of the forward declaration of blkvsc_open()
From: K. Y. Srinivasan @ 2011-04-06 21:35 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1302125720-10808-1-git-send-email-kys@microsoft.com>
Get rid of the forward declaration of blkvsc_open() by moving the code around.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 49 +++++++++++++++++++--------------------
1 files changed, 24 insertions(+), 25 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 4452700..173abe3 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -106,6 +106,7 @@ struct block_device_context {
int users;
};
+static DEFINE_MUTEX(blkvsc_mutex);
static const char *g_blk_driver_name = "blkvsc";
@@ -251,13 +252,34 @@ static unsigned int blkvsc_check_events(struct gendisk *gd,
}
+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);
+
+ if (!blkdev->users && blkdev->device_type == DVD_TYPE) {
+ spin_unlock(&blkdev->lock);
+ check_disk_change(bdev);
+ spin_lock(&blkdev->lock);
+ }
+
+ blkdev->users++;
+
+ spin_unlock(&blkdev->lock);
+ mutex_unlock(&blkvsc_mutex);
+ return 0;
+}
+
/* Static decl */
-static DEFINE_MUTEX(blkvsc_mutex);
static int blkvsc_probe(struct device *dev);
static int blkvsc_remove(struct device *device);
static void blkvsc_shutdown(struct device *device);
-static int blkvsc_open(struct block_device *bdev, fmode_t mode);
static int blkvsc_release(struct gendisk *disk, fmode_t mode);
static int blkvsc_revalidate_disk(struct gendisk *gd);
static int blkvsc_getgeo(struct block_device *bd, struct hd_geometry *hg);
@@ -1368,29 +1390,6 @@ static void blkvsc_request(struct request_queue *queue)
}
}
-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);
-
- if (!blkdev->users && blkdev->device_type == DVD_TYPE) {
- spin_unlock(&blkdev->lock);
- check_disk_change(bdev);
- spin_lock(&blkdev->lock);
- }
-
- blkdev->users++;
-
- spin_unlock(&blkdev->lock);
- mutex_unlock(&blkvsc_mutex);
- return 0;
-}
-
static int blkvsc_release(struct gendisk *disk, fmode_t mode)
{
struct block_device_context *blkdev = disk->private_data;
--
1.7.4.1
^ permalink raw reply related
* [PATCH 02/22] Staging: hv: Get rid of the forward declaration of blkvsc_check_events()
From: K. Y. Srinivasan @ 2011-04-06 21:35 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1302125720-10808-1-git-send-email-kys@microsoft.com>
Get rid of the forward declaration of blkvsc_check_events()
by moving the code around.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index efcc916..4452700 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -243,6 +243,14 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
}
+static unsigned int blkvsc_check_events(struct gendisk *gd,
+ unsigned int clearing)
+{
+ DPRINT_DBG(BLKVSC_DRV, "- enter\n");
+ return DISK_EVENT_MEDIA_CHANGE;
+}
+
+
/* Static decl */
static DEFINE_MUTEX(blkvsc_mutex);
static int blkvsc_probe(struct device *dev);
@@ -251,8 +259,6 @@ static void blkvsc_shutdown(struct device *device);
static int blkvsc_open(struct block_device *bdev, fmode_t mode);
static int blkvsc_release(struct gendisk *disk, fmode_t mode);
-static unsigned int blkvsc_check_events(struct gendisk *gd,
- unsigned int clearing);
static int blkvsc_revalidate_disk(struct gendisk *gd);
static int blkvsc_getgeo(struct block_device *bd, struct hd_geometry *hg);
static int blkvsc_ioctl(struct block_device *bd, fmode_t mode,
@@ -1407,13 +1413,6 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode)
return 0;
}
-static unsigned int blkvsc_check_events(struct gendisk *gd,
- unsigned int clearing)
-{
- DPRINT_DBG(BLKVSC_DRV, "- enter\n");
- return DISK_EVENT_MEDIA_CHANGE;
-}
-
static int blkvsc_revalidate_disk(struct gendisk *gd)
{
struct block_device_context *blkdev = gd->private_data;
--
1.7.4.1
^ permalink raw reply related
* [PATCH 01/22] Staging: hv: Get rid of the forward declaration of blkvsc_submit_request()
From: K. Y. Srinivasan @ 2011-04-06 21:34 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1302125655-10741-1-git-send-email-kys@microsoft.com>
Get rid of the forward declaration of blkvsc_submit_request() by moving the
code around.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 117 ++++++++++++++++++++-------------------
1 files changed, 59 insertions(+), 58 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index d1ecd60..efcc916 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -184,6 +184,65 @@ static int blk_vsc_initialize(struct hv_driver *driver)
return ret;
}
+
+static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
+ void (*request_completion)(struct hv_storvsc_request *))
+{
+ struct block_device_context *blkdev = blkvsc_req->dev;
+ struct hv_device *device_ctx = blkdev->device_ctx;
+ struct hv_driver *drv =
+ drv_to_hv_drv(device_ctx->device.driver);
+ struct storvsc_driver_object *storvsc_drv_obj =
+ drv->priv;
+ struct hv_storvsc_request *storvsc_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);
+#if 0
+ for (i = 0; i < (blkvsc_req->request.data_buffer.len >> 12); i++) {
+ DPRINT_DBG(BLKVSC_DRV, "blkvsc_submit_request() - "
+ "req %p pfn[%d] %llx\n",
+ blkvsc_req, i,
+ blkvsc_req->request.data_buffer.pfn_array[i]);
+ }
+#endif
+
+ storvsc_req = &blkvsc_req->request;
+ vm_srb = &storvsc_req->vstor_packet.vm_srb;
+
+ vm_srb->data_in = blkvsc_req->write ? WRITE_TYPE : READ_TYPE;
+
+ storvsc_req->on_io_completion = request_completion;
+ storvsc_req->context = blkvsc_req;
+
+ vm_srb->port_number = blkdev->port;
+ vm_srb->path_id = blkdev->path;
+ vm_srb->target_id = blkdev->target;
+ vm_srb->lun = 0; /* this is not really used at all */
+
+ vm_srb->cdb_length = blkvsc_req->cmd_len;
+
+ memcpy(vm_srb->cdb, blkvsc_req->cmnd, vm_srb->cdb_length);
+
+ storvsc_req->sense_buffer = blkvsc_req->sense_buffer;
+
+ ret = storvsc_drv_obj->on_io_request(blkdev->device_ctx,
+ &blkvsc_req->request);
+ if (ret == 0)
+ blkdev->num_outstanding_reqs++;
+
+ return ret;
+}
+
+
/* Static decl */
static DEFINE_MUTEX(blkvsc_mutex);
static int blkvsc_probe(struct device *dev);
@@ -202,8 +261,6 @@ static void blkvsc_request(struct request_queue *queue);
static void blkvsc_request_completion(struct hv_storvsc_request *request);
static int blkvsc_do_request(struct block_device_context *blkdev,
struct request *req);
-static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
- void (*request_completion)(struct hv_storvsc_request *));
static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req);
static void blkvsc_cmd_completion(struct hv_storvsc_request *request);
static int blkvsc_do_inquiry(struct block_device_context *blkdev);
@@ -891,62 +948,6 @@ static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req)
}
}
-static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
- void (*request_completion)(struct hv_storvsc_request *))
-{
- struct block_device_context *blkdev = blkvsc_req->dev;
- struct hv_device *device_ctx = blkdev->device_ctx;
- struct hv_driver *drv =
- drv_to_hv_drv(device_ctx->device.driver);
- struct storvsc_driver_object *storvsc_drv_obj =
- drv->priv;
- struct hv_storvsc_request *storvsc_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);
-#if 0
- for (i = 0; i < (blkvsc_req->request.data_buffer.len >> 12); i++) {
- DPRINT_DBG(BLKVSC_DRV, "blkvsc_submit_request() - "
- "req %p pfn[%d] %llx\n",
- blkvsc_req, i,
- blkvsc_req->request.data_buffer.pfn_array[i]);
- }
-#endif
-
- storvsc_req = &blkvsc_req->request;
- vm_srb = &storvsc_req->vstor_packet.vm_srb;
-
- vm_srb->data_in = blkvsc_req->write ? WRITE_TYPE : READ_TYPE;
-
- storvsc_req->on_io_completion = request_completion;
- storvsc_req->context = blkvsc_req;
-
- vm_srb->port_number = blkdev->port;
- vm_srb->path_id = blkdev->path;
- vm_srb->target_id = blkdev->target;
- vm_srb->lun = 0; /* this is not really used at all */
-
- vm_srb->cdb_length = blkvsc_req->cmd_len;
-
- memcpy(vm_srb->cdb, blkvsc_req->cmnd, vm_srb->cdb_length);
-
- storvsc_req->sense_buffer = blkvsc_req->sense_buffer;
-
- ret = storvsc_drv_obj->on_io_request(blkdev->device_ctx,
- &blkvsc_req->request);
- if (ret == 0)
- blkdev->num_outstanding_reqs++;
-
- return ret;
-}
/*
* We break the request into 1 or more blkvsc_requests and submit
--
1.7.4.1
^ permalink raw reply related
* [RESEND] [PATCH 00/22] Staging: hv: Cleanup-storage-drivers-phase-III
From: K. Y. Srinivasan @ 2011-04-06 21:34 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
The latest upstream merge changed struct block_device_operations:
This merge got rid of blkvsc_media_changed and introduced the
function blkvsc_check_events. This broke all the patches that
were sent after the tree was closed the last time. This is a resend of
this patch-set to account for this change in the kernel.
This patch-set deals with some of the style isues in blkvsc_drv.c. We also
get rid most of the "dead code" in this file:
1) Get rid of most of the forward declarations in this file.
The only remaining forward declarations are to deal with
circular dependencies.
2) Get rid of most of the dead code in the file. Some of
the functions in this file are place holders - they are not
fuly implementedi yet (blkvsc_ioctl(), blkvsc_media_changed().
We have retained some comments/dead code, to help us in the
final implementation.
Regads,
K. Y
^ permalink raw reply
* Re: [PATCH] virtio_blk: decrement index when blockdevice is removed
From: Ryan Harper @ 2011-04-06 19:17 UTC (permalink / raw)
To: Takuma Umeya
Cc: john cooper, Jens Axboe, linux-kernel, virtualization, Tejun Heo,
Christoph Hellwig
In-Reply-To: <1969774563.659835.1301978981017.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com>
* Takuma Umeya <tumeya@redhat.com> [2011-04-05 00:00]:
> When virtio block device is removed, index does not get decremented. When
> another virtio disk is attached it uses the next device letter to the
> one that is suppose to be available.
>
> Signed-off-by: Takuma Umeya <tumeya@redhat.com>
>
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 6ecf89c..730e7af 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -489,6 +489,7 @@ static void __devexit virtblk_remove(struct virtio_device *vdev)
> mempool_destroy(vblk->pool);
> vdev->config->del_vqs(vdev);
> kfree(vblk);
> + index--;
> }
What about referencing /dev/disk/by-id and using drive serial numbers?
How much do we care about re-using minor numbers? IIRC, virtio-blk can
go out to vdxxx; that's a lot of disks or add/removes.
>
> static const struct virtio_device_id id_table[] = {
>
> --
> Umeya, Takuma
> Technical Account Manager
> Red Hat GSS APAC
> +81.3.5798.8584 (direct)
> tumeya@redhat.com
> _______________________________________________
> Virtualization mailing list
> Virtualization@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/virtualization
--
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ryanh@us.ibm.com
^ permalink raw reply
* [PATCH 2/2] Staging: hv: Zero out the request structure on allocation
From: K. Y. Srinivasan @ 2011-04-06 18:25 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
Cc: K. Y. Srinivasan, Hank Janssen
In-Reply-To: <1302114339-2198-1-git-send-email-kys@microsoft.com>
As part of the cleanup of the I/O request structure, allocate them zeroed
out. This fixes a bug that was introduced in the patch-set titled:
Staging: hv: Cleanup-storage-drivers-phase-II.
A corrected version of this patch-set was sent out earlier, however
the earlier (buggy) version of this patch-set was already applied.
This patch fixes the problem.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/storvsc_drv.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 6128ffd..ae61735 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -738,7 +738,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
request_size = sizeof(struct storvsc_cmd_request);
- cmd_request = kmem_cache_alloc(host_device_ctx->request_pool,
+ cmd_request = kmem_cache_zalloc(host_device_ctx->request_pool,
GFP_ATOMIC);
if (!cmd_request) {
DPRINT_ERR(STORVSC_DRV, "scmnd (%p) - unable to allocate "
--
1.7.4.1
^ permalink raw reply related
* [PATCH 1/2] Staging: hv: Properly capture the error state
From: K. Y. Srinivasan @ 2011-04-06 18:25 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
In-Reply-To: <1302114286-2127-1-git-send-email-kys@microsoft.com>
Properly capture the error state after the completion of I/O. This fixes a bug
that was introduced in the patch-set titled:
Staging: hv: Cleanup-storage-drivers-phase-II.
A corrected version of this patch-set was sent out earlier, however
the earlier (buggy) version of this patch-set was already applied.
This patch fixes the problem.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/storvsc.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 55865fa..d7ce393 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -279,6 +279,7 @@ static void stor_vsc_on_io_completion(struct hv_device *device,
struct hv_storvsc_request *request)
{
struct storvsc_device *stor_device;
+ struct vstor_packet *stor_pkt;
stor_device = must_get_stor_device(device);
if (!stor_device) {
@@ -287,19 +288,24 @@ static void stor_vsc_on_io_completion(struct hv_device *device,
return;
}
- DPRINT_DBG(STORVSC, "IO_COMPLETE_OPERATION - request %p "
+ DPRINT_DBG(STORVSC, "IO_COMPLETE_OPERATION - request %p "
"completed bytes xfer %u", request,
vstor_packet->vm_srb.data_transfer_length);
+ stor_pkt = &request->vstor_packet;
/* Copy over the status...etc */
+ stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status;
+ stor_pkt->vm_srb.srb_status = vstor_packet->vm_srb.srb_status;
+ stor_pkt->vm_srb.sense_info_length =
+ vstor_packet->vm_srb.sense_info_length;
if (vstor_packet->vm_srb.scsi_status != 0 ||
vstor_packet->vm_srb.srb_status != 1) {
DPRINT_WARN(STORVSC,
"cmd 0x%x scsi status 0x%x srb status 0x%x\n",
- vstor_packet->vm_srb.cdb[0],
+ stor_pkt->vm_srb.cdb[0],
vstor_packet->vm_srb.scsi_status,
vstor_packet->vm_srb.srb_status);
}
@@ -319,6 +325,8 @@ static void stor_vsc_on_io_completion(struct hv_device *device,
}
}
+ stor_pkt->vm_srb.data_transfer_length =
+ vstor_packet->vm_srb.data_transfer_length;
request->on_io_completion(request);
@@ -535,6 +543,7 @@ int stor_vsc_on_io_request(struct hv_device *device,
request->device = device;
+
vstor_packet->flags |= REQUEST_COMPLETION_FLAG;
vstor_packet->vm_srb.length = sizeof(struct vmscsi_request);
--
1.7.4.1
^ permalink raw reply related
* [PATCH 0/2] Staging: hv: Fixup Phase II storage driver cleanup
From: K. Y. Srinivasan @ 2011-04-06 18:24 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization; +Cc: K. Y. Srinivasan
This fixes a couple of bugs that was introduced in the patch-set titled:
Staging: hv: Cleanup storage drivers phase II.
A corrected version of this patch-set was sent out earlier, however
the earlier (buggy) version of this patch-set was already applied.
This patch set fixes this problem..
Regards,
K. Y
^ permalink raw reply
* Re: [PATCH] virtio_blk: decrement index when blockdevice is removed
From: Jens Axboe @ 2011-04-06 3:05 UTC (permalink / raw)
To: Rusty Russell
Cc: john cooper, linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org, Tejun Heo,
Christoph Hellwig
In-Reply-To: <87hbacw4fb.fsf@rustcorp.com.au>
On 2011-04-06 03:32, Rusty Russell wrote:
> On Tue, 05 Apr 2011 07:08:12 +0200, Jens Axboe <jaxboe@fusionio.com> wrote:
>> On 2011-04-05 06:49, Takuma Umeya wrote:
>>> When virtio block device is removed, index does not get decremented. When
>>> another virtio disk is attached it uses the next device letter to the
>>> one that is suppose to be available.
>>>
>>> Signed-off-by: Takuma Umeya <tumeya@redhat.com>
>>>
>>> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
>>> index 6ecf89c..730e7af 100644
>>> --- a/drivers/block/virtio_blk.c
>>> +++ b/drivers/block/virtio_blk.c
>>> @@ -489,6 +489,7 @@ static void __devexit virtblk_remove(struct virtio_device *vdev)
>>> mempool_destroy(vblk->pool);
>>> vdev->config->del_vqs(vdev);
>>> kfree(vblk);
>>> + index--;
>>> }
>>>
>>> static const struct virtio_device_id id_table[] = {
>>
>> What happens when you delete a device that isn't the last one?
>
> Obviously we should do something cleverer for assigning drives.
>
> It might be a cute if genhd gave us a function to get the next free
> index for a given major number, and format it for us, like so:
>
> /* Return the next available minor for a given @major, at least
> * @spacing after the previous and, and append appropriate letters
> * to @name if it's not NULL. -ve errno on fail (-ENOSPC?). */
> int disk_next_minor(int major, unsigned spacing, char *name);
>
> A trivial optimization would be to remember the last major and max minor
> (resetting that if any disks are removed).
>
> This could clean up other code, too.
Something like idr would be a good fit for this. But yes, adding some
helpers for this might not hurt...
--
Jens Axboe
^ permalink raw reply
* Re: [PATCH] virtio_blk: decrement index when blockdevice is removed
From: Rusty Russell @ 2011-04-06 1:32 UTC (permalink / raw)
To: Jens Axboe, Takuma Umeya
Cc: john cooper, Tejun Heo, Christoph Hellwig,
linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org
In-Reply-To: <4D9AA3BC.6030907@fusionio.com>
On Tue, 05 Apr 2011 07:08:12 +0200, Jens Axboe <jaxboe@fusionio.com> wrote:
> On 2011-04-05 06:49, Takuma Umeya wrote:
> > When virtio block device is removed, index does not get decremented. When
> > another virtio disk is attached it uses the next device letter to the
> > one that is suppose to be available.
> >
> > Signed-off-by: Takuma Umeya <tumeya@redhat.com>
> >
> > diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> > index 6ecf89c..730e7af 100644
> > --- a/drivers/block/virtio_blk.c
> > +++ b/drivers/block/virtio_blk.c
> > @@ -489,6 +489,7 @@ static void __devexit virtblk_remove(struct virtio_device *vdev)
> > mempool_destroy(vblk->pool);
> > vdev->config->del_vqs(vdev);
> > kfree(vblk);
> > + index--;
> > }
> >
> > static const struct virtio_device_id id_table[] = {
>
> What happens when you delete a device that isn't the last one?
Obviously we should do something cleverer for assigning drives.
It might be a cute if genhd gave us a function to get the next free
index for a given major number, and format it for us, like so:
/* Return the next available minor for a given @major, at least
* @spacing after the previous and, and append appropriate letters
* to @name if it's not NULL. -ve errno on fail (-ENOSPC?). */
int disk_next_minor(int major, unsigned spacing, char *name);
A trivial optimization would be to remember the last major and max minor
(resetting that if any disks are removed).
This could clean up other code, too.
Cheers,
Rusty.
^ permalink raw reply
* RE: [PATCH 07/07] Replaced printk with pr_info in hv_timesource
From: Hank Janssen @ 2011-04-06 0:14 UTC (permalink / raw)
To: Greg KH
Cc: Haiyang Zhang, gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org,
KY Srinivasan
In-Reply-To: <20110405050045.GA4663@kroah.com>
> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Monday, April 04, 2011 10:01 PM
> To: Hank Janssen
> Cc: Haiyang Zhang; gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; KY Srinivasan
> Subject: Re: [PATCH 07/07] Replaced printk with pr_info in hv_timesource
>
> > #include <linux/version.h>
> > #include <linux/clocksource.h>
> > @@ -91,7 +92,7 @@ static int __init init_hv_clocksource(void)
> > if (!dmi_check_system(hv_timesource_dmi_table))
> > return -ENODEV;
> >
> > - printk(KERN_INFO "Registering HyperV clock source\n");
> > + pr_info("Registering HyperV clock source\n");
>
> Why is this line even needed at all? Please remove it in future patches.
>
Of course, since there have been so many changes I will wait a day or two
To get stuff settled in staging and I will send the patch to remove it.
Hank.
^ permalink raw reply
* RE: [PATCH] staging: hv: Fix GARP not sent after Quick Migration
From: Haiyang Zhang @ 2011-04-05 17:32 UTC (permalink / raw)
To: Greg KH
Cc: Hank Janssen, KY Srinivasan,
Abhishek Kane (Mindtree Consulting PVT LTD), gregkh@suse.de,
linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
virtualization@lists.osdl.org, stable, Mike Surcouf
In-Reply-To: <20110405162306.GA1800@kroah.com>
> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Tuesday, April 05, 2011 12:23 PM
> Instead, use a proper timer as you do know how long you need to wait,
> right? Don't abuse workqueues for something they were not designed for.
Thanks for the suggestion, I will add an msleep. And, yes, this delay will
be removed if the Hyper-V side is fixed.
Thanks,
- Haiyang
^ permalink raw reply
* [PATCH] staging: hv: Fix GARP not sent after Quick Migration
From: Haiyang Zhang @ 2011-04-05 16:24 UTC (permalink / raw)
To: haiyangz, hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
vir
Cc: stable, Mike Surcouf
After Quick Migration, the network is not immediately operational in the
current context when receiving RNDIS_STATUS_MEDIA_CONNECT event. So, I put
the netif_notify_peers() into a scheduled work, otherwise GARP packet will
not be sent after quick migration, and cause network disconnection.
Thanks to Mike Surcouf <mike@surcouf.co.uk> for reporting the bug and
testing the patch.
This patch should also be backported to stable kernel 2.6.32 and later.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: Mike Surcouf <mike@surcouf.co.uk>
Cc: stable <stable@kernel.org>
---
drivers/staging/hv/netvsc_drv.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 2d40f5f..3566456 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -46,6 +46,7 @@ struct net_device_context {
/* point back to our device context */
struct hv_device *device_ctx;
unsigned long avail;
+ struct work_struct work;
};
@@ -219,6 +220,7 @@ static void netvsc_linkstatus_callback(struct hv_device *device_obj,
unsigned int status)
{
struct net_device *net = dev_get_drvdata(&device_obj->device);
+ struct net_device_context *ndev_ctx;
if (!net) {
DPRINT_ERR(NETVSC_DRV, "got link status but net device "
@@ -229,7 +231,8 @@ static void netvsc_linkstatus_callback(struct hv_device *device_obj,
if (status == 1) {
netif_carrier_on(net);
netif_wake_queue(net);
- netif_notify_peers(net);
+ ndev_ctx = netdev_priv(net);
+ schedule_work(&ndev_ctx->work);
} else {
netif_carrier_off(net);
netif_stop_queue(net);
@@ -328,6 +331,24 @@ static const struct net_device_ops device_ops = {
.ndo_set_mac_address = eth_mac_addr,
};
+/*
+ * Send GARP packet to network peers after migrations.
+ * After Quick Migration, the network is not immediately operational in the
+ * current context when receiving RNDIS_STATUS_MEDIA_CONNECT event. So, I put
+ * the netif_notify_peers() into a scheduled work, otherwise GARP packet will
+ * not be sent after quick migration, and cause network disconnection.
+ */
+static void netvsc_send_garp(struct work_struct *w)
+{
+ struct net_device_context *ndev_ctx;
+ struct net_device *net;
+
+ ndev_ctx = container_of(w, struct net_device_context, work);
+ net = dev_get_drvdata(&ndev_ctx->device_ctx->device);
+ netif_notify_peers(net);
+}
+
+
static int netvsc_probe(struct device *device)
{
struct hv_driver *drv =
@@ -353,6 +374,7 @@ static int netvsc_probe(struct device *device)
net_device_ctx->device_ctx = device_obj;
net_device_ctx->avail = ring_size;
dev_set_drvdata(device, net);
+ INIT_WORK(&net_device_ctx->work, netvsc_send_garp);
/* Notify the netvsc driver of the new device */
ret = net_drv_obj->base.dev_add(device_obj, &device_info);
--
1.7.4.1
^ permalink raw reply related
* Re: [PATCH] staging: hv: Fix GARP not sent after Quick Migration
From: Greg KH @ 2011-04-05 16:23 UTC (permalink / raw)
To: Haiyang Zhang
Cc: hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
virtualization, stable, Mike Surcouf
In-Reply-To: <1302020655-27133-1-git-send-email-haiyangz@microsoft.com>
On Tue, Apr 05, 2011 at 09:24:15AM -0700, Haiyang Zhang wrote:
> After Quick Migration, the network is not immediately operational in the
> current context when receiving RNDIS_STATUS_MEDIA_CONNECT event. So, I put
> the netif_notify_peers() into a scheduled work, otherwise GARP packet will
> not be sent after quick migration, and cause network disconnection.
Wait, what are you relying on here for the delay? What happens when
processors get faster and that work queue gets run even sooner than
today? You are relying on the scheduler to introduce a "delay" here and
you can't rely on that at all.
Instead, use a proper timer as you do know how long you need to wait,
right? Don't abuse workqueues for something they were not designed for.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH] staging: hv: Fix GARP not sent after Quick Migration
From: Greg KH @ 2011-04-05 16:19 UTC (permalink / raw)
To: Haiyang Zhang
Cc: Hank Janssen, KY Srinivasan,
Abhishek Kane (Mindtree Consulting PVT LTD),
linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
virtualization@lists.osdl.org, Mike Surcouf, stable
In-Reply-To: <A1F3067C9B68744AA19F6802BAB8FFDC03FB03A6@TK5EX14MBXC223.redmond.corp.microsoft.com>
On Tue, Apr 05, 2011 at 03:54:54PM +0000, Haiyang Zhang wrote:
> > -----Original Message-----
> > From: Greg KH [mailto:gregkh@suse.de]
> > Sent: Tuesday, April 05, 2011 11:42 AM
> > But that's a hypervisor bug, right? It shouldn't be sending a "connect"
> > event on the ethernet device if the network really isn't present. How
> > about getting it fixed there, which will resolve the issues for all
> > guest operating systems, not just Linux.
> >
> > Or, if this is something that the hyperv developers are not going to
> > fix, we need to document it in the code itself so that people don't try
> > to remove it in a few years as an "optimization".
>
> Fix on the Hyper-V side is not available for now at least. I will add the
> comments into code.
What happens when the hyperv code is fixed? Will this be removed? Or
will all guests have this delay in them for no reason and the older
"unfixed" guests suddenly work faster? That seems odd...
thanks,
greg k-h
^ permalink raw reply
* RE: [PATCH] staging: hv: Fix GARP not sent after Quick Migration
From: Haiyang Zhang @ 2011-04-05 15:54 UTC (permalink / raw)
To: Greg KH
Cc: Hank Janssen, KY Srinivasan,
Abhishek Kane (Mindtree Consulting PVT LTD),
linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
virtualization@lists.osdl.org, Mike Surcouf, stable
In-Reply-To: <20110405154133.GA30923@suse.de>
> -----Original Message-----
> From: Greg KH [mailto:gregkh@suse.de]
> Sent: Tuesday, April 05, 2011 11:42 AM
> But that's a hypervisor bug, right? It shouldn't be sending a "connect"
> event on the ethernet device if the network really isn't present. How
> about getting it fixed there, which will resolve the issues for all
> guest operating systems, not just Linux.
>
> Or, if this is something that the hyperv developers are not going to
> fix, we need to document it in the code itself so that people don't try
> to remove it in a few years as an "optimization".
Fix on the Hyper-V side is not available for now at least. I will add the
comments into code.
Thanks,
- Haiyang
^ permalink raw reply
* Re: [PATCH] staging: hv: Fix GARP not sent after Quick Migration
From: Greg KH @ 2011-04-05 15:41 UTC (permalink / raw)
To: Haiyang Zhang
Cc: hjanssen, kys, v-abkane, linux-kernel, devel, virtualization,
Mike Surcouf, stable
In-Reply-To: <1302017268-22913-1-git-send-email-haiyangz@microsoft.com>
On Tue, Apr 05, 2011 at 08:27:48AM -0700, Haiyang Zhang wrote:
> After Quick Migration, the network is not immediately operational in the
> current context when receiving RNDIS_STATUS_MEDIA_CONNECT event. So, I put
> the netif_notify_peers() into a scheduled work, otherwise GARP packet will
> not be sent after quick migration, and cause network disconnection.
But that's a hypervisor bug, right? It shouldn't be sending a "connect"
event on the ethernet device if the network really isn't present. How
about getting it fixed there, which will resolve the issues for all
guest operating systems, not just Linux.
Or, if this is something that the hyperv developers are not going to
fix, we need to document it in the code itself so that people don't try
to remove it in a few years as an "optimization".
thanks,
greg k-h
^ permalink raw reply
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