Whamcloud - gitweb
LU-2701 osp: wake up sync thread
authorAlex Zhuravlev <alexey.zhuravlev@intel.com>
Tue, 19 Feb 2013 08:02:14 +0000 (12:02 +0400)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 15 Mar 2013 05:26:55 +0000 (01:26 -0400)
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 <alexey.zhuravlev@intel.com>
Change-Id: I5251013afc2aee55627c806a11eb826a9d3dbec9
Reviewed-on: http://review.whamcloud.com/5463
Tested-by: Hudson
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osp/osp_sync.c

index fc67e5c..219744f 100644 (file)
@@ -738,6 +738,11 @@ static void osp_sync_process_committed(const struct lu_env *env,
 
        osp_sync_check_for_work(d);
 
 
        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;
 }
 
        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;
        struct obd_device       *obd = d->opd_obd;
        struct llog_handle      *llh;
        struct lu_env            env;
-       int                      rc;
+       int                      rc, count;
        char                     pname[16];
 
        ENTRY;
        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 */
                 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);
        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);
        }
 
        llog_cat_close(&env, llh);