From 4afaaf3fb660b9b61476ab72dd3fd4196b09fc6f Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Fri, 30 Dec 2011 14:27:45 +0000 Subject: [PATCH] Reduced waiting time between retries of WRITE commands --- cdrskin/cdrskin_timestamp.h | 2 +- libburn/mmc.c | 33 +++++++++++++++++++++++++++++++++ libburn/spc.c | 17 ++++++++++++++--- libburn/spc.h | 10 +++++++++- 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index 62242d0..d7f5d7a 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2011.12.28.152153" +#define Cdrskin_timestamP "2011.12.30.142742" diff --git a/libburn/mmc.c b/libburn/mmc.c index b4550ec..9d37880 100644 --- a/libburn/mmc.c +++ b/libburn/mmc.c @@ -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) { diff --git a/libburn/spc.c b/libburn/spc.c index cc58f0d..d292537 100644 --- a/libburn/spc.c +++ b/libburn/spc.c @@ -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 */ - usleep_time = Libburn_scsi_retry_usleeP + - loop_count * Libburn_scsi_retry_incR; + 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,7 +1698,8 @@ int scsi_eval_cmd_outcome(struct burn_drive *d, struct command *c, void *fp, } if (d->cancel) {done = 1; goto ex;} - usleep(usleep_time); + if (usleep_time > 0) + usleep(usleep_time); if (d->cancel) {done = 1; goto ex;} if (burn_sg_log_scsi & 3) diff --git a/libburn/spc.h b/libburn/spc.h index 28467d6..bf51517 100644 --- a/libburn/spc.h +++ b/libburn/spc.h @@ -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 */