swap: use __bio_add_page to add page to bio
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Wed, 31 May 2023 11:50:24 +0000 (04:50 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 31 May 2023 15:50:02 +0000 (09:50 -0600)
The swap code only adds a single page to a newly created bio. So use
__bio_add_page() to add the page which is guaranteed to succeed in this
case.

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

Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/5bdafd9de806b2dab92302b30eb7a3a5f10c37d9.1685532726.git.johannes.thumshirn@wdc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
mm/page_io.c

index 87b682d188503c2bb0d65267d03d290b106560d8..684cd3c7b59b0cbd07674b22b13bcaece711b62f 100644 (file)
@@ -338,7 +338,7 @@ static void swap_writepage_bdev_sync(struct page *page,
        bio_init(&bio, sis->bdev, &bv, 1,
                 REQ_OP_WRITE | REQ_SWAP | wbc_to_write_flags(wbc));
        bio.bi_iter.bi_sector = swap_page_sector(page);
-       bio_add_page(&bio, page, thp_size(page), 0);
+       __bio_add_page(&bio, page, thp_size(page), 0);
 
        bio_associate_blkg_from_page(&bio, page);
        count_swpout_vm_event(page);
@@ -360,7 +360,7 @@ static void swap_writepage_bdev_async(struct page *page,
                        GFP_NOIO);
        bio->bi_iter.bi_sector = swap_page_sector(page);
        bio->bi_end_io = end_swap_bio_write;
-       bio_add_page(bio, page, thp_size(page), 0);
+       __bio_add_page(bio, page, thp_size(page), 0);
 
        bio_associate_blkg_from_page(bio, page);
        count_swpout_vm_event(page);
@@ -468,7 +468,7 @@ static void swap_readpage_bdev_sync(struct page *page,
 
        bio_init(&bio, sis->bdev, &bv, 1, REQ_OP_READ);
        bio.bi_iter.bi_sector = swap_page_sector(page);
-       bio_add_page(&bio, page, thp_size(page), 0);
+       __bio_add_page(&bio, page, thp_size(page), 0);
        /*
         * Keep this task valid during swap readpage because the oom killer may
         * attempt to access it in the page fault retry time check.
@@ -488,7 +488,7 @@ static void swap_readpage_bdev_async(struct page *page,
        bio = bio_alloc(sis->bdev, 1, REQ_OP_READ, GFP_KERNEL);
        bio->bi_iter.bi_sector = swap_page_sector(page);
        bio->bi_end_io = end_swap_bio_read;
-       bio_add_page(bio, page, thp_size(page), 0);
+       __bio_add_page(bio, page, thp_size(page), 0);
        count_vm_event(PSWPIN);
        submit_bio(bio);
 }