#include "server_util.h"
#include "holding.h"
+#define planner_debug(i,x) do { \
+ if ((i) <= debug_planner) { \
+ dbprintf(x); \
+ } \
+} while (0)
+
#define MAX_LEVELS 3 /* max# of estimates per filesys */
#define RUNS_REDZONE 5 /* should be in conf file? */
int new_argc, my_argc;
char **new_argv, **my_argv;
int nb_disk;
- char *errstr;
+ char *errstr = NULL;
safe_fd(-1, 0);
setvbuf(stderr, (char *)NULL, (int)_IOLBF, 0);
- parse_server_conf(argc, argv, &new_argc, &new_argv);
+ parse_conf(argc, argv, &new_argc, &new_argv);
my_argc = new_argc;
my_argv = new_argv;
error("could not open info db \"%s\"", conf_infofile);
/*NOTREACHED*/
}
+ if (check_infofile(conf_infofile, &origq, &errstr) == -1) {
+ log_add(L_WARNING, "problem copying infofile: %s", errstr);
+ amfree(errstr);
+ }
amfree(conf_infofile);
conf_tapetype = getconf_str(CNF_TAPETYPE);
conf_dumpcycle = getconf_int(CNF_DUMPCYCLE);
conf_runspercycle = getconf_int(CNF_RUNSPERCYCLE);
conf_tapecycle = getconf_int(CNF_TAPECYCLE);
- conf_etimeout = getconf_time(CNF_ETIMEOUT);
+ conf_etimeout = (time_t)getconf_int(CNF_ETIMEOUT);
conf_reserve = getconf_int(CNF_RESERVE);
conf_autoflush = getconf_boolean(CNF_AUTOFLUSH);
conf_usetimestamps = getconf_boolean(CNF_USETIMESTAMPS);
dumpfile_t file;
sl_t *holding_list;
sle_t *holding_file;
- holding_list = get_flush(NULL, NULL, 0, 0);
+ char *qdisk, *qhname;
+ holding_list = holding_get_files_for_flush(NULL, 0);
for(holding_file=holding_list->first; holding_file != NULL;
holding_file = holding_file->next) {
- get_dumpfile(holding_file->name, &file);
+ holding_file_get_dumpfile(holding_file->name, &file);
+
+ if (holding_file_size(holding_file->name, 1) <= 0) {
+ log_add(L_INFO, "%s: removing file with no data.",
+ holding_file->name);
+ holding_file_unlink(holding_file->name);
+ continue;
+ }
- log_add(L_DISK, "%s %s", file.name, file.disk);
+ qdisk = quote_string(file.disk);
+ qhname = quote_string(holding_file->name);
+ log_add(L_DISK, "%s %s", file.name, qdisk);
fprintf(stderr,
"FLUSH %s %s %s %d %s\n",
file.name,
- file.disk,
+ qdisk,
file.datestamp,
file.dumplevel,
- holding_file->name);
+ qhname);
fprintf(stdout,
"FLUSH %s %s %s %d %s\n",
file.name,
- file.disk,
+ qdisk,
file.datestamp,
file.dumplevel,
- holding_file->name);
+ qhname);
+ amfree(qdisk);
+ amfree(qhname);
}
free_sl(holding_list);
holding_list = NULL;
/* adjust priority levels */
/* warn if dump will be overwritten */
- if(ep->last_level > -1) {
+ if (ep->last_level > -1 && strlen(info.inf[0].label) > 0) {
overwrite_runs = when_overwrite(info.inf[0].label);
if(overwrite_runs == 0) {
log_add(L_WARNING, "Last full dump of %s:%s "
time_t estimates, timeout;
size_t req_len;
const security_driver_t *secdrv;
- char * dumper;
+ char * backup_api;
char * calcsize;
char * qname;
+ char * qdevice;
assert(hostp->disks != NULL);
}
qname = quote_string(dp->name);
+ qdevice = quote_string(dp->device);
if(dp->estimate == ES_CLIENT ||
dp->estimate == ES_CALCSIZE) {
nb_client++;
else
calcsize = "CALCSIZE ";
- if(strncmp(dp->program,"DUMP",4) == 0 ||
- strncmp(dp->program,"GNUTAR",6) == 0) {
- dumper = "";
+ if(strcmp(dp->program,"DUMP") == 0 ||
+ strcmp(dp->program,"GNUTAR") == 0) {
+ backup_api = "";
} else {
- dumper = "DUMPER ";
+ backup_api = "BACKUP ";
}
l = vstralloc(calcsize,
- dumper,
+ backup_api,
dp->program,
" ", qname,
- " ", dp->device ? dp->device : "",
+ " ", dp->device ? qdevice : "",
" ", level,
" ", est(dp)->dumpdate[i],
" ", spindle,
enqueue_disk(&estq, dp);
}
amfree(qname);
+ amfree(qdevice);
}
if(estimates == 0) {
* We use ctimeout for the "noop" request because it should be
* very fast and etimeout has other side effects.
*/
- timeout = getconf_time(CNF_CTIMEOUT);
+ timeout = (time_t)getconf_int(CNF_CTIMEOUT);
}
secdrv = security_getdriver(hostp->disks->security_driver);
off_t size;
disk_t *dp;
am_host_t *hostp;
- char *msgdisk=NULL, *msgdisk_undo=NULL, msgdisk_undo_ch = '\0';
+ char *msg, msg_undo;
char *remoterr, *errbuf = NULL;
char *s;
char *t;
int tch;
char *qname;
char *disk;
+ OFF_T_FMT_TYPE size_;
hostp = (am_host_t *)datap;
hostp->up = HOST_READY;
goto error_return;
}
if (pkt->type == P_NAK) {
-#define sc "ERROR "
- if(strncmp(pkt->body, sc, SIZEOF(sc)-1) == 0) {
- s = pkt->body + SIZEOF(sc)-1;
+ s = pkt->body;
+ if(strncmp_const_skip(s, "ERROR ", s, ch) == 0) {
ch = *s++;
-#undef sc
} else {
goto NAK_parse_failed;
}
}
}
- msgdisk_undo = NULL;
s = pkt->body;
ch = *s++;
while(ch) {
line = s - 1;
-#define sc "OPTIONS "
- if(strncmp(line, sc, SIZEOF(sc)-1) == 0) {
-#undef sc
-
-#define sc "features="
- t = strstr(line, sc);
+ if(strncmp_const(line, "OPTIONS ") == 0) {
+ t = strstr(line, "features=");
if(t != NULL && (isspace((int)t[-1]) || t[-1] == ';')) {
- t += SIZEOF(sc)-1;
-#undef sc
+ t += SIZEOF("features=")-1;
am_release_feature_set(hostp->features);
if((hostp->features = am_string_to_feature(t)) == NULL) {
errbuf = vstralloc(hostp->hostname,
continue;
}
-#define sc "ERROR "
- if(strncmp(line, sc, SIZEOF(sc) - 1) == 0) {
- t = line + SIZEOF(sc) - 1;
- tch = t[-1];
-#undef sc
-
+ t = line;
+ if(strncmp_const_skip(t, "ERROR ", t, tch) == 0) {
fp = t - 1;
skip_whitespace(t, tch);
if (tch == '\n') {
&& pkt->type == P_NAK
&& (strcmp(t - 1, "unknown service: noop") == 0
|| strcmp(t - 1, "noop: invalid service") == 0)) {
+ skip_quoted_line(s, ch);
continue;
}
errbuf = vstralloc(hostp->hostname,
goto error_return;
}
- msgdisk = t = line;
+ msg = t = line;
tch = *(t++);
skip_quoted_string(t, tch);
- msgdisk_undo = t - 1;
- msgdisk_undo_ch = *msgdisk_undo;
- *msgdisk_undo = '\0';
- disk = unquote_string(msgdisk);
+ t[-1] = '\0';
+ disk = unquote_string(msg);
+
skip_whitespace(t, tch);
- s = t;
- ch = tch;
- if (sscanf(t - 1, "%d SIZE " OFF_T_FMT , &level,
- (OFF_T_FMT_TYPE *)&size) != 2) {
+ if (sscanf(t - 1, "%d", &level) != 1) {
goto bad_msg;
}
- dp = lookup_hostdisk(hostp, disk);
- amfree(disk);
- *msgdisk_undo = msgdisk_undo_ch; /* for error message */
- msgdisk_undo = NULL;
+ skip_integer(t, tch);
+ skip_whitespace(t, tch);
+ dp = lookup_hostdisk(hostp, disk);
+ dp = lookup_hostdisk(hostp, disk);
if(dp == NULL) {
log_add(L_ERROR, "%s: invalid reply from sendsize: `%s'\n",
hostp->hostname, line);
+ goto bad_msg;
+ }
+
+ size = (off_t)-1;
+ if (strncmp_const(t-1,"SIZE ") == 0) {
+ if (sscanf(t - 1, "SIZE " OFF_T_FMT ,
+ (OFF_T_FMT_TYPE *)&size_) != 1) {
+ goto bad_msg;
+ }
+ size = size_;
+ } else if (strncmp_const(t-1,"ERROR ") == 0) {
+ skip_non_whitespace(t, tch);
+ skip_whitespace(t, tch);
+ msg = t-1;
+ skip_quoted_string(t,tch);
+ msg_undo = t[-1];
+ t[-1] = '\0';
+ if (pkt->type == P_REP) {
+ est(dp)->errstr = unquote_string(msg);
+ }
+ t[-1] = msg_undo;
} else {
+ goto bad_msg;
+ }
+
+ amfree(disk);
+
+ if (size > (off_t)-1) {
for(i = 0; i < MAX_LEVELS; i++) {
if(est(dp)->level[i] == level) {
est(dp)->est_size[i] = size;
}
est(dp)->got_estimate++;
}
+ s = t;
+ ch = tch;
skip_quoted_line(s, ch);
}
", all estimate failed", NULL);
}
else {
- fprintf(stderr, "error result for host %s disk %s: missing estimate\n",
- dp->host->hostname, qname);
- est(dp)->errstr = vstralloc("missing result for ", qname,
- " in ", dp->host->hostname,
- " response",
- NULL);
+ fprintf(stderr,
+ "error result for host %s disk %s: missing estimate\n",
+ dp->host->hostname, qname);
+ if (est(dp)->errstr == NULL) {
+ est(dp)->errstr = vstralloc("missing result for ",
+ qname, " in ",
+ dp->host->hostname,
+ " response", NULL);
+ }
}
}
}
NAK_parse_failed:
- /* msgdisk_undo is always NULL */
- /* if(msgdisk_undo) { */
- /* *msgdisk_undo = msgdisk_undo_ch; */
- /* msgdisk_undo = NULL; */
- /* } */
errbuf = stralloc2(hostp->hostname, " NAK: [NAK parse failed]");
fprintf(stderr, "got strange nak from %s:\n----\n%s----\n\n",
hostp->hostname, pkt->body);
goto error_return;
bad_msg:
- if(msgdisk_undo) {
- *msgdisk_undo = msgdisk_undo_ch;
- msgdisk_undo = NULL;
- }
fprintf(stderr,"got a bad message, stopped at:\n");
/*@ignore@*/
fprintf(stderr,"----\n%s----\n\n", line);
errstr = est(dp)->errstr? est(dp)->errstr : "hmm, no error indicator!";
+fprintf(stderr,"errstr:%s:\n", errstr);
fprintf(stderr, "%s: FAILED %s %s %s 0 [%s]\n",
get_pname(), dp->host->hostname, qname, planner_timestamp, errstr);
full_size = est_tape_size(dp, 0);
if (full_size > tapetype_get_length(tape) * (off_t)avail_tapes) {
char *qname = quote_string(dp->name);
- log_add(L_WARNING, "disk %s:%s, full dump (" OFF_T_FMT
- "KB) will be larger than available tape space",
- dp->host->hostname, qname,
- (OFF_T_FMT_TYPE)full_size);
+ if (conf_runtapes > 1 && dp->tape_splitsize == (off_t)0) {
+ log_add(L_WARNING, "disk %s:%s, full dump (" OFF_T_FMT
+ "KB) will be larger than available tape space"
+ ", you could define a splitsize",
+ dp->host->hostname, qname,
+ (OFF_T_FMT_TYPE)full_size);
+ } else {
+ log_add(L_WARNING, "disk %s:%s, full dump (" OFF_T_FMT
+ "KB) will be larger than available tape space",
+ dp->host->hostname, qname,
+ (OFF_T_FMT_TYPE)full_size);
+ }
amfree(qname);
}