mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 04:10:18 +09:00
Revert "loop: Avoid updating block size under exclusive owner"
Revert commitce8da5d13dwhich is commit 7e49538288e523427beedd26993d446afef1a6fb upstream. This reverts commitce8da5d13d("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
06146c26f5
commit
42a6aeb4b2
@@ -1472,36 +1472,19 @@ static int loop_set_dio(struct loop_device *lo, unsigned long arg)
|
||||
return error;
|
||||
}
|
||||
|
||||
static int loop_set_block_size(struct loop_device *lo, blk_mode_t mode,
|
||||
struct block_device *bdev, unsigned long arg)
|
||||
static int loop_set_block_size(struct loop_device *lo, unsigned long arg)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
/*
|
||||
* If we don't hold exclusive handle for the device, upgrade to it
|
||||
* here to avoid changing device under exclusive owner.
|
||||
*/
|
||||
if (!(mode & BLK_OPEN_EXCL)) {
|
||||
err = bd_prepare_to_claim(bdev, loop_set_block_size, NULL);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
err = mutex_lock_killable(&lo->lo_mutex);
|
||||
if (err)
|
||||
goto abort_claim;
|
||||
|
||||
if (lo->lo_state != Lo_bound) {
|
||||
err = -ENXIO;
|
||||
goto unlock;
|
||||
}
|
||||
if (lo->lo_state != Lo_bound)
|
||||
return -ENXIO;
|
||||
|
||||
err = blk_validate_block_size(arg);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (lo->lo_queue->limits.logical_block_size == arg)
|
||||
goto unlock;
|
||||
return 0;
|
||||
|
||||
sync_blockdev(lo->lo_device);
|
||||
invalidate_bdev(lo->lo_device);
|
||||
@@ -1513,11 +1496,6 @@ static int loop_set_block_size(struct loop_device *lo, blk_mode_t mode,
|
||||
loop_update_dio(lo);
|
||||
blk_mq_unfreeze_queue(lo->lo_queue);
|
||||
|
||||
unlock:
|
||||
mutex_unlock(&lo->lo_mutex);
|
||||
abort_claim:
|
||||
if (!(mode & BLK_OPEN_EXCL))
|
||||
bd_abort_claiming(bdev, loop_set_block_size);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -1536,6 +1514,9 @@ static int lo_simple_ioctl(struct loop_device *lo, unsigned int cmd,
|
||||
case LOOP_SET_DIRECT_IO:
|
||||
err = loop_set_dio(lo, arg);
|
||||
break;
|
||||
case LOOP_SET_BLOCK_SIZE:
|
||||
err = loop_set_block_size(lo, arg);
|
||||
break;
|
||||
default:
|
||||
err = -EINVAL;
|
||||
}
|
||||
@@ -1590,12 +1571,9 @@ static int lo_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||
break;
|
||||
case LOOP_GET_STATUS64:
|
||||
return loop_get_status64(lo, argp);
|
||||
case LOOP_SET_BLOCK_SIZE:
|
||||
if (!(mode & BLK_OPEN_WRITE) && !capable(CAP_SYS_ADMIN))
|
||||
return -EPERM;
|
||||
return loop_set_block_size(lo, mode, bdev, arg);
|
||||
case LOOP_SET_CAPACITY:
|
||||
case LOOP_SET_DIRECT_IO:
|
||||
case LOOP_SET_BLOCK_SIZE:
|
||||
if (!(mode & BLK_OPEN_WRITE) && !capable(CAP_SYS_ADMIN))
|
||||
return -EPERM;
|
||||
fallthrough;
|
||||
|
||||
Reference in New Issue
Block a user