Skip to content

Commit 19f553d

Browse files
YongjiXieaxboe
authored andcommitted
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>
1 parent e515be8 commit 19f553d

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

‎drivers/block/loop.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,6 @@ static int __loop_clr_fd(struct loop_device *lo, bool release)
13291329
{
13301330
struct file *filp = NULL;
13311331
gfp_t gfp = lo->old_gfp_mask;
1332-
struct block_device *bdev = lo->lo_device;
13331332
int err = 0;
13341333
bool partscan = false;
13351334
int lo_number;
@@ -1397,16 +1396,14 @@ static int __loop_clr_fd(struct loop_device *lo, bool release)
13971396
blk_queue_io_min(lo->lo_queue, 512);
13981397
invalidate_disk(lo->lo_disk);
13991398
loop_sysfs_exit(lo);
1400-
if (bdev) {
1401-
/* let user-space know about this change */
1402-
kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE);
1403-
}
1399+
/* let user-space know about this change */
1400+
kobject_uevent(&disk_to_dev(lo->lo_disk)->kobj, KOBJ_CHANGE);
14041401
mapping_set_gfp_mask(filp->f_mapping, gfp);
14051402
/* This is safe: open() is still holding a reference. */
14061403
module_put(THIS_MODULE);
14071404
blk_mq_unfreeze_queue(lo->lo_queue);
14081405

1409-
partscan = lo->lo_flags & LO_FLAGS_PARTSCAN && bdev;
1406+
partscan = lo->lo_flags & LO_FLAGS_PARTSCAN;
14101407
lo_number = lo->lo_number;
14111408
disk_force_media_change(lo->lo_disk, DISK_EVENT_MEDIA_CHANGE);
14121409
out_unlock:

0 commit comments

Comments
 (0)