diff options
| -rw-r--r-- | drivers/md/bcache/bcache.h | 23 | ||||
| -rw-r--r-- | drivers/md/bcache/bset.h | 21 | ||||
| -rw-r--r-- | drivers/md/bcache/util.h | 6 |
3 files changed, 26 insertions, 24 deletions
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index 25f017248a81..3fd87323368c 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h | |||
| @@ -704,11 +704,6 @@ struct bbio { | |||
| 704 | struct bio bio; | 704 | struct bio bio; |
| 705 | }; | 705 | }; |
| 706 | 706 | ||
| 707 | static inline unsigned local_clock_us(void) | ||
| 708 | { | ||
| 709 | return local_clock() >> 10; | ||
| 710 | } | ||
| 711 | |||
| 712 | #define BTREE_PRIO USHRT_MAX | 707 | #define BTREE_PRIO USHRT_MAX |
| 713 | #define INITIAL_PRIO 32768 | 708 | #define INITIAL_PRIO 32768 |
| 714 | 709 | ||
| @@ -776,6 +771,24 @@ static inline struct bucket *PTR_BUCKET(struct cache_set *c, | |||
| 776 | return PTR_CACHE(c, k, ptr)->buckets + PTR_BUCKET_NR(c, k, ptr); | 771 | return PTR_CACHE(c, k, ptr)->buckets + PTR_BUCKET_NR(c, k, ptr); |
| 777 | } | 772 | } |
| 778 | 773 | ||
| 774 | static inline uint8_t gen_after(uint8_t a, uint8_t b) | ||
| 775 | { | ||
| 776 | uint8_t r = a - b; | ||
| 777 | return r > 128U ? 0 : r; | ||
| 778 | } | ||
| 779 | |||
| 780 | static inline uint8_t ptr_stale(struct cache_set *c, const struct bkey *k, | ||
| 781 | unsigned i) | ||
| 782 | { | ||
| 783 | return gen_after(PTR_BUCKET(c, k, i)->gen, PTR_GEN(k, i)); | ||
| 784 | } | ||
| 785 | |||
| 786 | static inline bool ptr_available(struct cache_set *c, const struct bkey *k, | ||
| 787 | unsigned i) | ||
| 788 | { | ||
| 789 | return (PTR_DEV(k, i) < MAX_CACHES_PER_SET) && PTR_CACHE(c, k, i); | ||
| 790 | } | ||
| 791 | |||
| 779 | /* Btree key macros */ | 792 | /* Btree key macros */ |
| 780 | 793 | ||
| 781 | static inline void bkey_init(struct bkey *k) | 794 | static inline void bkey_init(struct bkey *k) |
diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h index 1d3c24f9fa0e..ba02f055bc64 100644 --- a/drivers/md/bcache/bset.h +++ b/drivers/md/bcache/bset.h | |||
| @@ -142,6 +142,8 @@ | |||
| 142 | * first key in that range of bytes again. | 142 | * first key in that range of bytes again. |
| 143 | */ | 143 | */ |
| 144 | 144 | ||
| 145 | struct cache_set; | ||
| 146 | |||
| 145 | /* Btree key comparison/iteration */ | 147 | /* Btree key comparison/iteration */ |
| 146 | 148 | ||
| 147 | #define MAX_BSETS 4U | 149 | #define MAX_BSETS 4U |
| @@ -282,25 +284,6 @@ bool bch_extent_ptr_invalid(struct cache_set *, const struct bkey *); | |||
| 282 | 284 | ||
| 283 | bool bch_ptr_bad(struct btree *, const struct bkey *); | 285 | bool bch_ptr_bad(struct btree *, const struct bkey *); |
| 284 | 286 | ||
| 285 | static inline uint8_t gen_after(uint8_t a, uint8_t b) | ||
| 286 | { | ||
| 287 | uint8_t r = a - b; | ||
| 288 | return r > 128U ? 0 : r; | ||
| 289 | } | ||
| 290 | |||
| 291 | static inline uint8_t ptr_stale(struct cache_set *c, const struct bkey *k, | ||
| 292 | unsigned i) | ||
| 293 | { | ||
| 294 | return gen_after(PTR_BUCKET(c, k, i)->gen, PTR_GEN(k, i)); | ||
| 295 | } | ||
| 296 | |||
| 297 | static inline bool ptr_available(struct cache_set *c, const struct bkey *k, | ||
| 298 | unsigned i) | ||
| 299 | { | ||
| 300 | return (PTR_DEV(k, i) < MAX_CACHES_PER_SET) && PTR_CACHE(c, k, i); | ||
| 301 | } | ||
| 302 | |||
| 303 | |||
| 304 | typedef bool (*ptr_filter_fn)(struct btree *, const struct bkey *); | 287 | typedef bool (*ptr_filter_fn)(struct btree *, const struct bkey *); |
| 305 | 288 | ||
| 306 | struct bkey *bch_btree_iter_next(struct btree_iter *); | 289 | struct bkey *bch_btree_iter_next(struct btree_iter *); |
diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h index 1030c6020e98..3ebaef5f645b 100644 --- a/drivers/md/bcache/util.h +++ b/drivers/md/bcache/util.h | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | #ifndef _BCACHE_UTIL_H | 2 | #ifndef _BCACHE_UTIL_H |
| 3 | #define _BCACHE_UTIL_H | 3 | #define _BCACHE_UTIL_H |
| 4 | 4 | ||
| 5 | #include <linux/blkdev.h> | ||
| 5 | #include <linux/errno.h> | 6 | #include <linux/errno.h> |
| 6 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
| 7 | #include <linux/llist.h> | 8 | #include <linux/llist.h> |
| @@ -391,6 +392,11 @@ struct time_stats { | |||
| 391 | 392 | ||
| 392 | void bch_time_stats_update(struct time_stats *stats, uint64_t time); | 393 | void bch_time_stats_update(struct time_stats *stats, uint64_t time); |
| 393 | 394 | ||
| 395 | static inline unsigned local_clock_us(void) | ||
| 396 | { | ||
| 397 | return local_clock() >> 10; | ||
| 398 | } | ||
| 399 | |||
| 394 | #define NSEC_PER_ns 1L | 400 | #define NSEC_PER_ns 1L |
| 395 | #define NSEC_PER_us NSEC_PER_USEC | 401 | #define NSEC_PER_us NSEC_PER_USEC |
| 396 | #define NSEC_PER_ms NSEC_PER_MSEC | 402 | #define NSEC_PER_ms NSEC_PER_MSEC |
