mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Stephen M. Cameron" <scameron@beardog.cce.hp.com>
To: akpm@linux-foundation.org, axboe@kernel.dk
Cc: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
	andrew.patterson@hp.com, mikem@beardog.cce.hp.com,
	scameron@beardog.cce.hp.com
Subject: [PATCH 09/20] cciss: Handle special case for sysfs attributes of the first logical drive.
Date: Thu, 17 Sep 2009 13:47:34 -0500	[thread overview]
Message-ID: <20090917184734.15105.71632.stgit@beardog.cce.hp.com> (raw)
In-Reply-To: <20090917184310.15105.43508.stgit@beardog.cce.hp.com>

For c0dx where x is not 0, we handle deletion and addition simply,
but for c0d0, there is the special case that even when there's no
disk, the device node exists so that the controller may be accessed.
So, for c0d0, we only create the sysfs entries once, when a controller
is added, and only remove them once, when a controller is being
taken down.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---

 drivers/block/cciss.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 7043b3b..98d8efe 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -681,6 +681,10 @@ static long cciss_create_ld_sysfs_entry(struct ctlr_info *h,
 {
 	struct device *dev;
 
+	/* Special case for c*d0, we only create it once. */
+	if (drv_index == 0 && h->drv[drv_index].dev != NULL)
+		return 0;
+
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
 		return -ENOMEM;
@@ -697,9 +701,15 @@ static long cciss_create_ld_sysfs_entry(struct ctlr_info *h,
 /*
  * Remove sysfs entries for a logical drive.
  */
-static void cciss_destroy_ld_sysfs_entry(struct ctlr_info *h, int drv_index)
+static void cciss_destroy_ld_sysfs_entry(struct ctlr_info *h, int drv_index,
+	int ctlr_exiting)
 {
 	struct device *dev = h->drv[drv_index].dev;
+
+	/* special case for c*d0, we only destroy it on controller exit */
+	if (drv_index == 0 && !ctlr_exiting)
+		return;
+
 	device_del(dev);
 	put_device(dev); /* the "final" put. */
 	h->drv[drv_index].dev = NULL;
@@ -1919,6 +1929,7 @@ static int cciss_add_gendisk(ctlr_info_t *h, __u32 lunid, int controller_node)
 	drv_index = cciss_find_free_drive_index(h->ctlr, controller_node);
 	if (drv_index == -1)
 		return -1;
+
 	/*Check if the gendisk needs to be allocated */
 	if (!h->gendisk[drv_index]) {
 		h->gendisk[drv_index] =
@@ -2164,7 +2175,7 @@ static int deregister_disk(ctlr_info_t *h, int drv_index,
 	if (h->gendisk[0] != disk) {
 		struct request_queue *q = disk->queue;
 		if (disk->flags & GENHD_FL_UP) {
-			cciss_destroy_ld_sysfs_entry(h, drv_index);
+			cciss_destroy_ld_sysfs_entry(h, drv_index, 0);
 			del_gendisk(disk);
 		}
 		if (q) {
@@ -2210,7 +2221,6 @@ static int deregister_disk(ctlr_info_t *h, int drv_index,
 				 * indicate that this element of the drive
 				 * array is free.
 				 */
-
 	if (clear_all) {
 		/* check to see if it was the last disk */
 		if (drv == h->drv + h->highest_lun) {
@@ -4328,7 +4338,7 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev)
 			struct request_queue *q = disk->queue;
 
 			if (disk->flags & GENHD_FL_UP) {
-				cciss_destroy_ld_sysfs_entry(hba[i], j);
+				cciss_destroy_ld_sysfs_entry(hba[i], j, 1);
 				del_gendisk(disk);
 			}
 			if (q)


  parent reply	other threads:[~2009-09-17 18:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-17 18:46 [PATCH 00/20] cciss: fix scan_thread, sysfs stuff, dynamically allocate per drive structure Stephen M. Cameron
2009-09-17 18:46 ` [PATCH 01/20] cciss: Remove sysfs entries for logical drives on driver cleanup Stephen M. Cameron
2009-09-17 18:46 ` [PATCH 02/20] cciss: Use one scan thread per controller and fix hang during rmmod Stephen M. Cameron
2009-09-17 18:47 ` [PATCH 03/20] cciss: Allow triggering of rescan of logical drive topology via sysfs entry Stephen M. Cameron
2009-09-17 18:47 ` [PATCH 04/20] cciss: Remove some unused code in rebuild_lun_table() Stephen M. Cameron
2009-09-17 18:47 ` [PATCH 05/20] cciss: Dynamically allocate struct device for each logical drive as needed Stephen M. Cameron
2009-09-17 18:47 ` [PATCH 06/20] cciss: Rearrange logical drive sysfs code to make the "changing a disk" path work Stephen M. Cameron
2009-09-17 18:47 ` [PATCH 07/20] cciss: Handle failure of blk_init_queue gracefully in cciss_add_disk Stephen M. Cameron
2009-09-17 18:47 ` [PATCH 08/20] cciss: Handle cases when cciss_add_disk fails Stephen M. Cameron
2009-09-17 18:47 ` Stephen M. Cameron [this message]
2009-09-17 18:47 ` [PATCH 10/20] cciss: Clear all sysfs-exposed data for deleted logical drives Stephen M. Cameron
2009-09-17 18:47 ` [PATCH 11/20] cciss: Fix usage_count check in rebuild_lun_table when triggered via sysfs Stephen M. Cameron
2009-09-17 18:47 ` [PATCH 12/20] cciss: Fix excessive gendisk freeing bug on driver unload Stephen M. Cameron
2009-09-17 18:47 ` [PATCH 13/20] cciss: Silence noisy per-disk messages output by cciss_read_capacity Stephen M. Cameron
2009-09-17 18:48 ` [PATCH 14/20] cciss: Preserve all 8 bytes of LUN ID for logical drives Stephen M. Cameron
2009-09-17 18:48 ` [PATCH 15/20] cciss: Don't check h->busy_initializing in cciss_open() Stephen M. Cameron
2009-09-17 18:48 ` [PATCH 16/20] cciss: Add lunid attribute to each logical drive in /sys Stephen M. Cameron
2009-09-17 18:48 ` [PATCH 17/20] cciss: fix some magic numbers in the raid-level decoding Stephen M. Cameron
2009-09-17 18:48 ` [PATCH 18/20] cciss: Add a "raid_level" attribute to each logical drive in /sys Stephen M. Cameron
2009-09-17 18:48 ` [PATCH 19/20] cciss: Add usage_count " Stephen M. Cameron
2009-09-17 18:48 ` [PATCH 20/20] cciss: Dynamically allocate the drive_info_struct for each logical drive Stephen M. Cameron
2009-09-18 20:14 ` [PATCH 00/20] cciss: fix scan_thread, sysfs stuff, dynamically allocate per drive structure Jens Axboe

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=20090917184734.15105.71632.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@beardog.cce.hp.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