Skip to contentSkip to conversation

AOE: fix up the block device registration so that it actually works now.

PATCH In review Greg KH 2 participants 6 messages Jan 19, 2005 – Jan 20, 2005

Subsystems (2)
lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 AOE: fix up the block device registration so that it actually works now.

Ed, I need the following patch against the latest -bk tree in order to get the aoe code to load and work properly. Does it look good to you?

thanks,

greg k-h

-------------

AOE: fix up the block device registration so that it actually works now.

drivers/block/aoe/aoeblk.c +1 -0
diff -Nru a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
@@ -249,6 +249,7 @@
 aoeblk_exit(void)
 {
 	kmem_cache_destroy(buf_pool_cache);
+	unregister_blkdev(AOE_MAJOR, DEVICE_NAME);
 }
 
 int __init
drivers/block/aoe/aoemain.c +0 -5
diff -Nru a/drivers/block/aoe/aoemain.c b/drivers/block/aoe/aoemain.c
@@ -82,11 +82,6 @@
 	ret = aoenet_init();
 	if (ret)
 		goto net_fail;
-	ret = register_blkdev(AOE_MAJOR, DEVICE_NAME);
-	if (ret < 0) {
-		printk(KERN_ERR "aoe: aoeblk_init: can't register major\n");
-		goto blkreg_fail;
-	}
 
 	printk(KERN_INFO
 	       "aoe: aoe_init: AoE v2.6-%s initialised.\n",
#1 lore raw
Quoted 2 lines · Greg KH

Ed, I need the following patch against the latest -bk tree in order to get the aoe code to load and work properly. Does it look good to you?

I'm having trouble seeing what's in -bk. I have a clone of bk://linux.bkbits.net/linux-2.5, but when I "bk pull" there it says "Nothing to pull." And my clone doesn't have all the aoe patches I've seen get pushed to -bk.

...

Quoted 10 lines

-------------

AOE: fix up the block device registration so that it actually works now.

diff -Nru a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c

drivers/block/aoe/aoeblk.c line 253

Quoted 5 lines
drivers/block/aoe/aoeblk.c +1 -0
@@ -249,6 +249,7 @@
 aoeblk_exit(void)
 {
 	kmem_cache_destroy(buf_pool_cache);
+	unregister_blkdev(AOE_MAJOR, DEVICE_NAME);
 }

The unregister_blkdev should already be in aoemain.c:aoe_exit.

static void
aoe_exit(void)

{
	discover_timer(TKILL);

	aoenet_exit();
	unregister_blkdev(AOE_MAJOR, DEVICE_NAME);
	aoechr_exit();
	aoedev_exit();
	aoeblk_exit();		/* free cache after de-allocating bufs */
}
Quoted 6 lines
drivers/block/aoe/aoeblk.c +0 -0
 int __init

diff -Nru a/drivers/block/aoe/aoemain.c b/drivers/block/aoe/aoemain.c

drivers/block/aoe/aoemain.c +0 -0
@@ -82,11 +82,6 @@
 	ret = aoenet_init();

drivers/block/aoe/aoemain.c line 87

Quoted 10 lines
drivers/block/aoe/aoemain.c +0 -5
 	if (ret)
 		goto net_fail;
-	ret = register_blkdev(AOE_MAJOR, DEVICE_NAME);
-	if (ret < 0) {
-		printk(KERN_ERR "aoe: aoeblk_init: can't register major\n");
-		goto blkreg_fail;
-	}
 
 	printk(KERN_INFO
 	       "aoe: aoe_init: AoE v2.6-%s initialised.\n",

Hmm. I'll try to send a patch against usb, since I can pull from there.

Signature · 1 line
  Ed L Cashin <[email protected]>
author
#2 lore raw
Quoted 11 lines · Ed L Cashin

drivers/block/aoe/aoeblk.c line 253

Quoted 9 lines

diff -Nru a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c

drivers/block/aoe/aoeblk.c +1 -0
@@ -249,6 +249,7 @@
 aoeblk_exit(void)
 {
 	kmem_cache_destroy(buf_pool_cache);
+	unregister_blkdev(AOE_MAJOR, DEVICE_NAME);
 }

The unregister_blkdev should already be in aoemain.c:aoe_exit.

Why? You do a register_blockdev() in this file, so if something fails, you should also unregister here. The big problem is you were trying to register the same major twice :(

thanks,

greg k-h

#3 lore raw
Quoted 13 lines · Greg KH
Quoted 11 lines · Ed L Cashin

drivers/block/aoe/aoeblk.c line 253

Quoted 9 lines

diff -Nru a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c

drivers/block/aoe/aoeblk.c +1 -0
@@ -249,6 +249,7 @@
 aoeblk_exit(void)
 {
 	kmem_cache_destroy(buf_pool_cache);
+	unregister_blkdev(AOE_MAJOR, DEVICE_NAME);
 }

The unregister_blkdev should already be in aoemain.c:aoe_exit.

Quoted 2 lines

Why? You do a register_blockdev() in this file, so if something fails, you should also unregister here.

No, the register_blkdev that you see in aoeblk.c is the artifact of a snafu I made in patch submission. I submitted a small patch yesterday (ID below) that corrects the snafu and makes block-2.6 the same as the driver I have.

Message-ID: <[email protected]>

In the current aoe driver, register_blkdev is only in aoemain.c:aoe_init, and that register_blkdev is the last step in the initialization sequence. If register_blkdev fails, then I don't unregister_blkdev, because presumably I shouldn't undo something that wasn't done.

Quoted 2 lines

The big problem is you were trying to
register the same major twice :(

That's because two snippets of my recent fixes got orphaned (my fault) instead of getting included in the submitted patches, so instead of my patches moving register_blkdev it got duplicated. The patch I sent yesterday corrects the problem and brings block-2.6 back into accordance with what I've got. Sorry for the confusion.

Signature · 1 line
  Ed L Cashin <[email protected]>
author
#4 lore raw
Quoted 18 lines · Ed L Cashin
Quoted 13 lines · Greg KH
Quoted 11 lines · Ed L Cashin

drivers/block/aoe/aoeblk.c line 253

Quoted 9 lines

diff -Nru a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c

drivers/block/aoe/aoeblk.c +1 -0
@@ -249,6 +249,7 @@
 aoeblk_exit(void)
 {
 	kmem_cache_destroy(buf_pool_cache);
+	unregister_blkdev(AOE_MAJOR, DEVICE_NAME);
 }

The unregister_blkdev should already be in aoemain.c:aoe_exit.

Quoted 2 lines

Why? You do a register_blockdev() in this file, so if something fails, you should also unregister here.

Quoted 6 lines

No, the register_blkdev that you see in aoeblk.c is the artifact of a snafu I made in patch submission. I submitted a small patch yesterday (ID below) that corrects the snafu and makes block-2.6 the same as the driver I have.

Message-ID: <[email protected]>

Ah, missed that as you didn't CC: me... I'll apply that one later on today.

thanks,

greg k-h

#5 lore raw
In reply to Greg KH
Quoted 2 lines · Greg KH

Ed, I need the following patch against the latest -bk tree in order to get the aoe code to load and work properly. Does it look good to you?

I hadn't submitted all my changes correctly, sorry. Here's a patch against block-2.6 that rectifies the omission.

Remove allow aoeblk_exit to be called from __init code, and move register_blkdev into aoe_init.

linux/drivers/block/aoe/aoeblk.c renamed from drivers/block/aoe/aoeblk.c +1 -8
diff -uprN block-2.6-export-a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
@@ -245,7 +252,7 @@ aoeblk_gdalloc(void *vp)
 		d->fw_ver, (long long)d->ssize);
 }
 
-void __exit
+void
 aoeblk_exit(void)
 {
 	kmem_cache_destroy(buf_pool_cache);
@@ -254,19 +261,12 @@ aoeblk_exit(void)
 int __init
 aoeblk_init(void)
 {
-	int n;
-
 	buf_pool_cache = kmem_cache_create("aoe_bufs", 
 					   sizeof(struct buf),
 					   0, 0, NULL, NULL);
 	if (buf_pool_cache == NULL)
 		return -ENOMEM;
 
-	n = register_blkdev(AOE_MAJOR, DEVICE_NAME);
-	if (n < 0) {
-		printk(KERN_ERR "aoe: aoeblk_init: can't register major\n");
-		return n;
-	}
 	return 0;
 }
 
Signature · 2 lines
-- 
  Ed L Cashin <[email protected]>