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

cciss: add cciss_tape_cmds module paramter

This is to allow number of commands reserved for use by SCSI tape drives
and medium changers to be adjusted at driver load time via the kernel
parameter cciss_tape_cmds, with a default value of 6, and a range
of 2 - 16 inclusive. Previously, the driver limited the number of
commands which could be queued to the SCSI half of the the driver
to only 2. This is to fix the problem that if you had more than
two tape drives, you couldn't, for example, erase or rewind them all
at the same time.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>

authored by

Stephen M. Cameron and committed by
Jens Axboe
8a4ec67b 063d2cf7

+48 -23
+15
Documentation/blockdev/cciss.txt
··· 169 169 must rewind the tape (by issuing "mt -f /dev/st0 rewind" for example) 170 170 before i/o can proceed again to a tape drive which was reset. 171 171 172 + There is a cciss_tape_cmds module parameter which can be used to make cciss 173 + allocate more commands for use by tape drives. Ordinarily only a few commands 174 + (6) are allocated for tape drives because tape drives are slow and 175 + infrequently used and the primary purpose of Smart Array controllers is to 176 + act as a RAID controller for disk drives, so the vast majority of commands 177 + are allocated for disk devices. However, if you have more than a few tape 178 + drives attached to a smart array, the default number of commands may not be 179 + enought (for example, if you have 8 tape drives, you could only rewind 6 180 + at one time with the default number of commands.) The cciss_tape_cmds module 181 + parameter allows more commands (up to 16 more) to be allocated for use by 182 + tape drives. For example: 183 + 184 + insmod cciss.ko cciss_tape_cmds=16 185 + 186 + Or, as a kernel boot parameter passed in via grub: cciss.cciss_tape_cmds=8
+10 -1
drivers/block/cciss.c
··· 64 64 MODULE_SUPPORTED_DEVICE("HP Smart Array Controllers"); 65 65 MODULE_VERSION("3.6.26"); 66 66 MODULE_LICENSE("GPL"); 67 + static int cciss_tape_cmds = 6; 68 + module_param(cciss_tape_cmds, int, 0644); 69 + MODULE_PARM_DESC(cciss_tape_cmds, 70 + "number of commands to allocate for tape devices (default: 6)"); 67 71 68 72 static DEFINE_MUTEX(cciss_mutex); 69 73 static struct proc_dir_entry *proc_cciss; ··· 4225 4221 static void __devinit cciss_find_board_params(ctlr_info_t *h) 4226 4222 { 4227 4223 cciss_get_max_perf_mode_cmds(h); 4228 - h->nr_cmds = h->max_commands - 4; /* Allow room for some ioctls */ 4224 + h->nr_cmds = h->max_commands - 4 - cciss_tape_cmds; 4229 4225 h->maxsgentries = readl(&(h->cfgtable->MaxSGElements)); 4230 4226 /* 4231 4227 * Limit in-command s/g elements to 32 save dma'able memory. ··· 4962 4958 4963 4959 sprintf(h->devname, "cciss%d", i); 4964 4960 h->ctlr = i; 4961 + 4962 + if (cciss_tape_cmds < 2) 4963 + cciss_tape_cmds = 2; 4964 + if (cciss_tape_cmds > 16) 4965 + cciss_tape_cmds = 16; 4965 4966 4966 4967 init_completion(&h->scan_wait); 4967 4968
+23 -18
drivers/block/cciss_scsi.c
··· 84 84 .proc_name = "cciss", 85 85 .proc_info = cciss_scsi_proc_info, 86 86 .queuecommand = cciss_scsi_queue_command, 87 - .can_queue = SCSI_CCISS_CAN_QUEUE, 88 87 .this_id = 7, 89 88 .cmd_per_lun = 1, 90 89 .use_clustering = DISABLE_CLUSTERING, ··· 107 108 108 109 #pragma pack() 109 110 110 - #define CMD_STACK_SIZE (SCSI_CCISS_CAN_QUEUE * \ 111 - CCISS_MAX_SCSI_DEVS_PER_HBA + 2) 112 - // plus two for init time usage 113 - 114 111 #pragma pack(1) 115 112 struct cciss_scsi_cmd_stack_t { 116 113 struct cciss_scsi_cmd_stack_elem_t *pool; 117 - struct cciss_scsi_cmd_stack_elem_t *elem[CMD_STACK_SIZE]; 114 + struct cciss_scsi_cmd_stack_elem_t **elem; 118 115 dma_addr_t cmd_pool_handle; 119 116 int top; 117 + int nelems; 120 118 }; 121 119 #pragma pack() 122 120 ··· 187 191 sa = h->scsi_ctlr; 188 192 stk = &sa->cmd_stack; 189 193 stk->top++; 190 - if (stk->top >= CMD_STACK_SIZE) { 194 + if (stk->top >= stk->nelems) { 191 195 dev_err(&h->pdev->dev, 192 196 "scsi_cmd_free called too many times.\n"); 193 197 BUG(); ··· 202 206 struct cciss_scsi_cmd_stack_t *stk; 203 207 size_t size; 204 208 209 + stk = &sa->cmd_stack; 210 + stk->nelems = cciss_tape_cmds + 2; 205 211 sa->cmd_sg_list = cciss_allocate_sg_chain_blocks(h, 206 - h->chainsize, CMD_STACK_SIZE); 212 + h->chainsize, stk->nelems); 207 213 if (!sa->cmd_sg_list && h->chainsize > 0) 208 214 return -ENOMEM; 209 215 210 - stk = &sa->cmd_stack; 211 - size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * CMD_STACK_SIZE; 216 + size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * stk->nelems; 212 217 213 218 /* Check alignment, see cciss_cmd.h near CommandList_struct def. */ 214 219 BUILD_BUG_ON((sizeof(*stk->pool) % COMMANDLIST_ALIGNMENT) != 0); ··· 218 221 pci_alloc_consistent(h->pdev, size, &stk->cmd_pool_handle); 219 222 220 223 if (stk->pool == NULL) { 221 - cciss_free_sg_chain_blocks(sa->cmd_sg_list, CMD_STACK_SIZE); 224 + cciss_free_sg_chain_blocks(sa->cmd_sg_list, stk->nelems); 222 225 sa->cmd_sg_list = NULL; 223 226 return -ENOMEM; 224 227 } 225 - 226 - for (i=0; i<CMD_STACK_SIZE; i++) { 228 + stk->elem = kmalloc(sizeof(stk->elem[0]) * stk->nelems, GFP_KERNEL); 229 + if (!stk->elem) { 230 + pci_free_consistent(h->pdev, size, stk->pool, 231 + stk->cmd_pool_handle); 232 + return -1; 233 + } 234 + for (i = 0; i < stk->nelems; i++) { 227 235 stk->elem[i] = &stk->pool[i]; 228 236 stk->elem[i]->busaddr = (__u32) (stk->cmd_pool_handle + 229 237 (sizeof(struct cciss_scsi_cmd_stack_elem_t) * i)); 230 238 stk->elem[i]->cmdindex = i; 231 239 } 232 - stk->top = CMD_STACK_SIZE-1; 240 + stk->top = stk->nelems-1; 233 241 return 0; 234 242 } 235 243 ··· 247 245 248 246 sa = h->scsi_ctlr; 249 247 stk = &sa->cmd_stack; 250 - if (stk->top != CMD_STACK_SIZE-1) { 248 + if (stk->top != stk->nelems-1) { 251 249 dev_warn(&h->pdev->dev, 252 250 "bug: %d scsi commands are still outstanding.\n", 253 - CMD_STACK_SIZE - stk->top); 251 + stk->nelems - stk->top); 254 252 } 255 - size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * CMD_STACK_SIZE; 253 + size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * stk->nelems; 256 254 257 255 pci_free_consistent(h->pdev, size, stk->pool, stk->cmd_pool_handle); 258 256 stk->pool = NULL; 259 - cciss_free_sg_chain_blocks(sa->cmd_sg_list, CMD_STACK_SIZE); 257 + cciss_free_sg_chain_blocks(sa->cmd_sg_list, stk->nelems); 258 + kfree(stk->elem); 259 + stk->elem = NULL; 260 260 } 261 261 262 262 #if 0 ··· 863 859 sh->io_port = 0; // good enough? FIXME, 864 860 sh->n_io_port = 0; // I don't think we use these two... 865 861 sh->this_id = SELF_SCSI_ID; 862 + sh->can_queue = cciss_tape_cmds; 866 863 sh->sg_tablesize = h->maxsgentries; 867 864 sh->max_cmd_len = MAX_COMMAND_SIZE; 868 865
-4
drivers/block/cciss_scsi.h
··· 36 36 addressible natively, and may in fact turn 37 37 out to be not scsi at all. */ 38 38 39 - #define SCSI_CCISS_CAN_QUEUE 2 40 39 41 40 /* 42 - 43 - Note, cmd_per_lun could give us some trouble, so I'm setting it very low. 44 - Likewise, SCSI_CCISS_CAN_QUEUE is set very conservatively. 45 41 46 42 If the upper scsi layer tries to track how many commands we have 47 43 outstanding, it will be operating under the misapprehension that it is