From: <vl...@us...> - 2008-03-05 18:22:07
|
Revision: 298 http://scst.svn.sourceforge.net/scst/?rev=298&view=rev Author: vlnb Date: 2008-03-05 10:22:01 -0800 (Wed, 05 Mar 2008) Log Message: ----------- - Fixed race on TM processing leading to BUG() - Fixed dev_cdrom and dev_modisk load failures if there are no media in the drives - Other minor fixes and cleanups Modified Paths: -------------- trunk/iscsi-scst/kernel/param.c trunk/iscsi-scst/usr/plain.c trunk/scst/include/scsi_tgt.h trunk/scst/src/dev_handlers/scst_cdrom.c trunk/scst/src/dev_handlers/scst_modisk.c trunk/scst/src/scst_targ.c Modified: trunk/iscsi-scst/kernel/param.c =================================================================== --- trunk/iscsi-scst/kernel/param.c 2008-02-29 18:25:56 UTC (rev 297) +++ trunk/iscsi-scst/kernel/param.c 2008-03-05 18:22:01 UTC (rev 298) @@ -16,31 +16,34 @@ #include "iscsi.h" #include "digest.h" -#define CHECK_PARAM(info, iparam, word, min, max) \ -do { \ - if (!info->partial || (info->partial & 1 << key_##word)) \ - if (iparam[key_##word] < min || \ - iparam[key_##word] > max) { \ - PRINT_ERROR("%s: %u is out of range (%u %u)",\ - #word, iparam[key_##word], min, max); \ - iparam[key_##word] = min; \ - } \ +#define CHECK_PARAM(info, iparam, word, min, max) \ +do { \ + if (!(info)->partial || ((info)->partial & 1 << key_##word)) \ + if ((iparam)[key_##word] < (min) || \ + (iparam)[key_##word] > (max)) { \ + PRINT_ERROR("%s: %u is out of range (%u %u)", \ + #word, (iparam)[key_##word], (min), (max)); \ + if ((iparam)[key_##word] < (min)) \ + (iparam)[key_##word] = (min); \ + else \ + (iparam)[key_##word] = (max); \ + } \ } while (0) -#define SET_PARAM(param, info, iparam, word) \ -({ \ - int changed = 0; \ - if (!info->partial || (info->partial & 1 << key_##word)) { \ - if (param->word != iparam[key_##word]) \ - changed = 1; \ - param->word = iparam[key_##word]; \ - } \ - changed; \ +#define SET_PARAM(param, info, iparam, word) \ +({ \ + int changed = 0; \ + if (!(info)->partial || ((info)->partial & 1 << key_##word)) { \ + if ((param)->word != (iparam)[key_##word]) \ + changed = 1; \ + (param)->word = (iparam)[key_##word]; \ + } \ + changed; \ }) -#define GET_PARAM(param, info, iparam, word) \ -do { \ - iparam[key_##word] = param->word; \ +#define GET_PARAM(param, info, iparam, word) \ +do { \ + (iparam)[key_##word] = (param)->word; \ } while (0) static const char *get_bool_name(int val) @@ -191,7 +194,7 @@ trgt_param_set(target, info); prm = &target->trgt_param; - PRINT_INFO("Target parameter changed: queued_cmnds %d", + PRINT_INFO("Target parameter changed: QueuedCommands %d", prm->queued_cmnds); } else trgt_param_get(&target->trgt_param, info); Modified: trunk/iscsi-scst/usr/plain.c =================================================================== --- trunk/iscsi-scst/usr/plain.c 2008-02-29 18:25:56 UTC (rev 297) +++ trunk/iscsi-scst/usr/plain.c 2008-03-05 18:22:01 UTC (rev 298) @@ -102,8 +102,9 @@ u32 tid; int idx, res = 0; - if (!(fp = fopen(filename, "r"))) - return -EIO; + if (!(fp = fopen(filename, "r"))) { + return errno == ENOENT ? 0 : -errno; + } tid = 0; while (fgets(buf, sizeof(buf), fp)) { @@ -520,8 +521,9 @@ u32 tid, val; int res = 0; - if (!(config = fopen(filename, "r"))) - return -errno; + if (!(config = fopen(filename, "r"))) { + return errno == ENOENT ? 0 : -errno; + } tid = 0; while (fgets(buf, BUFSIZE, config)) { Modified: trunk/scst/include/scsi_tgt.h =================================================================== --- trunk/scst/include/scsi_tgt.h 2008-02-29 18:25:56 UTC (rev 297) +++ trunk/scst/include/scsi_tgt.h 2008-03-05 18:22:01 UTC (rev 298) @@ -1077,12 +1077,6 @@ unsigned int sg_buff_modified:1; /* - * Set if the cmd's memory requirements are checked and found - * acceptable - */ - unsigned int mem_checked:1; - - /* * Set if scst_cmd_init_stage1_done() called and the target * want that preprocessing_done() will be called */ @@ -1147,6 +1141,8 @@ lun_t lun; /* LUN for this cmd */ + unsigned long start_time; + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) struct scsi_request *scsi_req; /* SCSI request */ #endif Modified: trunk/scst/src/dev_handlers/scst_cdrom.c =================================================================== --- trunk/scst/src/dev_handlers/scst_cdrom.c 2008-02-29 18:25:56 UTC (rev 297) +++ trunk/scst/src/dev_handlers/scst_cdrom.c 2008-03-05 18:22:01 UTC (rev 298) @@ -119,18 +119,17 @@ TRACE_DBG("READ_CAPACITY done: %x", res); - if (!res || (sbuff[12] != 0x28 && sbuff[12] != 0x29)) - { + if ((res == 0) || (sbuff[2] != UNIT_ATTENTION)) break; - } + if (!--retries) { - PRINT_ERROR("UA not clear after %d retries", + PRINT_ERROR("UA not cleared after %d retries", SCST_DEV_UA_RETRIES); params->block_shift = CDROM_DEF_BLOCK_SHIFT; -// res = -ENODEV; goto out_free_buf; } } + if (res == 0) { int sector_size = ((buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | (buffer[7] << 0)); @@ -143,8 +142,6 @@ } else { TRACE_BUFFER("Sense set", sbuff, SCST_SENSE_BUFFERSIZE); params->block_shift = CDROM_DEF_BLOCK_SHIFT; -// res = -ENODEV; - goto out_free_buf; } res = scst_obtain_device_parameters(dev); Modified: trunk/scst/src/dev_handlers/scst_modisk.c =================================================================== --- trunk/scst/src/dev_handlers/scst_modisk.c 2008-02-29 18:25:56 UTC (rev 297) +++ trunk/scst/src/dev_handlers/scst_modisk.c 2008-03-05 18:22:01 UTC (rev 298) @@ -207,16 +207,16 @@ TRACE_DBG("READ_CAPACITY done: %x", res); - if (!res || (sbuff[2] != UNIT_ATTENTION)) - { + if (!res || (sbuff[2] != UNIT_ATTENTION)) break; - } + if (!--retries) { - PRINT_ERROR("UA not clear after %d retries", + PRINT_ERROR("UA not cleared after %d retries", SCST_DEV_UA_RETRIES); goto out_free_buf; } } + if (res == 0) { int sector_size = ((buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | (buffer[7] << 0)); @@ -229,9 +229,10 @@ } else { TRACE_BUFFER("Sense set", sbuff, SCST_SENSE_BUFFERSIZE); - if (sbuff[2] != NOT_READY) + if (sbuff[2] != NOT_READY) { res = -ENODEV; - goto out_free_buf; + goto out_free_buf; + } } res = scst_obtain_device_parameters(dev); Modified: trunk/scst/src/scst_targ.c =================================================================== --- trunk/scst/src/scst_targ.c 2008-02-29 18:25:56 UTC (rev 297) +++ trunk/scst/src/scst_targ.c 2008-03-05 18:22:01 UTC (rev 298) @@ -76,6 +76,8 @@ cmd->tgt = sess->tgt; cmd->tgtt = sess->tgt->tgtt; + cmd->start_time = jiffies; + /* * For both wrong lun and CDB defer the error reporting for * scst_cmd_init_done() @@ -3566,9 +3568,10 @@ * we must wait here to be sure that we won't receive * double commands with the same tag. */ - TRACE_MGMT_DBG("cmd %p (tag %llu) being executed/" - "xmitted (state %d), deferring ABORT...", - cmd, cmd->tag, cmd->state); + TRACE_MGMT_DBG("cmd %p (tag %llu) being executed/xmitted " + "(state %d, proc time %ld sec.), deferring ABORT...", + cmd, cmd->tag, cmd->state, + (long)(jiffies - cmd->start_time)/HZ); mcmd->cmd_finish_wait_count++; @@ -4346,7 +4349,9 @@ sess->unreg_cmds_done_fn = NULL; } + spin_lock_irq(&scst_mcmd_lock); mcmd->nexus_loss_check_done = 1; + spin_unlock_irq(&scst_mcmd_lock); res = scst_set_mcmd_next_state(mcmd); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |