fs: buffer: use __bio_add_page to add single page to bio
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Wed, 31 May 2023 11:50:27 +0000 (04:50 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 31 May 2023 15:50:02 +0000 (09:50 -0600)
The buffer_head submission code uses bio_add_page() to add a page to a
newly created bio. bio_add_page() can fail, but the return value is never
checked.

Use __bio_add_page() as adding a single page to a newly created bio is
guaranteed to succeed.

This brings us a step closer to marking bio_add_page() as __must_check.

Reviewed-by: Gou Hao <gouhao@uniontech.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/84ff2dcbe81b258a73ad900adb5266e208b61a4d.1685532726.git.johannes.thumshirn@wdc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/buffer.c

index a7fc561758b1ac10816181bc6bd9fcbc1c737925..63da30ce946a4294fd6082ffb74873607da59b68 100644 (file)
@@ -2760,8 +2760,7 @@ static void submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
 
        bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9);
 
-       bio_add_page(bio, bh->b_page, bh->b_size, bh_offset(bh));
-       BUG_ON(bio->bi_iter.bi_size != bh->b_size);
+       __bio_add_page(bio, bh->b_page, bh->b_size, bh_offset(bh));
 
        bio->bi_end_io = end_bio_bh_io_sync;
        bio->bi_private = bh;