Whamcloud - gitweb
LU-4536 ldlm: Recalculate interval in ldlm_pool_recalc() 47/12547/4
authorNathaniel Clark <nathaniel.l.clark@intel.com>
Tue, 4 Nov 2014 02:26:33 +0000 (21:26 -0500)
committerAndreas Dilger <andreas.dilger@intel.com>
Tue, 16 Dec 2014 20:02:40 +0000 (20:02 +0000)
Instead of rechecking a static value, recalculate to see if pool stats
need to be updated.
Add newline so message will print instead of warning about missing
newline.

Test-Parameters: mdsfilesystemtype=zfs mdtfilesystemtype=zfs ostfilesystemtype=zfs testlist=sanity,sanity,sanity,sanity,sanity,sanity,sanity,sanity,sanity,sanity
Signed-off-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Change-Id: Ic31cc0c1d09a85a9bd5ee04ac34c388263190df1
Reviewed-on: http://review.whamcloud.com/12547
Tested-by: Jenkins
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
lustre/ldlm/ldlm_pool.c

index cecb2e2..ca24afc 100644 (file)
@@ -579,42 +579,50 @@ static struct ldlm_pool_ops ldlm_cli_pool_ops = {
  */
 int ldlm_pool_recalc(struct ldlm_pool *pl)
 {
  */
 int ldlm_pool_recalc(struct ldlm_pool *pl)
 {
-        time_t recalc_interval_sec;
-        int count;
-
-        recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time;
-        if (recalc_interval_sec <= 0)
-                goto recalc;
+       time_t recalc_interval_sec;
+       int count;
 
 
-       spin_lock(&pl->pl_lock);
+       recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time;
        if (recalc_interval_sec > 0) {
        if (recalc_interval_sec > 0) {
-               /*
-                * Update pool statistics every 1s.
-                */
-               ldlm_pool_recalc_stats(pl);
+               spin_lock(&pl->pl_lock);
+               recalc_interval_sec = cfs_time_current_sec() -
+                       pl->pl_recalc_time;
+
+               if (recalc_interval_sec > 0) {
+                       /*
+                        * Update pool statistics every 1s.
+                        */
+                       ldlm_pool_recalc_stats(pl);
+
+                       /*
+                        * Zero out all rates and speed for the last period.
+                        */
+                       atomic_set(&pl->pl_grant_rate, 0);
+                       atomic_set(&pl->pl_cancel_rate, 0);
+               }
+               spin_unlock(&pl->pl_lock);
+       }
 
 
-               /*
-                * Zero out all rates and speed for the last period.
-                */
-               atomic_set(&pl->pl_grant_rate, 0);
-               atomic_set(&pl->pl_cancel_rate, 0);
+       if (pl->pl_ops->po_recalc != NULL) {
+               count = pl->pl_ops->po_recalc(pl);
+               lprocfs_counter_add(pl->pl_stats, LDLM_POOL_RECALC_STAT,
+                                   count);
        }
        }
-       spin_unlock(&pl->pl_lock);
 
 
- recalc:
-        if (pl->pl_ops->po_recalc != NULL) {
-                count = pl->pl_ops->po_recalc(pl);
-                lprocfs_counter_add(pl->pl_stats, LDLM_POOL_RECALC_STAT,
-                                    count);
-        }
        recalc_interval_sec = pl->pl_recalc_time - cfs_time_current_sec() +
                              pl->pl_recalc_period;
        if (recalc_interval_sec <= 0) {
        recalc_interval_sec = pl->pl_recalc_time - cfs_time_current_sec() +
                              pl->pl_recalc_period;
        if (recalc_interval_sec <= 0) {
+               /* DEBUG: should be re-removed after LU-4536 is fixed */
+               CDEBUG(D_DLMTRACE, "%s: Negative interval(%ld), "
+                      "too short period(%ld)\n",
+                      pl->pl_name, recalc_interval_sec,
+                      pl->pl_recalc_period);
+
                /* Prevent too frequent recalculation. */
                recalc_interval_sec = 1;
        }
 
                /* Prevent too frequent recalculation. */
                recalc_interval_sec = 1;
        }
 
-        return recalc_interval_sec;
+       return recalc_interval_sec;
 }
 
 /**
 }
 
 /**