]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/io_types.h
Update bcachefs sources to d7f6da1d60 bcachefs: fix missing include
[bcachefs-tools-debian] / libbcachefs / io_types.h
1 #ifndef _BCACHEFS_IO_TYPES_H
2 #define _BCACHEFS_IO_TYPES_H
3
4 #include "alloc_types.h"
5 #include "btree_types.h"
6 #include "buckets_types.h"
7 #include "extents_types.h"
8 #include "keylist_types.h"
9 #include "opts.h"
10 #include "super_types.h"
11
12 #include <linux/llist.h>
13 #include <linux/workqueue.h>
14
15 struct bch_read_bio {
16         struct bch_fs           *c;
17         u64                     start_time;
18         u64                     submit_time;
19
20         /*
21          * Reads will often have to be split, and if the extent being read from
22          * was checksummed or compressed we'll also have to allocate bounce
23          * buffers and copy the data back into the original bio.
24          *
25          * If we didn't have to split, we have to save and restore the original
26          * bi_end_io - @split below indicates which:
27          */
28         union {
29         struct bch_read_bio     *parent;
30         bio_end_io_t            *end_io;
31         };
32
33         /*
34          * Saved copy of bio->bi_iter, from submission time - allows us to
35          * resubmit on IO error, and also to copy data back to the original bio
36          * when we're bouncing:
37          */
38         struct bvec_iter        bvec_iter;
39
40         u16                     flags;
41         union {
42         struct {
43         u16                     bounce:1,
44                                 split:1,
45                                 kmalloc:1,
46                                 have_ioref:1,
47                                 narrow_crcs:1,
48                                 hole:1,
49                                 retry:2,
50                                 context:2;
51         };
52         u16                     _state;
53         };
54
55         struct bch_devs_list    devs_have;
56
57         struct extent_pick_ptr  pick;
58         /* start pos of data we read (may not be pos of data we want) */
59         struct bpos             pos;
60         struct bversion         version;
61
62         struct promote_op       *promote;
63
64         struct bch_io_opts      opts;
65
66         struct work_struct      work;
67
68         struct bio              bio;
69 };
70
71 struct bch_write_bio {
72         struct bch_fs           *c;
73         struct bch_write_bio    *parent;
74
75         u64                     submit_time;
76
77         struct bch_devs_list    failed;
78         u8                      order;
79         u8                      dev;
80
81         unsigned                split:1,
82                                 bounce:1,
83                                 put_bio:1,
84                                 have_ioref:1,
85                                 used_mempool:1;
86
87         struct bio              bio;
88 };
89
90 struct bch_write_op {
91         struct closure          cl;
92         struct bch_fs           *c;
93         struct workqueue_struct *io_wq;
94         u64                     start_time;
95
96         unsigned                written; /* sectors */
97         u16                     flags;
98         s16                     error; /* dio write path expects it to hold -ERESTARTSYS... */
99
100         unsigned                csum_type:4;
101         unsigned                compression_type:4;
102         unsigned                nr_replicas:4;
103         unsigned                nr_replicas_required:4;
104         unsigned                alloc_reserve:4;
105
106         struct bch_devs_list    devs_have;
107         u16                     target;
108         u16                     nonce;
109
110         struct bch_io_opts      opts;
111
112         struct bpos             pos;
113         struct bversion         version;
114
115         /* For BCH_WRITE_DATA_ENCODED: */
116         struct bch_extent_crc_unpacked crc;
117
118         struct write_point_specifier write_point;
119
120         struct disk_reservation res;
121
122         struct open_buckets     open_buckets;
123
124         /*
125          * If caller wants to flush but hasn't passed us a journal_seq ptr, we
126          * still need to stash the journal_seq somewhere:
127          */
128         union {
129                 u64                     *journal_seq_p;
130                 u64                     journal_seq;
131         };
132
133         int                     (*index_update_fn)(struct bch_write_op *);
134
135         struct bch_devs_mask    failed;
136
137         struct keylist          insert_keys;
138         u64                     inline_keys[BKEY_EXTENT_U64s_MAX * 2];
139
140         /* Must be last: */
141         struct bch_write_bio    wbio;
142 };
143
144 #endif /* _BCACHEFS_IO_TYPES_H */