Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 757ecf40 authored by Jan Kara's avatar Jan Kara Committed by Jens Axboe
Browse files

loop: Push loop_ctl_mutex down to loop_set_fd()



Push lo_ctl_mutex down to loop_set_fd(). We will need this to be able to
call loop_reread_partitions() without lo_ctl_mutex.

Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 550df5fd
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -918,13 +918,17 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
	if (!file)
		goto out;

	error = mutex_lock_killable_nested(&loop_ctl_mutex, 1);
	if (error)
		goto out_putf;

	error = -EBUSY;
	if (lo->lo_state != Lo_unbound)
		goto out_putf;
		goto out_unlock;

	error = loop_validate_file(file, bdev);
	if (error)
		goto out_putf;
		goto out_unlock;

	mapping = file->f_mapping;
	inode = mapping->host;
@@ -936,10 +940,10 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
	error = -EFBIG;
	size = get_loop_size(lo, file);
	if ((loff_t)(sector_t)size != size)
		goto out_putf;
		goto out_unlock;
	error = loop_prepare_queue(lo);
	if (error)
		goto out_putf;
		goto out_unlock;

	error = 0;

@@ -978,8 +982,11 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
	 * put /dev/loopXX inode. Later in __loop_clr_fd() we bdput(bdev).
	 */
	bdgrab(bdev);
	mutex_unlock(&loop_ctl_mutex);
	return 0;

out_unlock:
	mutex_unlock(&loop_ctl_mutex);
out_putf:
	fput(file);
out:
@@ -1460,12 +1467,7 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode,

	switch (cmd) {
	case LOOP_SET_FD:
		err = mutex_lock_killable_nested(&loop_ctl_mutex, 1);
		if (err)
			return err;
		err = loop_set_fd(lo, mode, bdev, arg);
		mutex_unlock(&loop_ctl_mutex);
		break;
		return loop_set_fd(lo, mode, bdev, arg);
	case LOOP_CHANGE_FD:
		err = mutex_lock_killable_nested(&loop_ctl_mutex, 1);
		if (err)