Whamcloud - gitweb
Branch HEAD
authorbwzhou <bwzhou>
Tue, 29 Jan 2008 16:29:45 +0000 (16:29 +0000)
committerbwzhou <bwzhou>
Tue, 29 Jan 2008 16:29:45 +0000 (16:29 +0000)
b=13079
r=green, nikita

add obd recovery time cap (initially for Cray_XT3)

lustre/include/lprocfs_status.h
lustre/include/lustre_lib.h
lustre/include/obd.h
lustre/ldlm/ldlm_lib.c
lustre/obdclass/lprocfs_status.c
lustre/obdfilter/lproc_obdfilter.c

index e2dd9c4..4516175 100644 (file)
@@ -457,6 +457,13 @@ struct file_operations name##_fops = {                                     \
 #define LPROC_SEQ_FOPS_RO(name)         __LPROC_SEQ_FOPS(name, NULL)
 #define LPROC_SEQ_FOPS(name)            __LPROC_SEQ_FOPS(name, name##_seq_write)
 
+/* lprocfs_status.c: read recovery max time bz13079 */
+int lprocfs_obd_rd_recovery_maxtime(char *page, char **start, off_t off,
+                                    int count, int *eof, void *data);
+
+/* lprocfs_status.c: write recovery max time bz13079 */
+int lprocfs_obd_wr_recovery_maxtime(struct file *file, const char *buffer,
+                                    unsigned long count, void *data);
 #else
 /* LPROCFS is not defined */
 static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
index 20f73e0..352205d 100644 (file)
@@ -76,6 +76,7 @@ int target_handle_dqacq_callback(struct ptlrpc_request *req);
 void target_cancel_recovery_timer(struct obd_device *obd);
 
 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2) /* *waves hands* */
+#define OBD_RECOVERY_MAX_TIME (obd_timeout * 18) /* b13079 */
 void target_start_recovery_timer(struct obd_device *obd);
 int target_start_recovery_thread(struct obd_device *obd, 
                                   svc_handler_t handler);
index b5c14c0..8d6e9f1 100644 (file)
@@ -921,8 +921,9 @@ struct obd_device {
         struct list_head                 obd_uncommitted_replies;
         spinlock_t                       obd_uncommitted_replies_lock;
         cfs_timer_t                      obd_recovery_timer;
-        time_t                           obd_recovery_start;
-        time_t                           obd_recovery_end;
+        time_t                           obd_recovery_start; /* seconds */
+        time_t                           obd_recovery_end; /* seconds */
+        time_t                           obd_recovery_max_time; /* seconds, bz13079 */
         
         /* new recovery stuff from CMD2 */
         struct target_recovery_data      obd_recovery_data;
index 79c3fc9..12ab289 100644 (file)
@@ -1173,18 +1173,22 @@ void target_cancel_recovery_timer(struct obd_device *obd)
 
 static void reset_recovery_timer(struct obd_device *obd)
 {
+        time_t timeout_shift = OBD_RECOVERY_TIMEOUT;
         spin_lock_bh(&obd->obd_processing_task_lock);
         if (!obd->obd_recovering) {
                 spin_unlock_bh(&obd->obd_processing_task_lock);
                 return;
         }
-        cfs_timer_arm(&obd->obd_recovery_timer,
-                      cfs_time_shift(OBD_RECOVERY_TIMEOUT));
+        if (cfs_time_current_sec() + OBD_RECOVERY_TIMEOUT > 
+            obd->obd_recovery_start + obd->obd_recovery_max_time)
+                timeout_shift = obd->obd_recovery_start + 
+                        obd->obd_recovery_max_time - cfs_time_current_sec();
+        cfs_timer_arm(&obd->obd_recovery_timer, cfs_time_shift(timeout_shift));
         spin_unlock_bh(&obd->obd_processing_task_lock);
         CDEBUG(D_HA, "%s: timer will expire in %u seconds\n", obd->obd_name,
-               OBD_RECOVERY_TIMEOUT);
+               (unsigned int)timeout_shift);
         /* Only used for lprocfs_status */
-        obd->obd_recovery_end = CURRENT_SECONDS + OBD_RECOVERY_TIMEOUT;
+        obd->obd_recovery_end = CURRENT_SECONDS + timeout_shift;
 }
 
 
@@ -1615,6 +1619,8 @@ void target_recovery_init(struct obd_device *obd, svc_handler_t handler)
         obd->obd_recovery_start = CURRENT_SECONDS;
         /* Only used for lprocfs_status */
         obd->obd_recovery_end = obd->obd_recovery_start + OBD_RECOVERY_TIMEOUT;
+        /* bz13079: this should be set to desired value for ost but not for mds */
+        obd->obd_recovery_max_time = OBD_RECOVERY_MAX_TIME;
 }
 EXPORT_SYMBOL(target_recovery_init);
 
index f4b685e..a4e61bf 100644 (file)
@@ -1581,6 +1581,33 @@ out:
 }
 EXPORT_SYMBOL(lprocfs_obd_rd_recovery_status);
 
+int lprocfs_obd_rd_recovery_maxtime(char *page, char **start, off_t off,
+                                    int count, int *eof, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+        LASSERT(obd != NULL);
+
+        return snprintf(page, count, "%lu\n", 
+                        obd->obd_recovery_max_time);
+}
+EXPORT_SYMBOL(lprocfs_obd_rd_recovery_maxtime);
+
+int lprocfs_obd_wr_recovery_maxtime(struct file *file, const char *buffer,
+                                    unsigned long count, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+        int val, rc;
+        LASSERT(obd != NULL);
+
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        obd->obd_recovery_max_time = val;
+        return count;
+}
+EXPORT_SYMBOL(lprocfs_obd_wr_recovery_maxtime);
+
 EXPORT_SYMBOL(lprocfs_register);
 EXPORT_SYMBOL(lprocfs_srch);
 EXPORT_SYMBOL(lprocfs_remove);
index 2b7d846..22ef020 100644 (file)
@@ -247,6 +247,8 @@ static struct lprocfs_vars lprocfs_filter_obd_vars[] = {
         { "tot_pending",  lprocfs_filter_rd_tot_pending, 0, 0 },
         { "tot_granted",  lprocfs_filter_rd_tot_granted, 0, 0 },
         { "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 },
+        { "recovery_maxtime", lprocfs_obd_rd_recovery_maxtime,
+                              lprocfs_obd_wr_recovery_maxtime, 0},
         { "evict_client", 0, lprocfs_wr_evict_client, 0,
                                 &lprocfs_evict_client_fops},
         { "num_exports",  lprocfs_rd_num_exports,   0, 0 },