Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] cciss: add support for 1024 logical volumes

Add the support for a large number of logical volumes. We will soon have
hardware that support up to 1024 logical volumes.

Signed-off-by: Mike Miller <mike.miller@hp.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Mike Miller and committed by
Linus Torvalds
799202cb 3833a748

+80 -41
+77 -37
drivers/block/cciss.c
··· 1315 1315 /* if it's the controller it's already added */ 1316 1316 if (drv_index) { 1317 1317 disk->queue = blk_init_queue(do_cciss_request, &h->lock); 1318 + sprintf(disk->disk_name, "cciss/c%dd%d", ctlr, drv_index); 1319 + disk->major = h->major; 1320 + disk->first_minor = drv_index << NWD_SHIFT; 1321 + disk->fops = &cciss_fops; 1322 + disk->private_data = &h->drv[drv_index]; 1318 1323 1319 1324 /* Set up queue information */ 1320 1325 disk->queue->backing_dev_info.ra_pages = READ_AHEAD; ··· 1398 1393 1399 1394 /* Set busy_configuring flag for this operation */ 1400 1395 spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); 1401 - if (h->num_luns >= CISS_MAX_LUN) { 1402 - spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); 1403 - return -EINVAL; 1404 - } 1405 - 1406 1396 if (h->busy_configuring) { 1407 1397 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); 1408 1398 return -EBUSY; ··· 1430 1430 0, 0, TYPE_CMD); 1431 1431 1432 1432 if (return_code == IO_OK) { 1433 - listlength |= 1434 - (0xff & (unsigned int)(ld_buff->LUNListLength[0])) 1435 - << 24; 1436 - listlength |= 1437 - (0xff & (unsigned int)(ld_buff->LUNListLength[1])) 1438 - << 16; 1439 - listlength |= 1440 - (0xff & (unsigned int)(ld_buff->LUNListLength[2])) 1441 - << 8; 1442 - listlength |= 1443 - 0xff & (unsigned int)(ld_buff->LUNListLength[3]); 1433 + listlength = 1434 + be32_to_cpu(*(__u32 *) ld_buff->LUNListLength); 1444 1435 } else { /* reading number of logical volumes failed */ 1445 1436 printk(KERN_WARNING "cciss: report logical volume" 1446 1437 " command failed\n"); ··· 1482 1491 if (drv_index == -1) 1483 1492 goto freeret; 1484 1493 1494 + /*Check if the gendisk needs to be allocated */ 1495 + if (!h->gendisk[drv_index]){ 1496 + h->gendisk[drv_index] = alloc_disk(1 << NWD_SHIFT); 1497 + if (!h->gendisk[drv_index]){ 1498 + printk(KERN_ERR "cciss: could not allocate new disk %d\n", drv_index); 1499 + goto mem_msg; 1500 + } 1501 + } 1485 1502 } 1486 1503 h->drv[drv_index].LunID = lunid; 1487 1504 cciss_update_drive_info(ctlr, drv_index); ··· 1527 1528 static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, 1528 1529 int clear_all) 1529 1530 { 1531 + int i; 1530 1532 ctlr_info_t *h = get_host(disk); 1531 1533 1532 1534 if (!capable(CAP_SYS_RAWIO)) ··· 1551 1551 del_gendisk(disk); 1552 1552 if (q) { 1553 1553 blk_cleanup_queue(q); 1554 + /* Set drv->queue to NULL so that we do not try 1555 + * to call blk_start_queue on this queue in the 1556 + * interrupt handler 1557 + */ 1554 1558 drv->queue = NULL; 1555 1559 } 1560 + /* If clear_all is set then we are deleting the logical 1561 + * drive, not just refreshing its info. For drives 1562 + * other than disk 0 we will call put_disk. We do not 1563 + * do this for disk 0 as we need it to be able to 1564 + * configure the controller. 1565 + */ 1566 + if (clear_all){ 1567 + /* This isn't pretty, but we need to find the 1568 + * disk in our array and NULL our the pointer. 1569 + * This is so that we will call alloc_disk if 1570 + * this index is used again later. 1571 + */ 1572 + for (i=0; i < CISS_MAX_LUN; i++){ 1573 + if(h->gendisk[i] == disk){ 1574 + h->gendisk[i] = NULL; 1575 + break; 1576 + } 1577 + } 1578 + put_disk(disk); 1579 + } 1556 1580 } 1581 + } else { 1582 + set_capacity(disk, 0); 1557 1583 } 1558 1584 1559 1585 --h->num_luns; ··· 3145 3119 /* Returns -1 if no free entries are left. */ 3146 3120 static int alloc_cciss_hba(void) 3147 3121 { 3148 - struct gendisk *disk[NWD]; 3149 - int i, n; 3150 - for (n = 0; n < NWD; n++) { 3151 - disk[n] = alloc_disk(1 << NWD_SHIFT); 3152 - if (!disk[n]) 3153 - goto out; 3154 - } 3122 + int i; 3155 3123 3156 3124 for (i = 0; i < MAX_CTLR; i++) { 3157 3125 if (!hba[i]) { ··· 3153 3133 p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL); 3154 3134 if (!p) 3155 3135 goto Enomem; 3156 - for (n = 0; n < NWD; n++) 3157 - p->gendisk[n] = disk[n]; 3136 + p->gendisk[0] = alloc_disk(1 << NWD_SHIFT); 3137 + if (!p->gendisk[0]) 3138 + goto Enomem; 3158 3139 hba[i] = p; 3159 3140 return i; 3160 3141 } 3161 3142 } 3162 3143 printk(KERN_WARNING "cciss: This driver supports a maximum" 3163 3144 " of %d controllers.\n", MAX_CTLR); 3164 - goto out; 3165 - Enomem: 3145 + return -1; 3146 + Enomem: 3166 3147 printk(KERN_ERR "cciss: out of memory.\n"); 3167 - out: 3168 - while (n--) 3169 - put_disk(disk[n]); 3170 3148 return -1; 3171 3149 } 3172 3150 ··· 3174 3156 int n; 3175 3157 3176 3158 hba[i] = NULL; 3177 - for (n = 0; n < NWD; n++) 3159 + for (n = 0; n < CISS_MAX_LUN; n++) 3178 3160 put_disk(p->gendisk[n]); 3179 3161 kfree(p); 3180 3162 } ··· 3187 3169 static int __devinit cciss_init_one(struct pci_dev *pdev, 3188 3170 const struct pci_device_id *ent) 3189 3171 { 3190 - request_queue_t *q; 3191 3172 int i; 3192 - int j; 3173 + int j = 0; 3193 3174 int rc; 3194 3175 int dac; 3195 3176 ··· 3300 3283 3301 3284 hba[i]->busy_initializing = 0; 3302 3285 3303 - for (j = 0; j < NWD; j++) { /* mfm */ 3286 + do { 3304 3287 drive_info_struct *drv = &(hba[i]->drv[j]); 3305 3288 struct gendisk *disk = hba[i]->gendisk[j]; 3289 + request_queue_t *q; 3290 + 3291 + /* Check if the disk was allocated already */ 3292 + if (!disk){ 3293 + hba[i]->gendisk[j] = alloc_disk(1 << NWD_SHIFT); 3294 + disk = hba[i]->gendisk[j]; 3295 + } 3296 + 3297 + /* Check that the disk was able to be allocated */ 3298 + if (!disk) { 3299 + printk(KERN_ERR "cciss: unable to allocate memory for disk %d\n", j); 3300 + goto clean4; 3301 + } 3306 3302 3307 3303 q = blk_init_queue(do_cciss_request, &hba[i]->lock); 3308 3304 if (!q) { 3309 3305 printk(KERN_ERR 3310 3306 "cciss: unable to allocate queue for disk %d\n", 3311 3307 j); 3312 - break; 3308 + goto clean4; 3313 3309 } 3314 3310 drv->queue = q; 3315 3311 ··· 3354 3324 blk_queue_hardsect_size(q, drv->block_size); 3355 3325 set_capacity(disk, drv->nr_blocks); 3356 3326 add_disk(disk); 3357 - } 3327 + j++; 3328 + } while (j <= hba[i]->highest_lun); 3358 3329 3359 3330 return 1; 3360 3331 ··· 3378 3347 unregister_blkdev(hba[i]->major, hba[i]->devname); 3379 3348 clean1: 3380 3349 hba[i]->busy_initializing = 0; 3350 + /* cleanup any queues that may have been initialized */ 3351 + for (j=0; j <= hba[i]->highest_lun; j++){ 3352 + drive_info_struct *drv = &(hba[i]->drv[j]); 3353 + if (drv->queue) 3354 + blk_cleanup_queue(drv->queue); 3355 + } 3356 + pci_release_regions(pdev); 3357 + pci_disable_device(pdev); 3358 + pci_set_drvdata(pdev, NULL); 3381 3359 free_hba(i); 3382 3360 return -1; 3383 3361 } ··· 3434 3394 remove_proc_entry(hba[i]->devname, proc_cciss); 3435 3395 3436 3396 /* remove it from the disk list */ 3437 - for (j = 0; j < NWD; j++) { 3397 + for (j = 0; j < CISS_MAX_LUN; j++) { 3438 3398 struct gendisk *disk = hba[i]->gendisk[j]; 3439 3399 if (disk) { 3440 3400 request_queue_t *q = disk->queue;
+1 -2
drivers/block/cciss.h
··· 6 6 #include "cciss_cmd.h" 7 7 8 8 9 - #define NWD 16 10 9 #define NWD_SHIFT 4 11 10 #define MAX_PART (1 << NWD_SHIFT) 12 11 ··· 111 112 int next_to_run; 112 113 113 114 // Disk structures we need to pass back 114 - struct gendisk *gendisk[NWD]; 115 + struct gendisk *gendisk[CISS_MAX_LUN]; 115 116 #ifdef CONFIG_CISS_SCSI_TAPE 116 117 void *scsi_ctlr; /* ptr to structure containing scsi related stuff */ 117 118 /* list of block side commands the scsi error handling sucked up */
+1 -1
drivers/block/cciss_cmd.h
··· 89 89 //########################################################################### 90 90 //STRUCTURES 91 91 //########################################################################### 92 - #define CISS_MAX_LUN 16 92 + #define CISS_MAX_LUN 1024 93 93 #define CISS_MAX_PHYS_LUN 1024 94 94 // SCSI-3 Cmmands 95 95
+1 -1
include/linux/cciss_ioctl.h
··· 80 80 #define HWORD __u16 81 81 #define DWORD __u32 82 82 83 - #define CISS_MAX_LUN 16 83 + #define CISS_MAX_LUN 1024 84 84 85 85 #define LEVEL2LUN 1 // index into Target(x) structure, due to byte swapping 86 86 #define LEVEL3LUN 0