Change __loop_clr_fd() to take struct gendisk *disk instead of struct loop_device *lo and use disk directly instead of lo->lo_disk. Its sole caller is lo_release(), which already has disk and holds disk->open_mutex. This change prepares for annotating lo_release() and __loop_clr_fd() with __must_hold(&disk->open_mutex). Clang's context analysis cannot prove that lo->lo_disk equals disk across disk->private_data. No functional change is intended since disk->private_data == lo and lo->lo_disk == disk. Signed-off-by: Bart Van Assche --- drivers/block/loop.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index d122cb008811..2034205c9cc7 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1030,8 +1030,9 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode, return error; } -static void __loop_clr_fd(struct loop_device *lo) +static void __loop_clr_fd(struct gendisk *disk) { + struct loop_device *lo = disk->private_data; struct queue_limits lim; struct file *filp; gfp_t gfp = lo->old_gfp_mask; @@ -1059,15 +1060,15 @@ static void __loop_clr_fd(struct loop_device *lo) lim.io_min = SECTOR_SIZE; queue_limits_commit_update(lo->lo_queue, &lim); - invalidate_disk(lo->lo_disk); + invalidate_disk(disk); loop_sysfs_exit(lo); /* let user-space know about this change */ - kobject_uevent(&disk_to_dev(lo->lo_disk)->kobj, KOBJ_CHANGE); + kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE); mapping_set_gfp_mask(filp->f_mapping, gfp); /* This is safe: open() is still holding a reference. */ module_put(THIS_MODULE); - disk_force_media_change(lo->lo_disk); + disk_force_media_change(disk); /* * Remove all partitions, including partitions added manually with @@ -1076,7 +1077,7 @@ static void __loop_clr_fd(struct loop_device *lo) * open_mutex has been held already in release path, so don't acquire * it here. */ - err = bdev_disk_changed(lo->lo_disk, false); + err = bdev_disk_changed(disk, false); if (err) pr_warn("%s: partition scan of loop%d failed (rc=%d)\n", __func__, lo->lo_number, err); @@ -1090,7 +1091,7 @@ static void __loop_clr_fd(struct loop_device *lo) */ lo->lo_flags = 0; if (!part_shift) - set_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state); + set_bit(GD_SUPPRESS_PART_SCAN, &disk->state); mutex_lock(&lo->lo_mutex); WRITE_ONCE(lo->lo_state, Lo_unbound); mutex_unlock(&lo->lo_mutex); @@ -1695,7 +1696,7 @@ static void lo_release(struct gendisk *disk) mutex_unlock(&lo->lo_mutex); if (need_clear) - __loop_clr_fd(lo); + __loop_clr_fd(disk); } static void lo_free_disk(struct gendisk *disk)