Print this page
5046 comstar: use the correct type instead of casting all the time


 181 /* Internal tracing */
 182 volatile int    stmf_trace_on = 1;
 183 volatile int    stmf_trace_buf_size = (1 * 1024 * 1024);
 184 /*
 185  * The reason default task timeout is 75 is because we want the
 186  * host to timeout 1st and mostly host timeout is 60 seconds.
 187  */
 188 volatile int    stmf_default_task_timeout = 75;
 189 /*
 190  * Setting this to one means, you are responsible for config load and keeping
 191  * things in sync with persistent database.
 192  */
 193 volatile int    stmf_allow_modunload = 0;
 194 
 195 volatile int stmf_max_nworkers = 256;
 196 volatile int stmf_min_nworkers = 4;
 197 volatile int stmf_worker_scale_down_delay = 20;
 198 
 199 /* === [ Debugging and fault injection ] === */
 200 #ifdef  DEBUG
 201 volatile int stmf_drop_task_counter = 0;
 202 volatile int stmf_drop_buf_counter = 0;
 203 
 204 #endif
 205 
 206 stmf_state_t            stmf_state;
 207 static stmf_lu_t        *dlun0;
 208 
 209 static uint8_t stmf_first_zero[] =
 210         { 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 0xff };
 211 static uint8_t stmf_first_one[] =
 212         { 0xff, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 };
 213 
 214 static kmutex_t trace_buf_lock;
 215 static int      trace_buf_size;
 216 static int      trace_buf_curndx;
 217 caddr_t stmf_trace_buf;
 218 
 219 static enum {
 220         STMF_WORKERS_DISABLED = 0,
 221         STMF_WORKERS_ENABLING,
 222         STMF_WORKERS_ENABLED


4596         stmf_status_t ret = STMF_SUCCESS;
4597 
4598         stmf_i_scsi_task_t *itask =
4599             (stmf_i_scsi_task_t *)task->task_stmf_private;
4600 
4601         stmf_task_audit(itask, TE_XFER_START, ioflags, dbuf);
4602 
4603         if (ioflags & STMF_IOF_LU_DONE) {
4604                 uint32_t new, old;
4605                 do {
4606                         new = old = itask->itask_flags;
4607                         if (new & ITASK_BEING_ABORTED)
4608                                 return (STMF_ABORTED);
4609                         new &= ~ITASK_KNOWN_TO_LU;
4610                 } while (atomic_cas_32(&itask->itask_flags, old, new) != old);
4611         }
4612         if (itask->itask_flags & ITASK_BEING_ABORTED)
4613                 return (STMF_ABORTED);
4614 #ifdef  DEBUG
4615         if (!(ioflags & STMF_IOF_STATS_ONLY) && stmf_drop_buf_counter > 0) {
4616                 if (atomic_dec_32_nv((uint32_t *)&stmf_drop_buf_counter) ==
4617                     1)
4618                         return (STMF_SUCCESS);
4619         }
4620 #endif
4621 
4622         stmf_update_kstat_lu_io(task, dbuf);
4623         stmf_update_kstat_lport_io(task, dbuf);
4624         stmf_lport_xfer_start(itask, dbuf);
4625         if (ioflags & STMF_IOF_STATS_ONLY) {
4626                 stmf_lport_xfer_done(itask, dbuf);
4627                 return (STMF_SUCCESS);
4628         }
4629 
4630         dbuf->db_flags |= DB_LPORT_XFER_ACTIVE;
4631         ret = task->task_lport->lport_xfer_data(task, dbuf, ioflags);
4632 
4633         /*
4634          * Port provider may have already called the buffer callback in
4635          * which case dbuf->db_xfer_start_timestamp will be 0.
4636          */
4637         if (ret != STMF_SUCCESS) {


6325                 /* We made it here means we are going to call LU */
6326                 if ((itask->itask_flags & ITASK_DEFAULT_HANDLING) == 0)
6327                         lu = task->task_lu;
6328                 else
6329                         lu = dlun0;
6330                 dbuf = itask->itask_dbufs[ITASK_CMD_BUF_NDX(curcmd)];
6331                 mutex_exit(&w->worker_lock);
6332                 curcmd &= ITASK_CMD_MASK;
6333                 stmf_task_audit(itask, TE_PROCESS_CMD, curcmd, dbuf);
6334                 switch (curcmd) {
6335                 case ITASK_CMD_NEW_TASK:
6336                         iss = (stmf_i_scsi_session_t *)
6337                             task->task_session->ss_stmf_private;
6338                         stmf_itl_lu_new_task(itask);
6339                         if (iss->iss_flags & ISS_LUN_INVENTORY_CHANGED) {
6340                                 if (stmf_handle_cmd_during_ic(itask))
6341                                         break;
6342                         }
6343 #ifdef  DEBUG
6344                         if (stmf_drop_task_counter > 0) {
6345                                 if (atomic_dec_32_nv((uint32_t *)&stmf_drop_task_counter) ==
6346                                     1) {
6347                                         break;
6348                                 }
6349                         }
6350 #endif
6351                         DTRACE_PROBE1(scsi__task__start, scsi_task_t *, task);
6352                         lu->lu_new_task(task, dbuf);
6353                         break;
6354                 case ITASK_CMD_DATA_XFER_DONE:
6355                         lu->lu_dbuf_xfer_done(task, dbuf);
6356                         break;
6357                 case ITASK_CMD_STATUS_DONE:
6358                         lu->lu_send_status_done(task);
6359                         break;
6360                 case ITASK_CMD_ABORT:
6361                         if (abort_free) {
6362                                 stmf_task_free(task);
6363                         } else {
6364                                 stmf_do_task_abort(task);
6365                         }
6366                         break;
6367                 case ITASK_CMD_POLL_LU:
6368                         if (!wait_queue) {
6369                                 lu->lu_task_poll(task);




 181 /* Internal tracing */
 182 volatile int    stmf_trace_on = 1;
 183 volatile int    stmf_trace_buf_size = (1 * 1024 * 1024);
 184 /*
 185  * The reason default task timeout is 75 is because we want the
 186  * host to timeout 1st and mostly host timeout is 60 seconds.
 187  */
 188 volatile int    stmf_default_task_timeout = 75;
 189 /*
 190  * Setting this to one means, you are responsible for config load and keeping
 191  * things in sync with persistent database.
 192  */
 193 volatile int    stmf_allow_modunload = 0;
 194 
 195 volatile int stmf_max_nworkers = 256;
 196 volatile int stmf_min_nworkers = 4;
 197 volatile int stmf_worker_scale_down_delay = 20;
 198 
 199 /* === [ Debugging and fault injection ] === */
 200 #ifdef  DEBUG
 201 volatile uint32_t stmf_drop_task_counter = 0;
 202 volatile uint32_t stmf_drop_buf_counter = 0;
 203 
 204 #endif
 205 
 206 stmf_state_t            stmf_state;
 207 static stmf_lu_t        *dlun0;
 208 
 209 static uint8_t stmf_first_zero[] =
 210         { 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 0xff };
 211 static uint8_t stmf_first_one[] =
 212         { 0xff, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 };
 213 
 214 static kmutex_t trace_buf_lock;
 215 static int      trace_buf_size;
 216 static int      trace_buf_curndx;
 217 caddr_t stmf_trace_buf;
 218 
 219 static enum {
 220         STMF_WORKERS_DISABLED = 0,
 221         STMF_WORKERS_ENABLING,
 222         STMF_WORKERS_ENABLED


4596         stmf_status_t ret = STMF_SUCCESS;
4597 
4598         stmf_i_scsi_task_t *itask =
4599             (stmf_i_scsi_task_t *)task->task_stmf_private;
4600 
4601         stmf_task_audit(itask, TE_XFER_START, ioflags, dbuf);
4602 
4603         if (ioflags & STMF_IOF_LU_DONE) {
4604                 uint32_t new, old;
4605                 do {
4606                         new = old = itask->itask_flags;
4607                         if (new & ITASK_BEING_ABORTED)
4608                                 return (STMF_ABORTED);
4609                         new &= ~ITASK_KNOWN_TO_LU;
4610                 } while (atomic_cas_32(&itask->itask_flags, old, new) != old);
4611         }
4612         if (itask->itask_flags & ITASK_BEING_ABORTED)
4613                 return (STMF_ABORTED);
4614 #ifdef  DEBUG
4615         if (!(ioflags & STMF_IOF_STATS_ONLY) && stmf_drop_buf_counter > 0) {
4616                 if (atomic_dec_32_nv(&stmf_drop_buf_counter) == 1)

4617                         return (STMF_SUCCESS);
4618         }
4619 #endif
4620 
4621         stmf_update_kstat_lu_io(task, dbuf);
4622         stmf_update_kstat_lport_io(task, dbuf);
4623         stmf_lport_xfer_start(itask, dbuf);
4624         if (ioflags & STMF_IOF_STATS_ONLY) {
4625                 stmf_lport_xfer_done(itask, dbuf);
4626                 return (STMF_SUCCESS);
4627         }
4628 
4629         dbuf->db_flags |= DB_LPORT_XFER_ACTIVE;
4630         ret = task->task_lport->lport_xfer_data(task, dbuf, ioflags);
4631 
4632         /*
4633          * Port provider may have already called the buffer callback in
4634          * which case dbuf->db_xfer_start_timestamp will be 0.
4635          */
4636         if (ret != STMF_SUCCESS) {


6324                 /* We made it here means we are going to call LU */
6325                 if ((itask->itask_flags & ITASK_DEFAULT_HANDLING) == 0)
6326                         lu = task->task_lu;
6327                 else
6328                         lu = dlun0;
6329                 dbuf = itask->itask_dbufs[ITASK_CMD_BUF_NDX(curcmd)];
6330                 mutex_exit(&w->worker_lock);
6331                 curcmd &= ITASK_CMD_MASK;
6332                 stmf_task_audit(itask, TE_PROCESS_CMD, curcmd, dbuf);
6333                 switch (curcmd) {
6334                 case ITASK_CMD_NEW_TASK:
6335                         iss = (stmf_i_scsi_session_t *)
6336                             task->task_session->ss_stmf_private;
6337                         stmf_itl_lu_new_task(itask);
6338                         if (iss->iss_flags & ISS_LUN_INVENTORY_CHANGED) {
6339                                 if (stmf_handle_cmd_during_ic(itask))
6340                                         break;
6341                         }
6342 #ifdef  DEBUG
6343                         if (stmf_drop_task_counter > 0) {
6344                                 if (atomic_dec_32_nv(&stmf_drop_task_counter) == 1)

6345                                         break;
6346                         }

6347 #endif
6348                         DTRACE_PROBE1(scsi__task__start, scsi_task_t *, task);
6349                         lu->lu_new_task(task, dbuf);
6350                         break;
6351                 case ITASK_CMD_DATA_XFER_DONE:
6352                         lu->lu_dbuf_xfer_done(task, dbuf);
6353                         break;
6354                 case ITASK_CMD_STATUS_DONE:
6355                         lu->lu_send_status_done(task);
6356                         break;
6357                 case ITASK_CMD_ABORT:
6358                         if (abort_free) {
6359                                 stmf_task_free(task);
6360                         } else {
6361                                 stmf_do_task_abort(task);
6362                         }
6363                         break;
6364                 case ITASK_CMD_POLL_LU:
6365                         if (!wait_queue) {
6366                                 lu->lu_task_poll(task);