Commit ad2b9312 authored by Mike Miller's avatar Mike Miller Committed by Linus Torvalds

[PATCH] cciss per disk queue

This patch adds per disk queue functionality to cciss.  Sometime back I
submitted a patch but it looks like only part of what I needed.  In the 2.6
kernel if we have more than one logical volume the driver will Oops during
rmmod.  It seems all of the queues actually point back to the same queue.
So after deleting the first volume you hit a null pointer on the second
one.

This has been tested in our labs.  There is no difference in performance,
it just fixes the Oops.
Signed-off-by: default avatarMike Miller <mike.miller@hp.com>
Cc: Jens Axboe <axboe@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent eaaf9c68
...@@ -1135,7 +1135,7 @@ static int revalidate_allvol(ctlr_info_t *host) ...@@ -1135,7 +1135,7 @@ static int revalidate_allvol(ctlr_info_t *host)
/* this is for the online array utilities */ /* this is for the online array utilities */
if (!drv->heads && i) if (!drv->heads && i)
continue; continue;
blk_queue_hardsect_size(host->queue, drv->block_size); blk_queue_hardsect_size(drv->queue, drv->block_size);
set_capacity(disk, drv->nr_blocks); set_capacity(disk, drv->nr_blocks);
add_disk(disk); add_disk(disk);
} }
...@@ -1691,7 +1691,7 @@ static int cciss_revalidate(struct gendisk *disk) ...@@ -1691,7 +1691,7 @@ static int cciss_revalidate(struct gendisk *disk)
cciss_read_capacity(h->ctlr, logvol, size_buff, 1, &total_size, &block_size); cciss_read_capacity(h->ctlr, logvol, size_buff, 1, &total_size, &block_size);
cciss_geometry_inquiry(h->ctlr, logvol, 1, total_size, block_size, inq_buff, drv); cciss_geometry_inquiry(h->ctlr, logvol, 1, total_size, block_size, inq_buff, drv);
blk_queue_hardsect_size(h->queue, drv->block_size); blk_queue_hardsect_size(drv->queue, drv->block_size);
set_capacity(disk, drv->nr_blocks); set_capacity(disk, drv->nr_blocks);
kfree(size_buff); kfree(size_buff);
...@@ -2248,12 +2248,12 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs) ...@@ -2248,12 +2248,12 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs)
* them up. We will also keep track of the next queue to run so * them up. We will also keep track of the next queue to run so
* that every queue gets a chance to be started first. * that every queue gets a chance to be started first.
*/ */
for (j=0; j < NWD; j++){ for (j=0; j < h->highest_lun + 1; j++){
int curr_queue = (start_queue + j) % NWD; int curr_queue = (start_queue + j) % (h->highest_lun + 1);
/* make sure the disk has been added and the drive is real /* make sure the disk has been added and the drive is real
* because this can be called from the middle of init_one. * because this can be called from the middle of init_one.
*/ */
if(!(h->gendisk[curr_queue]->queue) || if(!(h->drv[curr_queue].queue) ||
!(h->drv[curr_queue].heads)) !(h->drv[curr_queue].heads))
continue; continue;
blk_start_queue(h->gendisk[curr_queue]->queue); blk_start_queue(h->gendisk[curr_queue]->queue);
...@@ -2264,14 +2264,14 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs) ...@@ -2264,14 +2264,14 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs)
if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS)
{ {
if (curr_queue == start_queue){ if (curr_queue == start_queue){
h->next_to_run = (start_queue + 1) % NWD; h->next_to_run = (start_queue + 1) % (h->highest_lun + 1);
goto cleanup; goto cleanup;
} else { } else {
h->next_to_run = curr_queue; h->next_to_run = curr_queue;
goto cleanup; goto cleanup;
} }
} else { } else {
curr_queue = (curr_queue + 1) % NWD; curr_queue = (curr_queue + 1) % (h->highest_lun + 1);
} }
} }
...@@ -2279,7 +2279,6 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs) ...@@ -2279,7 +2279,6 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs)
spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
/* /*
* We cannot read the structure directly, for portablity we must use * We cannot read the structure directly, for portablity we must use
* the io functions. * the io functions.
...@@ -2789,13 +2788,6 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, ...@@ -2789,13 +2788,6 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
} }
spin_lock_init(&hba[i]->lock); spin_lock_init(&hba[i]->lock);
q = blk_init_queue(do_cciss_request, &hba[i]->lock);
if (!q)
goto clean4;
q->backing_dev_info.ra_pages = READ_AHEAD;
hba[i]->queue = q;
q->queuedata = hba[i];
/* Initialize the pdev driver private data. /* Initialize the pdev driver private data.
have it point to hba[i]. */ have it point to hba[i]. */
...@@ -2817,6 +2809,20 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, ...@@ -2817,6 +2809,20 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
cciss_procinit(i); cciss_procinit(i);
for(j=0; j < NWD; j++) { /* mfm */
drive_info_struct *drv = &(hba[i]->drv[j]);
struct gendisk *disk = hba[i]->gendisk[j];
q = blk_init_queue(do_cciss_request, &hba[i]->lock);
if (!q) {
printk(KERN_ERR
"cciss: unable to allocate queue for disk %d\n",
j);
break;
}
drv->queue = q;
q->backing_dev_info.ra_pages = READ_AHEAD;
blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask); blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask);
/* This is a hardware imposed limit. */ /* This is a hardware imposed limit. */
...@@ -2827,26 +2833,23 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, ...@@ -2827,26 +2833,23 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
blk_queue_max_sectors(q, 512); blk_queue_max_sectors(q, 512);
q->queuedata = hba[i];
for(j=0; j<NWD; j++) {
drive_info_struct *drv = &(hba[i]->drv[j]);
struct gendisk *disk = hba[i]->gendisk[j];
sprintf(disk->disk_name, "cciss/c%dd%d", i, j); sprintf(disk->disk_name, "cciss/c%dd%d", i, j);
sprintf(disk->devfs_name, "cciss/host%d/target%d", i, j); sprintf(disk->devfs_name, "cciss/host%d/target%d", i, j);
disk->major = hba[i]->major; disk->major = hba[i]->major;
disk->first_minor = j << NWD_SHIFT; disk->first_minor = j << NWD_SHIFT;
disk->fops = &cciss_fops; disk->fops = &cciss_fops;
disk->queue = hba[i]->queue; disk->queue = q;
disk->private_data = drv; disk->private_data = drv;
/* we must register the controller even if no disks exist */ /* we must register the controller even if no disks exist */
/* this is for the online array utilities */ /* this is for the online array utilities */
if(!drv->heads && j) if(!drv->heads && j)
continue; continue;
blk_queue_hardsect_size(hba[i]->queue, drv->block_size); blk_queue_hardsect_size(q, drv->block_size);
set_capacity(disk, drv->nr_blocks); set_capacity(disk, drv->nr_blocks);
add_disk(disk); add_disk(disk);
} }
return(1); return(1);
clean4: clean4:
...@@ -2912,10 +2915,10 @@ static void __devexit cciss_remove_one (struct pci_dev *pdev) ...@@ -2912,10 +2915,10 @@ static void __devexit cciss_remove_one (struct pci_dev *pdev)
for (j = 0; j < NWD; j++) { for (j = 0; j < NWD; j++) {
struct gendisk *disk = hba[i]->gendisk[j]; struct gendisk *disk = hba[i]->gendisk[j];
if (disk->flags & GENHD_FL_UP) if (disk->flags & GENHD_FL_UP)
blk_cleanup_queue(disk->queue);
del_gendisk(disk); del_gendisk(disk);
} }
blk_cleanup_queue(hba[i]->queue);
pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct), pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct),
hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle);
pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof( ErrorInfo_struct), pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof( ErrorInfo_struct),
......
...@@ -29,6 +29,7 @@ typedef struct _drive_info_struct ...@@ -29,6 +29,7 @@ typedef struct _drive_info_struct
{ {
__u32 LunID; __u32 LunID;
int usage_count; int usage_count;
struct request_queue *queue;
sector_t nr_blocks; sector_t nr_blocks;
int block_size; int block_size;
int heads; int heads;
...@@ -72,7 +73,6 @@ struct ctlr_info ...@@ -72,7 +73,6 @@ struct ctlr_info
unsigned int maxQsinceinit; unsigned int maxQsinceinit;
unsigned int maxSG; unsigned int maxSG;
spinlock_t lock; spinlock_t lock;
struct request_queue *queue;
//* pointers to command and error info pool */ //* pointers to command and error info pool */
CommandList_struct *cmd_pool; CommandList_struct *cmd_pool;
...@@ -260,7 +260,7 @@ struct board_type { ...@@ -260,7 +260,7 @@ struct board_type {
struct access_method *access; struct access_method *access;
}; };
#define CCISS_LOCK(i) (hba[i]->queue->queue_lock) #define CCISS_LOCK(i) (&hba[i]->lock)
#endif /* CCISS_H */ #endif /* CCISS_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment