@@ -311,6 +311,13 @@ static void loop_clear_limits(struct loop_device *lo, int mode)
311
311
lim .discard_granularity = 0 ;
312
312
}
313
313
314
+ /*
315
+ * XXX: this updates the queue limits without freezing the queue, which
316
+ * is against the locking protocol and dangerous. But we can't just
317
+ * freeze the queue as we're inside the ->queue_rq method here. So this
318
+ * should move out into a workqueue unless we get the file operations to
319
+ * advertise if they support specific fallocate operations.
320
+ */
314
321
queue_limits_commit_update (lo -> lo_queue , & lim );
315
322
}
316
323
@@ -1091,6 +1098,7 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,
1091
1098
1092
1099
lim = queue_limits_start_update (lo -> lo_queue );
1093
1100
loop_update_limits (lo , & lim , config -> block_size );
1101
+ /* No need to freeze the queue as the device isn't bound yet. */
1094
1102
error = queue_limits_commit_update (lo -> lo_queue , & lim );
1095
1103
if (error )
1096
1104
goto out_unlock ;
@@ -1151,7 +1159,12 @@ static void __loop_clr_fd(struct loop_device *lo)
1151
1159
lo -> lo_sizelimit = 0 ;
1152
1160
memset (lo -> lo_file_name , 0 , LO_NAME_SIZE );
1153
1161
1154
- /* reset the block size to the default */
1162
+ /*
1163
+ * Reset the block size to the default.
1164
+ *
1165
+ * No queue freezing needed because this is called from the final
1166
+ * ->release call only, so there can't be any outstanding I/O.
1167
+ */
1155
1168
lim = queue_limits_start_update (lo -> lo_queue );
1156
1169
lim .logical_block_size = SECTOR_SIZE ;
1157
1170
lim .physical_block_size = SECTOR_SIZE ;
@@ -1471,9 +1484,10 @@ static int loop_set_block_size(struct loop_device *lo, unsigned long arg)
1471
1484
sync_blockdev (lo -> lo_device );
1472
1485
invalidate_bdev (lo -> lo_device );
1473
1486
1474
- blk_mq_freeze_queue (lo -> lo_queue );
1475
1487
lim = queue_limits_start_update (lo -> lo_queue );
1476
1488
loop_update_limits (lo , & lim , arg );
1489
+
1490
+ blk_mq_freeze_queue (lo -> lo_queue );
1477
1491
err = queue_limits_commit_update (lo -> lo_queue , & lim );
1478
1492
loop_update_dio (lo );
1479
1493
blk_mq_unfreeze_queue (lo -> lo_queue );
0 commit comments