~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/bio.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/linux/bio.h (Version linux-6.12-rc7) and /include/linux/bio.h (Version linux-5.16.20)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*                                                  2 /*
  3  * Copyright (C) 2001 Jens Axboe <axboe@suse.d      3  * Copyright (C) 2001 Jens Axboe <axboe@suse.de>
  4  */                                                 4  */
  5 #ifndef __LINUX_BIO_H                               5 #ifndef __LINUX_BIO_H
  6 #define __LINUX_BIO_H                               6 #define __LINUX_BIO_H
  7                                                     7 
  8 #include <linux/mempool.h>                          8 #include <linux/mempool.h>
  9 /* struct bio, bio_vec and BIO_* flags are def      9 /* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */
 10 #include <linux/blk_types.h>                       10 #include <linux/blk_types.h>
 11 #include <linux/uio.h>                             11 #include <linux/uio.h>
 12                                                    12 
 13 #define BIO_MAX_VECS            256U               13 #define BIO_MAX_VECS            256U
 14                                                    14 
 15 struct queue_limits;                           << 
 16                                                << 
 17 static inline unsigned int bio_max_segs(unsign     15 static inline unsigned int bio_max_segs(unsigned int nr_segs)
 18 {                                                  16 {
 19         return min(nr_segs, BIO_MAX_VECS);         17         return min(nr_segs, BIO_MAX_VECS);
 20 }                                                  18 }
 21                                                    19 
 22 #define bio_prio(bio)                   (bio)-     20 #define bio_prio(bio)                   (bio)->bi_ioprio
 23 #define bio_set_prio(bio, prio)         ((bio)     21 #define bio_set_prio(bio, prio)         ((bio)->bi_ioprio = prio)
 24                                                    22 
 25 #define bio_iter_iovec(bio, iter)                  23 #define bio_iter_iovec(bio, iter)                               \
 26         bvec_iter_bvec((bio)->bi_io_vec, (iter     24         bvec_iter_bvec((bio)->bi_io_vec, (iter))
 27                                                    25 
 28 #define bio_iter_page(bio, iter)                   26 #define bio_iter_page(bio, iter)                                \
 29         bvec_iter_page((bio)->bi_io_vec, (iter     27         bvec_iter_page((bio)->bi_io_vec, (iter))
 30 #define bio_iter_len(bio, iter)                    28 #define bio_iter_len(bio, iter)                                 \
 31         bvec_iter_len((bio)->bi_io_vec, (iter)     29         bvec_iter_len((bio)->bi_io_vec, (iter))
 32 #define bio_iter_offset(bio, iter)                 30 #define bio_iter_offset(bio, iter)                              \
 33         bvec_iter_offset((bio)->bi_io_vec, (it     31         bvec_iter_offset((bio)->bi_io_vec, (iter))
 34                                                    32 
 35 #define bio_page(bio)           bio_iter_page(     33 #define bio_page(bio)           bio_iter_page((bio), (bio)->bi_iter)
 36 #define bio_offset(bio)         bio_iter_offse     34 #define bio_offset(bio)         bio_iter_offset((bio), (bio)->bi_iter)
 37 #define bio_iovec(bio)          bio_iter_iovec     35 #define bio_iovec(bio)          bio_iter_iovec((bio), (bio)->bi_iter)
 38                                                    36 
 39 #define bvec_iter_sectors(iter) ((iter).bi_siz     37 #define bvec_iter_sectors(iter) ((iter).bi_size >> 9)
 40 #define bvec_iter_end_sector(iter) ((iter).bi_     38 #define bvec_iter_end_sector(iter) ((iter).bi_sector + bvec_iter_sectors((iter)))
 41                                                    39 
 42 #define bio_sectors(bio)        bvec_iter_sect     40 #define bio_sectors(bio)        bvec_iter_sectors((bio)->bi_iter)
 43 #define bio_end_sector(bio)     bvec_iter_end_     41 #define bio_end_sector(bio)     bvec_iter_end_sector((bio)->bi_iter)
 44                                                    42 
 45 /*                                                 43 /*
 46  * Return the data direction, READ or WRITE.       44  * Return the data direction, READ or WRITE.
 47  */                                                45  */
 48 #define bio_data_dir(bio) \                        46 #define bio_data_dir(bio) \
 49         (op_is_write(bio_op(bio)) ? WRITE : RE     47         (op_is_write(bio_op(bio)) ? WRITE : READ)
 50                                                    48 
 51 /*                                                 49 /*
 52  * Check whether this bio carries any data or      50  * Check whether this bio carries any data or not. A NULL bio is allowed.
 53  */                                                51  */
 54 static inline bool bio_has_data(struct bio *bi     52 static inline bool bio_has_data(struct bio *bio)
 55 {                                                  53 {
 56         if (bio &&                                 54         if (bio &&
 57             bio->bi_iter.bi_size &&                55             bio->bi_iter.bi_size &&
 58             bio_op(bio) != REQ_OP_DISCARD &&       56             bio_op(bio) != REQ_OP_DISCARD &&
 59             bio_op(bio) != REQ_OP_SECURE_ERASE     57             bio_op(bio) != REQ_OP_SECURE_ERASE &&
 60             bio_op(bio) != REQ_OP_WRITE_ZEROES     58             bio_op(bio) != REQ_OP_WRITE_ZEROES)
 61                 return true;                       59                 return true;
 62                                                    60 
 63         return false;                              61         return false;
 64 }                                                  62 }
 65                                                    63 
 66 static inline bool bio_no_advance_iter(const s     64 static inline bool bio_no_advance_iter(const struct bio *bio)
 67 {                                                  65 {
 68         return bio_op(bio) == REQ_OP_DISCARD |     66         return bio_op(bio) == REQ_OP_DISCARD ||
 69                bio_op(bio) == REQ_OP_SECURE_ER     67                bio_op(bio) == REQ_OP_SECURE_ERASE ||
                                                   >>  68                bio_op(bio) == REQ_OP_WRITE_SAME ||
 70                bio_op(bio) == REQ_OP_WRITE_ZER     69                bio_op(bio) == REQ_OP_WRITE_ZEROES;
 71 }                                                  70 }
 72                                                    71 
 73 static inline void *bio_data(struct bio *bio)      72 static inline void *bio_data(struct bio *bio)
 74 {                                                  73 {
 75         if (bio_has_data(bio))                     74         if (bio_has_data(bio))
 76                 return page_address(bio_page(b     75                 return page_address(bio_page(bio)) + bio_offset(bio);
 77                                                    76 
 78         return NULL;                               77         return NULL;
 79 }                                                  78 }
 80                                                    79 
 81 static inline bool bio_next_segment(const stru     80 static inline bool bio_next_segment(const struct bio *bio,
 82                                     struct bve     81                                     struct bvec_iter_all *iter)
 83 {                                                  82 {
 84         if (iter->idx >= bio->bi_vcnt)             83         if (iter->idx >= bio->bi_vcnt)
 85                 return false;                      84                 return false;
 86                                                    85 
 87         bvec_advance(&bio->bi_io_vec[iter->idx     86         bvec_advance(&bio->bi_io_vec[iter->idx], iter);
 88         return true;                               87         return true;
 89 }                                                  88 }
 90                                                    89 
 91 /*                                                 90 /*
 92  * drivers should _never_ use the all version      91  * drivers should _never_ use the all version - the bio may have been split
 93  * before it got to the driver and the driver      92  * before it got to the driver and the driver won't own all of it
 94  */                                                93  */
 95 #define bio_for_each_segment_all(bvl, bio, ite     94 #define bio_for_each_segment_all(bvl, bio, iter) \
 96         for (bvl = bvec_init_iter_all(&iter);      95         for (bvl = bvec_init_iter_all(&iter); bio_next_segment((bio), &iter); )
 97                                                    96 
 98 static inline void bio_advance_iter(const stru     97 static inline void bio_advance_iter(const struct bio *bio,
 99                                     struct bve     98                                     struct bvec_iter *iter, unsigned int bytes)
100 {                                                  99 {
101         iter->bi_sector += bytes >> 9;            100         iter->bi_sector += bytes >> 9;
102                                                   101 
103         if (bio_no_advance_iter(bio))             102         if (bio_no_advance_iter(bio))
104                 iter->bi_size -= bytes;           103                 iter->bi_size -= bytes;
105         else                                      104         else
106                 bvec_iter_advance(bio->bi_io_v    105                 bvec_iter_advance(bio->bi_io_vec, iter, bytes);
107                 /* TODO: It is reasonable to c    106                 /* TODO: It is reasonable to complete bio with error here. */
108 }                                                 107 }
109                                                   108 
110 /* @bytes should be less or equal to bvec[i->b    109 /* @bytes should be less or equal to bvec[i->bi_idx].bv_len */
111 static inline void bio_advance_iter_single(con    110 static inline void bio_advance_iter_single(const struct bio *bio,
112                                            str    111                                            struct bvec_iter *iter,
113                                            uns    112                                            unsigned int bytes)
114 {                                                 113 {
115         iter->bi_sector += bytes >> 9;            114         iter->bi_sector += bytes >> 9;
116                                                   115 
117         if (bio_no_advance_iter(bio))             116         if (bio_no_advance_iter(bio))
118                 iter->bi_size -= bytes;           117                 iter->bi_size -= bytes;
119         else                                      118         else
120                 bvec_iter_advance_single(bio->    119                 bvec_iter_advance_single(bio->bi_io_vec, iter, bytes);
121 }                                                 120 }
122                                                   121 
123 void __bio_advance(struct bio *, unsigned byte    122 void __bio_advance(struct bio *, unsigned bytes);
124                                                   123 
125 /**                                               124 /**
126  * bio_advance - increment/complete a bio by s    125  * bio_advance - increment/complete a bio by some number of bytes
127  * @bio:        bio to advance                    126  * @bio:        bio to advance
128  * @nbytes:     number of bytes to complete    !! 127  * @bytes:      number of bytes to complete
129  *                                                128  *
130  * This updates bi_sector, bi_size and bi_idx;    129  * This updates bi_sector, bi_size and bi_idx; if the number of bytes to
131  * complete doesn't align with a bvec boundary    130  * complete doesn't align with a bvec boundary, then bv_len and bv_offset will
132  * be updated on the last bvec as well.           131  * be updated on the last bvec as well.
133  *                                                132  *
134  * @bio will then represent the remaining, unc    133  * @bio will then represent the remaining, uncompleted portion of the io.
135  */                                               134  */
136 static inline void bio_advance(struct bio *bio    135 static inline void bio_advance(struct bio *bio, unsigned int nbytes)
137 {                                                 136 {
138         if (nbytes == bio->bi_iter.bi_size) {     137         if (nbytes == bio->bi_iter.bi_size) {
139                 bio->bi_iter.bi_size = 0;         138                 bio->bi_iter.bi_size = 0;
140                 return;                           139                 return;
141         }                                         140         }
142         __bio_advance(bio, nbytes);               141         __bio_advance(bio, nbytes);
143 }                                                 142 }
144                                                   143 
145 #define __bio_for_each_segment(bvl, bio, iter,    144 #define __bio_for_each_segment(bvl, bio, iter, start)                   \
146         for (iter = (start);                      145         for (iter = (start);                                            \
147              (iter).bi_size &&                    146              (iter).bi_size &&                                          \
148                 ((bvl = bio_iter_iovec((bio),     147                 ((bvl = bio_iter_iovec((bio), (iter))), 1);             \
149              bio_advance_iter_single((bio), &(    148              bio_advance_iter_single((bio), &(iter), (bvl).bv_len))
150                                                   149 
151 #define bio_for_each_segment(bvl, bio, iter)      150 #define bio_for_each_segment(bvl, bio, iter)                            \
152         __bio_for_each_segment(bvl, bio, iter,    151         __bio_for_each_segment(bvl, bio, iter, (bio)->bi_iter)
153                                                   152 
154 #define __bio_for_each_bvec(bvl, bio, iter, st    153 #define __bio_for_each_bvec(bvl, bio, iter, start)              \
155         for (iter = (start);                      154         for (iter = (start);                                            \
156              (iter).bi_size &&                    155              (iter).bi_size &&                                          \
157                 ((bvl = mp_bvec_iter_bvec((bio    156                 ((bvl = mp_bvec_iter_bvec((bio)->bi_io_vec, (iter))), 1); \
158              bio_advance_iter_single((bio), &(    157              bio_advance_iter_single((bio), &(iter), (bvl).bv_len))
159                                                   158 
160 /* iterate over multi-page bvec */                159 /* iterate over multi-page bvec */
161 #define bio_for_each_bvec(bvl, bio, iter)         160 #define bio_for_each_bvec(bvl, bio, iter)                       \
162         __bio_for_each_bvec(bvl, bio, iter, (b    161         __bio_for_each_bvec(bvl, bio, iter, (bio)->bi_iter)
163                                                   162 
164 /*                                                163 /*
165  * Iterate over all multi-page bvecs. Drivers     164  * Iterate over all multi-page bvecs. Drivers shouldn't use this version for the
166  * same reasons as bio_for_each_segment_all().    165  * same reasons as bio_for_each_segment_all().
167  */                                               166  */
168 #define bio_for_each_bvec_all(bvl, bio, i)        167 #define bio_for_each_bvec_all(bvl, bio, i)              \
169         for (i = 0, bvl = bio_first_bvec_all(b    168         for (i = 0, bvl = bio_first_bvec_all(bio);      \
170              i < (bio)->bi_vcnt; i++, bvl++)   !! 169              i < (bio)->bi_vcnt; i++, bvl++)            \
171                                                   170 
172 #define bio_iter_last(bvec, iter) ((iter).bi_s    171 #define bio_iter_last(bvec, iter) ((iter).bi_size == (bvec).bv_len)
173                                                   172 
174 static inline unsigned bio_segments(struct bio    173 static inline unsigned bio_segments(struct bio *bio)
175 {                                                 174 {
176         unsigned segs = 0;                        175         unsigned segs = 0;
177         struct bio_vec bv;                        176         struct bio_vec bv;
178         struct bvec_iter iter;                    177         struct bvec_iter iter;
179                                                   178 
180         /*                                        179         /*
181          * We special case discard/write same/    180          * We special case discard/write same/write zeroes, because they
182          * interpret bi_size differently:         181          * interpret bi_size differently:
183          */                                       182          */
184                                                   183 
185         switch (bio_op(bio)) {                    184         switch (bio_op(bio)) {
186         case REQ_OP_DISCARD:                      185         case REQ_OP_DISCARD:
187         case REQ_OP_SECURE_ERASE:                 186         case REQ_OP_SECURE_ERASE:
188         case REQ_OP_WRITE_ZEROES:                 187         case REQ_OP_WRITE_ZEROES:
189                 return 0;                         188                 return 0;
                                                   >> 189         case REQ_OP_WRITE_SAME:
                                                   >> 190                 return 1;
190         default:                                  191         default:
191                 break;                            192                 break;
192         }                                         193         }
193                                                   194 
194         bio_for_each_segment(bv, bio, iter)       195         bio_for_each_segment(bv, bio, iter)
195                 segs++;                           196                 segs++;
196                                                   197 
197         return segs;                              198         return segs;
198 }                                                 199 }
199                                                   200 
200 /*                                                201 /*
201  * get a reference to a bio, so it won't disap    202  * get a reference to a bio, so it won't disappear. the intended use is
202  * something like:                                203  * something like:
203  *                                                204  *
204  * bio_get(bio);                                  205  * bio_get(bio);
205  * submit_bio(rw, bio);                           206  * submit_bio(rw, bio);
206  * if (bio->bi_flags ...)                         207  * if (bio->bi_flags ...)
207  *      do_something                              208  *      do_something
208  * bio_put(bio);                                  209  * bio_put(bio);
209  *                                                210  *
210  * without the bio_get(), it could potentially    211  * without the bio_get(), it could potentially complete I/O before submit_bio
211  * returns. and then bio would be freed memory    212  * returns. and then bio would be freed memory when if (bio->bi_flags ...)
212  * runs                                           213  * runs
213  */                                               214  */
214 static inline void bio_get(struct bio *bio)       215 static inline void bio_get(struct bio *bio)
215 {                                                 216 {
216         bio->bi_flags |= (1 << BIO_REFFED);       217         bio->bi_flags |= (1 << BIO_REFFED);
217         smp_mb__before_atomic();                  218         smp_mb__before_atomic();
218         atomic_inc(&bio->__bi_cnt);               219         atomic_inc(&bio->__bi_cnt);
219 }                                                 220 }
220                                                   221 
221 static inline void bio_cnt_set(struct bio *bio    222 static inline void bio_cnt_set(struct bio *bio, unsigned int count)
222 {                                                 223 {
223         if (count != 1) {                         224         if (count != 1) {
224                 bio->bi_flags |= (1 << BIO_REF    225                 bio->bi_flags |= (1 << BIO_REFFED);
225                 smp_mb();                         226                 smp_mb();
226         }                                         227         }
227         atomic_set(&bio->__bi_cnt, count);        228         atomic_set(&bio->__bi_cnt, count);
228 }                                                 229 }
229                                                   230 
230 static inline bool bio_flagged(struct bio *bio    231 static inline bool bio_flagged(struct bio *bio, unsigned int bit)
231 {                                                 232 {
232         return bio->bi_flags & (1U << bit);    !! 233         return (bio->bi_flags & (1U << bit)) != 0;
233 }                                                 234 }
234                                                   235 
235 static inline void bio_set_flag(struct bio *bi    236 static inline void bio_set_flag(struct bio *bio, unsigned int bit)
236 {                                                 237 {
237         bio->bi_flags |= (1U << bit);             238         bio->bi_flags |= (1U << bit);
238 }                                                 239 }
239                                                   240 
240 static inline void bio_clear_flag(struct bio *    241 static inline void bio_clear_flag(struct bio *bio, unsigned int bit)
241 {                                                 242 {
242         bio->bi_flags &= ~(1U << bit);            243         bio->bi_flags &= ~(1U << bit);
243 }                                                 244 }
244                                                   245 
245 static inline struct bio_vec *bio_first_bvec_a    246 static inline struct bio_vec *bio_first_bvec_all(struct bio *bio)
246 {                                                 247 {
247         WARN_ON_ONCE(bio_flagged(bio, BIO_CLON    248         WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED));
248         return bio->bi_io_vec;                    249         return bio->bi_io_vec;
249 }                                                 250 }
250                                                   251 
251 static inline struct page *bio_first_page_all(    252 static inline struct page *bio_first_page_all(struct bio *bio)
252 {                                                 253 {
253         return bio_first_bvec_all(bio)->bv_pag    254         return bio_first_bvec_all(bio)->bv_page;
254 }                                                 255 }
255                                                   256 
256 static inline struct folio *bio_first_folio_al << 
257 {                                              << 
258         return page_folio(bio_first_page_all(b << 
259 }                                              << 
260                                                << 
261 static inline struct bio_vec *bio_last_bvec_al    257 static inline struct bio_vec *bio_last_bvec_all(struct bio *bio)
262 {                                                 258 {
263         WARN_ON_ONCE(bio_flagged(bio, BIO_CLON    259         WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED));
264         return &bio->bi_io_vec[bio->bi_vcnt -     260         return &bio->bi_io_vec[bio->bi_vcnt - 1];
265 }                                                 261 }
266                                                   262 
267 /**                                            !! 263 enum bip_flags {
268  * struct folio_iter - State for iterating all !! 264         BIP_BLOCK_INTEGRITY     = 1 << 0, /* block layer owns integrity data */
269  * @folio: The current folio we're iterating.  !! 265         BIP_MAPPED_INTEGRITY    = 1 << 1, /* ref tag has been remapped */
270  * @offset: The byte offset within the current !! 266         BIP_CTRL_NOCHECK        = 1 << 2, /* disable HBA integrity checking */
271  * @length: The number of bytes in this iterat !! 267         BIP_DISK_NOCHECK        = 1 << 3, /* disable disk integrity checking */
272  *      boundary).                             !! 268         BIP_IP_CHECKSUM         = 1 << 4, /* IP checksum */
273  */                                            << 
274 struct folio_iter {                            << 
275         struct folio *folio;                   << 
276         size_t offset;                         << 
277         size_t length;                         << 
278         /* private: for use by the iterator */ << 
279         struct folio *_next;                   << 
280         size_t _seg_count;                     << 
281         int _i;                                << 
282 };                                                269 };
283                                                   270 
284 static inline void bio_first_folio(struct foli !! 271 /*
285                                    int i)      !! 272  * bio integrity payload
                                                   >> 273  */
                                                   >> 274 struct bio_integrity_payload {
                                                   >> 275         struct bio              *bip_bio;       /* parent bio */
                                                   >> 276 
                                                   >> 277         struct bvec_iter        bip_iter;
                                                   >> 278 
                                                   >> 279         unsigned short          bip_vcnt;       /* # of integrity bio_vecs */
                                                   >> 280         unsigned short          bip_max_vcnt;   /* integrity bio_vec slots */
                                                   >> 281         unsigned short          bip_flags;      /* control flags */
                                                   >> 282 
                                                   >> 283         struct bvec_iter        bio_iter;       /* for rewinding parent bio */
                                                   >> 284 
                                                   >> 285         struct work_struct      bip_work;       /* I/O completion */
                                                   >> 286 
                                                   >> 287         struct bio_vec          *bip_vec;
                                                   >> 288         struct bio_vec          bip_inline_vecs[];/* embedded bvec array */
                                                   >> 289 };
                                                   >> 290 
                                                   >> 291 #if defined(CONFIG_BLK_DEV_INTEGRITY)
                                                   >> 292 
                                                   >> 293 static inline struct bio_integrity_payload *bio_integrity(struct bio *bio)
286 {                                                 294 {
287         struct bio_vec *bvec = bio_first_bvec_ !! 295         if (bio->bi_opf & REQ_INTEGRITY)
                                                   >> 296                 return bio->bi_integrity;
288                                                   297 
289         if (unlikely(i >= bio->bi_vcnt)) {     !! 298         return NULL;
290                 fi->folio = NULL;              !! 299 }
291                 return;                        << 
292         }                                      << 
293                                                   300 
294         fi->folio = page_folio(bvec->bv_page); !! 301 static inline bool bio_integrity_flagged(struct bio *bio, enum bip_flags flag)
295         fi->offset = bvec->bv_offset +         !! 302 {
296                         PAGE_SIZE * (bvec->bv_ !! 303         struct bio_integrity_payload *bip = bio_integrity(bio);
297         fi->_seg_count = bvec->bv_len;         !! 304 
298         fi->length = min(folio_size(fi->folio) !! 305         if (bip)
299         fi->_next = folio_next(fi->folio);     !! 306                 return bip->bip_flags & flag;
300         fi->_i = i;                            !! 307 
301 }                                              !! 308         return false;
302                                                << 
303 static inline void bio_next_folio(struct folio << 
304 {                                              << 
305         fi->_seg_count -= fi->length;          << 
306         if (fi->_seg_count) {                  << 
307                 fi->folio = fi->_next;         << 
308                 fi->offset = 0;                << 
309                 fi->length = min(folio_size(fi << 
310                 fi->_next = folio_next(fi->fol << 
311         } else {                               << 
312                 bio_first_folio(fi, bio, fi->_ << 
313         }                                      << 
314 }                                                 309 }
315                                                   310 
316 /**                                            !! 311 static inline sector_t bip_get_seed(struct bio_integrity_payload *bip)
317  * bio_for_each_folio_all - Iterate over each  !! 312 {
318  * @fi: struct folio_iter which is updated for !! 313         return bip->bip_iter.bi_sector;
319  * @bio: struct bio to iterate over.           !! 314 }
320  */                                            !! 315 
321 #define bio_for_each_folio_all(fi, bio)        !! 316 static inline void bip_set_seed(struct bio_integrity_payload *bip,
322         for (bio_first_folio(&fi, bio, 0); fi. !! 317                                 sector_t seed)
                                                   >> 318 {
                                                   >> 319         bip->bip_iter.bi_sector = seed;
                                                   >> 320 }
                                                   >> 321 
                                                   >> 322 #endif /* CONFIG_BLK_DEV_INTEGRITY */
323                                                   323 
324 void bio_trim(struct bio *bio, sector_t offset    324 void bio_trim(struct bio *bio, sector_t offset, sector_t size);
325 extern struct bio *bio_split(struct bio *bio,     325 extern struct bio *bio_split(struct bio *bio, int sectors,
326                              gfp_t gfp, struct    326                              gfp_t gfp, struct bio_set *bs);
327 int bio_split_rw_at(struct bio *bio, const str << 
328                 unsigned *segs, unsigned max_b << 
329                                                   327 
330 /**                                               328 /**
331  * bio_next_split - get next @sectors from a b    329  * bio_next_split - get next @sectors from a bio, splitting if necessary
332  * @bio:        bio to split                      330  * @bio:        bio to split
333  * @sectors:    number of sectors to split fro    331  * @sectors:    number of sectors to split from the front of @bio
334  * @gfp:        gfp mask                          332  * @gfp:        gfp mask
335  * @bs:         bio set to allocate from          333  * @bs:         bio set to allocate from
336  *                                                334  *
337  * Return: a bio representing the next @sector !! 335  * Returns a bio representing the next @sectors of @bio - if the bio is smaller
338  * than @sectors, returns the original bio unc    336  * than @sectors, returns the original bio unchanged.
339  */                                               337  */
340 static inline struct bio *bio_next_split(struc    338 static inline struct bio *bio_next_split(struct bio *bio, int sectors,
341                                          gfp_t    339                                          gfp_t gfp, struct bio_set *bs)
342 {                                                 340 {
343         if (sectors >= bio_sectors(bio))          341         if (sectors >= bio_sectors(bio))
344                 return bio;                       342                 return bio;
345                                                   343 
346         return bio_split(bio, sectors, gfp, bs    344         return bio_split(bio, sectors, gfp, bs);
347 }                                                 345 }
348                                                   346 
349 enum {                                            347 enum {
350         BIOSET_NEED_BVECS = BIT(0),               348         BIOSET_NEED_BVECS = BIT(0),
351         BIOSET_NEED_RESCUER = BIT(1),             349         BIOSET_NEED_RESCUER = BIT(1),
352         BIOSET_PERCPU_CACHE = BIT(2),             350         BIOSET_PERCPU_CACHE = BIT(2),
353 };                                                351 };
354 extern int bioset_init(struct bio_set *, unsig    352 extern int bioset_init(struct bio_set *, unsigned int, unsigned int, int flags);
355 extern void bioset_exit(struct bio_set *);        353 extern void bioset_exit(struct bio_set *);
356 extern int biovec_init_pool(mempool_t *pool, i    354 extern int biovec_init_pool(mempool_t *pool, int pool_entries);
                                                   >> 355 extern int bioset_init_from_src(struct bio_set *bs, struct bio_set *src);
357                                                   356 
358 struct bio *bio_alloc_bioset(struct block_devi !! 357 struct bio *bio_alloc_bioset(gfp_t gfp, unsigned short nr_iovecs,
359                              blk_opf_t opf, gf !! 358                 struct bio_set *bs);
360                              struct bio_set *b !! 359 struct bio *bio_alloc_kiocb(struct kiocb *kiocb, unsigned short nr_vecs,
361 struct bio *bio_kmalloc(unsigned short nr_vecs !! 360                 struct bio_set *bs);
                                                   >> 361 struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned short nr_iovecs);
362 extern void bio_put(struct bio *);                362 extern void bio_put(struct bio *);
363                                                   363 
364 struct bio *bio_alloc_clone(struct block_devic !! 364 extern void __bio_clone_fast(struct bio *, struct bio *);
365                 gfp_t gfp, struct bio_set *bs) !! 365 extern struct bio *bio_clone_fast(struct bio *, gfp_t, struct bio_set *);
366 int bio_init_clone(struct block_device *bdev,  << 
367                 struct bio *bio_src, gfp_t gfp << 
368                                                   366 
369 extern struct bio_set fs_bio_set;                 367 extern struct bio_set fs_bio_set;
370                                                   368 
371 static inline struct bio *bio_alloc(struct blo !! 369 static inline struct bio *bio_alloc(gfp_t gfp_mask, unsigned short nr_iovecs)
372                 unsigned short nr_vecs, blk_op << 
373 {                                                 370 {
374         return bio_alloc_bioset(bdev, nr_vecs, !! 371         return bio_alloc_bioset(gfp_mask, nr_iovecs, &fs_bio_set);
375 }                                                 372 }
376                                                   373 
377 void submit_bio(struct bio *bio);                 374 void submit_bio(struct bio *bio);
378                                                   375 
379 extern void bio_endio(struct bio *);              376 extern void bio_endio(struct bio *);
380                                                   377 
381 static inline void bio_io_error(struct bio *bi    378 static inline void bio_io_error(struct bio *bio)
382 {                                                 379 {
383         bio->bi_status = BLK_STS_IOERR;           380         bio->bi_status = BLK_STS_IOERR;
384         bio_endio(bio);                           381         bio_endio(bio);
385 }                                                 382 }
386                                                   383 
387 static inline void bio_wouldblock_error(struct    384 static inline void bio_wouldblock_error(struct bio *bio)
388 {                                                 385 {
389         bio_set_flag(bio, BIO_QUIET);             386         bio_set_flag(bio, BIO_QUIET);
390         bio->bi_status = BLK_STS_AGAIN;           387         bio->bi_status = BLK_STS_AGAIN;
391         bio_endio(bio);                           388         bio_endio(bio);
392 }                                                 389 }
393                                                   390 
394 /*                                                391 /*
395  * Calculate number of bvec segments that shou    392  * Calculate number of bvec segments that should be allocated to fit data
396  * pointed by @iter. If @iter is backed by bve    393  * pointed by @iter. If @iter is backed by bvec it's going to be reused
397  * instead of allocating a new one.               394  * instead of allocating a new one.
398  */                                               395  */
399 static inline int bio_iov_vecs_to_alloc(struct    396 static inline int bio_iov_vecs_to_alloc(struct iov_iter *iter, int max_segs)
400 {                                                 397 {
401         if (iov_iter_is_bvec(iter))               398         if (iov_iter_is_bvec(iter))
402                 return 0;                         399                 return 0;
403         return iov_iter_npages(iter, max_segs)    400         return iov_iter_npages(iter, max_segs);
404 }                                                 401 }
405                                                   402 
406 struct request_queue;                             403 struct request_queue;
407                                                   404 
408 extern int submit_bio_wait(struct bio *bio);      405 extern int submit_bio_wait(struct bio *bio);
409 void bio_init(struct bio *bio, struct block_de !! 406 extern void bio_init(struct bio *bio, struct bio_vec *table,
410               unsigned short max_vecs, blk_opf !! 407                      unsigned short max_vecs);
411 extern void bio_uninit(struct bio *);             408 extern void bio_uninit(struct bio *);
412 void bio_reset(struct bio *bio, struct block_d !! 409 extern void bio_reset(struct bio *);
413 void bio_chain(struct bio *, struct bio *);       410 void bio_chain(struct bio *, struct bio *);
414                                                   411 
415 int __must_check bio_add_page(struct bio *bio, !! 412 extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int);
416                               unsigned off);   << 
417 bool __must_check bio_add_folio(struct bio *bi << 
418                                 size_t len, si << 
419 extern int bio_add_pc_page(struct request_queu    413 extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *,
420                            unsigned int, unsig    414                            unsigned int, unsigned int);
421 int bio_add_zone_append_page(struct bio *bio,     415 int bio_add_zone_append_page(struct bio *bio, struct page *page,
422                              unsigned int len,    416                              unsigned int len, unsigned int offset);
423 void __bio_add_page(struct bio *bio, struct pa    417 void __bio_add_page(struct bio *bio, struct page *page,
424                 unsigned int len, unsigned int    418                 unsigned int len, unsigned int off);
425 void bio_add_folio_nofail(struct bio *bio, str << 
426                           size_t off);         << 
427 int bio_iov_iter_get_pages(struct bio *bio, st    419 int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter);
428 void bio_iov_bvec_set(struct bio *bio, struct     420 void bio_iov_bvec_set(struct bio *bio, struct iov_iter *iter);
429 void __bio_release_pages(struct bio *bio, bool    421 void __bio_release_pages(struct bio *bio, bool mark_dirty);
430 extern void bio_set_pages_dirty(struct bio *bi    422 extern void bio_set_pages_dirty(struct bio *bio);
431 extern void bio_check_pages_dirty(struct bio *    423 extern void bio_check_pages_dirty(struct bio *bio);
432                                                   424 
433 extern void bio_copy_data_iter(struct bio *dst    425 extern void bio_copy_data_iter(struct bio *dst, struct bvec_iter *dst_iter,
434                                struct bio *src    426                                struct bio *src, struct bvec_iter *src_iter);
435 extern void bio_copy_data(struct bio *dst, str    427 extern void bio_copy_data(struct bio *dst, struct bio *src);
436 extern void bio_free_pages(struct bio *bio);      428 extern void bio_free_pages(struct bio *bio);
437 void guard_bio_eod(struct bio *bio);              429 void guard_bio_eod(struct bio *bio);
438 void zero_fill_bio_iter(struct bio *bio, struc !! 430 void zero_fill_bio(struct bio *bio);
439                                                << 
440 static inline void zero_fill_bio(struct bio *b << 
441 {                                              << 
442         zero_fill_bio_iter(bio, bio->bi_iter); << 
443 }                                              << 
444                                                   431 
445 static inline void bio_release_pages(struct bi    432 static inline void bio_release_pages(struct bio *bio, bool mark_dirty)
446 {                                                 433 {
447         if (bio_flagged(bio, BIO_PAGE_PINNED)) !! 434         if (!bio_flagged(bio, BIO_NO_PAGE_REF))
448                 __bio_release_pages(bio, mark_    435                 __bio_release_pages(bio, mark_dirty);
449 }                                                 436 }
450                                                   437 
                                                   >> 438 extern const char *bio_devname(struct bio *bio, char *buffer);
                                                   >> 439 
451 #define bio_dev(bio) \                            440 #define bio_dev(bio) \
452         disk_devt((bio)->bi_bdev->bd_disk)        441         disk_devt((bio)->bi_bdev->bd_disk)
453                                                   442 
454 #ifdef CONFIG_BLK_CGROUP                          443 #ifdef CONFIG_BLK_CGROUP
455 void bio_associate_blkg(struct bio *bio);         444 void bio_associate_blkg(struct bio *bio);
456 void bio_associate_blkg_from_css(struct bio *b    445 void bio_associate_blkg_from_css(struct bio *bio,
457                                  struct cgroup    446                                  struct cgroup_subsys_state *css);
458 void bio_clone_blkg_association(struct bio *ds    447 void bio_clone_blkg_association(struct bio *dst, struct bio *src);
459 void blkcg_punt_bio_submit(struct bio *bio);   << 
460 #else   /* CONFIG_BLK_CGROUP */                   448 #else   /* CONFIG_BLK_CGROUP */
461 static inline void bio_associate_blkg(struct b    449 static inline void bio_associate_blkg(struct bio *bio) { }
462 static inline void bio_associate_blkg_from_css    450 static inline void bio_associate_blkg_from_css(struct bio *bio,
463                                                   451                                                struct cgroup_subsys_state *css)
464 { }                                               452 { }
465 static inline void bio_clone_blkg_association(    453 static inline void bio_clone_blkg_association(struct bio *dst,
466                                                   454                                               struct bio *src) { }
467 static inline void blkcg_punt_bio_submit(struc << 
468 {                                              << 
469         submit_bio(bio);                       << 
470 }                                              << 
471 #endif  /* CONFIG_BLK_CGROUP */                   455 #endif  /* CONFIG_BLK_CGROUP */
472                                                   456 
473 static inline void bio_set_dev(struct bio *bio    457 static inline void bio_set_dev(struct bio *bio, struct block_device *bdev)
474 {                                                 458 {
475         bio_clear_flag(bio, BIO_REMAPPED);        459         bio_clear_flag(bio, BIO_REMAPPED);
476         if (bio->bi_bdev != bdev)                 460         if (bio->bi_bdev != bdev)
477                 bio_clear_flag(bio, BIO_BPS_TH !! 461                 bio_clear_flag(bio, BIO_THROTTLED);
478         bio->bi_bdev = bdev;                      462         bio->bi_bdev = bdev;
479         bio_associate_blkg(bio);                  463         bio_associate_blkg(bio);
480 }                                                 464 }
481                                                   465 
                                                   >> 466 static inline void bio_copy_dev(struct bio *dst, struct bio *src)
                                                   >> 467 {
                                                   >> 468         bio_clear_flag(dst, BIO_REMAPPED);
                                                   >> 469         dst->bi_bdev = src->bi_bdev;
                                                   >> 470         bio_clone_blkg_association(dst, src);
                                                   >> 471 }
                                                   >> 472 
482 /*                                                473 /*
483  * BIO list management for use by remapping dr    474  * BIO list management for use by remapping drivers (e.g. DM or MD) and loop.
484  *                                                475  *
485  * A bio_list anchors a singly-linked list of     476  * A bio_list anchors a singly-linked list of bios chained through the bi_next
486  * member of the bio.  The bio_list also cache    477  * member of the bio.  The bio_list also caches the last list member to allow
487  * fast access to the tail.                       478  * fast access to the tail.
488  */                                               479  */
489 struct bio_list {                                 480 struct bio_list {
490         struct bio *head;                         481         struct bio *head;
491         struct bio *tail;                         482         struct bio *tail;
492 };                                                483 };
493                                                   484 
494 static inline int bio_list_empty(const struct     485 static inline int bio_list_empty(const struct bio_list *bl)
495 {                                                 486 {
496         return bl->head == NULL;                  487         return bl->head == NULL;
497 }                                                 488 }
498                                                   489 
499 static inline void bio_list_init(struct bio_li    490 static inline void bio_list_init(struct bio_list *bl)
500 {                                                 491 {
501         bl->head = bl->tail = NULL;               492         bl->head = bl->tail = NULL;
502 }                                                 493 }
503                                                   494 
504 #define BIO_EMPTY_LIST  { NULL, NULL }            495 #define BIO_EMPTY_LIST  { NULL, NULL }
505                                                   496 
506 #define bio_list_for_each(bio, bl) \              497 #define bio_list_for_each(bio, bl) \
507         for (bio = (bl)->head; bio; bio = bio-    498         for (bio = (bl)->head; bio; bio = bio->bi_next)
508                                                   499 
509 static inline unsigned bio_list_size(const str    500 static inline unsigned bio_list_size(const struct bio_list *bl)
510 {                                                 501 {
511         unsigned sz = 0;                          502         unsigned sz = 0;
512         struct bio *bio;                          503         struct bio *bio;
513                                                   504 
514         bio_list_for_each(bio, bl)                505         bio_list_for_each(bio, bl)
515                 sz++;                             506                 sz++;
516                                                   507 
517         return sz;                                508         return sz;
518 }                                                 509 }
519                                                   510 
520 static inline void bio_list_add(struct bio_lis    511 static inline void bio_list_add(struct bio_list *bl, struct bio *bio)
521 {                                                 512 {
522         bio->bi_next = NULL;                      513         bio->bi_next = NULL;
523                                                   514 
524         if (bl->tail)                             515         if (bl->tail)
525                 bl->tail->bi_next = bio;          516                 bl->tail->bi_next = bio;
526         else                                      517         else
527                 bl->head = bio;                   518                 bl->head = bio;
528                                                   519 
529         bl->tail = bio;                           520         bl->tail = bio;
530 }                                                 521 }
531                                                   522 
532 static inline void bio_list_add_head(struct bi    523 static inline void bio_list_add_head(struct bio_list *bl, struct bio *bio)
533 {                                                 524 {
534         bio->bi_next = bl->head;                  525         bio->bi_next = bl->head;
535                                                   526 
536         bl->head = bio;                           527         bl->head = bio;
537                                                   528 
538         if (!bl->tail)                            529         if (!bl->tail)
539                 bl->tail = bio;                   530                 bl->tail = bio;
540 }                                                 531 }
541                                                   532 
542 static inline void bio_list_merge(struct bio_l    533 static inline void bio_list_merge(struct bio_list *bl, struct bio_list *bl2)
543 {                                                 534 {
544         if (!bl2->head)                           535         if (!bl2->head)
545                 return;                           536                 return;
546                                                   537 
547         if (bl->tail)                             538         if (bl->tail)
548                 bl->tail->bi_next = bl2->head;    539                 bl->tail->bi_next = bl2->head;
549         else                                      540         else
550                 bl->head = bl2->head;             541                 bl->head = bl2->head;
551                                                   542 
552         bl->tail = bl2->tail;                     543         bl->tail = bl2->tail;
553 }                                                 544 }
554                                                   545 
555 static inline void bio_list_merge_init(struct  << 
556                 struct bio_list *bl2)          << 
557 {                                              << 
558         bio_list_merge(bl, bl2);               << 
559         bio_list_init(bl2);                    << 
560 }                                              << 
561                                                << 
562 static inline void bio_list_merge_head(struct     546 static inline void bio_list_merge_head(struct bio_list *bl,
563                                        struct     547                                        struct bio_list *bl2)
564 {                                                 548 {
565         if (!bl2->head)                           549         if (!bl2->head)
566                 return;                           550                 return;
567                                                   551 
568         if (bl->head)                             552         if (bl->head)
569                 bl2->tail->bi_next = bl->head;    553                 bl2->tail->bi_next = bl->head;
570         else                                      554         else
571                 bl->tail = bl2->tail;             555                 bl->tail = bl2->tail;
572                                                   556 
573         bl->head = bl2->head;                     557         bl->head = bl2->head;
574 }                                                 558 }
575                                                   559 
576 static inline struct bio *bio_list_peek(struct    560 static inline struct bio *bio_list_peek(struct bio_list *bl)
577 {                                                 561 {
578         return bl->head;                          562         return bl->head;
579 }                                                 563 }
580                                                   564 
581 static inline struct bio *bio_list_pop(struct     565 static inline struct bio *bio_list_pop(struct bio_list *bl)
582 {                                                 566 {
583         struct bio *bio = bl->head;               567         struct bio *bio = bl->head;
584                                                   568 
585         if (bio) {                                569         if (bio) {
586                 bl->head = bl->head->bi_next;     570                 bl->head = bl->head->bi_next;
587                 if (!bl->head)                    571                 if (!bl->head)
588                         bl->tail = NULL;          572                         bl->tail = NULL;
589                                                   573 
590                 bio->bi_next = NULL;              574                 bio->bi_next = NULL;
591         }                                         575         }
592                                                   576 
593         return bio;                               577         return bio;
594 }                                                 578 }
595                                                   579 
596 static inline struct bio *bio_list_get(struct     580 static inline struct bio *bio_list_get(struct bio_list *bl)
597 {                                                 581 {
598         struct bio *bio = bl->head;               582         struct bio *bio = bl->head;
599                                                   583 
600         bl->head = bl->tail = NULL;               584         bl->head = bl->tail = NULL;
601                                                   585 
602         return bio;                               586         return bio;
603 }                                                 587 }
604                                                   588 
605 /*                                                589 /*
606  * Increment chain count for the bio. Make sur    590  * Increment chain count for the bio. Make sure the CHAIN flag update
607  * is visible before the raised count.            591  * is visible before the raised count.
608  */                                               592  */
609 static inline void bio_inc_remaining(struct bi    593 static inline void bio_inc_remaining(struct bio *bio)
610 {                                                 594 {
611         bio_set_flag(bio, BIO_CHAIN);             595         bio_set_flag(bio, BIO_CHAIN);
612         smp_mb__before_atomic();                  596         smp_mb__before_atomic();
613         atomic_inc(&bio->__bi_remaining);         597         atomic_inc(&bio->__bi_remaining);
614 }                                                 598 }
615                                                   599 
616 /*                                                600 /*
617  * bio_set is used to allow other portions of     601  * bio_set is used to allow other portions of the IO system to
618  * allocate their own private memory pools for    602  * allocate their own private memory pools for bio and iovec structures.
619  * These memory pools in turn all allocate fro    603  * These memory pools in turn all allocate from the bio_slab
620  * and the bvec_slabs[].                          604  * and the bvec_slabs[].
621  */                                               605  */
622 #define BIO_POOL_SIZE 2                           606 #define BIO_POOL_SIZE 2
623                                                   607 
624 struct bio_set {                                  608 struct bio_set {
625         struct kmem_cache *bio_slab;              609         struct kmem_cache *bio_slab;
626         unsigned int front_pad;                   610         unsigned int front_pad;
627                                                   611 
628         /*                                        612         /*
629          * per-cpu bio alloc cache                613          * per-cpu bio alloc cache
630          */                                       614          */
631         struct bio_alloc_cache __percpu *cache    615         struct bio_alloc_cache __percpu *cache;
632                                                   616 
633         mempool_t bio_pool;                       617         mempool_t bio_pool;
634         mempool_t bvec_pool;                      618         mempool_t bvec_pool;
635 #if defined(CONFIG_BLK_DEV_INTEGRITY)             619 #if defined(CONFIG_BLK_DEV_INTEGRITY)
636         mempool_t bio_integrity_pool;             620         mempool_t bio_integrity_pool;
637         mempool_t bvec_integrity_pool;            621         mempool_t bvec_integrity_pool;
638 #endif                                            622 #endif
639                                                   623 
640         unsigned int back_pad;                    624         unsigned int back_pad;
641         /*                                        625         /*
642          * Deadlock avoidance for stacking blo    626          * Deadlock avoidance for stacking block drivers: see comments in
643          * bio_alloc_bioset() for details         627          * bio_alloc_bioset() for details
644          */                                       628          */
645         spinlock_t              rescue_lock;      629         spinlock_t              rescue_lock;
646         struct bio_list         rescue_list;      630         struct bio_list         rescue_list;
647         struct work_struct      rescue_work;      631         struct work_struct      rescue_work;
648         struct workqueue_struct *rescue_workqu    632         struct workqueue_struct *rescue_workqueue;
649                                                   633 
650         /*                                        634         /*
651          * Hot un-plug notifier for the per-cp    635          * Hot un-plug notifier for the per-cpu cache, if used
652          */                                       636          */
653         struct hlist_node cpuhp_dead;             637         struct hlist_node cpuhp_dead;
654 };                                                638 };
655                                                   639 
656 static inline bool bioset_initialized(struct b    640 static inline bool bioset_initialized(struct bio_set *bs)
657 {                                                 641 {
658         return bs->bio_slab != NULL;              642         return bs->bio_slab != NULL;
659 }                                                 643 }
660                                                   644 
                                                   >> 645 #if defined(CONFIG_BLK_DEV_INTEGRITY)
                                                   >> 646 
                                                   >> 647 #define bip_for_each_vec(bvl, bip, iter)                                \
                                                   >> 648         for_each_bvec(bvl, (bip)->bip_vec, iter, (bip)->bip_iter)
                                                   >> 649 
                                                   >> 650 #define bio_for_each_integrity_vec(_bvl, _bio, _iter)                   \
                                                   >> 651         for_each_bio(_bio)                                              \
                                                   >> 652                 bip_for_each_vec(_bvl, _bio->bi_integrity, _iter)
                                                   >> 653 
                                                   >> 654 extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int);
                                                   >> 655 extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int);
                                                   >> 656 extern bool bio_integrity_prep(struct bio *);
                                                   >> 657 extern void bio_integrity_advance(struct bio *, unsigned int);
                                                   >> 658 extern void bio_integrity_trim(struct bio *);
                                                   >> 659 extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t);
                                                   >> 660 extern int bioset_integrity_create(struct bio_set *, int);
                                                   >> 661 extern void bioset_integrity_free(struct bio_set *);
                                                   >> 662 extern void bio_integrity_init(void);
                                                   >> 663 
                                                   >> 664 #else /* CONFIG_BLK_DEV_INTEGRITY */
                                                   >> 665 
                                                   >> 666 static inline void *bio_integrity(struct bio *bio)
                                                   >> 667 {
                                                   >> 668         return NULL;
                                                   >> 669 }
                                                   >> 670 
                                                   >> 671 static inline int bioset_integrity_create(struct bio_set *bs, int pool_size)
                                                   >> 672 {
                                                   >> 673         return 0;
                                                   >> 674 }
                                                   >> 675 
                                                   >> 676 static inline void bioset_integrity_free (struct bio_set *bs)
                                                   >> 677 {
                                                   >> 678         return;
                                                   >> 679 }
                                                   >> 680 
                                                   >> 681 static inline bool bio_integrity_prep(struct bio *bio)
                                                   >> 682 {
                                                   >> 683         return true;
                                                   >> 684 }
                                                   >> 685 
                                                   >> 686 static inline int bio_integrity_clone(struct bio *bio, struct bio *bio_src,
                                                   >> 687                                       gfp_t gfp_mask)
                                                   >> 688 {
                                                   >> 689         return 0;
                                                   >> 690 }
                                                   >> 691 
                                                   >> 692 static inline void bio_integrity_advance(struct bio *bio,
                                                   >> 693                                          unsigned int bytes_done)
                                                   >> 694 {
                                                   >> 695         return;
                                                   >> 696 }
                                                   >> 697 
                                                   >> 698 static inline void bio_integrity_trim(struct bio *bio)
                                                   >> 699 {
                                                   >> 700         return;
                                                   >> 701 }
                                                   >> 702 
                                                   >> 703 static inline void bio_integrity_init(void)
                                                   >> 704 {
                                                   >> 705         return;
                                                   >> 706 }
                                                   >> 707 
                                                   >> 708 static inline bool bio_integrity_flagged(struct bio *bio, enum bip_flags flag)
                                                   >> 709 {
                                                   >> 710         return false;
                                                   >> 711 }
                                                   >> 712 
                                                   >> 713 static inline void *bio_integrity_alloc(struct bio * bio, gfp_t gfp,
                                                   >> 714                                                                 unsigned int nr)
                                                   >> 715 {
                                                   >> 716         return ERR_PTR(-EINVAL);
                                                   >> 717 }
                                                   >> 718 
                                                   >> 719 static inline int bio_integrity_add_page(struct bio *bio, struct page *page,
                                                   >> 720                                         unsigned int len, unsigned int offset)
                                                   >> 721 {
                                                   >> 722         return 0;
                                                   >> 723 }
                                                   >> 724 
                                                   >> 725 #endif /* CONFIG_BLK_DEV_INTEGRITY */
                                                   >> 726 
661 /*                                                727 /*
662  * Mark a bio as polled. Note that for async p    728  * Mark a bio as polled. Note that for async polled IO, the caller must
663  * expect -EWOULDBLOCK if we cannot allocate a    729  * expect -EWOULDBLOCK if we cannot allocate a request (or other resources).
664  * We cannot block waiting for requests on pol    730  * We cannot block waiting for requests on polled IO, as those completions
665  * must be found by the caller. This is differ    731  * must be found by the caller. This is different than IRQ driven IO, where
666  * it's safe to wait for IO to complete.          732  * it's safe to wait for IO to complete.
667  */                                               733  */
668 static inline void bio_set_polled(struct bio *    734 static inline void bio_set_polled(struct bio *bio, struct kiocb *kiocb)
669 {                                                 735 {
670         bio->bi_opf |= REQ_POLLED;                736         bio->bi_opf |= REQ_POLLED;
671         if (kiocb->ki_flags & IOCB_NOWAIT)     !! 737         if (!is_sync_kiocb(kiocb))
672                 bio->bi_opf |= REQ_NOWAIT;        738                 bio->bi_opf |= REQ_NOWAIT;
673 }                                                 739 }
674                                                   740 
675 static inline void bio_clear_polled(struct bio !! 741 struct bio *blk_next_bio(struct bio *bio, unsigned int nr_pages, gfp_t gfp);
676 {                                              << 
677         bio->bi_opf &= ~REQ_POLLED;            << 
678 }                                              << 
679                                                << 
680 struct bio *blk_next_bio(struct bio *bio, stru << 
681                 unsigned int nr_pages, blk_opf << 
682 struct bio *bio_chain_and_submit(struct bio *p << 
683                                                << 
684 struct bio *blk_alloc_discard_bio(struct block << 
685                 sector_t *sector, sector_t *nr << 
686                                                   742 
687 #endif /* __LINUX_BIO_H */                        743 #endif /* __LINUX_BIO_H */
688                                                   744 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php