Commit 64914207 authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov Committed by Greg Kroah-Hartman

Drivers: hv: vss: Introduce timeout for communication with userspace

In contrast with KVP there is no timeout when communicating with
userspace VSS daemon. In case it gets stuck performing freeze/thaw
operation no message will be sent to the host so it will take very
long (around 10 minutes) before backup fails. Introduce 10 second
timeout using schedule_delayed_work().
Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1a3c724a
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#define VSS_MINOR 0 #define VSS_MINOR 0
#define VSS_VERSION (VSS_MAJOR << 16 | VSS_MINOR) #define VSS_VERSION (VSS_MAJOR << 16 | VSS_MINOR)
#define VSS_USERSPACE_TIMEOUT (msecs_to_jiffies(10 * 1000))
/* /*
* Global state maintained for transaction that is being processed. * Global state maintained for transaction that is being processed.
...@@ -55,12 +55,24 @@ static const char vss_name[] = "vss_kernel_module"; ...@@ -55,12 +55,24 @@ static const char vss_name[] = "vss_kernel_module";
static __u8 *recv_buffer; static __u8 *recv_buffer;
static void vss_send_op(struct work_struct *dummy); static void vss_send_op(struct work_struct *dummy);
static void vss_timeout_func(struct work_struct *dummy);
static DECLARE_DELAYED_WORK(vss_timeout_work, vss_timeout_func);
static DECLARE_WORK(vss_send_op_work, vss_send_op); static DECLARE_WORK(vss_send_op_work, vss_send_op);
/* /*
* Callback when data is received from user mode. * Callback when data is received from user mode.
*/ */
static void vss_timeout_func(struct work_struct *dummy)
{
/*
* Timeout waiting for userspace component to reply happened.
*/
pr_warn("VSS: timeout waiting for daemon to reply\n");
vss_respond_to_host(HV_E_FAIL);
}
static void static void
vss_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp) vss_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
{ {
...@@ -76,7 +88,8 @@ vss_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp) ...@@ -76,7 +88,8 @@ vss_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
return; return;
} }
vss_respond_to_host(vss_msg->error); if (cancel_delayed_work_sync(&vss_timeout_work))
vss_respond_to_host(vss_msg->error);
} }
...@@ -223,6 +236,8 @@ void hv_vss_onchannelcallback(void *context) ...@@ -223,6 +236,8 @@ void hv_vss_onchannelcallback(void *context)
case VSS_OP_FREEZE: case VSS_OP_FREEZE:
case VSS_OP_THAW: case VSS_OP_THAW:
schedule_work(&vss_send_op_work); schedule_work(&vss_send_op_work);
schedule_delayed_work(&vss_timeout_work,
VSS_USERSPACE_TIMEOUT);
return; return;
case VSS_OP_HOT_BACKUP: case VSS_OP_HOT_BACKUP:
...@@ -277,5 +292,6 @@ hv_vss_init(struct hv_util_service *srv) ...@@ -277,5 +292,6 @@ hv_vss_init(struct hv_util_service *srv)
void hv_vss_deinit(void) void hv_vss_deinit(void)
{ {
cn_del_callback(&vss_id); cn_del_callback(&vss_id);
cancel_delayed_work_sync(&vss_timeout_work);
cancel_work_sync(&vss_send_op_work); cancel_work_sync(&vss_send_op_work);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment