patch-pre2.0.6 linux/drivers/block/ll_rw_blk.c

Next file: linux/drivers/cdrom/aztcd.c
Previous file: linux/drivers/block/ide-cd.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file pre2.0.5/linux/drivers/block/ll_rw_blk.c linux/drivers/block/ll_rw_blk.c
@@ -286,9 +286,17 @@
 
 	count = bh->b_size >> 9;
 	sector = bh->b_rsector;
+
+	/* Uhhuh.. Nasty dead-lock possible here.. */
+	if (buffer_locked(bh))
+		return;
+	/* Maybe the above fixes it, and maybe it doesn't boot. Life is interesting */
+
+	lock_buffer(bh);
+
 	if (blk_size[major])
 		if (blk_size[major][MINOR(bh->b_rdev)] < (sector + count)>>1) {
-			bh->b_state = 0;
+			bh->b_state &= (1 << BH_Lock) | (1 << BH_FreeOnIO);
                         /* This may well happen - the kernel calls bread()
                            without checking the size of the device, e.g.,
                            when mounting a device. */
@@ -298,13 +306,9 @@
                                kdevname(bh->b_rdev), rw,
                                (sector + count)>>1,
                                blk_size[major][MINOR(bh->b_rdev)]);
+			unlock_buffer(bh);
 			return;
 		}
-	/* Uhhuh.. Nasty dead-lock possible here.. */
-	if (buffer_locked(bh))
-		return;
-	/* Maybe the above fixes it, and maybe it doesn't boot. Life is interesting */
-	lock_buffer(bh);
 
 	rw_ahead = 0;	/* normal case; gets changed below for READA/WRITEA */
 	switch (rw) {

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this