loop.c (4b2731226d7de4302e4d8766c86e3a21c56dc3b1) loop.c (9f65c489b68d42427dc0651488dd260d678f525d)
1/*
2 * linux/drivers/block/loop.c
3 *
4 * Written by Theodore Ts'o, 3/29/93
5 *
6 * Copyright 1993 by Theodore Ts'o. Redistribution of this file is
7 * permitted under the GNU General Public License.
8 *

--- 760 unchanged lines hidden (view full) ---

769
770 error = -EINVAL;
771
772 /* size of the new backing store needs to be the same */
773 if (get_loop_size(lo, file) != get_loop_size(lo, old_file))
774 goto out_err;
775
776 /* and ... switch */
1/*
2 * linux/drivers/block/loop.c
3 *
4 * Written by Theodore Ts'o, 3/29/93
5 *
6 * Copyright 1993 by Theodore Ts'o. Redistribution of this file is
7 * permitted under the GNU General Public License.
8 *

--- 760 unchanged lines hidden (view full) ---

769
770 error = -EINVAL;
771
772 /* size of the new backing store needs to be the same */
773 if (get_loop_size(lo, file) != get_loop_size(lo, old_file))
774 goto out_err;
775
776 /* and ... switch */
777 disk_force_media_change(lo->lo_disk, DISK_EVENT_MEDIA_CHANGE);
777 blk_mq_freeze_queue(lo->lo_queue);
778 mapping_set_gfp_mask(old_file->f_mapping, lo->old_gfp_mask);
779 lo->lo_backing_file = file;
780 lo->old_gfp_mask = mapping_gfp_mask(file->f_mapping);
781 mapping_set_gfp_mask(file->f_mapping,
782 lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
783 loop_update_dio(lo);
784 blk_mq_unfreeze_queue(lo->lo_queue);

--- 467 unchanged lines hidden (view full) ---

1252 WQ_UNBOUND | WQ_FREEZABLE,
1253 0,
1254 lo->lo_number);
1255 if (!lo->workqueue) {
1256 error = -ENOMEM;
1257 goto out_unlock;
1258 }
1259
778 blk_mq_freeze_queue(lo->lo_queue);
779 mapping_set_gfp_mask(old_file->f_mapping, lo->old_gfp_mask);
780 lo->lo_backing_file = file;
781 lo->old_gfp_mask = mapping_gfp_mask(file->f_mapping);
782 mapping_set_gfp_mask(file->f_mapping,
783 lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
784 loop_update_dio(lo);
785 blk_mq_unfreeze_queue(lo->lo_queue);

--- 467 unchanged lines hidden (view full) ---

1253 WQ_UNBOUND | WQ_FREEZABLE,
1254 0,
1255 lo->lo_number);
1256 if (!lo->workqueue) {
1257 error = -ENOMEM;
1258 goto out_unlock;
1259 }
1260
1261 disk_force_media_change(lo->lo_disk, DISK_EVENT_MEDIA_CHANGE);
1260 set_disk_ro(lo->lo_disk, (lo->lo_flags & LO_FLAGS_READ_ONLY) != 0);
1261
1262 INIT_WORK(&lo->rootcg_work, loop_rootcg_workfn);
1263 INIT_LIST_HEAD(&lo->rootcg_cmd_list);
1264 INIT_LIST_HEAD(&lo->idle_worker_list);
1265 lo->worker_tree = RB_ROOT;
1266 timer_setup(&lo->timer, loop_free_idle_workers,
1267 TIMER_DEFERRABLE);

--- 137 unchanged lines hidden (view full) ---

1405 }
1406 mapping_set_gfp_mask(filp->f_mapping, gfp);
1407 /* This is safe: open() is still holding a reference. */
1408 module_put(THIS_MODULE);
1409 blk_mq_unfreeze_queue(lo->lo_queue);
1410
1411 partscan = lo->lo_flags & LO_FLAGS_PARTSCAN && bdev;
1412 lo_number = lo->lo_number;
1262 set_disk_ro(lo->lo_disk, (lo->lo_flags & LO_FLAGS_READ_ONLY) != 0);
1263
1264 INIT_WORK(&lo->rootcg_work, loop_rootcg_workfn);
1265 INIT_LIST_HEAD(&lo->rootcg_cmd_list);
1266 INIT_LIST_HEAD(&lo->idle_worker_list);
1267 lo->worker_tree = RB_ROOT;
1268 timer_setup(&lo->timer, loop_free_idle_workers,
1269 TIMER_DEFERRABLE);

--- 137 unchanged lines hidden (view full) ---

1407 }
1408 mapping_set_gfp_mask(filp->f_mapping, gfp);
1409 /* This is safe: open() is still holding a reference. */
1410 module_put(THIS_MODULE);
1411 blk_mq_unfreeze_queue(lo->lo_queue);
1412
1413 partscan = lo->lo_flags & LO_FLAGS_PARTSCAN && bdev;
1414 lo_number = lo->lo_number;
1415 disk_force_media_change(lo->lo_disk, DISK_EVENT_MEDIA_CHANGE);
1413out_unlock:
1414 mutex_unlock(&lo->lo_mutex);
1415 if (partscan) {
1416 /*
1417 * open_mutex has been held already in release path, so don't
1418 * acquire it if this function is called in such case.
1419 *
1420 * If the reread partition isn't from release path, lo_refcnt

--- 960 unchanged lines hidden (view full) ---

2381 spin_lock_init(&lo->lo_lock);
2382 spin_lock_init(&lo->lo_work_lock);
2383 disk->major = LOOP_MAJOR;
2384 disk->first_minor = i << part_shift;
2385 disk->minors = 1 << part_shift;
2386 disk->fops = &lo_fops;
2387 disk->private_data = lo;
2388 disk->queue = lo->lo_queue;
1416out_unlock:
1417 mutex_unlock(&lo->lo_mutex);
1418 if (partscan) {
1419 /*
1420 * open_mutex has been held already in release path, so don't
1421 * acquire it if this function is called in such case.
1422 *
1423 * If the reread partition isn't from release path, lo_refcnt

--- 960 unchanged lines hidden (view full) ---

2384 spin_lock_init(&lo->lo_lock);
2385 spin_lock_init(&lo->lo_work_lock);
2386 disk->major = LOOP_MAJOR;
2387 disk->first_minor = i << part_shift;
2388 disk->minors = 1 << part_shift;
2389 disk->fops = &lo_fops;
2390 disk->private_data = lo;
2391 disk->queue = lo->lo_queue;
2392 disk->events = DISK_EVENT_MEDIA_CHANGE;
2393 disk->event_flags = DISK_EVENT_FLAG_UEVENT;
2389 sprintf(disk->disk_name, "loop%d", i);
2390 add_disk(disk);
2391 mutex_unlock(&loop_ctl_mutex);
2392 return i;
2393
2394out_cleanup_tags:
2395 blk_mq_free_tag_set(&lo->tag_set);
2396out_free_idr:

--- 211 unchanged lines hidden ---
2394 sprintf(disk->disk_name, "loop%d", i);
2395 add_disk(disk);
2396 mutex_unlock(&loop_ctl_mutex);
2397 return i;
2398
2399out_cleanup_tags:
2400 blk_mq_free_tag_set(&lo->tag_set);
2401out_free_idr:

--- 211 unchanged lines hidden ---