bio_alloc() with __GFP_WAIT never returns NULL

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 #2703
This commit is contained in:
Isaac Huang 2014-10-21 12:20:10 -06:00 committed by Brian Behlendorf
parent aaed7c408c
commit 29b763cd2c
1 changed files with 5 additions and 3 deletions

View File

@ -520,7 +520,7 @@ retry:
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;
@ -554,7 +554,8 @@ retry:
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);
}
@ -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;