@@ -7,7 +7,7 @@
struct erofs_fileio_rq {
struct bio_vec bvecs[16];
- struct bio bio;
+ struct bio_hdr bio;
struct kiocb iocb;
struct super_block *sb;
};
@@ -26,20 +26,21 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret)
if (ret > 0) {
if (ret != rq->bio.bi_iter.bi_size) {
- bio_advance(&rq->bio, ret);
- zero_fill_bio(&rq->bio);
+ bio_advance(container_of(&rq->bio, struct bio, __hdr),
+ ret);
+ zero_fill_bio(container_of(&rq->bio, struct bio, __hdr));
}
ret = 0;
}
if (rq->bio.bi_end_io) {
- rq->bio.bi_end_io(&rq->bio);
+ rq->bio.bi_end_io(container_of(&rq->bio, struct bio, __hdr));
} else {
- bio_for_each_folio_all(fi, &rq->bio) {
+ bio_for_each_folio_all(fi, container_of(&rq->bio, struct bio, __hdr)) {
DBG_BUGON(folio_test_uptodate(fi.folio));
erofs_onlinefolio_end(fi.folio, ret);
}
}
- bio_uninit(&rq->bio);
+ bio_uninit(container_of(&rq->bio, struct bio, __hdr));
kfree(rq);
}
@@ -68,7 +69,8 @@ static struct erofs_fileio_rq *erofs_fileio_rq_alloc(struct erofs_map_dev *mdev)
struct erofs_fileio_rq *rq = kzalloc(sizeof(*rq),
GFP_KERNEL | __GFP_NOFAIL);
- bio_init(&rq->bio, NULL, rq->bvecs, ARRAY_SIZE(rq->bvecs), REQ_OP_READ);
+ bio_init(container_of(&rq->bio, struct bio, __hdr), NULL, rq->bvecs,
+ ARRAY_SIZE(rq->bvecs), REQ_OP_READ);
rq->iocb.ki_filp = mdev->m_dif->file;
rq->sb = mdev->m_sb;
return rq;
@@ -76,12 +78,13 @@ static struct erofs_fileio_rq *erofs_fileio_rq_alloc(struct erofs_map_dev *mdev)
struct bio *erofs_fileio_bio_alloc(struct erofs_map_dev *mdev)
{
- return &erofs_fileio_rq_alloc(mdev)->bio;
+ return container_of(&erofs_fileio_rq_alloc(mdev)->bio, struct bio, __hdr);
}
void erofs_fileio_submit_bio(struct bio *bio)
{
- return erofs_fileio_rq_submit(container_of(bio, struct erofs_fileio_rq,
+ return erofs_fileio_rq_submit(container_of(&bio->__hdr,
+ struct erofs_fileio_rq,
bio));
}
@@ -150,7 +153,9 @@ static int erofs_fileio_scan_folio(struct erofs_fileio *io, struct folio *folio)
}
if (!attached++)
erofs_onlinefolio_split(folio);
- if (!bio_add_folio(&io->rq->bio, folio, len, cur))
+ if (!bio_add_folio(container_of(&io->rq->bio,
+ struct bio, __hdr),
+ folio, len, cur))
goto io_retry;
io->dev.m_pa += len;
}
@@ -176,7 +176,7 @@ static int erofs_fscache_read_io_async(struct fscache_cookie *cookie,
struct erofs_fscache_bio {
struct erofs_fscache_io io;
- struct bio bio; /* w/o bdev to share bio_add_page/endio() */
+ struct bio_hdr bio; /* w/o bdev to share bio_add_page/endio() */
struct bio_vec bvecs[BIO_MAX_VECS];
};
@@ -187,7 +187,7 @@ static void erofs_fscache_bio_endio(void *priv,
if (IS_ERR_VALUE(transferred_or_error))
io->bio.bi_status = errno_to_blk_status(transferred_or_error);
- io->bio.bi_end_io(&io->bio);
+ io->bio.bi_end_io(container_of(&io->bio, struct bio, __hdr));
BUILD_BUG_ON(offsetof(struct erofs_fscache_bio, io) != 0);
erofs_fscache_io_put(&io->io);
}
@@ -197,17 +197,18 @@ struct bio *erofs_fscache_bio_alloc(struct erofs_map_dev *mdev)
struct erofs_fscache_bio *io;
io = kmalloc(sizeof(*io), GFP_KERNEL | __GFP_NOFAIL);
- bio_init(&io->bio, NULL, io->bvecs, BIO_MAX_VECS, REQ_OP_READ);
+ bio_init(container_of(&io->bio, struct bio, __hdr), NULL, io->bvecs,
+ BIO_MAX_VECS, REQ_OP_READ);
io->io.private = mdev->m_dif->fscache->cookie;
io->io.end_io = erofs_fscache_bio_endio;
refcount_set(&io->io.ref, 1);
- return &io->bio;
+ return container_of(&io->bio, struct bio, __hdr);
}
void erofs_fscache_submit_bio(struct bio *bio)
{
- struct erofs_fscache_bio *io = container_of(bio,
- struct erofs_fscache_bio, bio);
+ struct erofs_fscache_bio *io =
+ container_of(&bio->__hdr, struct erofs_fscache_bio, bio);
int ret;
iov_iter_bvec(&io->io.iter, ITER_DEST, io->bvecs, bio->bi_vcnt,
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally. Change the type of the middle struct member currently causing trouble from `struct bio` to `struct bio_hdr`. We also use `container_of()` whenever we need to retrieve a pointer to the flexible structure `struct bio`, through which we can access the flexible-array member in it, if necessary. With these changes fix the following warnings: fs/erofs/fileio.c:10:20: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] fs/erofs/fscache.c:179:20: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> --- fs/erofs/fileio.c | 25 +++++++++++++++---------- fs/erofs/fscache.c | 13 +++++++------ 2 files changed, 22 insertions(+), 16 deletions(-)