diff options
author | Vitaly Kuznetsov <vkuznets@redhat.com> | 2014-11-06 12:21:24 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-11-26 22:00:32 -0500 |
commit | 649142074d86afebe0505431a93957505d244dd6 (patch) | |
tree | 4e135e9056ba74312a3536c112c83531604a62de | |
parent | 1a3c724afd07a485c7066140f67d466f39263dc6 (diff) |
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: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/hv/hv_snapshot.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/drivers/hv/hv_snapshot.c b/drivers/hv/hv_snapshot.c index 34f14fddb666..21e51be74e6c 100644 --- a/drivers/hv/hv_snapshot.c +++ b/drivers/hv/hv_snapshot.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #define VSS_MINOR 0 | 28 | #define VSS_MINOR 0 |
29 | #define VSS_VERSION (VSS_MAJOR << 16 | VSS_MINOR) | 29 | #define VSS_VERSION (VSS_MAJOR << 16 | VSS_MINOR) |
30 | 30 | ||
31 | 31 | #define VSS_USERSPACE_TIMEOUT (msecs_to_jiffies(10 * 1000)) | |
32 | 32 | ||
33 | /* | 33 | /* |
34 | * Global state maintained for transaction that is being processed. | 34 | * Global state maintained for transaction that is being processed. |
@@ -55,12 +55,24 @@ static const char vss_name[] = "vss_kernel_module"; | |||
55 | static __u8 *recv_buffer; | 55 | static __u8 *recv_buffer; |
56 | 56 | ||
57 | static void vss_send_op(struct work_struct *dummy); | 57 | static void vss_send_op(struct work_struct *dummy); |
58 | static void vss_timeout_func(struct work_struct *dummy); | ||
59 | |||
60 | static DECLARE_DELAYED_WORK(vss_timeout_work, vss_timeout_func); | ||
58 | static DECLARE_WORK(vss_send_op_work, vss_send_op); | 61 | static DECLARE_WORK(vss_send_op_work, vss_send_op); |
59 | 62 | ||
60 | /* | 63 | /* |
61 | * Callback when data is received from user mode. | 64 | * Callback when data is received from user mode. |
62 | */ | 65 | */ |
63 | 66 | ||
67 | static void vss_timeout_func(struct work_struct *dummy) | ||
68 | { | ||
69 | /* | ||
70 | * Timeout waiting for userspace component to reply happened. | ||
71 | */ | ||
72 | pr_warn("VSS: timeout waiting for daemon to reply\n"); | ||
73 | vss_respond_to_host(HV_E_FAIL); | ||
74 | } | ||
75 | |||
64 | static void | 76 | static void |
65 | vss_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp) | 77 | vss_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp) |
66 | { | 78 | { |
@@ -76,7 +88,8 @@ vss_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp) | |||
76 | return; | 88 | return; |
77 | 89 | ||
78 | } | 90 | } |
79 | vss_respond_to_host(vss_msg->error); | 91 | if (cancel_delayed_work_sync(&vss_timeout_work)) |
92 | vss_respond_to_host(vss_msg->error); | ||
80 | } | 93 | } |
81 | 94 | ||
82 | 95 | ||
@@ -223,6 +236,8 @@ void hv_vss_onchannelcallback(void *context) | |||
223 | case VSS_OP_FREEZE: | 236 | case VSS_OP_FREEZE: |
224 | case VSS_OP_THAW: | 237 | case VSS_OP_THAW: |
225 | schedule_work(&vss_send_op_work); | 238 | schedule_work(&vss_send_op_work); |
239 | schedule_delayed_work(&vss_timeout_work, | ||
240 | VSS_USERSPACE_TIMEOUT); | ||
226 | return; | 241 | return; |
227 | 242 | ||
228 | case VSS_OP_HOT_BACKUP: | 243 | case VSS_OP_HOT_BACKUP: |
@@ -277,5 +292,6 @@ hv_vss_init(struct hv_util_service *srv) | |||
277 | void hv_vss_deinit(void) | 292 | void hv_vss_deinit(void) |
278 | { | 293 | { |
279 | cn_del_callback(&vss_id); | 294 | cn_del_callback(&vss_id); |
295 | cancel_delayed_work_sync(&vss_timeout_work); | ||
280 | cancel_work_sync(&vss_send_op_work); | 296 | cancel_work_sync(&vss_send_op_work); |
281 | } | 297 | } |