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 bch_bio_free_pages_pool(struct cache_set *, struct bio *);
13 void bch_bio_alloc_pages_pool(struct cache_set *, 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 cache_set *c,
38 return c->write_points +
39 hash_long(v, ilog2(ARRAY_SIZE(c->write_points)));
42 void bch_write_op_init(struct bch_write_op *, struct cache_set *,
43 struct bch_write_bio *,
44 struct disk_reservation, struct write_point *,
45 struct bpos, u64 *, unsigned);
46 void bch_write(struct closure *);
48 struct cache_promote_op;
50 struct extent_pick_ptr;
52 void bch_read_extent_iter(struct cache_set *, struct bch_read_bio *,
53 struct bvec_iter, struct bkey_s_c k,
54 struct extent_pick_ptr *, unsigned);
56 static inline void bch_read_extent(struct cache_set *c,
57 struct bch_read_bio *orig,
59 struct extent_pick_ptr *pick,
62 bch_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,
74 void bch_read(struct cache_set *, struct bch_read_bio *, u64);
76 void bch_generic_make_request(struct bio *, struct cache_set *);
77 void bch_bio_submit_work(struct work_struct *);
78 void bch_submit_wbio_replicas(struct bch_write_bio *, struct cache_set *,
79 const struct bkey_i *, bool);
81 int bch_discard(struct cache_set *, struct bpos, struct bpos,
82 u64, struct disk_reservation *,
83 struct extent_insert_hook *, u64 *);
85 void bch_read_retry_work(struct work_struct *);
86 void bch_wake_delayed_writes(unsigned long data);
88 void bch_bio_decompress_work(struct work_struct *);
90 #endif /* _BCACHE_IO_H */