2017-10-06 01:41:44 +03:00
|
|
|
#ifndef _BCACHEFS_ALLOC_H
|
|
|
|
#define _BCACHEFS_ALLOC_H
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2017-04-24 08:56:57 +03:00
|
|
|
#include "bcachefs.h"
|
2017-01-08 12:13:18 +03:00
|
|
|
#include "alloc_types.h"
|
|
|
|
|
|
|
|
struct bkey;
|
|
|
|
struct bucket;
|
2017-03-11 00:40:01 +03:00
|
|
|
struct bch_dev;
|
|
|
|
struct bch_fs;
|
|
|
|
struct dev_group;
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2017-10-06 01:41:44 +03:00
|
|
|
struct dev_alloc_list {
|
|
|
|
unsigned nr;
|
|
|
|
u8 devs[BCH_SB_MEMBERS_MAX];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct dev_alloc_list bch2_wp_alloc_list(struct bch_fs *,
|
|
|
|
struct write_point *,
|
|
|
|
struct bch_devs_mask *);
|
|
|
|
void bch2_wp_rescale(struct bch_fs *, struct bch_dev *,
|
|
|
|
struct write_point *);
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2017-05-08 13:28:15 +03:00
|
|
|
int bch2_alloc_read(struct bch_fs *, struct list_head *);
|
|
|
|
int bch2_alloc_replay_key(struct bch_fs *, struct bpos);
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2017-05-08 13:28:15 +03:00
|
|
|
long bch2_bucket_alloc(struct bch_fs *, struct bch_dev *, enum alloc_reserve);
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2017-03-20 02:56:34 +03:00
|
|
|
void bch2_open_bucket_put(struct bch_fs *, struct open_bucket *);
|
2017-03-01 13:45:15 +03:00
|
|
|
|
2017-03-20 02:56:34 +03:00
|
|
|
struct open_bucket *bch2_alloc_sectors_start(struct bch_fs *,
|
2017-01-08 12:13:18 +03:00
|
|
|
struct write_point *,
|
2017-03-09 20:27:30 +03:00
|
|
|
unsigned, unsigned,
|
|
|
|
enum alloc_reserve,
|
2017-01-08 12:13:18 +03:00
|
|
|
struct closure *);
|
|
|
|
|
2017-03-20 02:56:34 +03:00
|
|
|
void bch2_alloc_sectors_append_ptrs(struct bch_fs *, struct bkey_i_extent *,
|
2017-01-08 12:13:18 +03:00
|
|
|
unsigned, struct open_bucket *, unsigned);
|
2017-03-20 02:56:34 +03:00
|
|
|
void bch2_alloc_sectors_done(struct bch_fs *, struct write_point *,
|
2017-01-08 12:13:18 +03:00
|
|
|
struct open_bucket *);
|
|
|
|
|
2017-03-20 02:56:34 +03:00
|
|
|
struct open_bucket *bch2_alloc_sectors(struct bch_fs *, struct write_point *,
|
2017-03-09 20:27:30 +03:00
|
|
|
struct bkey_i_extent *, unsigned, unsigned,
|
2017-01-08 12:13:18 +03:00
|
|
|
enum alloc_reserve, struct closure *);
|
|
|
|
|
2017-03-20 02:56:34 +03:00
|
|
|
static inline void bch2_wake_allocator(struct bch_dev *ca)
|
2017-01-08 12:13:18 +03:00
|
|
|
{
|
|
|
|
struct task_struct *p;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
if ((p = ACCESS_ONCE(ca->alloc_thread)))
|
|
|
|
wake_up_process(p);
|
|
|
|
rcu_read_unlock();
|
|
|
|
}
|
|
|
|
|
2017-03-11 00:40:01 +03:00
|
|
|
#define open_bucket_for_each_ptr(_ob, _ptr) \
|
2017-01-08 12:13:18 +03:00
|
|
|
for ((_ptr) = (_ob)->ptrs; \
|
2017-03-11 00:40:01 +03:00
|
|
|
(_ptr) < (_ob)->ptrs + (_ob)->nr_ptrs; \
|
2017-01-08 12:13:18 +03:00
|
|
|
(_ptr)++)
|
|
|
|
|
2017-03-20 02:56:34 +03:00
|
|
|
void bch2_recalc_capacity(struct bch_fs *);
|
2017-05-08 13:28:15 +03:00
|
|
|
|
|
|
|
void bch2_dev_allocator_remove(struct bch_fs *, struct bch_dev *);
|
|
|
|
void bch2_dev_allocator_add(struct bch_fs *, struct bch_dev *);
|
|
|
|
|
2017-03-20 02:56:34 +03:00
|
|
|
void bch2_dev_allocator_stop(struct bch_dev *);
|
|
|
|
int bch2_dev_allocator_start(struct bch_dev *);
|
2017-05-08 13:28:15 +03:00
|
|
|
|
2017-03-20 02:56:34 +03:00
|
|
|
void bch2_fs_allocator_init(struct bch_fs *);
|
2017-01-08 12:13:18 +03:00
|
|
|
|
2017-05-08 13:28:15 +03:00
|
|
|
extern const struct bkey_ops bch2_bkey_alloc_ops;
|
|
|
|
|
2017-10-06 01:41:44 +03:00
|
|
|
#endif /* _BCACHEFS_ALLOC_H */
|