OSDN Git Service

dm: use time_in_range() and time_after()
authorManuel Schölling <manuel.schoelling@gmx.de>
Thu, 22 May 2014 20:42:37 +0000 (22:42 +0200)
committerMike Snitzer <snitzer@redhat.com>
Mon, 9 Feb 2015 18:06:48 +0000 (13:06 -0500)
To be future-proof and for better readability the time comparisons are modified
to use time_in_range() and time_after() instead of plain, error-prone math.

Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-cache-target.c
drivers/md/dm-log-userspace-base.c
drivers/md/dm-thin.c

index 1e96d78..2eca128 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/dm-io.h>
 #include <linux/dm-kcopyd.h>
+#include <linux/jiffies.h>
 #include <linux/init.h>
 #include <linux/mempool.h>
 #include <linux/module.h>
@@ -1547,8 +1548,8 @@ static void process_bio(struct cache *cache, struct prealloc *structs,
 
 static int need_commit_due_to_time(struct cache *cache)
 {
-       return jiffies < cache->last_commit_jiffies ||
-              jiffies > cache->last_commit_jiffies + COMMIT_PERIOD;
+       return !time_in_range(jiffies, cache->last_commit_jiffies,
+                             cache->last_commit_jiffies + COMMIT_PERIOD);
 }
 
 static int commit_if_needed(struct cache *cache)
index b953db6..03177ca 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/bio.h>
 #include <linux/slab.h>
+#include <linux/jiffies.h>
 #include <linux/dm-dirty-log.h>
 #include <linux/device-mapper.h>
 #include <linux/dm-log-userspace.h>
@@ -829,7 +830,7 @@ static int userspace_is_remote_recovering(struct dm_dirty_log *log,
        int r;
        uint64_t region64 = region;
        struct log_c *lc = log->context;
-       static unsigned long long limit;
+       static unsigned long limit;
        struct {
                int64_t is_recovering;
                uint64_t in_sync_hint;
@@ -845,7 +846,7 @@ static int userspace_is_remote_recovering(struct dm_dirty_log *log,
         */
        if (region < lc->in_sync_hint)
                return 0;
-       else if (jiffies < limit)
+       else if (time_after(limit, jiffies))
                return 1;
 
        limit = jiffies + (HZ / 4);
index 4934789..0f78145 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/device-mapper.h>
 #include <linux/dm-io.h>
 #include <linux/dm-kcopyd.h>
+#include <linux/jiffies.h>
 #include <linux/log2.h>
 #include <linux/list.h>
 #include <linux/rculist.h>
@@ -1700,8 +1701,8 @@ static void process_cell_fail(struct thin_c *tc, struct dm_bio_prison_cell *cell
  */
 static int need_commit_due_to_time(struct pool *pool)
 {
-       return jiffies < pool->last_commit_jiffies ||
-              jiffies > pool->last_commit_jiffies + COMMIT_PERIOD;
+       return !time_in_range(jiffies, pool->last_commit_jiffies,
+                             pool->last_commit_jiffies + COMMIT_PERIOD);
 }
 
 #define thin_pbd(node) rb_entry((node), struct dm_thin_endio_hook, rb_node)