Skip to content

Commit

Permalink
bio_alloc() with __GFP_WAIT never returns NULL
Browse files Browse the repository at this point in the history
Mark the error handling branch as unlikely() because the current
kernel interface can never return NULL.  However, we want to keep
the error handling in case this behavior changes in the futre.

Plus fix a small style issue.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Isaac Huang <he.huang@intel.com>
Closes openzfs#2703
  • Loading branch information
huangheintel authored and ryao committed Nov 29, 2014
1 parent dddc613 commit 07c1e78
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions module/zfs/vdev_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ __vdev_disk_physio(struct block_device *bdev, zio_t *zio, caddr_t kbuf_ptr,
return (ENOMEM);

if (zio && !(zio->io_flags & (ZIO_FLAG_IO_RETRY | ZIO_FLAG_TRYHARD)))
bio_set_flags_failfast(bdev, &flags);
bio_set_flags_failfast(bdev, &flags);

dr->dr_zio = zio;
dr->dr_rw = flags;
Expand Down Expand Up @@ -554,7 +554,8 @@ __vdev_disk_physio(struct block_device *bdev, zio_t *zio, caddr_t kbuf_ptr,

dr->dr_bio[i] = bio_alloc(GFP_NOIO,
bio_nr_pages(bio_ptr, bio_size));
if (dr->dr_bio[i] == NULL) {
/* bio_alloc() with __GFP_WAIT never returns NULL */
if (unlikely(dr->dr_bio[i] == NULL)) {
vdev_disk_dio_free(dr);
return (ENOMEM);
}
Expand Down Expand Up @@ -642,7 +643,8 @@ vdev_disk_io_flush(struct block_device *bdev, zio_t *zio)
return (ENXIO);

bio = bio_alloc(GFP_NOIO, 0);
if (!bio)
/* bio_alloc() with __GFP_WAIT never returns NULL */
if (unlikely(bio == NULL))
return (ENOMEM);

bio->bi_end_io = vdev_disk_io_flush_completion;
Expand Down

0 comments on commit 07c1e78

Please sign in to comment.