Drivers: hv: Fix some rescind handling issues
Subsystems (2)
cover Drivers: hv: Fix some rescind handling issues
From: K. Y. Srinivasan <[email protected]>
Fix some rescind handling issues.
K. Y. Srinivasan (4):
Drivers: hv: vmbus: Fix a rescind handling bug
Drivers: hv: util: kvp: Fix a rescind processing issue
Drivers: hv: util: Fcopy: Fix a rescind processing issue
Drivers: hv: util: Backup: Fix a rescind processing issue
drivers/hv/channel.c | 18 ++++++++++++++++++ drivers/hv/channel_mgmt.c | 25 +++++++++++++++++++++++++ drivers/hv/hv_fcopy.c | 4 ++++ drivers/hv/hv_kvp.c | 4 ++++ drivers/hv/hv_snapshot.c | 4 ++++ include/linux/hyperv.h | 1 + 6 files changed, 56 insertions(+), 0 deletions(-)
Signature · 1 line
1.7.4.1
PATCH 1/4 Drivers: hv: vmbus: Fix a rescind handling bug
From: K. Y. Srinivasan <[email protected]>
The host can rescind a channel that has been offered to the guest and once the channel is rescinded, the host does not respond to any requests on that channel. Deal with the case where the guest may be blocked waiting for a response from the host.
--- drivers/hv/channel.c | 18 ++++++++++++++++++ drivers/hv/channel_mgmt.c | 25 +++++++++++++++++++++++++ include/linux/hyperv.h | 1 + 3 files changed, 44 insertions(+), 0 deletions(-)
drivers/hv/channel.c +18 -0
@@ -157,6 +157,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, }init_completion (&open_info->waitevent); + open_info->waiting_channel = newchannel; open_msg = (struct vmbus_channel_open_channel *)open_info->msg; open_msg->header.msgtype =CHANNELMSG_OPENCHANNEL ;
@@ -194,6 +195,11 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,list_del (&open_info->msglistentry);spin_unlock_irqrestore (&vmbus_connection.channelmsg_lock, flags); +if (newchannel->rescind) { + err = -ENODEV ; + goto error_free_gpadl; + } +if (open_info->response.open_result.status) { err = -EAGAIN ; goto error_free_gpadl;
@@ -405,6 +411,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,return ret;init_completion (&msginfo->waitevent); + msginfo->waiting_channel = channel; gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->msg; gpadlmsg->header.msgtype =CHANNELMSG_GPADL_HEADER ;
@@ -441,6 +448,11 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, }wait_for_completion (&msginfo->waitevent); +if (channel->rescind) { + ret = -ENODEV ; + goto cleanup; + } +/* At this point, we received the gpadl created msg */ *gpadl_handle = gpadlmsg->gpadl;
@@ -474,6 +486,7 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)return -ENOMEM ;init_completion (&info->waitevent); + info->waiting_channel = channel; msg = (struct vmbus_channel_gpadl_teardown *)info->msg;
@@ -493,6 +506,11 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)wait_for_completion (&info->waitevent); +if (channel->rescind) { + ret = -ENODEV ; + goto post_msg_err; + } + post_msg_err:spin_lock_irqsave (&vmbus_connection.channelmsg_lock, flags);list_del (&info->msglistentry);
drivers/hv/channel_mgmt.c +25 -0
@@ -147,6 +147,29 @@ { HV_RDV_GUID }, }; +/* +* The rescinded channel may be blocked waiting for a response from the host; +* take care of that. +*/ +static void vmbus_rescind_cleanup (struct vmbus_channel *channel) +{ +struct vmbus_channel_msginfo *msginfo; +unsigned long flags; + + +spin_lock_irqsave (&vmbus_connection.channelmsg_lock, flags); + +list_for_each_entry (msginfo, &vmbus_connection.chn_msg_list, + msglistentry) { + +if (msginfo->waiting_channel == channel) { +complete (&msginfo->waitevent); +break ; + } + } +spin_unlock_irqrestore (&vmbus_connection.channelmsg_lock, flags); +} +static bool is_unsupported_vmbus_devs (const uuid_le *guid) {int i;
@@ -825,6 +848,8 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) channel->rescind = true;spin_unlock_irqrestore (&channel->lock, flags); +vmbus_rescind_cleanup (channel); +if (channel->device_obj) {if (channel->chn_rescind_callback) { channel->chn_rescind_callback (channel);
include/linux/hyperv.h +1 -0
@@ -627,6 +627,7 @@ struct vmbus_channel_msginfo {/* Synchronize the request/response if needed */ struct completion waitevent; +struct vmbus_channel *waiting_channel;union {struct vmbus_channel_version_supported version_supported;struct vmbus_channel_open_result open_result;
Signature · 1 line
1.7.4.1
PATCH 4/4 Drivers: hv: util: Backup: Fix a rescind processing issue
From: K. Y. Srinivasan <[email protected]>
VSS may use a char device to support the communication between the user level daemon and the driver. When the VSS channel is rescinded we need to make sure that the char device is fully cleaned up before we can process a new VSS offer from the host. Implement this logic.
--- drivers/hv/hv_snapshot.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/hv/hv_snapshot.c +4 -0
@@ -69,6 +69,7 @@static const char vss_devname[] ="vmbus/hv_vss" ;static __u8 *recv_buffer;static struct hvutil_transport *hvt; +static struct completion release_event;static void vss_timeout_func (struct work_struct *dummy);static void vss_handle_request (struct work_struct *dummy);
@@ -345,11 +346,13 @@ static void vss_on_reset(void)if (cancel_delayed_work_sync (&vss_timeout_work))vss_respond_to_host (HV_E_FAIL ); vss_transaction.state =HVUTIL_DEVICE_INIT ; +complete (&release_event); }int hv_vss_init (struct hv_util_service *srv) { +init_completion (&release_event);if (vmbus_proto_version <VERSION_WIN8_1 ) {pr_warn ("Integration service 'Backup (volume snapshot)'" " not supported on this host version.\n" );
@@ -382,4 +385,5 @@ void hv_vss_deinit(void)cancel_delayed_work_sync (&vss_timeout_work);cancel_work_sync (&vss_handle_request_work);hvutil_transport_destroy (hvt); +wait_for_completion (&release_event); }
Signature · 1 line
1.7.4.1
PATCH 2/4 Drivers: hv: util: kvp: Fix a rescind processing issue
In reply to [email protected]From: K. Y. Srinivasan <[email protected]>
KVP may use a char device to support the communication between the user level daemon and the driver. When the KVP channel is rescinded we need to make sure that the char device is fully cleaned up before we can process a new KVP offer from the host. Implement this logic.
--- drivers/hv/hv_kvp.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/hv/hv_kvp.c +4 -0
@@ -88,6 +88,7 @@static const char kvp_devname[] ="vmbus/hv_kvp" ;static u8 *recv_buffer;static struct hvutil_transport *hvt; +static struct completion release_event;/* * Register the kernel component with the user-level daemon. * As part of this registration, pass the LIC version number.
@@ -716,6 +717,7 @@ static void kvp_on_reset(void)if (cancel_delayed_work_sync (&kvp_timeout_work))kvp_respond_to_host (NULL ,HV_E_FAIL ); kvp_transaction.state =HVUTIL_DEVICE_INIT ; +complete (&release_event); }int
@@ -724,6 +726,7 @@ static void kvp_on_reset(void) recv_buffer = srv->recv_buffer; kvp_transaction.recv_channel = srv->channel; +init_completion (&release_event);/* * When this driver loads, the user level daemon that * processes the host requests may not yet be running.
@@ -747,4 +750,5 @@ void hv_kvp_deinit(void)cancel_delayed_work_sync (&kvp_timeout_work);cancel_work_sync (&kvp_sendkey_work);hvutil_transport_destroy (hvt); +wait_for_completion (&release_event); }
Signature · 1 line
1.7.4.1
PATCH 3/4 Drivers: hv: util: Fcopy: Fix a rescind processing issue
In reply to [email protected]From: K. Y. Srinivasan <[email protected]>
Fcopy may use a char device to support the communication between the user level daemon and the driver. When the Fcopy channel is rescinded we need to make sure that the char device is fully cleaned up before we can process a new Fcopy offer from the host. Implement this logic.
--- drivers/hv/hv_fcopy.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/hv/hv_fcopy.c +4 -0
@@ -61,6 +61,7 @@static const char fcopy_devname[] ="vmbus/hv_fcopy" ;static u8 *recv_buffer;static struct hvutil_transport *hvt; +static struct completion release_event;/* * This state maintains the version number registered by the daemon. */
@@ -317,6 +318,7 @@ static void fcopy_on_reset(void)if (cancel_delayed_work_sync (&fcopy_timeout_work))fcopy_respond_to_host (HV_E_FAIL ); +complete (&release_event); }int hv_fcopy_init (struct hv_util_service *srv)
@@ -324,6 +326,7 @@ int hv_fcopy_init(struct hv_util_service *srv) recv_buffer = srv->recv_buffer; fcopy_transaction.recv_channel = srv->channel; +init_completion (&release_event);/* * When this driver loads, the user level daemon that * processes the host requests may not yet be running.
@@ -345,4 +348,5 @@ void hv_fcopy_deinit(void) fcopy_transaction.state =HVUTIL_DEVICE_DYING ;cancel_delayed_work_sync (&fcopy_timeout_work);hvutil_transport_destroy (hvt); +wait_for_completion (&release_event); }
Signature · 1 line
1.7.4.1