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 enum bch_write_flags {
17 BCH_WRITE_ALLOC_NOWAIT = (1 << 0),
18 BCH_WRITE_DISCARD = (1 << 1),
19 BCH_WRITE_CACHED = (1 << 2),
20 BCH_WRITE_FLUSH = (1 << 3),
21 BCH_WRITE_DISCARD_ON_ERROR = (1 << 4),
22 BCH_WRITE_DATA_COMPRESSED = (1 << 5),
25 BCH_WRITE_JOURNAL_SEQ_PTR = (1 << 6),
26 BCH_WRITE_DONE = (1 << 7),
27 BCH_WRITE_LOOPED = (1 << 8),
30 static inline u64 *op_journal_seq(struct bch_write_op *op)
32 return (op->flags & BCH_WRITE_JOURNAL_SEQ_PTR)
33 ? op->journal_seq_p : &op->journal_seq;
36 static inline struct write_point *foreground_write_point(struct bch_fs *c,
39 return c->write_points +
40 hash_long(v, ilog2(ARRAY_SIZE(c->write_points)));
43 void bch2_write_op_init(struct bch_write_op *, struct bch_fs *,
44 struct bch_write_bio *,
45 struct disk_reservation, struct write_point *,
46 struct bpos, u64 *, unsigned);
47 void bch2_write(struct closure *);
49 struct cache_promote_op;
51 struct extent_pick_ptr;
53 void bch2_read_extent_iter(struct bch_fs *, struct bch_read_bio *,
54 struct bvec_iter, struct bkey_s_c k,
55 struct extent_pick_ptr *, unsigned);
57 static inline void bch2_read_extent(struct bch_fs *c,
58 struct bch_read_bio *orig,
60 struct extent_pick_ptr *pick,
63 bch2_read_extent_iter(c, orig, orig->bio.bi_iter,
68 BCH_READ_FORCE_BOUNCE = 1 << 0,
69 BCH_READ_RETRY_IF_STALE = 1 << 1,
70 BCH_READ_PROMOTE = 1 << 2,
71 BCH_READ_IS_LAST = 1 << 3,
72 BCH_READ_MAY_REUSE_BIO = 1 << 4,
73 BCH_READ_USER_MAPPED = 1 << 5,
76 void bch2_read(struct bch_fs *, struct bch_read_bio *, u64);
78 void bch2_submit_wbio_replicas(struct bch_write_bio *, struct bch_fs *,
79 const struct bkey_i *);
81 int bch2_discard(struct bch_fs *, struct bpos, struct bpos,
82 struct bversion, struct disk_reservation *,
83 struct extent_insert_hook *, u64 *);
85 void bch2_read_retry_work(struct work_struct *);
86 void bch2_wake_delayed_writes(unsigned long data);
88 #endif /* _BCACHE_IO_H */