summaryrefslogtreecommitdiff
path: root/libbcachefs/alloc_background.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-01-05 19:39:57 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2022-01-05 19:39:57 -0500
commit47c554c31abd26a23906b43d756569e64ff60f8d (patch)
tree41e25ea13636c3218a39422b05eebf77a4d60553 /libbcachefs/alloc_background.h
parent931ed5a709c2afa239cbae2e13bc22f13e99713c (diff)
Update bcachefs sources to 5242db9aec bcachefs: Fix bch2_check_fix_ptrs()
Diffstat (limited to 'libbcachefs/alloc_background.h')
-rw-r--r--libbcachefs/alloc_background.h42
1 files changed, 30 insertions, 12 deletions
diff --git a/libbcachefs/alloc_background.h b/libbcachefs/alloc_background.h
index 98c7866e..86b64177 100644
--- a/libbcachefs/alloc_background.h
+++ b/libbcachefs/alloc_background.h
@@ -38,23 +38,40 @@ static inline bool bkey_alloc_unpacked_cmp(struct bkey_alloc_unpacked l,
;
}
-struct bkey_alloc_buf {
- struct bkey_i k;
- struct bch_alloc_v3 v;
-
-#define x(_name, _bits) + _bits / 8
- u8 _pad[0 + BCH_ALLOC_FIELDS_V2()];
-#undef x
-} __attribute__((packed, aligned(8)));
-
struct bkey_alloc_unpacked bch2_alloc_unpack(struct bkey_s_c);
-struct bkey_alloc_buf *bch2_alloc_pack(struct btree_trans *,
- const struct bkey_alloc_unpacked);
int bch2_alloc_write(struct btree_trans *, struct btree_iter *,
struct bkey_alloc_unpacked *, unsigned);
int bch2_bucket_io_time_reset(struct btree_trans *, unsigned, size_t, int);
+static inline struct bkey_alloc_unpacked
+alloc_mem_to_key(struct bch_fs *c, struct btree_iter *iter)
+{
+ struct bch_dev *ca;
+ struct bucket *g;
+ struct bkey_alloc_unpacked ret;
+
+ percpu_down_read(&c->mark_lock);
+ ca = bch_dev_bkey_exists(c, iter->pos.inode);
+ g = bucket(ca, iter->pos.offset);
+ ret = (struct bkey_alloc_unpacked) {
+ .dev = iter->pos.inode,
+ .bucket = iter->pos.offset,
+ .gen = g->mark.gen,
+ .oldest_gen = g->oldest_gen,
+ .data_type = g->mark.data_type,
+ .dirty_sectors = g->mark.dirty_sectors,
+ .cached_sectors = g->mark.cached_sectors,
+ .read_time = g->io_time[READ],
+ .write_time = g->io_time[WRITE],
+ .stripe = g->stripe,
+ .stripe_redundancy = g->stripe_redundancy,
+ };
+ percpu_up_read(&c->mark_lock);
+
+ return ret;
+}
+
#define ALLOC_SCAN_BATCH(ca) max_t(size_t, 1, (ca)->mi.nbuckets >> 9)
const char *bch2_alloc_v1_invalid(const struct bch_fs *, struct bkey_s_c);
@@ -84,7 +101,7 @@ static inline bool bkey_is_alloc(const struct bkey *k)
k->type == KEY_TYPE_alloc_v3;
}
-int bch2_alloc_read(struct bch_fs *, bool, bool);
+int bch2_alloc_read(struct bch_fs *);
static inline void bch2_wake_allocator(struct bch_dev *ca)
{
@@ -122,6 +139,7 @@ void bch2_dev_allocator_quiesce(struct bch_fs *, struct bch_dev *);
void bch2_dev_allocator_stop(struct bch_dev *);
int bch2_dev_allocator_start(struct bch_dev *);
+int bch2_alloc_write_all(struct bch_fs *, unsigned);
void bch2_fs_allocator_background_init(struct bch_fs *);
#endif /* _BCACHEFS_ALLOC_BACKGROUND_H */