aoe: manipulate aoedev network stats under lock
authorEd Cashin <[email protected]>
Tue, 18 Dec 2012 00:03:47 +0000 (16:03 -0800)
committerLinus Torvalds <[email protected]>
Tue, 18 Dec 2012 01:15:24 +0000 (17:15 -0800)
With this bugfix in place the calculation of the criterion for "lateness"
is performed under lock.  Without the lock, there is a chance that one of
the non-atomic operations performed on the round trip time statistics
could be incomplete, such that an incorrect lateness criterion would be
calculated.

Without this change, the effect of the bug would be rare unecessary but
benign retransmissions.

Signed-off-by: Ed Cashin <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
drivers/block/aoe/aoecmd.c

index 6ea27fd8954df833b781c1fe639a3683b7e38c74..9aefbe3957ca6d8e9ed899c3918aa6db044de234 100644 (file)
@@ -603,14 +603,14 @@ rexmit_timer(ulong vp)
 
        d = (struct aoedev *) vp;
 
+       spin_lock_irqsave(&d->lock, flags);
+
        /* timeout based on observed timings and variations */
        timeout = 2 * d->rttavg >> RTTSCALE;
        timeout += 8 * d->rttdev >> RTTDSCALE;
        if (timeout == 0)
                timeout = 1;
 
-       spin_lock_irqsave(&d->lock, flags);
-
        if (d->flags & DEVFL_TKILL) {
                spin_unlock_irqrestore(&d->lock, flags);
                return;