From: Kern Sibbald Date: Wed, 19 Nov 2003 17:56:19 +0000 (+0000) Subject: Rtn oldest Lastwritten for find_next_vol+remove bad ASSERT+add more SD status if... X-Git-Tag: Release-7.0.0~9911 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4c93f2ed4fb0b99291e3b2b619200201d96eb134;p=bacula%2Fbacula Rtn oldest Lastwritten for find_next_vol+remove bad ASSERT+add more SD status if debug git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@810 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/sql_find.c b/bacula/src/cats/sql_find.c index 88e5243dbf..1dd40978de 100644 --- a/bacula/src/cats/sql_find.c +++ b/bacula/src/cats/sql_find.c @@ -223,21 +223,22 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, MEDIA_DBR *mr) 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); diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index 2846fc8567..b0bf2462bf 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -286,7 +286,7 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) 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); diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 0875b3021a..2480afbcee 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -268,7 +268,7 @@ int wait_for_job_termination(JCR *jcr) 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 */ diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index b8b7ebd525..85f57264ae 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -182,7 +182,7 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg) &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); @@ -198,11 +198,11 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg) 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; @@ -217,7 +217,7 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg) 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. diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 85e1aef4aa..ddeee967f9 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -292,7 +292,6 @@ int release_device(JCR *jcr, DEVICE *dev) /******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) { diff --git a/bacula/src/stored/append.c b/bacula/src/stored/append.c index e67a8d770e..4b7a0c010c 100644 --- a/bacula/src/stored/append.c +++ b/bacula/src/stored/append.c @@ -47,7 +47,7 @@ int do_append_data(JCR *jcr) 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; @@ -93,7 +93,7 @@ int do_append_data(JCR *jcr) 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; } @@ -131,7 +131,7 @@ int do_append_data(JCR *jcr) } Jmsg1(jcr, M_FATAL, 0, _("Error reading data header from FD. ERR=%s\n"), bnet_strerror(ds)); - ok = FALSE; + ok = false; break; } @@ -152,7 +152,7 @@ int do_append_data(JCR *jcr) } 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); @@ -162,7 +162,7 @@ int do_append_data(JCR *jcr) 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) { @@ -194,7 +194,7 @@ int do_append_data(JCR *jcr) 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; } } @@ -218,7 +218,7 @@ int do_append_data(JCR *jcr) 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; } @@ -229,15 +229,10 @@ int do_append_data(JCR *jcr) 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); @@ -253,22 +248,23 @@ int do_append_data(JCR *jcr) 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); diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index 8811dcbe5a..c7a8e4616e 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -187,13 +187,14 @@ int dir_update_volume_info(JCR *jcr, DEVICE *dev, int label) 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; diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index f9f269d1f4..acd39dda2e 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -63,7 +63,7 @@ int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir) 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; @@ -85,7 +85,7 @@ int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir) 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) { @@ -93,17 +93,17 @@ int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir) /* 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, @@ -116,11 +116,11 @@ int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir) 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 */ } @@ -219,7 +219,7 @@ static char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd) 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) { @@ -265,9 +265,9 @@ static char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd) 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; } diff --git a/bacula/src/stored/status.c b/bacula/src/stored/status.c index 196f31ac55..0d13588698 100644 --- a/bacula/src/stored/status.c +++ b/bacula/src/stored/status.c @@ -204,4 +204,40 @@ static void send_blocked_status(JCR *jcr, DEVICE *dev) 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); + } + }