diff options
Diffstat (limited to 'include/linux/bio.h')
-rw-r--r-- | include/linux/bio.h | 158 |
1 files changed, 8 insertions, 150 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h index 7fc5606e6ea5..5274103434ad 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
@@ -9,7 +9,7 @@ | |||
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 12 | * | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
@@ -28,6 +28,9 @@ | |||
28 | 28 | ||
29 | #include <asm/io.h> | 29 | #include <asm/io.h> |
30 | 30 | ||
31 | /* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */ | ||
32 | #include <linux/blk_types.h> | ||
33 | |||
31 | #define BIO_DEBUG | 34 | #define BIO_DEBUG |
32 | 35 | ||
33 | #ifdef BIO_DEBUG | 36 | #ifdef BIO_DEBUG |
@@ -41,154 +44,6 @@ | |||
41 | #define BIO_MAX_SECTORS (BIO_MAX_SIZE >> 9) | 44 | #define BIO_MAX_SECTORS (BIO_MAX_SIZE >> 9) |
42 | 45 | ||
43 | /* | 46 | /* |
44 | * was unsigned short, but we might as well be ready for > 64kB I/O pages | ||
45 | */ | ||
46 | struct bio_vec { | ||
47 | struct page *bv_page; | ||
48 | unsigned int bv_len; | ||
49 | unsigned int bv_offset; | ||
50 | }; | ||
51 | |||
52 | struct bio_set; | ||
53 | struct bio; | ||
54 | struct bio_integrity_payload; | ||
55 | typedef void (bio_end_io_t) (struct bio *, int); | ||
56 | typedef void (bio_destructor_t) (struct bio *); | ||
57 | |||
58 | /* | ||
59 | * main unit of I/O for the block layer and lower layers (ie drivers and | ||
60 | * stacking drivers) | ||
61 | */ | ||
62 | struct bio { | ||
63 | sector_t bi_sector; /* device address in 512 byte | ||
64 | sectors */ | ||
65 | struct bio *bi_next; /* request queue link */ | ||
66 | struct block_device *bi_bdev; | ||
67 | unsigned long bi_flags; /* status, command, etc */ | ||
68 | unsigned long bi_rw; /* bottom bits READ/WRITE, | ||
69 | * top bits priority | ||
70 | */ | ||
71 | |||
72 | unsigned short bi_vcnt; /* how many bio_vec's */ | ||
73 | unsigned short bi_idx; /* current index into bvl_vec */ | ||
74 | |||
75 | /* Number of segments in this BIO after | ||
76 | * physical address coalescing is performed. | ||
77 | */ | ||
78 | unsigned int bi_phys_segments; | ||
79 | |||
80 | unsigned int bi_size; /* residual I/O count */ | ||
81 | |||
82 | /* | ||
83 | * To keep track of the max segment size, we account for the | ||
84 | * sizes of the first and last mergeable segments in this bio. | ||
85 | */ | ||
86 | unsigned int bi_seg_front_size; | ||
87 | unsigned int bi_seg_back_size; | ||
88 | |||
89 | unsigned int bi_max_vecs; /* max bvl_vecs we can hold */ | ||
90 | |||
91 | unsigned int bi_comp_cpu; /* completion CPU */ | ||
92 | |||
93 | atomic_t bi_cnt; /* pin count */ | ||
94 | |||
95 | struct bio_vec *bi_io_vec; /* the actual vec list */ | ||
96 | |||
97 | bio_end_io_t *bi_end_io; | ||
98 | |||
99 | void *bi_private; | ||
100 | #if defined(CONFIG_BLK_DEV_INTEGRITY) | ||
101 | struct bio_integrity_payload *bi_integrity; /* data integrity */ | ||
102 | #endif | ||
103 | |||
104 | bio_destructor_t *bi_destructor; /* destructor */ | ||
105 | |||
106 | /* | ||
107 | * We can inline a number of vecs at the end of the bio, to avoid | ||
108 | * double allocations for a small number of bio_vecs. This member | ||
109 | * MUST obviously be kept at the very end of the bio. | ||
110 | */ | ||
111 | struct bio_vec bi_inline_vecs[0]; | ||
112 | }; | ||
113 | |||
114 | /* | ||
115 | * bio flags | ||
116 | */ | ||
117 | #define BIO_UPTODATE 0 /* ok after I/O completion */ | ||
118 | #define BIO_RW_BLOCK 1 /* RW_AHEAD set, and read/write would block */ | ||
119 | #define BIO_EOF 2 /* out-out-bounds error */ | ||
120 | #define BIO_SEG_VALID 3 /* bi_phys_segments valid */ | ||
121 | #define BIO_CLONED 4 /* doesn't own data */ | ||
122 | #define BIO_BOUNCED 5 /* bio is a bounce bio */ | ||
123 | #define BIO_USER_MAPPED 6 /* contains user pages */ | ||
124 | #define BIO_EOPNOTSUPP 7 /* not supported */ | ||
125 | #define BIO_CPU_AFFINE 8 /* complete bio on same CPU as submitted */ | ||
126 | #define BIO_NULL_MAPPED 9 /* contains invalid user pages */ | ||
127 | #define BIO_FS_INTEGRITY 10 /* fs owns integrity data, not block layer */ | ||
128 | #define BIO_QUIET 11 /* Make BIO Quiet */ | ||
129 | #define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) | ||
130 | |||
131 | /* | ||
132 | * top 4 bits of bio flags indicate the pool this bio came from | ||
133 | */ | ||
134 | #define BIO_POOL_BITS (4) | ||
135 | #define BIO_POOL_NONE ((1UL << BIO_POOL_BITS) - 1) | ||
136 | #define BIO_POOL_OFFSET (BITS_PER_LONG - BIO_POOL_BITS) | ||
137 | #define BIO_POOL_MASK (1UL << BIO_POOL_OFFSET) | ||
138 | #define BIO_POOL_IDX(bio) ((bio)->bi_flags >> BIO_POOL_OFFSET) | ||
139 | |||
140 | /* | ||
141 | * bio bi_rw flags | ||
142 | * | ||
143 | * bit 0 -- data direction | ||
144 | * If not set, bio is a read from device. If set, it's a write to device. | ||
145 | * bit 1 -- fail fast device errors | ||
146 | * bit 2 -- fail fast transport errors | ||
147 | * bit 3 -- fail fast driver errors | ||
148 | * bit 4 -- rw-ahead when set | ||
149 | * bit 5 -- barrier | ||
150 | * Insert a serialization point in the IO queue, forcing previously | ||
151 | * submitted IO to be completed before this one is issued. | ||
152 | * bit 6 -- synchronous I/O hint. | ||
153 | * bit 7 -- Unplug the device immediately after submitting this bio. | ||
154 | * bit 8 -- metadata request | ||
155 | * Used for tracing to differentiate metadata and data IO. May also | ||
156 | * get some preferential treatment in the IO scheduler | ||
157 | * bit 9 -- discard sectors | ||
158 | * Informs the lower level device that this range of sectors is no longer | ||
159 | * used by the file system and may thus be freed by the device. Used | ||
160 | * for flash based storage. | ||
161 | * Don't want driver retries for any fast fail whatever the reason. | ||
162 | * bit 10 -- Tell the IO scheduler not to wait for more requests after this | ||
163 | one has been submitted, even if it is a SYNC request. | ||
164 | */ | ||
165 | enum bio_rw_flags { | ||
166 | BIO_RW, | ||
167 | BIO_RW_FAILFAST_DEV, | ||
168 | BIO_RW_FAILFAST_TRANSPORT, | ||
169 | BIO_RW_FAILFAST_DRIVER, | ||
170 | /* above flags must match REQ_* */ | ||
171 | BIO_RW_AHEAD, | ||
172 | BIO_RW_BARRIER, | ||
173 | BIO_RW_SYNCIO, | ||
174 | BIO_RW_UNPLUG, | ||
175 | BIO_RW_META, | ||
176 | BIO_RW_DISCARD, | ||
177 | BIO_RW_NOIDLE, | ||
178 | }; | ||
179 | |||
180 | /* | ||
181 | * First four bits must match between bio->bi_rw and rq->cmd_flags, make | ||
182 | * that explicit here. | ||
183 | */ | ||
184 | #define BIO_RW_RQ_MASK 0xf | ||
185 | |||
186 | static inline bool bio_rw_flagged(struct bio *bio, enum bio_rw_flags flag) | ||
187 | { | ||
188 | return (bio->bi_rw & (1 << flag)) != 0; | ||
189 | } | ||
190 | |||
191 | /* | ||
192 | * upper 16 bits of bi_rw define the io priority of this bio | 47 | * upper 16 bits of bi_rw define the io priority of this bio |
193 | */ | 48 | */ |
194 | #define BIO_PRIO_SHIFT (8 * sizeof(unsigned long) - IOPRIO_BITS) | 49 | #define BIO_PRIO_SHIFT (8 * sizeof(unsigned long) - IOPRIO_BITS) |
@@ -211,7 +66,10 @@ static inline bool bio_rw_flagged(struct bio *bio, enum bio_rw_flags flag) | |||
211 | #define bio_offset(bio) bio_iovec((bio))->bv_offset | 66 | #define bio_offset(bio) bio_iovec((bio))->bv_offset |
212 | #define bio_segments(bio) ((bio)->bi_vcnt - (bio)->bi_idx) | 67 | #define bio_segments(bio) ((bio)->bi_vcnt - (bio)->bi_idx) |
213 | #define bio_sectors(bio) ((bio)->bi_size >> 9) | 68 | #define bio_sectors(bio) ((bio)->bi_size >> 9) |
214 | #define bio_empty_barrier(bio) (bio_rw_flagged(bio, BIO_RW_BARRIER) && !bio_has_data(bio) && !bio_rw_flagged(bio, BIO_RW_DISCARD)) | 69 | #define bio_empty_barrier(bio) \ |
70 | ((bio->bi_rw & REQ_HARDBARRIER) && \ | ||
71 | !bio_has_data(bio) && \ | ||
72 | !(bio->bi_rw & REQ_DISCARD)) | ||
215 | 73 | ||
216 | static inline unsigned int bio_cur_bytes(struct bio *bio) | 74 | static inline unsigned int bio_cur_bytes(struct bio *bio) |
217 | { | 75 | { |