]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: lustre: ldlm: pl_recalc time handling is wrong
authorArnd Bergmann <arnd@arndb.de>
Thu, 10 Nov 2016 15:21:20 +0000 (16:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 Nov 2016 14:56:18 +0000 (15:56 +0100)
James Simmons reports:
> The ldlm_pool field pl_recalc_time is set to the current
> monotonic clock value but the interval period is calculated
> with the wall clock. This means the interval period will
> always be far larger than the pl_recalc_period, which is
> just a small interval time period. The correct thing to
> do is to use monotomic clock current value instead of the
> wall clocks value when calculating recalc_interval_sec.

This broke when I converted the 32-bit get_seconds() into
ktime_get_{real_,}seconds() inconsistently. Either
one of those two would have worked, but mixing them
does not.

Staying with the original intention of the patch, this
changes the ktime_get_seconds() calls into ktime_get_real_seconds(),
using real time instead of mononic time.

Cc: stable@vger.kernel.org # v4.4+
Fixes: 8f83409cf238 ("staging/lustre: use 64-bit time for pl_recalc")
Reported-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/ldlm/ldlm_pool.c

index 19831c555c4940fc267d4cb41db1e9bfd8c11791..b820309d70e346eaae31b83676097418701fdba7 100644 (file)
@@ -356,10 +356,10 @@ static int ldlm_pool_recalc(struct ldlm_pool *pl)
        u32 recalc_interval_sec;
        int count;
 
-       recalc_interval_sec = ktime_get_seconds() - pl->pl_recalc_time;
+       recalc_interval_sec = ktime_get_real_seconds() - pl->pl_recalc_time;
        if (recalc_interval_sec > 0) {
                spin_lock(&pl->pl_lock);
-               recalc_interval_sec = ktime_get_seconds() - pl->pl_recalc_time;
+               recalc_interval_sec = ktime_get_real_seconds() - pl->pl_recalc_time;
 
                if (recalc_interval_sec > 0) {
                        /*
@@ -382,7 +382,7 @@ static int ldlm_pool_recalc(struct ldlm_pool *pl)
                                    count);
        }
 
-       recalc_interval_sec = pl->pl_recalc_time - ktime_get_seconds() +
+       recalc_interval_sec = pl->pl_recalc_time - ktime_get_real_seconds() +
                              pl->pl_recalc_period;
        if (recalc_interval_sec <= 0) {
                /* DEBUG: should be re-removed after LU-4536 is fixed */
@@ -657,7 +657,7 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
 
        spin_lock_init(&pl->pl_lock);
        atomic_set(&pl->pl_granted, 0);
-       pl->pl_recalc_time = ktime_get_seconds();
+       pl->pl_recalc_time = ktime_get_real_seconds();
        atomic_set(&pl->pl_lock_volume_factor, 1);
 
        atomic_set(&pl->pl_grant_rate, 0);