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

Commit cc66ea66 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "BACKPORT: loop: Fix missing discard support when using LOOP_CONFIGURE"

parents 9018ca15 3649dbb7
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -1083,8 +1083,6 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
	mapping = file->f_mapping;
	inode = mapping->host;

	size = get_loop_size(lo, file);

	if ((config->info.lo_flags & ~LOOP_CONFIGURE_SETTABLE_FLAGS) != 0) {
		error = -EINVAL;
		goto out_unlock;
@@ -1133,8 +1131,11 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
	blk_queue_physical_block_size(lo->lo_queue, bsize);
	blk_queue_io_min(lo->lo_queue, bsize);

	loop_config_discard(lo);
	loop_update_dio(lo);
	loop_sysfs_init(lo);

	size = get_loop_size(lo, file);
	loop_set_size(lo, size);

	set_blocksize(bdev, S_ISBLK(inode->i_mode) ?
@@ -1144,6 +1145,8 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
	if (part_shift)
		lo->lo_flags |= LO_FLAGS_PARTSCAN;
	partscan = lo->lo_flags & LO_FLAGS_PARTSCAN;
	if (partscan)
		lo->lo_disk->flags &= ~GENHD_FL_NO_PART_SCAN;

	/* Grab the block_device to prevent its destruction after we
	 * put /dev/loopXX inode. Later in __loop_clr_fd() we bdput(bdev).
@@ -1410,6 +1413,11 @@ loop_get_status(struct loop_device *lo, struct loop_info64 *info)
	info->lo_number = lo->lo_number;
	info->lo_offset = lo->lo_offset;
	info->lo_sizelimit = lo->lo_sizelimit;

	/* loff_t vars have been assigned __u64 */
	if (lo->lo_offset < 0 || lo->lo_sizelimit < 0)
		return -EOVERFLOW;

	info->lo_flags = lo->lo_flags;
	memcpy(info->lo_file_name, lo->lo_file_name, LO_NAME_SIZE);
	memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);