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: move updating lo_flags out of loop_set_status_from_info

While loop_configure simplify assigns the flags passed in by userspace,
loop_set_status only looks at the two changeable flags, and currently
has to do a complicate dance to implement that.

Move assign lo->lo_flags out of loop_set_status_from_info into the
callers and thus drastically simplify the lo_flags handling in
loop_set_status.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20250110073750.1582447-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
ae074d07 b03732a9

+8 -15
+8 -15
drivers/block/loop.c
··· 971 971 972 972 memcpy(lo->lo_file_name, info->lo_file_name, LO_NAME_SIZE); 973 973 lo->lo_file_name[LO_NAME_SIZE-1] = 0; 974 - lo->lo_flags = info->lo_flags; 975 974 return 0; 976 975 } 977 976 ··· 1068 1069 error = loop_set_status_from_info(lo, &config->info); 1069 1070 if (error) 1070 1071 goto out_unlock; 1072 + lo->lo_flags = config->info.lo_flags; 1071 1073 1072 1074 if (!(file->f_mode & FMODE_WRITE) || !(mode & BLK_OPEN_WRITE) || 1073 1075 !file->f_op->write_iter) ··· 1258 1258 loop_set_status(struct loop_device *lo, const struct loop_info64 *info) 1259 1259 { 1260 1260 int err; 1261 - int prev_lo_flags; 1262 1261 bool partscan = false; 1263 1262 bool size_changed = false; 1264 1263 ··· 1279 1280 /* I/O need to be drained during transfer transition */ 1280 1281 blk_mq_freeze_queue(lo->lo_queue); 1281 1282 1282 - prev_lo_flags = lo->lo_flags; 1283 - 1284 1283 err = loop_set_status_from_info(lo, info); 1285 1284 if (err) 1286 1285 goto out_unfreeze; 1287 1286 1288 - /* Mask out flags that can't be set using LOOP_SET_STATUS. */ 1289 - lo->lo_flags &= LOOP_SET_STATUS_SETTABLE_FLAGS; 1290 - /* For those flags, use the previous values instead */ 1291 - lo->lo_flags |= prev_lo_flags & ~LOOP_SET_STATUS_SETTABLE_FLAGS; 1292 - /* For flags that can't be cleared, use previous values too */ 1293 - lo->lo_flags |= prev_lo_flags & ~LOOP_SET_STATUS_CLEARABLE_FLAGS; 1287 + partscan = !(lo->lo_flags & LO_FLAGS_PARTSCAN) && 1288 + (info->lo_flags & LO_FLAGS_PARTSCAN); 1289 + 1290 + lo->lo_flags &= ~(LOOP_SET_STATUS_SETTABLE_FLAGS | 1291 + LOOP_SET_STATUS_CLEARABLE_FLAGS); 1292 + lo->lo_flags |= (info->lo_flags & LOOP_SET_STATUS_SETTABLE_FLAGS); 1294 1293 1295 1294 if (size_changed) { 1296 1295 loff_t new_size = get_size(lo->lo_offset, lo->lo_sizelimit, ··· 1301 1304 1302 1305 out_unfreeze: 1303 1306 blk_mq_unfreeze_queue(lo->lo_queue); 1304 - 1305 - if (!err && (lo->lo_flags & LO_FLAGS_PARTSCAN) && 1306 - !(prev_lo_flags & LO_FLAGS_PARTSCAN)) { 1307 + if (partscan) 1307 1308 clear_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state); 1308 - partscan = true; 1309 - } 1310 1309 out_unlock: 1311 1310 mutex_unlock(&lo->lo_mutex); 1312 1311 if (partscan)