summaryrefslogtreecommitdiff
path: root/drivers/md/bcache/util.c
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-07-31 07:03:54 (GMT)
committerKent Overstreet <kmo@daterainc.com>2013-11-11 05:56:40 (GMT)
commit65d22e911bfc4f46cda4751f1b1926b43c316c14 (patch)
tree2d860067f2cb0d25a3fda0b9d3873d911ce364fe /drivers/md/bcache/util.c
parent8aee122071a69ca6fa3314da7713bdf0b61dc07c (diff)
downloadlinux-65d22e911bfc4f46cda4751f1b1926b43c316c14.tar.xz
bcache: Move spinlock into struct time_stats
Minor cleanup. Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache/util.c')
-rw-r--r--drivers/md/bcache/util.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c
index 420dad5..462214e 100644
--- a/drivers/md/bcache/util.c
+++ b/drivers/md/bcache/util.c
@@ -168,10 +168,14 @@ int bch_parse_uuid(const char *s, char *uuid)
void bch_time_stats_update(struct time_stats *stats, uint64_t start_time)
{
- uint64_t now = local_clock();
- uint64_t duration = time_after64(now, start_time)
+ uint64_t now, duration, last;
+
+ spin_lock(&stats->lock);
+
+ now = local_clock();
+ duration = time_after64(now, start_time)
? now - start_time : 0;
- uint64_t last = time_after64(now, stats->last)
+ last = time_after64(now, stats->last)
? now - stats->last : 0;
stats->max_duration = max(stats->max_duration, duration);
@@ -188,6 +192,8 @@ void bch_time_stats_update(struct time_stats *stats, uint64_t start_time)
}
stats->last = now ?: 1;
+
+ spin_unlock(&stats->lock);
}
/**