Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

loop: Remove the unnecessary bdev checks and unused bdev variable

The lo->lo_device can't be null if the lo->lo_backing_file is set.
So let's remove the unnecessary bdev checks and the entire bdev
variable in __loop_clr_fd() since the lo->lo_backing_file is already
checked before.

Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210922123711.187-4-xieyongji@bytedance.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Xie Yongji and committed by
Jens Axboe
19f553db e515be8f

+3 -6
+3 -6
drivers/block/loop.c
··· 1329 1329 { 1330 1330 struct file *filp = NULL; 1331 1331 gfp_t gfp = lo->old_gfp_mask; 1332 - struct block_device *bdev = lo->lo_device; 1333 1332 int err = 0; 1334 1333 bool partscan = false; 1335 1334 int lo_number; ··· 1396 1397 blk_queue_io_min(lo->lo_queue, 512); 1397 1398 invalidate_disk(lo->lo_disk); 1398 1399 loop_sysfs_exit(lo); 1399 - if (bdev) { 1400 - /* let user-space know about this change */ 1401 - kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE); 1402 - } 1400 + /* let user-space know about this change */ 1401 + kobject_uevent(&disk_to_dev(lo->lo_disk)->kobj, KOBJ_CHANGE); 1403 1402 mapping_set_gfp_mask(filp->f_mapping, gfp); 1404 1403 /* This is safe: open() is still holding a reference. */ 1405 1404 module_put(THIS_MODULE); 1406 1405 blk_mq_unfreeze_queue(lo->lo_queue); 1407 1406 1408 - partscan = lo->lo_flags & LO_FLAGS_PARTSCAN && bdev; 1407 + partscan = lo->lo_flags & LO_FLAGS_PARTSCAN; 1409 1408 lo_number = lo->lo_number; 1410 1409 disk_force_media_change(lo->lo_disk, DISK_EVENT_MEDIA_CHANGE); 1411 1410 out_unlock: