Reduced waiting time between retries of WRITE commands

This commit is contained in:
Thomas Schmitt 2011-12-30 14:27:45 +00:00
parent 8f725bab11
commit 4afaaf3fb6
4 changed files with 57 additions and 5 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2011.12.28.152153"
#define Cdrskin_timestamP "2011.12.30.142742"

View File

@ -873,6 +873,30 @@ void mmc_write_12(struct burn_drive *d, int start, struct buffer *buf)
}
#ifdef Libburn_write_time_debuG
static int print_time(int flag)
{
static struct timeval prev = {0, 0};
struct timeval now;
struct timezone tz;
int ret, diff;
ret = gettimeofday(&now, &tz);
if (ret == -1)
return 0;
if (now.tv_sec - prev.tv_sec < Libburn_scsi_write_timeouT) {
diff = (now.tv_sec - prev.tv_sec) * 1000000 +
((int) (now.tv_usec) - (int) prev.tv_usec);
fprintf(stderr, "\nlibburn_DEBUG: %d.%-6d : %d\n", (int) now.tv_sec, (int) now.tv_usec, diff);
}
memcpy(&prev, &now, sizeof(struct timeval));
return 1;
}
#endif /* Libburn_write_time_debuG */
int mmc_write(struct burn_drive *d, int start, struct buffer *buf)
{
int cancelled;
@ -880,6 +904,10 @@ int mmc_write(struct burn_drive *d, int start, struct buffer *buf)
int len, key, asc, ascq;
char *msg = NULL;
#ifdef Libburn_write_time_debuG
extern int burn_sg_log_scsi;
#endif
c = &(d->casual_command);
#ifdef Libburn_log_in_and_out_streaM
@ -925,6 +953,11 @@ int mmc_write(struct burn_drive *d, int start, struct buffer *buf)
if(d->wait_for_buffer_free)
mmc_wait_for_buffer_free(d, buf);
#ifdef Libburn_write_time_debuG
if (burn_sg_log_scsi & 3)
print_time(0);
#endif
/* ts A80412 */
if(d->do_stream_recording > 0 && start >= d->stream_recording_start) {

View File

@ -1671,8 +1671,18 @@ int scsi_eval_cmd_outcome(struct burn_drive *d, struct command *c, void *fp,
if (outcome == RETRY && c->retry && !(flag & 1)) {
/* Calming down retries and breaking up endless cycle
*/
if (c->opcode[0] == 0x2A || c->opcode[0] == 0xAA) {
/* WRITE(10) , WRITE(12) */
usleep_time = Libburn_scsi_write_retry_usleeP +
loop_count * Libburn_scsi_write_retry_incR;
if (usleep_time > Libburn_scsi_write_retry_umaX)
usleep_time = Libburn_scsi_write_retry_umaX;
} else {
usleep_time = Libburn_scsi_retry_usleeP +
loop_count * Libburn_scsi_retry_incR;
if (usleep_time > Libburn_scsi_retry_umaX)
usleep_time = Libburn_scsi_retry_umaX;
}
if (time(NULL) + usleep_time / 1000000 - start_time >
timeout_ms / 1000 + 1) {
BURN_ALLOC_MEM(msg, char, 320);
@ -1688,6 +1698,7 @@ int scsi_eval_cmd_outcome(struct burn_drive *d, struct command *c, void *fp,
}
if (d->cancel)
{done = 1; goto ex;}
if (usleep_time > 0)
usleep(usleep_time);
if (d->cancel)
{done = 1; goto ex;}

View File

@ -111,12 +111,20 @@ int scsi_eval_cmd_outcome(struct burn_drive *d, struct command *c, void *fp_in,
int duration, time_t start_time, int timeout_ms,
int loop_count, int flag);
/* The waiting time before eventually retrying a failed SCSI command.
Before each retry wait Libburn_scsi_retry_incR longer than with
the previous one.
the previous one. At most wait for Libburn_scsi_retry_umaX microseconds.
*/
#define Libburn_scsi_retry_usleeP 100000
#define Libburn_scsi_retry_incR 100000
#define Libburn_scsi_retry_umaX 500000
/* The retry waiting time for commands WRITE(10) and WRITE(12).
*/
#define Libburn_scsi_write_retry_usleeP 0
#define Libburn_scsi_write_retry_incR 2000
#define Libburn_scsi_write_retry_umaX 25000
/* ts B11124 */