Whamcloud - gitweb
LU-1146 build: batch update copyright messages
[fs/lustre-release.git] / lustre / mgs / mgs_nids.c
index 587a9d0..6b0c818 100644 (file)
@@ -28,6 +28,8 @@
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -385,6 +387,25 @@ static int mgs_nidtbl_init_fs(struct fs_db *fsdb)
 }
 
 /* --------- Imperative Recovery relies on nidtbl stuff ------- */
+void mgs_ir_notify_complete(struct fs_db *fsdb)
+{
+        struct timeval tv;
+        cfs_duration_t delta;
+
+        cfs_atomic_set(&fsdb->fsdb_notify_phase, 0);
+
+        /* do statistic */
+        fsdb->fsdb_notify_count++;
+        delta = cfs_time_sub(cfs_time_current(), fsdb->fsdb_notify_start);
+        fsdb->fsdb_notify_total += delta;
+        if (delta > fsdb->fsdb_notify_max)
+                fsdb->fsdb_notify_max = delta;
+
+        cfs_duration_usec(delta, &tv);
+        CDEBUG(D_MGS, "Revoke recover lock of %s completed after %ld.%06lds\n",
+               fsdb->fsdb_name, tv.tv_sec, tv.tv_usec);
+}
+
 static int mgs_ir_notify(void *arg)
 {
         struct fs_db      *fsdb   = arg;
@@ -398,13 +419,11 @@ static int mgs_ir_notify(void *arg)
 
         cfs_complete(&fsdb->fsdb_notify_comp);
 
+        set_user_nice(current, -2);
+
         mgc_fsname2resid(fsdb->fsdb_name, &resid, CONFIG_T_RECOVER);
         while (1) {
                 struct l_wait_info   lwi = { 0 };
-                struct lustre_handle lockh;
-                cfs_time_t           curtime;
-                int                  lockrc;
-                int                  delta;
 
                 l_wait_event(fsdb->fsdb_notify_waitq,
                              fsdb->fsdb_notify_stop ||
@@ -416,24 +435,8 @@ static int mgs_ir_notify(void *arg)
                 CDEBUG(D_MGS, "%s woken up, phase is %d\n",
                        name, cfs_atomic_read(&fsdb->fsdb_notify_phase));
 
-                curtime = cfs_time_current();
-                lockrc = mgs_get_lock(fsdb->fsdb_obd, &resid, &lockh);
-                if (lockrc == ELDLM_OK) {
-                        cfs_atomic_set(&fsdb->fsdb_notify_phase, 0);
-                        mgs_put_lock(&lockh);
-
-                        /* do statistic */
-                        fsdb->fsdb_notify_count++;
-                        delta = (cfs_time_current() - curtime) / NSEC_PER_USEC;
-                        fsdb->fsdb_notify_total += delta;
-                        if (delta > fsdb->fsdb_notify_max)
-                                fsdb->fsdb_notify_max = delta;
-                        CDEBUG(D_MGS, "Revoke recover lock of %s spent %dus\n",
-                               fsdb->fsdb_name, delta);
-                } else {
-                        CERROR("Fatal error %d for fs %s\n",
-                               lockrc, fsdb->fsdb_name);
-                }
+                fsdb->fsdb_notify_start = cfs_time_current();
+                mgs_revoke_lock(fsdb->fsdb_obd, fsdb, CONFIG_T_RECOVER);
         }
 
         cfs_complete(&fsdb->fsdb_notify_comp);
@@ -789,18 +792,30 @@ int lprocfs_rd_ir_state(struct seq_file *seq, void *data)
         struct fs_db      *fsdb = data;
         struct mgs_nidtbl *tbl  = &fsdb->fsdb_nidtbl;
         const char        *ir_strings[] = IR_STRINGS;
+        struct timeval     tv_max;
+        struct timeval     tv;
 
         /* mgs_live_seq_show() already holds fsdb_sem. */
         ir_state_graduate(fsdb);
 
+        seq_printf(seq, "\nimperative_recovery_state:\n");
         seq_printf(seq,
-                   "\tstate: %s, nonir clients: %d\n"
-                   "\tnidtbl version: %lld\n",
+                   "    state: %s\n"
+                   "    nonir_clients: %d\n"
+                   "    nidtbl_version: %lld\n",
                    ir_strings[fsdb->fsdb_ir_state], fsdb->fsdb_nonir_clients,
                    tbl->mn_version);
-        seq_printf(seq, "\tnotify total/max/count: %u/%u/%u\n",
-                   fsdb->fsdb_notify_total, fsdb->fsdb_notify_max,
+
+        cfs_duration_usec(fsdb->fsdb_notify_total, &tv);
+        cfs_duration_usec(fsdb->fsdb_notify_max, &tv_max);
+
+        seq_printf(seq, "    notify_duration_total: %lu.%06lu\n"
+                        "    notify_duation_max: %lu.%06lu\n"
+                        "    notify_count: %u\n",
+                   tv.tv_sec, tv.tv_usec,
+                   tv_max.tv_sec, tv_max.tv_usec,
                    fsdb->fsdb_notify_count);
+
         return 0;
 }