From: "Stephen M. Cameron" <scameron@beardog.cce.hp.com>
To: linux-kernel@vger.kernel.org
Cc: linux-scsi@vger.kernel.org, akpm@linux-foundation.org,
axboe@kernel.dk, andrew.patterson@hp.com,
mikem@c18-ss-1-lb.cnet.com, scameron@beardog.cce.hp.com
Subject: [cciss: PATCH 08/17] Handle cases when cciss_add_disk fails.
Date: Thu, 20 Aug 2009 10:18:23 -0500 [thread overview]
Message-ID: <20090820151823.22833.20640.stgit@beardog.cce.hp.com> (raw)
In-Reply-To: <20090820151648.22833.14168.stgit@beardog.cce.hp.com>
Handle cases when cciss_add_disk fails.
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
drivers/block/cciss.c | 35 +++++++++++++++++++++++++----------
1 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 60fe3c6..7043b3b 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -199,6 +199,7 @@ static int scan_thread(void *data);
static int check_for_unit_attention(ctlr_info_t *h, CommandList_struct *c);
static void cciss_hba_release(struct device *dev);
static void cciss_device_release(struct device *dev);
+static void cciss_free_gendisk(ctlr_info_t *h, int drv_index);
#ifdef CONFIG_PROC_FS
static void cciss_procinit(int i);
@@ -1855,8 +1856,14 @@ static void cciss_update_drive_info(int ctlr, int drv_index, int first_time)
* (raid_leve == -1) then we want to update the
* logical drive's information.
*/
- if (drv_index || first_time)
- cciss_add_disk(h, disk, drv_index);
+ if (drv_index || first_time) {
+ if (cciss_add_disk(h, disk, drv_index) != 0) {
+ cciss_free_gendisk(h, drv_index);
+ printk(KERN_WARNING "cciss:%d could not update "
+ "disk %d\n", h->ctlr, drv_index);
+ --h->num_luns;
+ }
+ }
freeret:
kfree(inq_buff);
@@ -1890,6 +1897,12 @@ static int cciss_find_free_drive_index(int ctlr, int controller_node)
return -1;
}
+static void cciss_free_gendisk(ctlr_info_t *h, int drv_index)
+{
+ put_disk(h->gendisk[drv_index]);
+ h->gendisk[drv_index] = NULL;
+}
+
/* cciss_add_gendisk finds a free hba[]->drv structure
* and allocates a gendisk if needed, and sets the lunid
* in the drvinfo structure. It returns the index into
@@ -1930,8 +1943,7 @@ static int cciss_add_gendisk(ctlr_info_t *h, __u32 lunid, int controller_node)
return drv_index;
err_free_disk:
- put_disk(h->gendisk[drv_index]);
- h->gendisk[drv_index] = NULL;
+ cciss_free_gendisk(h, drv_index);
return -1;
}
@@ -1949,11 +1961,8 @@ static void cciss_add_controller_node(ctlr_info_t *h)
return;
drv_index = cciss_add_gendisk(h, 0, 1);
- if (drv_index == -1) {
- printk(KERN_WARNING "cciss%d: could not "
- "add disk 0.\n", h->ctlr);
- return;
- }
+ if (drv_index == -1)
+ goto error;
h->drv[drv_index].block_size = 512;
h->drv[drv_index].nr_blocks = 0;
h->drv[drv_index].heads = 0;
@@ -1962,7 +1971,13 @@ static void cciss_add_controller_node(ctlr_info_t *h)
h->drv[drv_index].raid_level = -1;
memset(h->drv[drv_index].serial_no, 0, 16);
disk = h->gendisk[drv_index];
- cciss_add_disk(h, disk, drv_index);
+ if (cciss_add_disk(h, disk, drv_index) == 0)
+ return;
+ cciss_free_gendisk(h, drv_index);
+error:
+ printk(KERN_WARNING "cciss%d: could not "
+ "add disk 0.\n", h->ctlr);
+ return;
}
/* This function will add and remove logical drives from the Logical
next prev parent reply other threads:[~2009-08-20 15:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-20 15:17 [cciss: PATCH 00/17] fix scan_thread, sysfs stuff, LUN addressing problem Stephen M. Cameron
2009-08-20 15:17 ` [cciss: PATCH 01/17] Remove sysfs entries for logical drives on driver cleanup Stephen M. Cameron
2009-08-20 15:17 ` [cciss: PATCH 02/17] Use one scan thread per controller and fix hang during rmmod Stephen M. Cameron
2009-08-20 15:17 ` [cciss: PATCH 03/17] Allow triggering of rescan of logical drive topology via sysfs entry Stephen M. Cameron
2009-08-20 15:18 ` [cciss: PATCH 04/17] Remove some unused code in rebuild_lun_table() Stephen M. Cameron
2009-08-20 15:18 ` [cciss: PATCH 05/17] Dynamically allocate struct device for each logical drive as needed Stephen M. Cameron
2009-08-20 15:18 ` [cciss: PATCH 06/17] Rearrange logical drive sysfs code to make the "changing a disk" path work Stephen M. Cameron
2009-08-20 15:18 ` [cciss: PATCH 07/17] Handle failure of blk_init_queue gracefully in cciss_add_disk Stephen M. Cameron
2009-08-20 15:18 ` Stephen M. Cameron [this message]
2009-08-20 15:18 ` [cciss: PATCH 09/17] Handle special case for sysfs attributes of the first logical drive Stephen M. Cameron
2009-08-20 15:18 ` [cciss: PATCH 10/17] Clear all sysfs-exposed data for deleted logical drives Stephen M. Cameron
2009-08-20 15:18 ` [cciss: PATCH 11/17] Fix usage_count check in rebuild_lun_table when triggered via sysfs Stephen M. Cameron
2009-08-20 15:18 ` [cciss: PATCH 12/17] Fix excessive gendisk freeing bug on driver unload Stephen M. Cameron
2009-08-20 15:18 ` [cciss: PATCH 13/17] Silence noisy per-disk messages output by cciss_read_capacity Stephen M. Cameron
2009-08-20 15:18 ` [cciss: PATCH 14/17] Preserve all 8 bytes of LUN ID for logical drives Stephen M. Cameron
2009-08-20 15:18 ` [cciss: PATCH 15/17] Add lunid attribute to each logical drive in /sys Stephen M. Cameron
2009-08-20 15:19 ` [cciss: PATCH 16/17] Add a "raid_level" " Stephen M. Cameron
2009-08-20 15:19 ` [cciss: PATCH 17/17] Add usage_count " Stephen M. Cameron
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=20090820151823.22833.20640.stgit@beardog.cce.hp.com \
--to=scameron@beardog.cce.hp.com \
--cc=akpm@linux-foundation.org \
--cc=andrew.patterson@hp.com \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mikem@c18-ss-1-lb.cnet.com \
/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
Powered by JetHome