Whamcloud - gitweb
LU-11762 ldlm: don't exceed hard timeout 36/36936/2
authorJames Simmons <jsimmons@infradead.org>
Thu, 4 Jul 2019 16:47:09 +0000 (12:47 -0400)
committerOleg Drokin <green@whamcloud.com>
Fri, 3 Jan 2020 23:41:35 +0000 (23:41 +0000)
For recovery lustre has both a soft timeout, obd_recovery_timeout
and a hard timeout, obd_recovery_time_hard. When the recovery
timer is adjust with the function extend_recovery_timer() you
can control if it takes in consideration what is left of the
timer. The current code is not very clear on its intent so this
patch attempts to make the code understandable. No function
change should happen with this patch.

Lustre-change: https://review.whamcloud.com/34408
Lustre-commit: 8bfe8939d810f5ac16484d3d4b81f829c7d7d0d7

Change-Id: I5701a6cd813ad64b6b4422863767af135eb8e94b
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Sergey Cheremencev <c17829@cray.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/36936
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ldlm/ldlm_lib.c

index 42f4820..dba468c 100644 (file)
@@ -40,6 +40,7 @@
 #define DEBUG_SUBSYSTEM S_LDLM
 
 #include <linux/jiffies.h>
+#include <linux/kernel.h>
 #include <linux/kthread.h>
 #include <libcfs/libcfs.h>
 #include <obd.h>
@@ -1738,15 +1739,16 @@ static void target_start_recovery_timer(struct obd_device *obd)
 /**
  * extend recovery window.
  *
- * if @extend is true, extend recovery window to have @drt remaining at least;
- * otherwise, make sure the recovery timeout value is not less than @drt.
+ * if @extend is true, extend recovery window to have @dr_timeout remaining
+ * at least; otherwise, make sure the recovery timeout value is not less
+ * than @dr_timeout.
  */
-static void extend_recovery_timer(struct obd_device *obd, time_t drt,
+static void extend_recovery_timer(struct obd_device *obd, time_t dr_timeout,
                                  bool extend)
 {
        ktime_t left_ns;
+       time_t timeout;
        time_t left;
-       time_t to;
 
        spin_lock(&obd->obd_dev_lock);
        if (!obd->obd_recovering || obd->obd_abort_recovery) {
@@ -1755,26 +1757,35 @@ static void extend_recovery_timer(struct obd_device *obd, time_t drt,
        }
        LASSERT(obd->obd_recovery_start != 0);
 
-       to = obd->obd_recovery_timeout;
        left_ns = hrtimer_expires_remaining(&obd->obd_recovery_timer);
        left = ktime_divns(left_ns, NSEC_PER_SEC);
-       if (extend && (drt > left))
-               to += drt - left;
-       else if (!extend && (drt > to))
-               to = drt;
 
-       if (to > obd->obd_recovery_time_hard) {
-               to = obd->obd_recovery_time_hard;
-               CWARN("%s: extended recovery timer reaching hard limit: %ld, extend: %d\n",
-                     obd->obd_name, to, extend);
+       if (extend) {
+               timeout = obd->obd_recovery_timeout;
+               /* dr_timeout will happen after the hrtimer has expired.
+                * Add the excess time to the soft recovery timeout without
+                * exceeding the hard recovery timeout.
+                */
+               if (dr_timeout > left) {
+                       timeout += dr_timeout - left;
+                       timeout = min_t(time_t, obd->obd_recovery_time_hard,
+                                       timeout);
+               }
+       } else {
+               timeout = clamp_t(time_t, dr_timeout, obd->obd_recovery_timeout,
+                                 obd->obd_recovery_time_hard);
        }
 
-       if (obd->obd_recovery_timeout < to) {
+       if (timeout == obd->obd_recovery_time_hard)
+               CWARN("%s: extended recovery timer reached hard limit: %ld, extend: %d\n",
+                     obd->obd_name, timeout, extend);
+
+       if (obd->obd_recovery_timeout < timeout) {
                ktime_t now = ktime_get_real();
                ktime_t end;
 
-               obd->obd_recovery_timeout = to;
-               end = ktime_set(obd->obd_recovery_start + to, 0);
+               obd->obd_recovery_timeout = timeout;
+               end = ktime_set(obd->obd_recovery_start + timeout, 0);
                left_ns = ktime_sub(end, now);
                hrtimer_forward_now(&obd->obd_recovery_timer, left_ns);
                left = ktime_divns(left_ns, NSEC_PER_MSEC);