static int nodump = 0;
static off_t tape_length = (off_t)0;
static int current_tape = 0;
+static int conf_max_dle_by_volume;
static int conf_taperalgo;
static int conf_taper_parallel_write;
static int conf_runtapes;
int no_taper = FALSE;
int from_client = FALSE;
+ if (argc > 1 && argv && argv[1] && g_str_equal(argv[1], "--version")) {
+ printf("driver-%s\n", VERSION);
+ return (0);
+ }
+
/*
* Configure program for internationalization:
* 1) Only set the message locale for now.
if (argc > 2) {
if (strcmp(argv[2], "--from-client") == 0) {
from_client = TRUE;
+ from_client = from_client;
argv++;
argc--;
}
conf_taper_parallel_write = getconf_int(CNF_TAPER_PARALLEL_WRITE);
conf_tapetype = getconf_str(CNF_TAPETYPE);
conf_runtapes = getconf_int(CNF_RUNTAPES);
+ conf_max_dle_by_volume = getconf_int(CNF_MAX_DLE_BY_VOLUME);
if (conf_taper_parallel_write > conf_runtapes) {
conf_taper_parallel_write = conf_runtapes;
}
conf_flush_threshold_dumped = getconf_int(CNF_FLUSH_THRESHOLD_DUMPED);
conf_flush_threshold_scheduled = getconf_int(CNF_FLUSH_THRESHOLD_SCHEDULED);
conf_taperflush = getconf_int(CNF_TAPERFLUSH);
-
flush_threshold_dumped = (conf_flush_threshold_dumped * tape_length) / 100;
flush_threshold_scheduled = (conf_flush_threshold_scheduled * tape_length) / 100;
taperflush = (conf_taperflush *tape_length) / 100;
}
-static void startaflush_tape(taper_t *taper);
+static void startaflush_tape(taper_t *taper, gboolean *state_changed);
static void
startaflush(void)
{
taper_t *taper;
+ gboolean state_changed = FALSE;
for(taper = tapetable; taper <= tapetable+conf_taper_parallel_write;
taper++) {
if (!(taper->state & TAPER_STATE_DONE) &&
taper->state & TAPER_STATE_WAIT_FOR_TAPE) {
- startaflush_tape(taper);
+ startaflush_tape(taper, &state_changed);
}
}
for(taper = tapetable; taper <= tapetable+conf_taper_parallel_write;
taper++) {
if (!(taper->state & TAPER_STATE_DONE) &&
taper->state & TAPER_STATE_TAPE_REQUESTED) {
- startaflush_tape(taper);
+ startaflush_tape(taper, &state_changed);
}
}
for(taper = tapetable; taper <= tapetable+conf_taper_parallel_write;
taper++) {
if (!(taper->state & TAPER_STATE_DONE) &&
taper->state & TAPER_STATE_INIT) {
- startaflush_tape(taper);
+ startaflush_tape(taper, &state_changed);
}
}
for(taper = tapetable; taper <= tapetable+conf_taper_parallel_write;
taper++) {
if (!(taper->state & TAPER_STATE_DONE) &&
taper->state & TAPER_STATE_IDLE) {
- startaflush_tape(taper);
+ startaflush_tape(taper, &state_changed);
}
}
+ if (state_changed) {
+ short_dump_state();
+ }
}
static void
startaflush_tape(
- taper_t *taper)
+ taper_t *taper,
+ gboolean *state_changed)
{
disk_t *dp = NULL;
disk_t *fit = NULL;
taper_cmd(NO_NEW_TAPE, taper->disk, why_no_new_tape, 0, NULL);
taper->state |= TAPER_STATE_DONE;
start_degraded_mode(&runq);
+ *state_changed = TRUE;
} else if (result_tape_action & TAPE_ACTION_MOVE) {
taper_t *taper1 = idle_taper();
if (taper1) {
taper1->state = TAPER_STATE_DEFAULT;
taper->state |= TAPER_STATE_TAPE_STARTED;
taper->left = taper1->left;
+ taper->nb_dle++;
if (last_started_taper == taper1) {
last_started_taper = taper;
}
+ *state_changed = TRUE;
}
}
handle_taper_result, NULL);
}
taper_nb_wait_reply++;
+ taper->nb_dle++;
sched(dp)->taper = taper;
taper_cmd(FILE_WRITE, dp, sched(dp)->destname, sched(dp)->level,
sched(dp)->datestamp);
(long long)sched(taper->disk)->act_size,
(long long)taper->left);
amfree(qname);
+ *state_changed = TRUE;
}
- short_dump_state();
}
}
char dumptype;
char *dumporder;
int dumper_to_holding = 0;
+ gboolean state_changed = FALSE;
/* don't start any actual dumps until the taper is started */
if (!taper_started) return;
taper->dumper = dumper;
taper->state |= TAPER_STATE_DUMP_TO_TAPE;
taper->state &= ~TAPER_STATE_IDLE;
+ taper->nb_dle++;
if (taper_nb_wait_reply == 0) {
taper_ev_read = event_register(taper_fd, EV_READFD,
handle_taper_result, NULL);
sched(diskp)->datestamp);
diskp->host->start_t = now + 15;
- short_dump_state();
+ state_changed = TRUE;
}
}
+ if (state_changed) {
+ short_dump_state();
+ }
}
/*
}
assert(taper != NULL);
taper->left = 0;
+ taper->nb_dle = 0;
taper->state &= ~TAPER_STATE_INIT;
taper->state |= TAPER_STATE_RESERVATION;
taper->state |= TAPER_STATE_IDLE;
taper = sched(dp)->taper;
/* Update our tape counter and reset taper->left */
current_tape++;
+ taper->nb_dle = 1;
taper->left = tape_length;
taper->state &= ~TAPER_STATE_WAIT_NEW_TAPE;
taper->state |= TAPER_STATE_TAPE_STARTED;
for (taper = tapetable;
taper < tapetable + conf_taper_parallel_write;
taper++) {
- if (taper && taper->disk && taper->result != LAST_TOK) {
+ if (taper && taper->disk) {
taper->tape_error = newstralloc(taper->tape_error,"BOGUS");
taper->result = cmd;
if (taper->dumper) {
g_strfreev(result_argv);
if (taper && taper->disk && taper->result != LAST_TOK) {
+ if (taper->nb_dle >= conf_max_dle_by_volume) {
+ taper_cmd(CLOSE_VOLUME, dp, NULL, 0, NULL);
+ }
if(taper->dumper) {
if (taper->dumper->result != LAST_TOK) {
// Dumper already returned it's result
{
dumper_t *dumper;
taper_t *taper;
- int is_partial;
char *qname;
dumper = sched(dp)->dumper;
update_failed_dump(dp);
}
- is_partial = dumper->result != DONE || taper->result != DONE;
-
sched(dp)->dump_attempted += 1;
sched(dp)->taper_attempted += 1;
dumper->chunker->result != LAST_TOK)
dumper_chunker_result(dp);
} else { /* send the dumper result to the taper */
- if (taper->sendresult) {
- if (cmd == DONE) {
- taper_cmd(DONE, dp, NULL, 0, NULL);
- } else {
- taper_cmd(FAILED, dp, NULL, 0, NULL);
- }
- taper->sendresult = 0;
+ if (cmd == DONE) {
+ taper_cmd(DONE, dp, NULL, 0, NULL);
+ } else {
+ taper_cmd(FAILED, dp, NULL, 0, NULL);
}
+ taper->sendresult = 0;
if (taper->dumper && taper->result != LAST_TOK) {
dumper_taper_result(dp);
}
break;
}
}
-
+ if (!ha || j >= num_holdalloc) {
+ fprintf(stderr,_("build_diskspace: holding disk file '%s' is not in a holding disk directory.\n"), filename);
+ amfree(used);
+ amfree(result);
+ return NULL;
+ }
if(stat(filename, &finfo) == -1) {
- g_fprintf(stderr, _("stat %s: %s\n"), filename, strerror(errno));
- finfo.st_size = (off_t)0;
+ g_fprintf(stderr, _("build_diskspace: can't stat %s: %s\n"),
+ filename, strerror(errno));
+ amfree(used);
+ amfree(result);
+ return NULL;
}
used[j] += ((off_t)finfo.st_size+(off_t)1023)/(off_t)1024;
if((fd = open(filename,O_RDONLY)) == -1) {
int dump_to_disk_terminated;
int nb_taper_active = nb_sent_new_tape;
int nb_taper_flushing = 0;
+ int dle_free = 0;
off_t data_next_tape = 0;
off_t data_free = 0;
off_t data_lost = 0;
off_t data_lost_next_tape = 0;
+ gboolean allow_size_or_number;
dumpers_size = 0;
for(dumper = dmptable; dumper < (dmptable+inparallel); dumper++) {
if (dumper->busy && !sched(dumper->dp)->taper)
dumpers_size += sched(dumper->dp)->est_size;
}
- driver_debug(1, _("dumpers_size: %lld\n"), (long long)dumpers_size);
+ driver_debug(2, _("dumpers_size: %lld\n"), (long long)dumpers_size);
runq_size = 0;
for(dp = runq.head; dp != NULL; dp = dp->next) {
runq_size += sched(dp)->est_size;
}
- driver_debug(1, _("runq_size: %lld\n"), (long long)runq_size);
+ driver_debug(2, _("runq_size: %lld\n"), (long long)runq_size);
directq_size = 0;
for(dp = directq.head; dp != NULL; dp = dp->next) {
directq_size += sched(dp)->est_size;
}
- driver_debug(1, _("directq_size: %lld\n"), (long long)directq_size);
+ driver_debug(2, _("directq_size: %lld\n"), (long long)directq_size);
tapeq_size = directq_size;
for(dp = tapeq.head; dp != NULL; dp = dp->next) {
taper1++) {
if (taper1->state & TAPER_STATE_TAPE_STARTED) {
tapeq_size -= taper1->left;
+ dle_free += (conf_max_dle_by_volume - taper1->nb_dle);
}
if (taper1->disk) {
off_t data_to_go;
if (data_to_go > taper1->left) {
data_next_tape += data_to_go - taper1->left;
data_lost += taper1->written + taper1->left;
+ if (taper1->state & TAPER_STATE_TAPE_STARTED) {
+ dle_free--;
+ } else {
+ dle_free += conf_max_dle_by_volume - 2;
+ }
} else {
data_free += taper1->left - data_to_go;
}
}
}
data_lost_next_tape = tape_length + data_free - data_next_tape - runq_size - directq_size - tapeq_size;
- driver_debug(1, _("data_lost: %lld\n"), (long long)data_lost);
- driver_debug(1, _("data_free: %lld\n"), (long long)data_free);
- driver_debug(1, _("data_next_tape: %lld\n"), (long long)data_next_tape);
- driver_debug(1, _("data_lost_next_tape: %lld\n"), (long long)data_lost_next_tape);
+ driver_debug(2, _("dle_free: %d\n"), dle_free);
+ driver_debug(2, _("data_lost: %lld\n"), (long long)data_lost);
+ driver_debug(2, _("data_free: %lld\n"), (long long)data_free);
+ driver_debug(2, _("data_next_tape: %lld\n"), (long long)data_next_tape);
+ driver_debug(2, _("data_lost_next_tape: %lld\n"), (long long)data_lost_next_tape);
;
- driver_debug(1, _("tapeq_size: %lld\n"), (long long)tapeq_size);
+ driver_debug(2, _("tapeq_size: %lld\n"), (long long)tapeq_size);
sched_size = runq_size + directq_size + tapeq_size + dumpers_size;
- driver_debug(1, _("sched_size: %lld\n"), (long long)sched_size);
+ driver_debug(2, _("sched_size: %lld\n"), (long long)sched_size);
dump_to_disk_size = dumpers_size + runq_size + directq_size;
- driver_debug(1, _("dump_to_disk_size: %lld\n"), (long long)dump_to_disk_size);
+ driver_debug(2, _("dump_to_disk_size: %lld\n"), (long long)dump_to_disk_size);
dump_to_disk_terminated = schedule_done && dump_to_disk_size == 0;
}
}
+ allow_size_or_number = (flush_threshold_dumped < tapeq_size &&
+ flush_threshold_scheduled < sched_size) ||
+ (dle_free < (queue_length(runq) +
+ queue_length(directq) +
+ queue_length(tapeq)));
+ driver_debug(2, "queue_length(runq) %d\n", queue_length(runq));
+ driver_debug(2, "queue_length(directq) %d\n", queue_length(directq));
+ driver_debug(2, "queue_length(tapeq) %d\n", queue_length(tapeq));
+ driver_debug(2, "allow_size_or_number %d\n", allow_size_or_number);
+
// Changing conditionals can produce a driver hang, take care.
//
// when to start writting to a new tape
if (taper->state & TAPER_STATE_TAPE_REQUESTED) {
+ driver_debug(2, "tape_action: TAPER_STATE_TAPE_REQUESTED\n");
if (current_tape >= conf_runtapes && taper_nb_scan_volume == 0 &&
nb_taper_active == 0) {
*why_no_new_tape = g_strdup_printf(_("%d tapes filled; runtapes=%d "
result |= TAPE_ACTION_NO_NEW_TAPE;
} else if (current_tape < conf_runtapes &&
taper_nb_scan_volume == 0 &&
- ((flush_threshold_dumped < tapeq_size &&
- flush_threshold_scheduled < sched_size) ||
+ (allow_size_or_number ||
(data_lost > data_lost_next_tape) ||
nb_taper_active == 0) &&
(last_started_taper == NULL ||
!empty(directq) || // if a dle is waiting for a dump to tape
!empty(roomq) || // holding disk constraint
idle_reason == IDLE_NO_DISKSPACE || // holding disk constraint
- (flush_threshold_dumped < tapeq_size && // flush-threshold-dumped &&
- flush_threshold_scheduled < sched_size) || // flush-threshold-scheduled
+ allow_size_or_number ||
(data_lost > data_lost_next_tape) ||
(taperflush < tapeq_size && // taperflush
(force_flush == 1 || // if force_flush
dump_to_disk_terminated)) // or all dump to disk terminated
)) {
+ driver_debug(2, "tape_action: TAPER_STATE_WAIT_FOR_TAPE return TAPE_ACTION_NEW_TAPE\n");
result |= TAPE_ACTION_NEW_TAPE;
// when to stop using new tape
} else if ((taper->state & TAPER_STATE_WAIT_FOR_TAPE) &&
(force_flush == 1 || // if force_flush
dump_to_disk_terminated)) // or all dump to disk
) {
+ driver_debug(2, "tape_action: TAPER_STATE_WAIT_FOR_TAPE B\n");
if (nb_taper_active <= 0) {
if (current_tape >= conf_runtapes) {
*why_no_new_tape = g_strdup_printf(_("%d tapes filled; runtapes=%d "
"does not allow additional tapes"), current_tape, conf_runtapes);
- } else {
+ driver_debug(2, "tape_action: TAPER_STATE_WAIT_FOR_TAPE return TAPE_ACTION_NO_NEW_TAPE\n");
+ result |= TAPE_ACTION_NO_NEW_TAPE;
+ } else if (dumpers_size <= 0) {
*why_no_new_tape = _("taperflush criteria not met");
+ driver_debug(2, "tape_action: TAPER_STATE_WAIT_FOR_TAPE return TAPE_ACTION_NO_NEW_TAPE\n");
+ result |= TAPE_ACTION_NO_NEW_TAPE;
}
- result |= TAPE_ACTION_NO_NEW_TAPE;
}
}
// when to start a flush
if (taper->state & TAPER_STATE_IDLE) {
+ driver_debug(2, "tape_action: TAPER_STATE_IDLE\n");
if (!degraded_mode && (!empty(tapeq) || !empty(directq)) &&
(taper->state & TAPER_STATE_TAPE_STARTED || // tape already started
!empty(roomq) || // holding disk constraint
idle_reason == IDLE_NO_DISKSPACE || // holding disk constraint
- (flush_threshold_dumped < tapeq_size && // flush-threshold-dumped &&
- flush_threshold_scheduled < sched_size) || // flush-threshold-scheduled
+ allow_size_or_number ||
(force_flush == 1 && taperflush < tapeq_size))) { // taperflush if force_flush
if (nb_taper_flushing == 0) {