mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
loop: fix LO_FLAGS_PARTSCAN hang
commite02898b423upstream. loop_reread_partitions() needs to do I/O, but we just froze the queue, so we end up waiting forever. This can easily be reproduced with losetup -P. Fix it by moving the reread to after we unfreeze the queue. Fixes:ecdd09597a("block/loop: fix race between I/O and set_status") Reported-by: Tejun Heo <tj@kernel.org> Signed-off-by: Omar Sandoval <osandov@fb.com> Reviewed-by: Ming Lei <tom.leiming@gmail.com> Signed-off-by: Jens Axboe <axboe@fb.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
356d71df73
commit
cd3db55c64
@@ -1153,13 +1153,6 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
|
|||||||
(info->lo_flags & LO_FLAGS_AUTOCLEAR))
|
(info->lo_flags & LO_FLAGS_AUTOCLEAR))
|
||||||
lo->lo_flags ^= LO_FLAGS_AUTOCLEAR;
|
lo->lo_flags ^= LO_FLAGS_AUTOCLEAR;
|
||||||
|
|
||||||
if ((info->lo_flags & LO_FLAGS_PARTSCAN) &&
|
|
||||||
!(lo->lo_flags & LO_FLAGS_PARTSCAN)) {
|
|
||||||
lo->lo_flags |= LO_FLAGS_PARTSCAN;
|
|
||||||
lo->lo_disk->flags &= ~GENHD_FL_NO_PART_SCAN;
|
|
||||||
loop_reread_partitions(lo, lo->lo_device);
|
|
||||||
}
|
|
||||||
|
|
||||||
lo->lo_encrypt_key_size = info->lo_encrypt_key_size;
|
lo->lo_encrypt_key_size = info->lo_encrypt_key_size;
|
||||||
lo->lo_init[0] = info->lo_init[0];
|
lo->lo_init[0] = info->lo_init[0];
|
||||||
lo->lo_init[1] = info->lo_init[1];
|
lo->lo_init[1] = info->lo_init[1];
|
||||||
@@ -1174,6 +1167,14 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
blk_mq_unfreeze_queue(lo->lo_queue);
|
blk_mq_unfreeze_queue(lo->lo_queue);
|
||||||
|
|
||||||
|
if (!err && (info->lo_flags & LO_FLAGS_PARTSCAN) &&
|
||||||
|
!(lo->lo_flags & LO_FLAGS_PARTSCAN)) {
|
||||||
|
lo->lo_flags |= LO_FLAGS_PARTSCAN;
|
||||||
|
lo->lo_disk->flags &= ~GENHD_FL_NO_PART_SCAN;
|
||||||
|
loop_reread_partitions(lo, lo->lo_device);
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user