diff options
author | Stephen M. Cameron <scameron@beardog.cce.hp.com> | 2009-09-17 14:47:29 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-10-01 15:15:42 -0400 |
commit | 361e9b07d11cfc8b77921a0e96910019402efe79 (patch) | |
tree | abaf13edbd4e7117a1f64a84119e2e4a8e1314cd | |
parent | e8074f79770953be26b64539803d06a46d1a6e58 (diff) |
cciss: Handle cases when cciss_add_disk fails.
Handle cases when cciss_add_disk fails.
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r-- | 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 b1211d530dae..ced71b006cd7 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -200,6 +200,7 @@ static int scan_thread(void *data); | |||
200 | static int check_for_unit_attention(ctlr_info_t *h, CommandList_struct *c); | 200 | static int check_for_unit_attention(ctlr_info_t *h, CommandList_struct *c); |
201 | static void cciss_hba_release(struct device *dev); | 201 | static void cciss_hba_release(struct device *dev); |
202 | static void cciss_device_release(struct device *dev); | 202 | static void cciss_device_release(struct device *dev); |
203 | static void cciss_free_gendisk(ctlr_info_t *h, int drv_index); | ||
203 | 204 | ||
204 | #ifdef CONFIG_PROC_FS | 205 | #ifdef CONFIG_PROC_FS |
205 | static void cciss_procinit(int i); | 206 | static void cciss_procinit(int i); |
@@ -1856,8 +1857,14 @@ static void cciss_update_drive_info(int ctlr, int drv_index, int first_time) | |||
1856 | * (raid_leve == -1) then we want to update the | 1857 | * (raid_leve == -1) then we want to update the |
1857 | * logical drive's information. | 1858 | * logical drive's information. |
1858 | */ | 1859 | */ |
1859 | if (drv_index || first_time) | 1860 | if (drv_index || first_time) { |
1860 | cciss_add_disk(h, disk, drv_index); | 1861 | if (cciss_add_disk(h, disk, drv_index) != 0) { |
1862 | cciss_free_gendisk(h, drv_index); | ||
1863 | printk(KERN_WARNING "cciss:%d could not update " | ||
1864 | "disk %d\n", h->ctlr, drv_index); | ||
1865 | --h->num_luns; | ||
1866 | } | ||
1867 | } | ||
1861 | 1868 | ||
1862 | freeret: | 1869 | freeret: |
1863 | kfree(inq_buff); | 1870 | kfree(inq_buff); |
@@ -1891,6 +1898,12 @@ static int cciss_find_free_drive_index(int ctlr, int controller_node) | |||
1891 | return -1; | 1898 | return -1; |
1892 | } | 1899 | } |
1893 | 1900 | ||
1901 | static void cciss_free_gendisk(ctlr_info_t *h, int drv_index) | ||
1902 | { | ||
1903 | put_disk(h->gendisk[drv_index]); | ||
1904 | h->gendisk[drv_index] = NULL; | ||
1905 | } | ||
1906 | |||
1894 | /* cciss_add_gendisk finds a free hba[]->drv structure | 1907 | /* cciss_add_gendisk finds a free hba[]->drv structure |
1895 | * and allocates a gendisk if needed, and sets the lunid | 1908 | * and allocates a gendisk if needed, and sets the lunid |
1896 | * in the drvinfo structure. It returns the index into | 1909 | * in the drvinfo structure. It returns the index into |
@@ -1931,8 +1944,7 @@ static int cciss_add_gendisk(ctlr_info_t *h, __u32 lunid, int controller_node) | |||
1931 | return drv_index; | 1944 | return drv_index; |
1932 | 1945 | ||
1933 | err_free_disk: | 1946 | err_free_disk: |
1934 | put_disk(h->gendisk[drv_index]); | 1947 | cciss_free_gendisk(h, drv_index); |
1935 | h->gendisk[drv_index] = NULL; | ||
1936 | return -1; | 1948 | return -1; |
1937 | } | 1949 | } |
1938 | 1950 | ||
@@ -1950,11 +1962,8 @@ static void cciss_add_controller_node(ctlr_info_t *h) | |||
1950 | return; | 1962 | return; |
1951 | 1963 | ||
1952 | drv_index = cciss_add_gendisk(h, 0, 1); | 1964 | drv_index = cciss_add_gendisk(h, 0, 1); |
1953 | if (drv_index == -1) { | 1965 | if (drv_index == -1) |
1954 | printk(KERN_WARNING "cciss%d: could not " | 1966 | goto error; |
1955 | "add disk 0.\n", h->ctlr); | ||
1956 | return; | ||
1957 | } | ||
1958 | h->drv[drv_index].block_size = 512; | 1967 | h->drv[drv_index].block_size = 512; |
1959 | h->drv[drv_index].nr_blocks = 0; | 1968 | h->drv[drv_index].nr_blocks = 0; |
1960 | h->drv[drv_index].heads = 0; | 1969 | h->drv[drv_index].heads = 0; |
@@ -1963,7 +1972,13 @@ static void cciss_add_controller_node(ctlr_info_t *h) | |||
1963 | h->drv[drv_index].raid_level = -1; | 1972 | h->drv[drv_index].raid_level = -1; |
1964 | memset(h->drv[drv_index].serial_no, 0, 16); | 1973 | memset(h->drv[drv_index].serial_no, 0, 16); |
1965 | disk = h->gendisk[drv_index]; | 1974 | disk = h->gendisk[drv_index]; |
1966 | cciss_add_disk(h, disk, drv_index); | 1975 | if (cciss_add_disk(h, disk, drv_index) == 0) |
1976 | return; | ||
1977 | cciss_free_gendisk(h, drv_index); | ||
1978 | error: | ||
1979 | printk(KERN_WARNING "cciss%d: could not " | ||
1980 | "add disk 0.\n", h->ctlr); | ||
1981 | return; | ||
1967 | } | 1982 | } |
1968 | 1983 | ||
1969 | /* This function will add and remove logical drives from the Logical | 1984 | /* This function will add and remove logical drives from the Logical |