mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Garzik <jeff@garzik.org>
To: Greg KH <greg@kroah.com>, ecashin@coraid.com
Cc: Andrew Morton <akpm@osdl.org>, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] drivers/block/aoe: handle sysfs errors
Date: Wed, 4 Oct 2006 09:58:19 -0400	[thread overview]
Message-ID: <20061004135819.GA29526@havoc.gtf.org> (raw)


Signed-off-by: Jeff Garzik <jeff@garzik.org>

---

 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

             reply	other threads:[~2006-10-04 13:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-04 13:58 Jeff Garzik [this message]
2006-10-04 23:26 ` Greg KH
2006-10-04 23:31 ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061004135819.GA29526@havoc.gtf.org \
    --to=jeff@garzik.org \
    --cc=akpm@osdl.org \
    --cc=ecashin@coraid.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®