From 29b763cd2c13e355b60fa095a6f20cf8a38f8651 Mon Sep 17 00:00:00 2001 From: Isaac Huang Date: Tue, 21 Oct 2014 12:20:10 -0600 Subject: [PATCH] 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 Signed-off-by: Isaac Huang Closes #2703 --- module/zfs/vdev_disk.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/module/zfs/vdev_disk.c b/module/zfs/vdev_disk.c index 9cc6745d1..ec93884ed 100644 --- a/module/zfs/vdev_disk.c +++ b/module/zfs/vdev_disk.c @@ -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;