Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

loop: refactor queue limits updates

Replace loop_reconfigure_limits with a slightly less encompassing
loop_update_limits that expects the caller to acquire and commit the
queue limits to prepare for sorting out the freeze vs limits lock
ordering.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>
Link: https://lore.kernel.org/r/20250110054726.1499538-11-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
b38c8be2 1233751f

+20 -16
+20 -16
drivers/block/loop.c
··· 977 977 return SECTOR_SIZE; 978 978 } 979 979 980 - static int loop_reconfigure_limits(struct loop_device *lo, unsigned int bsize) 980 + static void loop_update_limits(struct loop_device *lo, struct queue_limits *lim, 981 + unsigned int bsize) 981 982 { 982 983 struct file *file = lo->lo_backing_file; 983 984 struct inode *inode = file->f_mapping->host; 984 985 struct block_device *backing_bdev = NULL; 985 - struct queue_limits lim; 986 986 u32 granularity = 0, max_discard_sectors = 0; 987 987 988 988 if (S_ISBLK(inode->i_mode)) ··· 995 995 996 996 loop_get_discard_config(lo, &granularity, &max_discard_sectors); 997 997 998 - lim = queue_limits_start_update(lo->lo_queue); 999 - lim.logical_block_size = bsize; 1000 - lim.physical_block_size = bsize; 1001 - lim.io_min = bsize; 1002 - lim.features &= ~(BLK_FEAT_WRITE_CACHE | BLK_FEAT_ROTATIONAL); 998 + lim->logical_block_size = bsize; 999 + lim->physical_block_size = bsize; 1000 + lim->io_min = bsize; 1001 + lim->features &= ~(BLK_FEAT_WRITE_CACHE | BLK_FEAT_ROTATIONAL); 1003 1002 if (file->f_op->fsync && !(lo->lo_flags & LO_FLAGS_READ_ONLY)) 1004 - lim.features |= BLK_FEAT_WRITE_CACHE; 1003 + lim->features |= BLK_FEAT_WRITE_CACHE; 1005 1004 if (backing_bdev && !bdev_nonrot(backing_bdev)) 1006 - lim.features |= BLK_FEAT_ROTATIONAL; 1007 - lim.max_hw_discard_sectors = max_discard_sectors; 1008 - lim.max_write_zeroes_sectors = max_discard_sectors; 1005 + lim->features |= BLK_FEAT_ROTATIONAL; 1006 + lim->max_hw_discard_sectors = max_discard_sectors; 1007 + lim->max_write_zeroes_sectors = max_discard_sectors; 1009 1008 if (max_discard_sectors) 1010 - lim.discard_granularity = granularity; 1009 + lim->discard_granularity = granularity; 1011 1010 else 1012 - lim.discard_granularity = 0; 1013 - return queue_limits_commit_update(lo->lo_queue, &lim); 1011 + lim->discard_granularity = 0; 1014 1012 } 1015 1013 1016 1014 static int loop_configure(struct loop_device *lo, blk_mode_t mode, ··· 1017 1019 { 1018 1020 struct file *file = fget(config->fd); 1019 1021 struct address_space *mapping; 1022 + struct queue_limits lim; 1020 1023 int error; 1021 1024 loff_t size; 1022 1025 bool partscan; ··· 1089 1090 lo->old_gfp_mask = mapping_gfp_mask(mapping); 1090 1091 mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS)); 1091 1092 1092 - error = loop_reconfigure_limits(lo, config->block_size); 1093 + lim = queue_limits_start_update(lo->lo_queue); 1094 + loop_update_limits(lo, &lim, config->block_size); 1095 + error = queue_limits_commit_update(lo->lo_queue, &lim); 1093 1096 if (error) 1094 1097 goto out_unlock; 1095 1098 ··· 1459 1458 1460 1459 static int loop_set_block_size(struct loop_device *lo, unsigned long arg) 1461 1460 { 1461 + struct queue_limits lim; 1462 1462 int err = 0; 1463 1463 1464 1464 if (lo->lo_state != Lo_bound) ··· 1472 1470 invalidate_bdev(lo->lo_device); 1473 1471 1474 1472 blk_mq_freeze_queue(lo->lo_queue); 1475 - err = loop_reconfigure_limits(lo, arg); 1473 + lim = queue_limits_start_update(lo->lo_queue); 1474 + loop_update_limits(lo, &lim, arg); 1475 + err = queue_limits_commit_update(lo->lo_queue, &lim); 1476 1476 loop_update_dio(lo); 1477 1477 blk_mq_unfreeze_queue(lo->lo_queue); 1478 1478