From a5c0b7802cc9631e0dee67abd30c2f022621ae7c Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Wed, 4 Sep 2019 10:09:02 +0800 Subject: erofs: localize erofs_grab_bio() As Christoph pointed out [1], "erofs_grab_bio tries to handle a bio_alloc failure, except that the function will not actually fail due the mempool backing it." Sorry about useless code, fix it now and localize erofs_grab_bio [2]. [1] https://lore.kernel.org/r/20190830162812.GA10694@infradead.org/ [2] https://lore.kernel.org/r/20190902122016.GL15931@infradead.org/ Reported-by: Christoph Hellwig Signed-off-by: Gao Xiang Link: https://lore.kernel.org/r/20190904020912.63925-16-gaoxiang25@huawei.com Signed-off-by: Greg Kroah-Hartman --- fs/erofs/data.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'fs/erofs/data.c') diff --git a/fs/erofs/data.c b/fs/erofs/data.c index be11b5ea9d2e..0136ea117934 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -38,6 +38,19 @@ static inline void read_endio(struct bio *bio) bio_put(bio); } +static struct bio *erofs_grab_raw_bio(struct super_block *sb, + erofs_blk_t blkaddr, + unsigned int nr_pages) +{ + struct bio *bio = bio_alloc(GFP_NOIO, nr_pages); + + bio->bi_end_io = read_endio; + bio_set_dev(bio, sb->s_bdev); + bio->bi_iter.bi_sector = (sector_t)blkaddr << LOG_SECTORS_PER_BLOCK; + bio->bi_private = sb; + return bio; +} + /* prio -- true is used for dir */ struct page *__erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr, bool prio, bool nofail) @@ -62,12 +75,7 @@ repeat: if (!PageUptodate(page)) { struct bio *bio; - bio = erofs_grab_bio(sb, blkaddr, 1, sb, read_endio, nofail); - if (IS_ERR(bio)) { - DBG_BUGON(nofail); - err = PTR_ERR(bio); - goto err_out; - } + bio = erofs_grab_raw_bio(sb, blkaddr, 1); if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) { err = -EFAULT; @@ -276,13 +284,7 @@ submit_bio_retry: if (nblocks > BIO_MAX_PAGES) nblocks = BIO_MAX_PAGES; - bio = erofs_grab_bio(sb, blknr, nblocks, sb, - read_endio, false); - if (IS_ERR(bio)) { - err = PTR_ERR(bio); - bio = NULL; - goto err_out; - } + bio = erofs_grab_raw_bio(sb, blknr, nblocks); } err = bio_add_page(bio, page, PAGE_SIZE, 0); -- cgit