Commit ff9ea323816dc1c8ac7144afd4eab3ac97704430
Committed by
Jens Axboe
1 parent
f4da80727c
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
block, bdi: an active gendisk always has a request_queue associated with it
bdev_get_queue() returns the request_queue associated with the specified block_device. blk_get_backing_dev_info() makes use of bdev_get_queue() to determine the associated bdi given a block_device. All the callers of bdev_get_queue() including blk_get_backing_dev_info() assume that bdev_get_queue() may return NULL and implement NULL handling; however, bdev_get_queue() requires the passed in block_device is opened and attached to its gendisk. Because an active gendisk always has a valid request_queue associated with it, bdev_get_queue() can never return NULL and neither can blk_get_backing_dev_info(). Make it clear that neither of the two functions can return NULL and remove NULL handling from all the callers. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Chris Mason <clm@fb.com> Cc: Dave Chinner <david@fromorbit.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Showing 7 changed files with 5 additions and 21 deletions Side-by-side Diff
block/blk-core.c
... | ... | @@ -83,18 +83,14 @@ |
83 | 83 | * @bdev: device |
84 | 84 | * |
85 | 85 | * Locates the passed device's request queue and returns the address of its |
86 | - * backing_dev_info | |
87 | - * | |
88 | - * Will return NULL if the request queue cannot be located. | |
86 | + * backing_dev_info. This function can only be called if @bdev is opened | |
87 | + * and the return value is never NULL. | |
89 | 88 | */ |
90 | 89 | struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev) |
91 | 90 | { |
92 | - struct backing_dev_info *ret = NULL; | |
93 | 91 | struct request_queue *q = bdev_get_queue(bdev); |
94 | 92 | |
95 | - if (q) | |
96 | - ret = &q->backing_dev_info; | |
97 | - return ret; | |
93 | + return &q->backing_dev_info; | |
98 | 94 | } |
99 | 95 | EXPORT_SYMBOL(blk_get_backing_dev_info); |
100 | 96 |
block/compat_ioctl.c
... | ... | @@ -709,8 +709,6 @@ |
709 | 709 | if (!arg) |
710 | 710 | return -EINVAL; |
711 | 711 | bdi = blk_get_backing_dev_info(bdev); |
712 | - if (bdi == NULL) | |
713 | - return -ENOTTY; | |
714 | 712 | return compat_put_long(arg, |
715 | 713 | (bdi->ra_pages * PAGE_CACHE_SIZE) / 512); |
716 | 714 | case BLKROGET: /* compatible */ |
... | ... | @@ -731,8 +729,6 @@ |
731 | 729 | if (!capable(CAP_SYS_ADMIN)) |
732 | 730 | return -EACCES; |
733 | 731 | bdi = blk_get_backing_dev_info(bdev); |
734 | - if (bdi == NULL) | |
735 | - return -ENOTTY; | |
736 | 732 | bdi->ra_pages = (arg * 512) / PAGE_CACHE_SIZE; |
737 | 733 | return 0; |
738 | 734 | case BLKGETSIZE: |
block/ioctl.c
... | ... | @@ -356,8 +356,6 @@ |
356 | 356 | if (!arg) |
357 | 357 | return -EINVAL; |
358 | 358 | bdi = blk_get_backing_dev_info(bdev); |
359 | - if (bdi == NULL) | |
360 | - return -ENOTTY; | |
361 | 359 | return put_long(arg, (bdi->ra_pages * PAGE_CACHE_SIZE) / 512); |
362 | 360 | case BLKROGET: |
363 | 361 | return put_int(arg, bdev_read_only(bdev) != 0); |
... | ... | @@ -386,8 +384,6 @@ |
386 | 384 | if(!capable(CAP_SYS_ADMIN)) |
387 | 385 | return -EACCES; |
388 | 386 | bdi = blk_get_backing_dev_info(bdev); |
389 | - if (bdi == NULL) | |
390 | - return -ENOTTY; | |
391 | 387 | bdi->ra_pages = (arg * 512) / PAGE_CACHE_SIZE; |
392 | 388 | return 0; |
393 | 389 | case BLKBSZSET: |
fs/block_dev.c
fs/btrfs/disk-io.c
fs/xfs/xfs_buf.c
include/linux/blkdev.h