Skip to content

Commit

Permalink
cciss: Handle special case for sysfs attributes of the first logical …
Browse files Browse the repository at this point in the history
…drive.

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>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
  • Loading branch information
Stephen M. Cameron authored and Jens Axboe committed Oct 1, 2009
1 parent 361e9b0 commit 8ce5196
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions drivers/block/cciss.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,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;
Expand All @@ -698,9 +702,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;
Expand Down Expand Up @@ -1920,6 +1930,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] =
Expand Down Expand Up @@ -2165,7 +2176,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) {
Expand Down Expand Up @@ -2211,7 +2222,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) {
Expand Down Expand Up @@ -4329,7 +4339,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)
Expand Down

0 comments on commit 8ce5196

Please sign in to comment.