Skip to content

Commit

Permalink
nfs/blocklayout: remove bl_alloc_init_bio
Browse files Browse the repository at this point in the history
bio_alloc will never fail when it can sleep.  Remove the now simple
bl_alloc_init_bio helper and open code it in the only caller.

Signed-off-by: Christoph Hellwig <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Feb 2, 2022
1 parent f0d9119 commit 5d2ca21
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions fs/nfs/blocklayout/blocklayout.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,6 @@ bl_submit_bio(struct bio *bio)
return NULL;
}

static struct bio *bl_alloc_init_bio(unsigned int npg,
struct block_device *bdev, sector_t disk_sector,
bio_end_io_t end_io, struct parallel_io *par)
{
struct bio *bio;

npg = bio_max_segs(npg);
bio = bio_alloc(GFP_NOIO, npg);
if (bio) {
bio->bi_iter.bi_sector = disk_sector;
bio_set_dev(bio, bdev);
bio->bi_end_io = end_io;
bio->bi_private = par;
}
return bio;
}

static bool offset_in_map(u64 offset, struct pnfs_block_dev_map *map)
{
return offset >= map->start && offset < map->start + map->len;
Expand Down Expand Up @@ -171,10 +154,11 @@ do_add_page_to_bio(struct bio *bio, int npg, int rw, sector_t isect,

retry:
if (!bio) {
bio = bl_alloc_init_bio(npg, map->bdev,
disk_addr >> SECTOR_SHIFT, end_io, par);
if (!bio)
return ERR_PTR(-ENOMEM);
bio = bio_alloc(GFP_NOIO, bio_max_segs(npg));
bio->bi_iter.bi_sector = disk_addr >> SECTOR_SHIFT;
bio_set_dev(bio, map->bdev);
bio->bi_end_io = end_io;
bio->bi_private = par;
bio_set_op_attrs(bio, rw, 0);
}
if (bio_add_page(bio, page, *len, offset) < *len) {
Expand Down

0 comments on commit 5d2ca21

Please sign in to comment.