提交 f6c17484 编写于 作者: K K. Y. Srinivasan 提交者: Greg Kroah-Hartman

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: NK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: NHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 df977d6c
...@@ -266,7 +266,7 @@ struct storvsc_device { ...@@ -266,7 +266,7 @@ struct storvsc_device {
/* 0 indicates the device is being destroyed */ /* 0 indicates the device is being destroyed */
atomic_t ref_count; atomic_t ref_count;
bool destroy;
bool drain_notify; bool drain_notify;
atomic_t num_outstanding_req; atomic_t num_outstanding_req;
......
...@@ -43,7 +43,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device) ...@@ -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 */ /* Set to 2 to allow both inbound and outbound traffics */
/* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */ /* (ie get_out_stor_device() and get_in_stor_device()) to proceed. */
atomic_set(&stor_device->ref_count, 2); atomic_set(&stor_device->ref_count, 2);
stor_device->destroy = false;
init_waitqueue_head(&stor_device->waiting_to_drain); init_waitqueue_head(&stor_device->waiting_to_drain);
stor_device->device = device; stor_device->device = device;
device->ext = stor_device; device->ext = stor_device;
...@@ -399,9 +399,15 @@ int storvsc_dev_add(struct hv_device *device, ...@@ -399,9 +399,15 @@ int storvsc_dev_add(struct hv_device *device,
int storvsc_dev_remove(struct hv_device *device) int storvsc_dev_remove(struct hv_device *device)
{ {
struct storvsc_device *stor_device; struct storvsc_device *stor_device;
unsigned long flags;
stor_device = release_stor_device(device); 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 * At this point, all outbound traffic should be disable. We
* only allow inbound traffic (responses) to proceed so that * only allow inbound traffic (responses) to proceed so that
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册