Skip to contentSkip to conversation

Atomic lock

PATCH New HIBINO Kei 1 participant 1 message Jan 7, 2001 Block layer

lore
Share & tools
lore

HIBINO Kei

author
#0 lore raw

PATCH 1/1 Atomic lock

I think atomic lock is needed for SMP code.

drivers/block/ll_rw_blk.c +2 -4
diff -ur linux-2.2.19pre6/drivers/block/ll_rw_blk.c linux-2.2.19pre6+lockfix/drivers/block/ll_rw_blk.c
@@ -578,11 +578,9 @@
 	count = bh->b_size >> 9;
 	sector = bh->b_rsector;
 
-	/* Uhhuh.. Nasty dead-lock possible here.. */
-	if (buffer_locked(bh))
+	if(test_and_set_bit(BH_Lock, &bh->b_state)) { /* Does atomic lock resolv problems? */
 		return;
-	/* Maybe the above fixes it, and maybe it doesn't boot. Life is interesting */
-	lock_buffer(bh);
+	}
 
 	if (blk_size[major]) {
 		unsigned long maxsector = (blk_size[major][MINOR(bh->b_rdev)] << 1) + 1;
drivers/block/md.c +2 -2
diff -ur linux-2.2.19pre6/drivers/block/md.c linux-2.2.19pre6+lockfix/drivers/block/md.c
@@ -778,9 +778,9 @@
 int md_make_request (int minor, int rw, struct buffer_head * bh)
 {
 	if (md_dev [minor].pers->make_request) {
-		if (buffer_locked(bh))
+		if(test_and_set_bit(BH_Lock, &bh->b_state)) { /* atomic lock */
 			return 0;
-		set_bit(BH_Lock, &bh->b_state);
+		}
 		if (rw == WRITE || rw == WRITEA) {
 			if (!buffer_dirty(bh)) {
 				bh->b_end_io(bh, test_bit(BH_Uptodate, &bh->b_state));

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/