diff options
Diffstat (limited to 'libbcache/alloc.h')
-rw-r--r-- | libbcache/alloc.h | 85 |
1 files changed, 28 insertions, 57 deletions
diff --git a/libbcache/alloc.h b/libbcache/alloc.h index aec9fc5f..f8aa762d 100644 --- a/libbcache/alloc.h +++ b/libbcache/alloc.h @@ -5,48 +5,46 @@ struct bkey; struct bucket; -struct cache; -struct cache_set; -struct cache_group; +struct bch_dev; +struct bch_fs; +struct dev_group; -static inline size_t prios_per_bucket(const struct cache *ca) +static inline size_t prios_per_bucket(const struct bch_dev *ca) { return (bucket_bytes(ca) - sizeof(struct prio_set)) / sizeof(struct bucket_disk); } -static inline size_t prio_buckets(const struct cache *ca) +static inline size_t prio_buckets(const struct bch_dev *ca) { return DIV_ROUND_UP((size_t) (ca)->mi.nbuckets, prios_per_bucket(ca)); } -void bch_dev_group_remove(struct cache_group *, struct cache *); -void bch_dev_group_add(struct cache_group *, struct cache *); +void bch_dev_group_remove(struct dev_group *, struct bch_dev *); +void bch_dev_group_add(struct dev_group *, struct bch_dev *); -int bch_prio_read(struct cache *); +int bch_prio_read(struct bch_dev *); -void bch_recalc_min_prio(struct cache *, int); +size_t bch_bucket_alloc(struct bch_dev *, enum alloc_reserve); -size_t bch_bucket_alloc(struct cache *, enum alloc_reserve); +void bch_open_bucket_put(struct bch_fs *, struct open_bucket *); -void bch_open_bucket_put(struct cache_set *, struct open_bucket *); - -struct open_bucket *bch_alloc_sectors_start(struct cache_set *, +struct open_bucket *bch_alloc_sectors_start(struct bch_fs *, struct write_point *, unsigned, unsigned, enum alloc_reserve, struct closure *); -void bch_alloc_sectors_append_ptrs(struct cache_set *, struct bkey_i_extent *, +void bch_alloc_sectors_append_ptrs(struct bch_fs *, struct bkey_i_extent *, unsigned, struct open_bucket *, unsigned); -void bch_alloc_sectors_done(struct cache_set *, struct write_point *, +void bch_alloc_sectors_done(struct bch_fs *, struct write_point *, struct open_bucket *); -struct open_bucket *bch_alloc_sectors(struct cache_set *, struct write_point *, +struct open_bucket *bch_alloc_sectors(struct bch_fs *, struct write_point *, struct bkey_i_extent *, unsigned, unsigned, enum alloc_reserve, struct closure *); -static inline void bch_wake_allocator(struct cache *ca) +static inline void bch_wake_allocator(struct bch_dev *ca) { struct task_struct *p; @@ -56,59 +54,32 @@ static inline void bch_wake_allocator(struct cache *ca) rcu_read_unlock(); } -static inline struct cache *cache_group_next_rcu(struct cache_group *devs, - unsigned *iter) +static inline struct bch_dev *dev_group_next(struct dev_group *devs, + unsigned *iter) { - struct cache *ret = NULL; + struct bch_dev *ret = NULL; while (*iter < devs->nr && - !(ret = rcu_dereference(devs->d[*iter].dev))) + !(ret = rcu_dereference_check(devs->d[*iter].dev, + lockdep_is_held(&devs->lock)))) (*iter)++; return ret; } -#define group_for_each_cache_rcu(ca, devs, iter) \ +#define group_for_each_dev(ca, devs, iter) \ for ((iter) = 0; \ - ((ca) = cache_group_next_rcu((devs), &(iter))); \ + ((ca) = dev_group_next((devs), &(iter))); \ (iter)++) -static inline struct cache *cache_group_next(struct cache_group *devs, - unsigned *iter) -{ - struct cache *ret; - - rcu_read_lock(); - if ((ret = cache_group_next_rcu(devs, iter))) - percpu_ref_get(&ret->ref); - rcu_read_unlock(); - - return ret; -} - -#define group_for_each_cache(ca, devs, iter) \ - for ((iter) = 0; \ - (ca = cache_group_next(devs, &(iter))); \ - percpu_ref_put(&ca->ref), (iter)++) - -#define __open_bucket_next_online_device(_c, _ob, _ptr, _ca) \ -({ \ - (_ca) = NULL; \ - \ - while ((_ptr) < (_ob)->ptrs + (_ob)->nr_ptrs && \ - !((_ca) = PTR_CACHE(_c, _ptr))) \ - (_ptr)++; \ - (_ca); \ -}) - -#define open_bucket_for_each_online_device(_c, _ob, _ptr, _ca) \ +#define open_bucket_for_each_ptr(_ob, _ptr) \ for ((_ptr) = (_ob)->ptrs; \ - ((_ca) = __open_bucket_next_online_device(_c, _ob, _ptr, _ca));\ + (_ptr) < (_ob)->ptrs + (_ob)->nr_ptrs; \ (_ptr)++) -void bch_recalc_capacity(struct cache_set *); -void bch_dev_allocator_stop(struct cache *); -int bch_dev_allocator_start(struct cache *); -void bch_fs_allocator_init(struct cache_set *); +void bch_recalc_capacity(struct bch_fs *); +void bch_dev_allocator_stop(struct bch_dev *); +int bch_dev_allocator_start(struct bch_dev *); +void bch_fs_allocator_init(struct bch_fs *); #endif /* _BCACHE_ALLOC_H */ |