4 #include <linux/hash.h>
7 #define to_wbio(_bio) \
8 container_of((_bio), struct bch_write_bio, bio)
10 #define to_rbio(_bio) \
11 container_of((_bio), struct bch_read_bio, bio)
13 void bch2_bio_free_pages_pool(struct bch_fs *, struct bio *);
14 void bch2_bio_alloc_pages_pool(struct bch_fs *, struct bio *, size_t);
16 void bch2_submit_wbio_replicas(struct bch_write_bio *, struct bch_fs *,
17 enum bch_data_type, const struct bkey_i *);
19 enum bch_write_flags {
20 BCH_WRITE_ALLOC_NOWAIT = (1 << 0),
21 BCH_WRITE_CACHED = (1 << 1),
22 BCH_WRITE_FLUSH = (1 << 2),
23 BCH_WRITE_DATA_COMPRESSED = (1 << 3),
24 BCH_WRITE_THROTTLE = (1 << 4),
27 BCH_WRITE_JOURNAL_SEQ_PTR = (1 << 5),
28 BCH_WRITE_DONE = (1 << 6),
29 BCH_WRITE_LOOPED = (1 << 7),
32 static inline u64 *op_journal_seq(struct bch_write_op *op)
34 return (op->flags & BCH_WRITE_JOURNAL_SEQ_PTR)
35 ? op->journal_seq_p : &op->journal_seq;
38 static inline struct write_point *foreground_write_point(struct bch_fs *c,
41 return c->write_points +
42 hash_long(v, ilog2(ARRAY_SIZE(c->write_points)));
45 void bch2_write_op_init(struct bch_write_op *, struct bch_fs *,
46 struct disk_reservation, struct write_point *,
47 struct bpos, u64 *, unsigned);
48 void bch2_write(struct closure *);
50 static inline struct bch_write_bio *wbio_init(struct bio *bio)
52 struct bch_write_bio *wbio = to_wbio(bio);
54 memset(wbio, 0, offsetof(struct bch_write_bio, bio));
58 void bch2_wake_delayed_writes(unsigned long data);
61 struct cache_promote_op;
62 struct extent_pick_ptr;
64 int __bch2_read_extent(struct bch_fs *, struct bch_read_bio *, struct bvec_iter,
65 struct bkey_s_c k, struct extent_pick_ptr *, unsigned);
66 void __bch2_read(struct bch_fs *, struct bch_read_bio *, struct bvec_iter,
67 u64, struct bch_devs_mask *, unsigned);
70 BCH_READ_RETRY_IF_STALE = 1 << 0,
71 BCH_READ_MAY_PROMOTE = 1 << 1,
72 BCH_READ_USER_MAPPED = 1 << 2,
75 BCH_READ_MUST_BOUNCE = 1 << 3,
76 BCH_READ_MUST_CLONE = 1 << 4,
77 BCH_READ_IN_RETRY = 1 << 5,
80 static inline void bch2_read_extent(struct bch_fs *c,
81 struct bch_read_bio *rbio,
83 struct extent_pick_ptr *pick,
87 __bch2_read_extent(c, rbio, rbio->bio.bi_iter, k, pick, flags);
90 static inline void bch2_read(struct bch_fs *c, struct bch_read_bio *rbio,
94 __bch2_read(c, rbio, rbio->bio.bi_iter, inode, NULL,
95 BCH_READ_RETRY_IF_STALE|
97 BCH_READ_USER_MAPPED);
100 static inline struct bch_read_bio *rbio_init(struct bio *bio)
102 struct bch_read_bio *rbio = to_rbio(bio);
108 #endif /* _BCACHEFS_IO_H */