Message ID | 20230419140929.5924-20-jth@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | bio: check return values of bio_add_page | expand |
On Wed, Apr 19, 2023 at 04:09:29PM +0200, Johannes Thumshirn wrote: > Now that all users of bio_add_page check for the return value, mark > bio_add_page as __must_check. Should probably add __must_check to bio_add_folio too? If this is really the way you want to go ... means we also need a __bio_add_folio().
On 19/04/2023 16:19, Matthew Wilcox wrote: > On Wed, Apr 19, 2023 at 04:09:29PM +0200, Johannes Thumshirn wrote: >> Now that all users of bio_add_page check for the return value, mark >> bio_add_page as __must_check. > > Should probably add __must_check to bio_add_folio too? If this is > really the way you want to go ... means we also need a > __bio_add_folio(). I admit I haven't thought of folios, mea culpa. 3 of the callers of bio_add_folio() don't check the return value: $ git grep -E '\sbio_add_folio\b' fs/iomap/buffered-io.c: bio_add_folio(ctx->bio, folio, plen, poff); fs/iomap/buffered-io.c: bio_add_folio(&bio, folio, plen, poff); fs/iomap/buffered-io.c: bio_add_folio(wpc->ioend->io_bio, folio, len, poff); But from a quick look they look OK to me. Does that look reasonable to you: diff --git a/block/bio.c b/block/bio.c index fd11614bba4d..f3a3524b53e4 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1138,6 +1138,14 @@ int bio_add_page(struct bio *bio, struct page *page, } EXPORT_SYMBOL(bio_add_page); +void __bio_add_folio(struct bio *bio, struct folio *folio, size_t len, + size_t off) +{ + WARN_ON_ONCE(len > UINT_MAX); + WARN_ON_ONCE(off > UINT_MAX); + __bio_add_page(bio, &folio->page, len, off); +} + /** * bio_add_folio - Attempt to add part of a folio to a bio. * @bio: BIO to add to. Byte, Johannes
diff --git a/include/linux/bio.h b/include/linux/bio.h index d766be7152e1..0f8a8d7a6384 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -465,7 +465,7 @@ extern void bio_uninit(struct bio *); void bio_reset(struct bio *bio, struct block_device *bdev, blk_opf_t opf); void bio_chain(struct bio *, struct bio *); -int bio_add_page(struct bio *, struct page *, unsigned len, unsigned off); +int __must_check bio_add_page(struct bio *, struct page *, unsigned len, unsigned off); bool bio_add_folio(struct bio *, struct folio *, size_t len, size_t off); extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *, unsigned int, unsigned int);