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 <hch@infradead.org>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Link: https://lore.kernel.org/r/20190904020912.63925-16-gaoxiang25@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Gao Xiang
2019-09-04 10:09:02 +08:00
committed by Greg Kroah-Hartman
parent 688a5f2ed4
commit a5c0b7802c
3 changed files with 22 additions and 45 deletions

View File

@@ -411,35 +411,6 @@ static inline int z_erofs_map_blocks_iter(struct inode *inode,
#endif /* !CONFIG_EROFS_FS_ZIP */
/* data.c */
static inline struct bio *erofs_grab_bio(struct super_block *sb,
erofs_blk_t blkaddr,
unsigned int nr_pages,
void *bi_private, bio_end_io_t endio,
bool nofail)
{
const gfp_t gfp = GFP_NOIO;
struct bio *bio;
do {
if (nr_pages == 1) {
bio = bio_alloc(gfp | (nofail ? __GFP_NOFAIL : 0), 1);
if (!bio) {
DBG_BUGON(nofail);
return ERR_PTR(-ENOMEM);
}
break;
}
bio = bio_alloc(gfp, nr_pages);
nr_pages /= 2;
} while (!bio);
bio->bi_end_io = endio;
bio_set_dev(bio, sb->s_bdev);
bio->bi_iter.bi_sector = (sector_t)blkaddr << LOG_SECTORS_PER_BLOCK;
bio->bi_private = bi_private;
return bio;
}
static inline void __submit_bio(struct bio *bio, unsigned int op,
unsigned int op_flags)
{