Signed-off-by: Jeff Garzik <[email protected]>
---
drivers/block/aoe/aoeblk.c | 64 +++++++++++++++++++++++++++++++++------------
1 files changed, 47 insertions(+), 17 deletions(-)
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 393b86a..04f9b03 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -64,13 +64,36 @@ static struct disk_attribute disk_attr_f
.show = aoedisk_show_fwver
};
-static void
+static int
aoedisk_add_sysfs(struct aoedev *d)
{
- sysfs_create_file(&d->gd->kobj, &disk_attr_state.attr);
- sysfs_create_file(&d->gd->kobj, &disk_attr_mac.attr);
- sysfs_create_file(&d->gd->kobj, &disk_attr_netif.attr);
- sysfs_create_file(&d->gd->kobj, &disk_attr_fwver.attr);
+ int err;
+
+ err = sysfs_create_file(&d->gd->kobj, &disk_attr_state.attr);
+ if (err)
+ return err;
+
+ err = sysfs_create_file(&d->gd->kobj, &disk_attr_mac.attr);
+ if (err)
+ goto err_out_state;
+
+ err = sysfs_create_file(&d->gd->kobj, &disk_attr_netif.attr);
+ if (err)
+ goto err_out_mac;
+
+ err = sysfs_create_file(&d->gd->kobj, &disk_attr_fwver.attr);
+ if (err)
+ goto err_out_netif;
+
+ return 0;
+
+err_out_netif:
+ sysfs_remove_link(&d->gd->kobj, "netif");
+err_out_mac:
+ sysfs_remove_link(&d->gd->kobj, "mac");
+err_out_state:
+ sysfs_remove_link(&d->gd->kobj, "state");
+ return err;
}
void
aoedisk_rm_sysfs(struct aoedev *d)
@@ -205,24 +228,18 @@ aoeblk_gdalloc(void *vp)
if (gd == NULL) {
printk(KERN_ERR "aoe: aoeblk_gdalloc: cannot allocate disk "
"structure for %ld.%ld\n", d->aoemajor, d->aoeminor);
- spin_lock_irqsave(&d->lock, flags);
- d->flags &= ~DEVFL_GDALLOC;
- spin_unlock_irqrestore(&d->lock, flags);
- return;
+ goto err_out;
}
d->bufpool = mempool_create_slab_pool(MIN_BUFS, buf_pool_cache);
if (d->bufpool == NULL) {
printk(KERN_ERR "aoe: aoeblk_gdalloc: cannot allocate bufpool "
"for %ld.%ld\n", d->aoemajor, d->aoeminor);
- put_disk(gd);
- spin_lock_irqsave(&d->lock, flags);
- d->flags &= ~DEVFL_GDALLOC;
- spin_unlock_irqrestore(&d->lock, flags);
- return;
+ goto err_out_put;
}
spin_lock_irqsave(&d->lock, flags);
+
blk_queue_make_request(&d->blkq, aoeblk_make_request);
gd->major = AOE_MAJOR;
gd->first_minor = d->sysminor * AOE_PARTITIONS;
@@ -231,16 +248,29 @@ aoeblk_gdalloc(void *vp)
gd->capacity = d->ssize;
snprintf(gd->disk_name, sizeof gd->disk_name, "etherd/e%ld.%ld",
d->aoemajor, d->aoeminor);
-
gd->queue = &d->blkq;
+
+ spin_unlock_irqrestore(&d->lock, flags);
+
+ if (aoedisk_add_sysfs(d))
+ goto err_out_put;
+
+ spin_lock_irqsave(&d->lock, flags);
d->gd = gd;
d->flags &= ~DEVFL_GDALLOC;
d->flags |= DEVFL_UP;
-
spin_unlock_irqrestore(&d->lock, flags);
add_disk(gd);
- aoedisk_add_sysfs(d);
+
+ return;
+
+err_out_put:
+ put_disk(gd);
+err_out:
+ spin_lock_irqsave(&d->lock, flags);
+ d->flags &= ~DEVFL_GDALLOC;
+ spin_unlock_irqrestore(&d->lock, flags);
}
void
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]