aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Sandoval <osandov@fb.com>2017-03-01 13:42:38 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-12 00:41:45 -0500
commit8ca25e39ec2d67df1f69f08c1d4ad0d6310a5c5b (patch)
tree04a7da30d35164c171c2b490141494549b579f3a
parent50447afd96145b6d3d7aea412da178dce95f1f9b (diff)
loop: fix LO_FLAGS_PARTSCAN hang
commit e02898b423802b1f3a3aaa7f16e896da069ba8f7 upstream. 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: ecdd09597a57 ("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>
-rw-r--r--drivers/block/loop.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index ccc3acc0c5ba..24d6cefceb32 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1142,13 +1142,6 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
1142 (info->lo_flags & LO_FLAGS_AUTOCLEAR)) 1142 (info->lo_flags & LO_FLAGS_AUTOCLEAR))
1143 lo->lo_flags ^= LO_FLAGS_AUTOCLEAR; 1143 lo->lo_flags ^= LO_FLAGS_AUTOCLEAR;
1144 1144
1145 if ((info->lo_flags & LO_FLAGS_PARTSCAN) &&
1146 !(lo->lo_flags & LO_FLAGS_PARTSCAN)) {
1147 lo->lo_flags |= LO_FLAGS_PARTSCAN;
1148 lo->lo_disk->flags &= ~GENHD_FL_NO_PART_SCAN;
1149 loop_reread_partitions(lo, lo->lo_device);
1150 }
1151
1152 lo->lo_encrypt_key_size = info->lo_encrypt_key_size; 1145 lo->lo_encrypt_key_size = info->lo_encrypt_key_size;
1153 lo->lo_init[0] = info->lo_init[0]; 1146 lo->lo_init[0] = info->lo_init[0];
1154 lo->lo_init[1] = info->lo_init[1]; 1147 lo->lo_init[1] = info->lo_init[1];
@@ -1163,6 +1156,14 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
1163 1156
1164 exit: 1157 exit:
1165 blk_mq_unfreeze_queue(lo->lo_queue); 1158 blk_mq_unfreeze_queue(lo->lo_queue);
1159
1160 if (!err && (info->lo_flags & LO_FLAGS_PARTSCAN) &&
1161 !(lo->lo_flags & LO_FLAGS_PARTSCAN)) {
1162 lo->lo_flags |= LO_FLAGS_PARTSCAN;
1163 lo->lo_disk->flags &= ~GENHD_FL_NO_PART_SCAN;
1164 loop_reread_partitions(lo, lo->lo_device);
1165 }
1166
1166 return err; 1167 return err;
1167} 1168}
1168 1169