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