[d-kernel] PATCH: acpi irq safe gendisk_lock

Konstantin A. Lepikhov lakostis at anti-leasure.ru
Tue Oct 19 00:53:52 MSD 2004


Здравствуйте!

МБ этот патчик в -fix-acpi? Найден в логах BK.

-- 
WBR, Konstantin	      chat with ==>ICQ: 109916175
     Lepikhov,	      speak  to ==>JID: lakostis �� jabber.org
aka L.A. Kostis       write  to ==>mailto:lakostis �� pisem.net.nospam

...The information is like the bank... 			  (c) EC8OR
----------- следущая часть -----------
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/09/29 13:56:57-03:00 axboe �� suse.de 
#   [PATCH] irq safe gendisk_lock
#   
#   Hi,
#   
#   There's a problem with gendisk_lock in 2.4 right now - it never disables
#   interrupts, but io completion stat updates can grab the lock from
#   end_that_request_last -> req_finished_io -> locate_hd_struct ->
#   get_gendisk. So make the lock irq safe so we don't risk deadlocking with
#   eg people doing add_gendisk(). This race has been seen and traced in
#   real life.
#   
#   ===== drivers/block/genhd.c 1.26 vs edited =====
#   TAG: MailDone
# 
# drivers/block/genhd.c
#   2004/09/29 04:00:23-03:00 axboe �� suse.de +14 -10
#   irq safe gendisk_lock
# 
# arch/i386/kernel/acpi.c
#   2004/09/14 17:27:58-03:00 ha505 �� hszk.bme.hu +2 -0
#   [i386] acpi.c: implicit declaration of mp_irqs_alloc()
# 
diff -Nru a/arch/i386/kernel/acpi.c b/arch/i386/kernel/acpi.c
--- a/arch/i386/kernel/acpi.c	2004-09-29 12:03:30 -07:00
+++ b/arch/i386/kernel/acpi.c	2004-09-29 12:03:30 -07:00
@@ -389,6 +389,8 @@
 }
 
 
+extern int mp_irqs_alloc(void);
+
 /*
  * acpi_boot_init()
  *  called from setup_arch(), always.
diff -Nru a/drivers/block/genhd.c b/drivers/block/genhd.c
--- a/drivers/block/genhd.c	2004-09-29 12:03:30 -07:00
+++ b/drivers/block/genhd.c	2004-09-29 12:03:30 -07:00
@@ -49,8 +49,9 @@
 add_gendisk(struct gendisk *gp)
 {
 	struct gendisk *sgp;
+	unsigned long flags;
 
-	write_lock(&gendisk_lock);
+	write_lock_irqsave(&gendisk_lock, flags);
 
 	/*
  	 *	In 2.5 this will go away. Fix the drivers who rely on
@@ -70,7 +71,7 @@
 	gp->next = gendisk_head;
 	gendisk_head = gp;
 out:
-	write_unlock(&gendisk_lock);
+	write_unlock_irqrestore(&gendisk_lock, flags);
 }
 
 EXPORT_SYMBOL(add_gendisk);
@@ -87,15 +88,16 @@
 del_gendisk(struct gendisk *gp)
 {
 	struct gendisk **gpp;
+	unsigned long flags;
 
-	write_lock(&gendisk_lock);
+	write_lock_irqsave(&gendisk_lock, flags);
 	gendisk_array[gp->major] = NULL;
 	for (gpp = &gendisk_head; *gpp; gpp = &((*gpp)->next))
 		if (*gpp == gp)
 			break;
 	if (*gpp)
 		*gpp = (*gpp)->next;
-	write_unlock(&gendisk_lock);
+	write_unlock_irqrestore(&gendisk_lock, flags);
 }
 
 EXPORT_SYMBOL(del_gendisk);
@@ -113,8 +115,9 @@
 {
 	struct gendisk *gp = NULL;
 	int maj = MAJOR(dev);
+	unsigned long flags;
 
-	read_lock(&gendisk_lock);
+	read_lock_irqsave(&gendisk_lock, flags);
 	if ((gp = gendisk_array[maj]))
 		goto out;
 
@@ -123,7 +126,7 @@
 		if (gp->major == maj)
 			break;
 out:
-	read_unlock(&gendisk_lock);
+	read_unlock_irqrestore(&gendisk_lock, flags);
 	return gp;
 }
 
@@ -143,12 +146,13 @@
 {
 	struct gendisk *gp;
 	int error = 0;
+	unsigned long flags;
 
-	read_lock(&gendisk_lock);
+	read_lock_irqsave(&gendisk_lock, flags);
 	for (gp = gendisk_head; gp; gp = gp->next)
 		if ((error = walk(gp, data)))
 			break;
-	read_unlock(&gendisk_lock);
+	read_unlock_irqrestore(&gendisk_lock, flags);
 
 	return error;
 }
@@ -160,7 +164,7 @@
 	struct gendisk *gp;
 	loff_t pos = *ppos;
 
-	read_lock(&gendisk_lock);
+	read_lock_irq(&gendisk_lock);
 	for (gp = gendisk_head; gp; gp = gp->next)
 		if (!pos--)
 			return gp;
@@ -175,7 +179,7 @@
 
 static void part_stop(struct seq_file *s, void *v)
 {
-	read_unlock(&gendisk_lock);
+	read_unlock_irq(&gendisk_lock);
 }
 
 static int part_show(struct seq_file *s, void *v)


More information about the devel-kernel mailing list