Skip to contentSkip to conversation

loop setup calling bd_set_size too soon

PATCH New Chris Mason 1 participant 1 message Mar 29, 2004 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 loop setup calling bd_set_size too soon

Hello,

I think Andrew and I managed to mismerge the loop setup race fix. loop_set_fd is using get_capacity() to read the size of the disk and sending that to bd_set_size.

But, it is doing this before calling set_capacity, so the size being used is wrong. This should clean things up:

drivers/block/loop.c +1 -1
Index: linux.t/drivers/block/loop.c
===================================================================
@@ -687,7 +687,6 @@ static int loop_set_fd(struct loop_devic
 	lo->transfer = NULL;
 	lo->ioctl = NULL;
 	lo->lo_sizelimit = 0;
-	bd_set_size(bdev,(loff_t)get_capacity(disks[lo->lo_number])<<9);
 	lo->old_gfp_mask = mapping_gfp_mask(mapping);
 	mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
 
@@ -702,6 +701,7 @@ static int loop_set_fd(struct loop_devic
 	lo->lo_queue->unplug_fn = loop_unplug;
 
 	set_capacity(disks[lo->lo_number], size);
+	bd_set_size(bdev, size << 9);
 
 	set_blocksize(bdev, lo_blocksize);