if (item == -1) { /* find oldest volume */
/* Find oldest volume */
Mmsg(&mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks,"
-"VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
-"VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot,"
-"FirstWritten,LastWritten,VolStatus "
-"FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus IN ('Full',"
-"'Recycle','Purged','Used','Append') "
-"ORDER BY LastWritten LIMIT 1", mr->PoolId, mr->MediaType);
+ "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
+ "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot,"
+ "FirstWritten,LastWritten,VolStatus "
+ "FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus IN ('Full',"
+ "'Recycle','Purged','Used','Append') "
+ "ORDER BY LastWritten LIMIT 1", mr->PoolId, mr->MediaType);
item = 1;
} else {
/* Find next available volume */
Mmsg(&mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks,"
-"VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
-"VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot,"
-"FirstWritten,LastWritten,VolStatus "
-"FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus='%s' "
-"ORDER BY MediaId", mr->PoolId, mr->MediaType, mr->VolStatus);
+ "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
+ "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot,"
+ "FirstWritten,LastWritten,VolStatus "
+ "FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus='%s' "
+ "ORDER BY LastWritten",
+ mr->PoolId, mr->MediaType, mr->VolStatus);
}
if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
db_unlock(mdb);
mr->VolJobs, mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1),
mr->VolMounts, mr->VolErrors, mr->VolWrites,
edit_uint64(mr->MaxVolBytes, ed2), dt,
- mr->VolStatus, mr->Slot, mr->VolumeName, mr->Drive, mr->InChanger);
+ mr->VolStatus, mr->Slot, mr->Drive, mr->InChanger, mr->VolumeName);
Dmsg1(400, "%s\n", mdb->cmd);
Jmsg(jcr, M_FATAL, 0, _("No Job status returned from FD.\n"));
}
-// Dmsg4(000, "fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", fd_ok, jcr->FDJobStatus,
+// Dmsg4(100, "fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", fd_ok, jcr->FDJobStatus,
// jcr->JobStatus, jcr->SDJobStatus);
/* Return the first error status we find Dir, FD, or SD */
&sdmr.Slot, &label, &sdmr.Drive, &sdmr.InChanger) == 16) {
db_lock(jcr->db);
- Dmsg3(400, "Update media %s oldStat=%s newStat=%s\n", sdmr.VolumeName,
+ Dmsg3(100, "Update media %s oldStat=%s newStat=%s\n", sdmr.VolumeName,
mr.VolStatus, sdmr.VolStatus);
bstrncpy(mr.VolumeName, sdmr.VolumeName, sizeof(mr.VolumeName)); /* copy Volume name */
unbash_spaces(mr.VolumeName);
mr.FirstWritten = jcr->start_time; /* use Job start time as first write */
}
/* If we just labeled the tape set time */
- Dmsg2(400, "label=%d labeldate=%d\n", label, mr.LabelDate);
+ Dmsg2(100, "label=%d labeldate=%d\n", label, mr.LabelDate);
if (label || mr.LabelDate == 0) {
mr.LabelDate = time(NULL);
}
- Dmsg2(200, "Update media: BefVolJobs=%u After=%u\n", mr.VolJobs, sdmr.VolJobs);
+ Dmsg2(100, "Update media: BefVolJobs=%u After=%u\n", mr.VolJobs, sdmr.VolJobs);
/* Copy updated values to original media record */
mr.VolJobs = sdmr.VolJobs;
mr.VolFiles = sdmr.VolFiles;
mr.InChanger = sdmr.InChanger;
bstrncpy(mr.VolStatus, sdmr.VolStatus, sizeof(mr.VolStatus));
- Dmsg2(200, "db_update_media_record. Stat=%s Vol=%s\n", mr.VolStatus, mr.VolumeName);
+ Dmsg2(100, "db_update_media_record. Stat=%s Vol=%s\n", mr.VolStatus, mr.VolumeName);
/*
* Check if it has expired, and if not update the DB. Note, if
* Volume has expired, has_volume_expired() will update the DB.
/******FIXME**** send read volume usage statistics to director */
} else if (dev->num_writers > 0) {
- ASSERT(dev_state(dev, ST_APPEND));
dev->num_writers--;
Dmsg1(100, "There are %d writers in release_device\n", dev->num_writers);
if (dev->num_writers == 0) {
int32_t file_index, stream, last_file_index;
BSOCK *ds;
BSOCK *fd_sock = jcr->file_bsock;
- int ok = TRUE;
+ bool ok = true;
DEVICE *dev = jcr->device->dev;
DEV_RECORD rec;
DEV_BLOCK *block;
Jmsg1(jcr, M_FATAL, 0, _("Write session label failed. ERR=%s\n"),
strerror_dev(dev));
set_jcr_job_status(jcr, JS_ErrorTerminated);
- ok = FALSE;
+ ok = false;
}
}
Jmsg1(jcr, M_FATAL, 0, _("Error reading data header from FD. ERR=%s\n"),
bnet_strerror(ds));
- ok = FALSE;
+ ok = false;
break;
}
}
if (!B_ISSPACE(*p) || !B_ISDIGIT(*(p+1))) {
Jmsg1(jcr, M_FATAL, 0, _("Malformed data header from FD: %s\n"), ds->msg);
- ok = FALSE;
+ ok = false;
break;
}
stream = (int32_t)str_to_int64(p);
if (!(file_index > 0 && (file_index == last_file_index ||
file_index == last_file_index + 1))) {
Jmsg0(jcr, M_FATAL, 0, _("File index from FD not positive or sequential\n"));
- ok = FALSE;
+ ok = false;
break;
}
if (file_index != last_file_index) {
dev_name(dev), strerror_dev(dev));
Jmsg(jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
strerror_dev(dev));
- ok = FALSE;
+ ok = false;
break;
}
}
if (!dir_update_file_attributes(jcr, &rec)) {
Jmsg(jcr, M_FATAL, 0, _("Error updating file attributes. ERR=%s\n"),
bnet_strerror(jcr->dir_bsock));
- ok = FALSE;
+ ok = false;
jcr->dir_bsock->spool = 0;
break;
}
if (is_bnet_error(ds)) {
Jmsg1(jcr, M_FATAL, 0, _("Network error on data channel. ERR=%s\n"),
bnet_strerror(ds));
- ok = FALSE;
+ ok = false;
break;
}
}
- /*
- * We probably need a new flag that says "Do not attempt
- * to write because there is no tape".
- */
- Dmsg0(90, "Write_end_session_label()\n");
/* Create Job status for end of session label */
set_jcr_job_status(jcr, ok?JS_Terminated:JS_ErrorTerminated);
Jmsg1(jcr, M_FATAL, 0, _("Error writting end session label. ERR=%s\n"),
strerror_dev(dev));
set_jcr_job_status(jcr, JS_ErrorTerminated);
- ok = FALSE;
+ ok = false;
}
+ Dmsg0(90, "back from write_end_session_label()\n");
/* Flush out final partial block of this session */
if (!write_block_to_device(jcr, dev, block)) {
Dmsg0(100, _("Set ok=FALSE after write_block_to_device.\n"));
set_jcr_job_status(jcr, JS_ErrorTerminated);
- ok = FALSE;
+ ok = false;
}
}
- Dmsg1(200, "release device JobStatus=%d\n", jcr->JobStatus);
+ Dmsg1(200, "calling release device JobStatus=%d\n", jcr->JobStatus);
/* Release the device */
if (!release_device(jcr, dev)) {
Pmsg0(000, _("Error in release_device\n"));
set_jcr_job_status(jcr, JS_ErrorTerminated);
- ok = FALSE;
+ ok = false;
}
free_block(block);
vol->VolCatWrites, edit_uint64(vol->VolCatMaxBytes, ed2),
EndTime, vol->VolCatStatus, vol->Slot, label, vol->Drive,
vol->InChanger);
- Dmsg1(120, "update_volume_data(): %s", dir->msg);
+ Dmsg1(120, "update_volume_info(): %s", dir->msg);
unbash_spaces(vol->VolCatName);
if (!do_get_volume_info(jcr)) {
Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg);
return 0;
}
+ Dmsg1(120, "get_volume_info(): %s", dir->msg);
/* Update dev Volume info in case something changed (e.g. expired) */
memcpy(&dev->VolCatInfo, &jcr->VolCatInfo, sizeof(dev->VolCatInfo));
return 1;
slot = jcr->VolCatInfo.Slot;
}
}
- Dmsg1(100, "Want changer slot=%d\n", slot);
+ Dmsg1(400, "Want changer slot=%d\n", slot);
if (slot > 0 && jcr->device->changer_name && jcr->device->changer_command) {
uint32_t timeout = jcr->device->max_changer_wait;
Jmsg(jcr, M_INFO, 0, _("3991 Bad autochanger \"load slot\" status=%d.\n"), status);
loaded = -1; /* force unload */
}
- Dmsg1(100, "loaded=%s\n", results);
+ Dmsg1(400, "loaded=%s\n", results);
/* If bad status or tape we want is not loaded, load it. */
if (status != 0 || loaded != slot) {
/* We are going to load a new tape, so close the device */
force_close_dev(dev);
if (loaded != 0) { /* must unload drive */
- Dmsg0(100, "Doing changer unload.\n");
+ Dmsg0(400, "Doing changer unload.\n");
Jmsg(jcr, M_INFO, 0, _("3302 Issuing autochanger \"unload\" command.\n"));
changer = edit_device_codes(jcr, changer,
jcr->device->changer_command, "unload");
status = run_program(changer, timeout, NULL);
- Dmsg1(100, "unload status=%d\n", status);
+ Dmsg1(400, "unload status=%d\n", status);
}
/*
* Load the desired cassette
*/
- Dmsg1(100, "Doing changer load slot %d\n", slot);
+ Dmsg1(400, "Doing changer load slot %d\n", slot);
Jmsg(jcr, M_INFO, 0, _("3303 Issuing autochanger \"load slot %d\" command.\n"),
slot);
changer = edit_device_codes(jcr, changer,
Jmsg(jcr, M_INFO, 0, _("3992 Bad autochanger \"load slot\" status=%d.\n"),
status);
}
- Dmsg2(100, "load slot %d status=%d\n", slot, status);
+ Dmsg2(400, "load slot %d status=%d\n", slot, status);
}
free_pool_memory(changer);
free_pool_memory(results);
- Dmsg1(100, "After changer, status=%d\n", status);
+ Dmsg1(400, "After changer, status=%d\n", status);
if (status == 0) { /* did we succeed? */
rtn_stat = 1; /* tape loaded by changer */
}
char add[20];
*omsg = 0;
- Dmsg1(200, "edit_device_codes: %s\n", imsg);
+ Dmsg1(400, "edit_device_codes: %s\n", imsg);
for (p=imsg; *p; p++) {
if (*p == '%') {
switch (*++p) {
add[1] = 0;
str = add;
}
- Dmsg1(200, "add_str %s\n", str);
+ Dmsg1(400, "add_str %s\n", str);
pm_strcat(&omsg, (char *)str);
- Dmsg1(200, "omsg=%s\n", omsg);
+ Dmsg1(400, "omsg=%s\n", omsg);
}
return omsg;
}
default:
break;
}
+ if (debug_level > 1) {
+ bnet_fsend(user, _("Configured device capabilities:\n"));
+ bnet_fsend(user, "%sEOF ", dev->capabilities & CAP_EOF ? "" : "!");
+ bnet_fsend(user, "%sBSR ", dev->capabilities & CAP_BSR ? "" : "!");
+ bnet_fsend(user, "%sBSF ", dev->capabilities & CAP_BSF ? "" : "!");
+ bnet_fsend(user, "%sFSR ", dev->capabilities & CAP_FSR ? "" : "!");
+ bnet_fsend(user, "%sFSF ", dev->capabilities & CAP_FSF ? "" : "!");
+ bnet_fsend(user, "%sEOM ", dev->capabilities & CAP_EOM ? "" : "!");
+ bnet_fsend(user, "%sREM ", dev->capabilities & CAP_REM ? "" : "!");
+ bnet_fsend(user, "%sRACCESS ", dev->capabilities & CAP_RACCESS ? "" : "!");
+ bnet_fsend(user, "%sAUTOMOUNT ", dev->capabilities & CAP_AUTOMOUNT ? "" : "!");
+ bnet_fsend(user, "%sLABEL ", dev->capabilities & CAP_LABEL ? "" : "!");
+ bnet_fsend(user, "%sANONVOLS ", dev->capabilities & CAP_ANONVOLS ? "" : "!");
+ bnet_fsend(user, "%sALWAYSOPEN ", dev->capabilities & CAP_ALWAYSOPEN ? "" : "!");
+ bnet_fsend(user, "\n");
+
+ bnet_fsend(user, _("Device status:\n"));
+ bnet_fsend(user, "%sOPENED ", dev->state & ST_OPENED ? "" : "!");
+ bnet_fsend(user, "%sTAPE ", dev->state & ST_TAPE ? "" : "!");
+ bnet_fsend(user, "%sLABEL ", dev->state & ST_LABEL ? "" : "!");
+ bnet_fsend(user, "%sMALLOC ", dev->state & ST_MALLOC ? "" : "!");
+ bnet_fsend(user, "%sAPPEND ", dev->state & ST_APPEND ? "" : "!");
+ bnet_fsend(user, "%sREAD ", dev->state & ST_READ ? "" : "!");
+ bnet_fsend(user, "%sEOT ", dev->state & ST_EOT ? "" : "!");
+ bnet_fsend(user, "%sWEOT ", dev->state & ST_WEOT ? "" : "!");
+ bnet_fsend(user, "%sEOF ", dev->state & ST_EOF ? "" : "!");
+ bnet_fsend(user, "%sNEXTVOL ", dev->state & ST_NEXTVOL ? "" : "!");
+ bnet_fsend(user, "%sSHORT ", dev->state & ST_SHORT ? "" : "!");
+ bnet_fsend(user, "\n");
+
+ bnet_fsend(user, _("Device parameters:\n"));
+ bnet_fsend(user, "Device name: %s\n", dev->dev_name);
+ bnet_fsend(user, "File=%u block=%u\n", dev->file, dev->block_num);
+ bnet_fsend(user, "Min block=%u Max block=%u\n", dev->min_block_size, dev->max_block_size);
+ }
+
}