summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorK. Y. Srinivasan <kys@microsoft.com>2011-08-27 11:31:05 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2011-08-29 11:01:02 -0700
commitf6c17484eb386014ee52d9edc8b3e8263d57c640 (patch)
tree73f0b7cc4528ec925076c315a779b8bf33d6c2db
parentdf977d6c90632b3868055862262529007019d4ef (diff)
Staging: hv: storvsc: Introduce state to manage the lifecycle of stor device
Introduce state to manage the lifecycle of stor device. This would be the basis for managing the references on the stor object. Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/hv/hyperv_storage.h2
-rw-r--r--drivers/staging/hv/storvsc.c8
2 files changed, 8 insertions, 2 deletions
diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
index a2244138637..d93bf93eb24 100644
--- a/drivers/staging/hv/hyperv_storage.h
+++ b/drivers/staging/hv/hyperv_storage.h
@@ -266,7 +266,7 @@ struct storvsc_device {
/* 0 indicates the device is being destroyed */
atomic_t ref_count;
-
+ bool destroy;
bool drain_notify;
atomic_t num_outstanding_req;
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 48bd8dae02e..0f8c60961ec 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -43,7 +43,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
/* Set to 2 to allow both inbound and outbound traffics */
/* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */
atomic_set(&stor_device->ref_count, 2);
-
+ stor_device->destroy = false;
init_waitqueue_head(&stor_device->waiting_to_drain);
stor_device->device = device;
device->ext = stor_device;
@@ -399,9 +399,15 @@ int storvsc_dev_add(struct hv_device *device,
int storvsc_dev_remove(struct hv_device *device)
{
struct storvsc_device *stor_device;
+ unsigned long flags;
+
stor_device = release_stor_device(device);
+ spin_lock_irqsave(&device->channel->inbound_lock, flags);
+ stor_device->destroy = true;
+ spin_unlock_irqrestore(&device->channel->inbound_lock, flags);
+
/*
* At this point, all outbound traffic should be disable. We
* only allow inbound traffic (responses) to proceed so that