Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

block: remove the bi_inline_vecs variable sized array from struct bio

Bios are embedded into other structures, and at least spare is unhappy
about embedding structures with variable sized arrays. There's no
real need to the array anyway, we can replace it with a helper pointing
to the memory just behind the bio, and with the previous cleanups there
is very few site doing anything special with it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
d86eaa0f 70a6f71b

+17 -19
+2 -1
block/bio.c
··· 617 617 618 618 if (nr_vecs > BIO_MAX_INLINE_VECS) 619 619 return NULL; 620 - return kmalloc(struct_size(bio, bi_inline_vecs, nr_vecs), gfp_mask); 620 + return kmalloc(sizeof(*bio) + nr_vecs * sizeof(struct bio_vec), 621 + gfp_mask); 621 622 } 622 623 EXPORT_SYMBOL(bio_kmalloc); 623 624
+3 -3
drivers/md/bcache/movinggc.c
··· 145 145 continue; 146 146 } 147 147 148 - io = kzalloc(struct_size(io, bio.bio.bi_inline_vecs, 149 - DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS)), 150 - GFP_KERNEL); 148 + io = kzalloc(sizeof(*io) + sizeof(struct bio_vec) * 149 + DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS), 150 + GFP_KERNEL); 151 151 if (!io) 152 152 goto err; 153 153
+3 -3
drivers/md/bcache/writeback.c
··· 536 536 for (i = 0; i < nk; i++) { 537 537 w = keys[i]; 538 538 539 - io = kzalloc(struct_size(io, bio.bi_inline_vecs, 540 - DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS)), 541 - GFP_KERNEL); 539 + io = kzalloc(sizeof(*io) + sizeof(struct bio_vec) * 540 + DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS), 541 + GFP_KERNEL); 542 542 if (!io) 543 543 goto err; 544 544
+1 -1
drivers/md/dm-vdo/vio.c
··· 212 212 return VDO_SUCCESS; 213 213 214 214 bio->bi_ioprio = 0; 215 - bio->bi_io_vec = bio->bi_inline_vecs; 215 + bio->bi_io_vec = bio_inline_vecs(bio); 216 216 bio->bi_max_vecs = vio->block_count + 1; 217 217 if (VDO_ASSERT(size <= vio_size, "specified size %d is not greater than allocated %d", 218 218 size, vio_size) != VDO_SUCCESS)
-1
fs/bcachefs/data_update.h
··· 62 62 63 63 struct work_struct work; 64 64 struct data_update write; 65 - struct bio_vec bi_inline_vecs[]; /* must be last */ 66 65 }; 67 66 68 67 void bch2_data_update_to_text(struct printbuf *, struct data_update *);
+2 -2
fs/bcachefs/journal.c
··· 1627 1627 unsigned nr_bvecs = DIV_ROUND_UP(JOURNAL_ENTRY_SIZE_MAX, PAGE_SIZE); 1628 1628 1629 1629 for (unsigned i = 0; i < ARRAY_SIZE(ja->bio); i++) { 1630 - ja->bio[i] = kzalloc(struct_size(ja->bio[i], bio.bi_inline_vecs, 1631 - nr_bvecs), GFP_KERNEL); 1630 + ja->bio[i] = kzalloc(sizeof(*ja->bio[i]) + 1631 + sizeof(struct bio_vec) * nr_bvecs, GFP_KERNEL); 1632 1632 if (!ja->bio[i]) 1633 1633 return bch_err_throw(c, ENOMEM_dev_journal_init); 1634 1634
+1 -1
include/linux/bio.h
··· 408 408 static inline void bio_init_inline(struct bio *bio, struct block_device *bdev, 409 409 unsigned short max_vecs, blk_opf_t opf) 410 410 { 411 - bio_init(bio, bdev, bio->bi_inline_vecs, max_vecs, opf); 411 + bio_init(bio, bdev, bio_inline_vecs(bio), max_vecs, opf); 412 412 } 413 413 extern void bio_uninit(struct bio *); 414 414 void bio_reset(struct bio *bio, struct block_device *bdev, blk_opf_t opf);
+5 -7
include/linux/blk_types.h
··· 269 269 struct bio_vec *bi_io_vec; /* the actual vec list */ 270 270 271 271 struct bio_set *bi_pool; 272 - 273 - /* 274 - * We can inline a number of vecs at the end of the bio, to avoid 275 - * double allocations for a small number of bio_vecs. This member 276 - * MUST obviously be kept at the very end of the bio. 277 - */ 278 - struct bio_vec bi_inline_vecs[]; 279 272 }; 280 273 281 274 #define BIO_RESET_BYTES offsetof(struct bio, bi_max_vecs) 282 275 #define BIO_MAX_SECTORS (UINT_MAX >> SECTOR_SHIFT) 276 + 277 + static inline struct bio_vec *bio_inline_vecs(struct bio *bio) 278 + { 279 + return (struct bio_vec *)(bio + 1); 280 + } 283 281 284 282 /* 285 283 * bio flags