]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/io_types.h
Update bcachefs sources to 400f275d46 bcachefs: Fix check_overlapping_extents()
[bcachefs-tools-debian] / libbcachefs / io_types.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_IO_TYPES_H
3 #define _BCACHEFS_IO_TYPES_H
4
5 #include "alloc_types.h"
6 #include "btree_types.h"
7 #include "buckets_types.h"
8 #include "extents_types.h"
9 #include "keylist_types.h"
10 #include "opts.h"
11 #include "super_types.h"
12
13 #include <linux/llist.h>
14 #include <linux/workqueue.h>
15
16 struct bch_read_bio {
17         struct bch_fs           *c;
18         u64                     start_time;
19         u64                     submit_time;
20
21         /*
22          * Reads will often have to be split, and if the extent being read from
23          * was checksummed or compressed we'll also have to allocate bounce
24          * buffers and copy the data back into the original bio.
25          *
26          * If we didn't have to split, we have to save and restore the original
27          * bi_end_io - @split below indicates which:
28          */
29         union {
30         struct bch_read_bio     *parent;
31         bio_end_io_t            *end_io;
32         };
33
34         /*
35          * Saved copy of bio->bi_iter, from submission time - allows us to
36          * resubmit on IO error, and also to copy data back to the original bio
37          * when we're bouncing:
38          */
39         struct bvec_iter        bvec_iter;
40
41         unsigned                offset_into_extent;
42
43         u16                     flags;
44         union {
45         struct {
46         u16                     bounce:1,
47                                 split:1,
48                                 kmalloc:1,
49                                 have_ioref:1,
50                                 narrow_crcs:1,
51                                 hole:1,
52                                 retry:2,
53                                 context:2;
54         };
55         u16                     _state;
56         };
57
58         struct bch_devs_list    devs_have;
59
60         struct extent_ptr_decoded pick;
61
62         /*
63          * pos we read from - different from data_pos for indirect extents:
64          */
65         u32                     subvol;
66         struct bpos             read_pos;
67
68         /*
69          * start pos of data we read (may not be pos of data we want) - for
70          * promote, narrow extents paths:
71          */
72         enum btree_id           data_btree;
73         struct bpos             data_pos;
74         struct bversion         version;
75
76         struct promote_op       *promote;
77
78         struct bch_io_opts      opts;
79
80         struct work_struct      work;
81
82         struct bio              bio;
83 };
84
85 struct bch_write_bio {
86         struct_group(wbio,
87         struct bch_fs           *c;
88         struct bch_write_bio    *parent;
89
90         u64                     submit_time;
91         u64                     inode_offset;
92
93         struct bch_devs_list    failed;
94         u8                      dev;
95
96         unsigned                split:1,
97                                 bounce:1,
98                                 put_bio:1,
99                                 have_ioref:1,
100                                 nocow:1,
101                                 used_mempool:1,
102                                 first_btree_write:1;
103         );
104
105         struct bio              bio;
106 };
107
108 struct bch_write_op {
109         struct closure          cl;
110         struct bch_fs           *c;
111         void                    (*end_io)(struct bch_write_op *);
112         u64                     start_time;
113
114         unsigned                written; /* sectors */
115         u16                     flags;
116         s16                     error; /* dio write path expects it to hold -ERESTARTSYS... */
117
118         unsigned                csum_type:4;
119         unsigned                compression_type:4;
120         unsigned                nr_replicas:4;
121         unsigned                nr_replicas_required:4;
122         unsigned                alloc_reserve:3;
123         unsigned                incompressible:1;
124         unsigned                stripe_waited:1;
125
126         struct bch_devs_list    devs_have;
127         u16                     target;
128         u16                     nonce;
129         struct bch_io_opts      opts;
130
131         u32                     subvol;
132         struct bpos             pos;
133         struct bversion         version;
134
135         /* For BCH_WRITE_DATA_ENCODED: */
136         struct bch_extent_crc_unpacked crc;
137
138         struct write_point_specifier write_point;
139
140         struct write_point      *wp;
141         struct list_head        wp_list;
142
143         struct disk_reservation res;
144
145         struct open_buckets     open_buckets;
146
147         u64                     new_i_size;
148         s64                     i_sectors_delta;
149
150         struct bch_devs_mask    failed;
151
152         struct keylist          insert_keys;
153         u64                     inline_keys[BKEY_EXTENT_U64s_MAX * 2];
154
155         /*
156          * Bitmask of devices that have had nocow writes issued to them since
157          * last flush:
158          */
159         struct bch_devs_mask    *devs_need_flush;
160
161         /* Must be last: */
162         struct bch_write_bio    wbio;
163 };
164
165 #endif /* _BCACHEFS_IO_TYPES_H */