From 08f093ce2c799faf7a580f53850ecb13d2b71603 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Tue, 19 Feb 2013 12:02:14 +0400 Subject: [PATCH] LU-2701 osp: wake up sync thread osp_sync_process_committed() to wake up sync thread when it is requested to stop (e.g. umount) and there is no pending work left. the patch adds a sanity check to ensure this process is not taking too long. Signed-off-by: Alex Zhuravlev Change-Id: I5251013afc2aee55627c806a11eb826a9d3dbec9 Reviewed-on: http://review.whamcloud.com/5463 Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Keith Mannthey Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- lustre/osp/osp_sync.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lustre/osp/osp_sync.c b/lustre/osp/osp_sync.c index fc67e5c..219744f 100644 --- a/lustre/osp/osp_sync.c +++ b/lustre/osp/osp_sync.c @@ -738,6 +738,11 @@ static void osp_sync_process_committed(const struct lu_env *env, osp_sync_check_for_work(d); + /* wake up the thread if requested to stop: + * it might be waiting for in-progress to complete */ + if (unlikely(osp_sync_running(d) == 0)) + cfs_waitq_signal(&d->opd_syn_waitq); + EXIT; } @@ -832,7 +837,7 @@ static int osp_sync_thread(void *_arg) struct obd_device *obd = d->opd_obd; struct llog_handle *llh; struct lu_env env; - int rc; + int rc, count; char pname[16]; ENTRY; @@ -878,11 +883,21 @@ static int osp_sync_thread(void *_arg) d->opd_syn_rpc_in_flight); /* wait till all the requests are completed */ + count = 0; while (d->opd_syn_rpc_in_progress > 0) { osp_sync_process_committed(&env, d); - l_wait_event(d->opd_syn_waitq, - d->opd_syn_rpc_in_progress == 0, - &lwi); + + lwi = LWI_TIMEOUT(cfs_time_seconds(5), NULL, NULL); + rc = l_wait_event(d->opd_syn_waitq, + d->opd_syn_rpc_in_progress == 0, + &lwi); + if (rc == -ETIMEDOUT) + count++; + LASSERTF(count < 10, "%s: %d %d %sempty\n", + d->opd_obd->obd_name, d->opd_syn_rpc_in_progress, + d->opd_syn_rpc_in_flight, + cfs_list_empty(&d->opd_syn_committed_there) ? "" :"!"); + } llog_cat_close(&env, llh); -- 1.8.3.1