Skip to content

Commit 42a6aeb

Browse files
Eric Hagberggregkh
authored andcommitted
Revert "loop: Avoid updating block size under exclusive owner"
Revert commit ce8da5d which is commit 7e49538 upstream. This reverts commit ce8da5d ("loop: Avoid updating block size under exclusive owner") for the 6.6 kernel, because if the LTP ioctl_loop06 test is run with this patch in place, the test will fail, it leaves the host unable to kexec into the kernel again (hangs forever) and "losetup -a" will hang on attempting to access the /dev/loopN device that the test has set up. The patch doesn't need to be reverted from 6.12, as it works fine there. Cc: stable@vger.kernel.org # 6.6.x Signed-off-by: Eric Hagberg <ehagberg@janestreet.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 06146c2 commit 42a6aeb

1 file changed

Lines changed: 8 additions & 30 deletions

File tree

drivers/block/loop.c

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,36 +1472,19 @@ static int loop_set_dio(struct loop_device *lo, unsigned long arg)
14721472
return error;
14731473
}
14741474

1475-
static int loop_set_block_size(struct loop_device *lo, blk_mode_t mode,
1476-
struct block_device *bdev, unsigned long arg)
1475+
static int loop_set_block_size(struct loop_device *lo, unsigned long arg)
14771476
{
14781477
int err = 0;
14791478

1480-
/*
1481-
* If we don't hold exclusive handle for the device, upgrade to it
1482-
* here to avoid changing device under exclusive owner.
1483-
*/
1484-
if (!(mode & BLK_OPEN_EXCL)) {
1485-
err = bd_prepare_to_claim(bdev, loop_set_block_size, NULL);
1486-
if (err)
1487-
return err;
1488-
}
1489-
1490-
err = mutex_lock_killable(&lo->lo_mutex);
1491-
if (err)
1492-
goto abort_claim;
1493-
1494-
if (lo->lo_state != Lo_bound) {
1495-
err = -ENXIO;
1496-
goto unlock;
1497-
}
1479+
if (lo->lo_state != Lo_bound)
1480+
return -ENXIO;
14981481

14991482
err = blk_validate_block_size(arg);
15001483
if (err)
15011484
return err;
15021485

15031486
if (lo->lo_queue->limits.logical_block_size == arg)
1504-
goto unlock;
1487+
return 0;
15051488

15061489
sync_blockdev(lo->lo_device);
15071490
invalidate_bdev(lo->lo_device);
@@ -1513,11 +1496,6 @@ static int loop_set_block_size(struct loop_device *lo, blk_mode_t mode,
15131496
loop_update_dio(lo);
15141497
blk_mq_unfreeze_queue(lo->lo_queue);
15151498

1516-
unlock:
1517-
mutex_unlock(&lo->lo_mutex);
1518-
abort_claim:
1519-
if (!(mode & BLK_OPEN_EXCL))
1520-
bd_abort_claiming(bdev, loop_set_block_size);
15211499
return err;
15221500
}
15231501

@@ -1536,6 +1514,9 @@ static int lo_simple_ioctl(struct loop_device *lo, unsigned int cmd,
15361514
case LOOP_SET_DIRECT_IO:
15371515
err = loop_set_dio(lo, arg);
15381516
break;
1517+
case LOOP_SET_BLOCK_SIZE:
1518+
err = loop_set_block_size(lo, arg);
1519+
break;
15391520
default:
15401521
err = -EINVAL;
15411522
}
@@ -1590,12 +1571,9 @@ static int lo_ioctl(struct block_device *bdev, blk_mode_t mode,
15901571
break;
15911572
case LOOP_GET_STATUS64:
15921573
return loop_get_status64(lo, argp);
1593-
case LOOP_SET_BLOCK_SIZE:
1594-
if (!(mode & BLK_OPEN_WRITE) && !capable(CAP_SYS_ADMIN))
1595-
return -EPERM;
1596-
return loop_set_block_size(lo, mode, bdev, arg);
15971574
case LOOP_SET_CAPACITY:
15981575
case LOOP_SET_DIRECT_IO:
1576+
case LOOP_SET_BLOCK_SIZE:
15991577
if (!(mode & BLK_OPEN_WRITE) && !capable(CAP_SYS_ADMIN))
16001578
return -EPERM;
16011579
fallthrough;

0 commit comments

Comments
 (0)