diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c
index 593f37b0baed148314026280034846806fa06ed6..639bfbbb41890bc44c9e4a7d7e598f32ee6e190a 100644
--- a/lustre/obdfilter/filter.c
+++ b/lustre/obdfilter/filter.c
@@ -2336,20 +2336,20 @@ static int filter_llog_finish(struct obd_device *obd, int count)
 
         ctxt = llog_group_get_ctxt(&obd->obd_olg, LLOG_MDS_OST_REPL_CTXT);
         if (ctxt) {
+                /*
+                 * Make sure that no cached llcds left in recov_thread.
+                 * We actually do sync in disconnect time, but disconnect
+                 * may not come being marked rq_no_resend = 1.
+                 */
+                llog_sync(ctxt, NULL);
+
+                /*
+                 * Balance class_import_get() in llog_receptor_accept().
+                 * This is safe to do, as llog is already synchronized
+                 * and its import may go.
+                 */
                 mutex_down(&ctxt->loc_sem);
                 if (ctxt->loc_imp) {
-                        /*
-                         * Make sure that no cached llcds left in recov_thread.
-                         * We actually do sync in disconnect time, but disconnect
-                         * may not come being marked rq_no_resend = 1.
-                         */
-                        llog_sync(ctxt, NULL);
-
-                        /*
-                         * Balance class_import_get() in llog_receptor_accept().
-                         * This is safe to do, as llog is already synchronized
-                         * and its import may go.
-                         */
                         class_import_put(ctxt->loc_imp);
                         ctxt->loc_imp = NULL;
                 }