Commit 8ce51966d3b809d6c1ae4f3902058558589480b8
Committed by
Jens Axboe
1 parent
361e9b07d1
cciss: Handle special case for sysfs attributes of the first logical 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>
Showing 1 changed file with 14 additions and 4 deletions Side-by-side Diff
drivers/block/cciss.c
... | ... | @@ -682,6 +682,10 @@ |
682 | 682 | { |
683 | 683 | struct device *dev; |
684 | 684 | |
685 | + /* Special case for c*d0, we only create it once. */ | |
686 | + if (drv_index == 0 && h->drv[drv_index].dev != NULL) | |
687 | + return 0; | |
688 | + | |
685 | 689 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
686 | 690 | if (!dev) |
687 | 691 | return -ENOMEM; |
688 | 692 | |
... | ... | @@ -698,9 +702,15 @@ |
698 | 702 | /* |
699 | 703 | * Remove sysfs entries for a logical drive. |
700 | 704 | */ |
701 | -static void cciss_destroy_ld_sysfs_entry(struct ctlr_info *h, int drv_index) | |
705 | +static void cciss_destroy_ld_sysfs_entry(struct ctlr_info *h, int drv_index, | |
706 | + int ctlr_exiting) | |
702 | 707 | { |
703 | 708 | struct device *dev = h->drv[drv_index].dev; |
709 | + | |
710 | + /* special case for c*d0, we only destroy it on controller exit */ | |
711 | + if (drv_index == 0 && !ctlr_exiting) | |
712 | + return; | |
713 | + | |
704 | 714 | device_del(dev); |
705 | 715 | put_device(dev); /* the "final" put. */ |
706 | 716 | h->drv[drv_index].dev = NULL; |
... | ... | @@ -1920,6 +1930,7 @@ |
1920 | 1930 | drv_index = cciss_find_free_drive_index(h->ctlr, controller_node); |
1921 | 1931 | if (drv_index == -1) |
1922 | 1932 | return -1; |
1933 | + | |
1923 | 1934 | /*Check if the gendisk needs to be allocated */ |
1924 | 1935 | if (!h->gendisk[drv_index]) { |
1925 | 1936 | h->gendisk[drv_index] = |
... | ... | @@ -2165,7 +2176,7 @@ |
2165 | 2176 | if (h->gendisk[0] != disk) { |
2166 | 2177 | struct request_queue *q = disk->queue; |
2167 | 2178 | if (disk->flags & GENHD_FL_UP) { |
2168 | - cciss_destroy_ld_sysfs_entry(h, drv_index); | |
2179 | + cciss_destroy_ld_sysfs_entry(h, drv_index, 0); | |
2169 | 2180 | del_gendisk(disk); |
2170 | 2181 | } |
2171 | 2182 | if (q) { |
... | ... | @@ -2211,7 +2222,6 @@ |
2211 | 2222 | * indicate that this element of the drive |
2212 | 2223 | * array is free. |
2213 | 2224 | */ |
2214 | - | |
2215 | 2225 | if (clear_all) { |
2216 | 2226 | /* check to see if it was the last disk */ |
2217 | 2227 | if (drv == h->drv + h->highest_lun) { |
... | ... | @@ -4329,7 +4339,7 @@ |
4329 | 4339 | struct request_queue *q = disk->queue; |
4330 | 4340 | |
4331 | 4341 | if (disk->flags & GENHD_FL_UP) { |
4332 | - cciss_destroy_ld_sysfs_entry(hba[i], j); | |
4342 | + cciss_destroy_ld_sysfs_entry(hba[i], j, 1); | |
4333 | 4343 | del_gendisk(disk); |
4334 | 4344 | } |
4335 | 4345 | if (q) |