6 #define to_wbio(_bio) \
7 container_of((_bio), struct bch_write_bio, bio)
9 #define to_rbio(_bio) \
10 container_of((_bio), struct bch_read_bio, bio)
12 void bch2_bio_free_pages_pool(struct bch_fs *, struct bio *);
13 void bch2_bio_alloc_pages_pool(struct bch_fs *, struct bio *, size_t);
15 enum bch_write_flags {
16 BCH_WRITE_ALLOC_NOWAIT = (1 << 0),
17 BCH_WRITE_DISCARD = (1 << 1),
18 BCH_WRITE_CACHED = (1 << 2),
19 BCH_WRITE_FLUSH = (1 << 3),
20 BCH_WRITE_DISCARD_ON_ERROR = (1 << 4),
21 BCH_WRITE_DATA_COMPRESSED = (1 << 5),
24 BCH_WRITE_JOURNAL_SEQ_PTR = (1 << 6),
25 BCH_WRITE_DONE = (1 << 7),
26 BCH_WRITE_LOOPED = (1 << 8),
29 static inline u64 *op_journal_seq(struct bch_write_op *op)
31 return (op->flags & BCH_WRITE_JOURNAL_SEQ_PTR)
32 ? op->journal_seq_p : &op->journal_seq;
35 static inline struct write_point *foreground_write_point(struct bch_fs *c,
38 return c->write_points +
39 hash_long(v, ilog2(ARRAY_SIZE(c->write_points)));
42 void bch2_write_op_init(struct bch_write_op *, struct bch_fs *,
43 struct bch_write_bio *,
44 struct disk_reservation, struct write_point *,
45 struct bpos, u64 *, unsigned);
46 void bch2_write(struct closure *);
48 struct cache_promote_op;
50 struct extent_pick_ptr;
52 void bch2_read_extent_iter(struct bch_fs *, struct bch_read_bio *,
53 struct bvec_iter, struct bkey_s_c k,
54 struct extent_pick_ptr *, unsigned);
56 static inline void bch2_read_extent(struct bch_fs *c,
57 struct bch_read_bio *orig,
59 struct extent_pick_ptr *pick,
62 bch2_read_extent_iter(c, orig, orig->bio.bi_iter,
67 BCH_READ_FORCE_BOUNCE = 1 << 0,
68 BCH_READ_RETRY_IF_STALE = 1 << 1,
69 BCH_READ_PROMOTE = 1 << 2,
70 BCH_READ_IS_LAST = 1 << 3,
71 BCH_READ_MAY_REUSE_BIO = 1 << 4,
72 BCH_READ_USER_MAPPED = 1 << 5,
75 void bch2_read(struct bch_fs *, struct bch_read_bio *, u64);
77 void bch2_submit_wbio_replicas(struct bch_write_bio *, struct bch_fs *,
78 const struct bkey_i *);
80 int bch2_discard(struct bch_fs *, struct bpos, struct bpos,
81 struct bversion, struct disk_reservation *,
82 struct extent_insert_hook *, u64 *);
84 void bch2_read_retry_work(struct work_struct *);
85 void bch2_wake_delayed_writes(unsigned long data);
87 #endif /* _BCACHE_IO_H */