diff options
Diffstat (limited to 'include/linux/bio.h')
-rw-r--r-- | include/linux/bio.h | 183 |
1 files changed, 4 insertions, 179 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h index f655b54c9ef3..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,184 +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 | * Request flags. For use in the cmd_flags field of struct request, and in | ||
142 | * bi_rw of struct bio. Note that some flags are only valid in either one. | ||
143 | */ | ||
144 | enum rq_flag_bits { | ||
145 | /* common flags */ | ||
146 | __REQ_WRITE, /* not set, read. set, write */ | ||
147 | __REQ_FAILFAST_DEV, /* no driver retries of device errors */ | ||
148 | __REQ_FAILFAST_TRANSPORT, /* no driver retries of transport errors */ | ||
149 | __REQ_FAILFAST_DRIVER, /* no driver retries of driver errors */ | ||
150 | |||
151 | __REQ_HARDBARRIER, /* may not be passed by drive either */ | ||
152 | __REQ_SYNC, /* request is sync (sync write or read) */ | ||
153 | __REQ_META, /* metadata io request */ | ||
154 | __REQ_DISCARD, /* request to discard sectors */ | ||
155 | __REQ_NOIDLE, /* don't anticipate more IO after this one */ | ||
156 | |||
157 | /* bio only flags */ | ||
158 | __REQ_UNPLUG, /* unplug the immediately after submission */ | ||
159 | __REQ_RAHEAD, /* read ahead, can fail anytime */ | ||
160 | |||
161 | /* request only flags */ | ||
162 | __REQ_SORTED, /* elevator knows about this request */ | ||
163 | __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ | ||
164 | __REQ_FUA, /* forced unit access */ | ||
165 | __REQ_NOMERGE, /* don't touch this for merging */ | ||
166 | __REQ_STARTED, /* drive already may have started this one */ | ||
167 | __REQ_DONTPREP, /* don't call prep for this one */ | ||
168 | __REQ_QUEUED, /* uses queueing */ | ||
169 | __REQ_ELVPRIV, /* elevator private data attached */ | ||
170 | __REQ_FAILED, /* set if the request failed */ | ||
171 | __REQ_QUIET, /* don't worry about errors */ | ||
172 | __REQ_PREEMPT, /* set for "ide_preempt" requests */ | ||
173 | __REQ_ORDERED_COLOR, /* is before or after barrier */ | ||
174 | __REQ_ALLOCED, /* request came from our alloc pool */ | ||
175 | __REQ_COPY_USER, /* contains copies of user pages */ | ||
176 | __REQ_INTEGRITY, /* integrity metadata has been remapped */ | ||
177 | __REQ_FLUSH, /* request for cache flush */ | ||
178 | __REQ_IO_STAT, /* account I/O stat */ | ||
179 | __REQ_MIXED_MERGE, /* merge of different types, fail separately */ | ||
180 | __REQ_NR_BITS, /* stops here */ | ||
181 | }; | ||
182 | |||
183 | #define REQ_WRITE (1 << __REQ_WRITE) | ||
184 | #define REQ_FAILFAST_DEV (1 << __REQ_FAILFAST_DEV) | ||
185 | #define REQ_FAILFAST_TRANSPORT (1 << __REQ_FAILFAST_TRANSPORT) | ||
186 | #define REQ_FAILFAST_DRIVER (1 << __REQ_FAILFAST_DRIVER) | ||
187 | #define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER) | ||
188 | #define REQ_SYNC (1 << __REQ_SYNC) | ||
189 | #define REQ_META (1 << __REQ_META) | ||
190 | #define REQ_DISCARD (1 << __REQ_DISCARD) | ||
191 | #define REQ_NOIDLE (1 << __REQ_NOIDLE) | ||
192 | |||
193 | #define REQ_FAILFAST_MASK \ | ||
194 | (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER) | ||
195 | #define REQ_COMMON_MASK \ | ||
196 | (REQ_WRITE | REQ_FAILFAST_MASK | REQ_HARDBARRIER | REQ_SYNC | \ | ||
197 | REQ_META| REQ_DISCARD | REQ_NOIDLE) | ||
198 | |||
199 | #define REQ_UNPLUG (1 << __REQ_UNPLUG) | ||
200 | #define REQ_RAHEAD (1 << __REQ_RAHEAD) | ||
201 | |||
202 | #define REQ_SORTED (1 << __REQ_SORTED) | ||
203 | #define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) | ||
204 | #define REQ_FUA (1 << __REQ_FUA) | ||
205 | #define REQ_NOMERGE (1 << __REQ_NOMERGE) | ||
206 | #define REQ_STARTED (1 << __REQ_STARTED) | ||
207 | #define REQ_DONTPREP (1 << __REQ_DONTPREP) | ||
208 | #define REQ_QUEUED (1 << __REQ_QUEUED) | ||
209 | #define REQ_ELVPRIV (1 << __REQ_ELVPRIV) | ||
210 | #define REQ_FAILED (1 << __REQ_FAILED) | ||
211 | #define REQ_QUIET (1 << __REQ_QUIET) | ||
212 | #define REQ_PREEMPT (1 << __REQ_PREEMPT) | ||
213 | #define REQ_ORDERED_COLOR (1 << __REQ_ORDERED_COLOR) | ||
214 | #define REQ_ALLOCED (1 << __REQ_ALLOCED) | ||
215 | #define REQ_COPY_USER (1 << __REQ_COPY_USER) | ||
216 | #define REQ_INTEGRITY (1 << __REQ_INTEGRITY) | ||
217 | #define REQ_FLUSH (1 << __REQ_FLUSH) | ||
218 | #define REQ_IO_STAT (1 << __REQ_IO_STAT) | ||
219 | #define REQ_MIXED_MERGE (1 << __REQ_MIXED_MERGE) | ||
220 | |||
221 | /* | ||
222 | * 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 |
223 | */ | 48 | */ |
224 | #define BIO_PRIO_SHIFT (8 * sizeof(unsigned long) - IOPRIO_BITS) | 49 | #define BIO_PRIO_SHIFT (8 * sizeof(unsigned long) - IOPRIO_BITS) |