mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 18:09:56 +00:00
loop: Push loop_ctl_mutex down to loop_change_fd()
commit c371077000 upstream.
Push loop_ctl_mutex down to loop_change_fd(). We will need this to be
able to call loop_reread_partitions() without loop_ctl_mutex.
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
44e30aca07
commit
af2dfddd00
@@ -691,19 +691,22 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
|
|||||||
struct file *file, *old_file;
|
struct file *file, *old_file;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
error = mutex_lock_killable_nested(&loop_ctl_mutex, 1);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
error = -ENXIO;
|
error = -ENXIO;
|
||||||
if (lo->lo_state != Lo_bound)
|
if (lo->lo_state != Lo_bound)
|
||||||
goto out;
|
goto out_unlock;
|
||||||
|
|
||||||
/* the loop device has to be read-only */
|
/* the loop device has to be read-only */
|
||||||
error = -EINVAL;
|
error = -EINVAL;
|
||||||
if (!(lo->lo_flags & LO_FLAGS_READ_ONLY))
|
if (!(lo->lo_flags & LO_FLAGS_READ_ONLY))
|
||||||
goto out;
|
goto out_unlock;
|
||||||
|
|
||||||
error = -EBADF;
|
error = -EBADF;
|
||||||
file = fget(arg);
|
file = fget(arg);
|
||||||
if (!file)
|
if (!file)
|
||||||
goto out;
|
goto out_unlock;
|
||||||
|
|
||||||
error = loop_validate_file(file, bdev);
|
error = loop_validate_file(file, bdev);
|
||||||
if (error)
|
if (error)
|
||||||
@@ -730,11 +733,13 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
|
|||||||
fput(old_file);
|
fput(old_file);
|
||||||
if (lo->lo_flags & LO_FLAGS_PARTSCAN)
|
if (lo->lo_flags & LO_FLAGS_PARTSCAN)
|
||||||
loop_reread_partitions(lo, bdev);
|
loop_reread_partitions(lo, bdev);
|
||||||
|
mutex_unlock(&loop_ctl_mutex);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_putf:
|
out_putf:
|
||||||
fput(file);
|
fput(file);
|
||||||
out:
|
out_unlock:
|
||||||
|
mutex_unlock(&loop_ctl_mutex);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1469,12 +1474,7 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode,
|
|||||||
case LOOP_SET_FD:
|
case LOOP_SET_FD:
|
||||||
return loop_set_fd(lo, mode, bdev, arg);
|
return loop_set_fd(lo, mode, bdev, arg);
|
||||||
case LOOP_CHANGE_FD:
|
case LOOP_CHANGE_FD:
|
||||||
err = mutex_lock_killable_nested(&loop_ctl_mutex, 1);
|
return loop_change_fd(lo, bdev, arg);
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
err = loop_change_fd(lo, bdev, arg);
|
|
||||||
mutex_unlock(&loop_ctl_mutex);
|
|
||||||
break;
|
|
||||||
case LOOP_CLR_FD:
|
case LOOP_CLR_FD:
|
||||||
return loop_clr_fd(lo);
|
return loop_clr_fd(lo);
|
||||||
case LOOP_SET_STATUS:
|
case LOOP_SET_STATUS:
|
||||||
|
|||||||
Reference in New Issue
Block a user