Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm: use time_in_range() and time_after()

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>

authored by

Manuel Schölling and committed by
Mike Snitzer
0f30af98 3ca5a21a

+9 -6
+3 -2
drivers/md/dm-cache-target.c
··· 11 11 12 12 #include <linux/dm-io.h> 13 13 #include <linux/dm-kcopyd.h> 14 + #include <linux/jiffies.h> 14 15 #include <linux/init.h> 15 16 #include <linux/mempool.h> 16 17 #include <linux/module.h> ··· 1548 1547 1549 1548 static int need_commit_due_to_time(struct cache *cache) 1550 1549 { 1551 - return jiffies < cache->last_commit_jiffies || 1552 - jiffies > cache->last_commit_jiffies + COMMIT_PERIOD; 1550 + return !time_in_range(jiffies, cache->last_commit_jiffies, 1551 + cache->last_commit_jiffies + COMMIT_PERIOD); 1553 1552 } 1554 1553 1555 1554 static int commit_if_needed(struct cache *cache)
+3 -2
drivers/md/dm-log-userspace-base.c
··· 6 6 7 7 #include <linux/bio.h> 8 8 #include <linux/slab.h> 9 + #include <linux/jiffies.h> 9 10 #include <linux/dm-dirty-log.h> 10 11 #include <linux/device-mapper.h> 11 12 #include <linux/dm-log-userspace.h> ··· 830 829 int r; 831 830 uint64_t region64 = region; 832 831 struct log_c *lc = log->context; 833 - static unsigned long long limit; 832 + static unsigned long limit; 834 833 struct { 835 834 int64_t is_recovering; 836 835 uint64_t in_sync_hint; ··· 846 845 */ 847 846 if (region < lc->in_sync_hint) 848 847 return 0; 849 - else if (jiffies < limit) 848 + else if (time_after(limit, jiffies)) 850 849 return 1; 851 850 852 851 limit = jiffies + (HZ / 4);
+3 -2
drivers/md/dm-thin.c
··· 11 11 #include <linux/device-mapper.h> 12 12 #include <linux/dm-io.h> 13 13 #include <linux/dm-kcopyd.h> 14 + #include <linux/jiffies.h> 14 15 #include <linux/log2.h> 15 16 #include <linux/list.h> 16 17 #include <linux/rculist.h> ··· 1701 1700 */ 1702 1701 static int need_commit_due_to_time(struct pool *pool) 1703 1702 { 1704 - return jiffies < pool->last_commit_jiffies || 1705 - jiffies > pool->last_commit_jiffies + COMMIT_PERIOD; 1703 + return !time_in_range(jiffies, pool->last_commit_jiffies, 1704 + pool->last_commit_jiffies + COMMIT_PERIOD); 1706 1705 } 1707 1706 1708 1707 #define thin_pbd(node) rb_entry((node), struct dm_thin_endio_hook, rb_node)