Commit c2fccc1c9f7c81700cbac2120a4ad5441dd37004

Authored by Jens Axboe
1 parent c66bb3f075

Revert "loop: cleanup partitions when detaching loop device"

This reverts commit 8761a3dc1f07b163414e2215a2cadbb4cfe2a107.

There are situations where the destruction path is called
with the bdev->bd_mutex already held, which then deadlocks in
loop_clr_fd(). The normal partition cleanup does a trylock()
on the mutex, but it'd be nice to have a more bullet proof
method in loop. So punt this more involved fix to the next
merge window, and just back out this buggy fix for now.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

Showing 2 changed files with 2 additions and 20 deletions Side-by-side Diff

block/partition-generic.c
... ... @@ -257,7 +257,6 @@
257 257  
258 258 hd_struct_put(part);
259 259 }
260   -EXPORT_SYMBOL(delete_partition);
261 260  
262 261 static ssize_t whole_disk_show(struct device *dev,
263 262 struct device_attribute *attr, char *buf)
drivers/block/loop.c
... ... @@ -1044,29 +1044,12 @@
1044 1044 lo->lo_state = Lo_unbound;
1045 1045 /* This is safe: open() is still holding a reference. */
1046 1046 module_put(THIS_MODULE);
  1047 + if (lo->lo_flags & LO_FLAGS_PARTSCAN && bdev)
  1048 + ioctl_by_bdev(bdev, BLKRRPART, 0);
1047 1049 lo->lo_flags = 0;
1048 1050 if (!part_shift)
1049 1051 lo->lo_disk->flags |= GENHD_FL_NO_PART_SCAN;
1050 1052 mutex_unlock(&lo->lo_ctl_mutex);
1051   -
1052   - /*
1053   - * Remove all partitions, since BLKRRPART won't remove user
1054   - * added partitions when max_part=0
1055   - */
1056   - if (bdev) {
1057   - struct disk_part_iter piter;
1058   - struct hd_struct *part;
1059   -
1060   - mutex_lock_nested(&bdev->bd_mutex, 1);
1061   - invalidate_partition(bdev->bd_disk, 0);
1062   - disk_part_iter_init(&piter, bdev->bd_disk,
1063   - DISK_PITER_INCL_EMPTY);
1064   - while ((part = disk_part_iter_next(&piter)))
1065   - delete_partition(bdev->bd_disk, part->partno);
1066   - disk_part_iter_exit(&piter);
1067   - mutex_unlock(&bdev->bd_mutex);
1068   - }
1069   -
1070 1053 /*
1071 1054 * Need not hold lo_ctl_mutex to fput backing file.
1072 1055 * Calling fput holding lo_ctl_mutex triggers a circular