/* Print staticstics on memory pool usage */ void print_memory_pool_stats() { Pmsg0(-1, "Pool Maxsize Maxused Inuse\n"); for (int i=0; i<=PM_MAX; i++) Pmsg4(-1, "%5s %7d %7d %5d\n", pool_name(i), pool_ctl[i].max_allocated, pool_ctl[i].max_used, pool_ctl[i].in_use); Pmsg0(-1, "\n"); }
void b_UnlockRes(const char *file, int line) { int errstat; if ((errstat=rwl_writeunlock(&res_lock)) != 0) { Emsg3(M_ABORT, 0, _("rwl_writeunlock failure at %s:%d:. ERR=%s\n"), file, line, strerror(errstat)); } res_locked--; #ifdef TRACE_RES Pmsg4(000, "UnLockRes locked=%d wactive=%d at %s:%d\n", res_locked, res_lock.w_active, file, line); #endif }
void b_LockRes(const char *file, int line) { int errstat; #ifdef TRACE_RES Pmsg4(000, "LockRes locked=%d w_active=%d at %s:%d\n", res_locked, res_lock.w_active, file, line); if (res_locked) { Pmsg2(000, "LockRes writerid=%d myid=%d\n", res_lock.writer_id, pthread_self()); } #endif if ((errstat=rwl_writelock(&res_lock)) != 0) { Emsg3(M_ABORT, 0, _("rwl_writelock failure at %s:%d: ERR=%s\n"), file, line, strerror(errstat)); } res_locked++; }
static void dump_session_label(DEV_RECORD *rec, const char *type) { int dbl; struct date_time dt; struct tm tm; SESSION_LABEL label; char ec1[30], ec2[30], ec3[30], ec4[30], ec5[30], ec6[30], ec7[30]; unser_session_label(&label, rec); dbl = debug_level; debug_level = 1; Pmsg7(-1, _("\n%s Record:\n" "JobId : %d\n" "VerNum : %d\n" "PoolName : %s\n" "PoolType : %s\n" "JobName : %s\n" "ClientName : %s\n" ""), type, label.JobId, label.VerNum, label.PoolName, label.PoolType, label.JobName, label.ClientName); if (label.VerNum >= 10) { Pmsg4(-1, _( "Job (unique name) : %s\n" "FileSet : %s\n" "JobType : %c\n" "JobLevel : %c\n" ""), label.Job, label.FileSetName, label.JobType, label.JobLevel); } if (rec->FileIndex == EOS_LABEL) { Pmsg8(-1, _( "JobFiles : %s\n" "JobBytes : %s\n" "StartBlock : %s\n" "EndBlock : %s\n" "StartFile : %s\n" "EndFile : %s\n" "JobErrors : %s\n" "JobStatus : %c\n" ""), edit_uint64_with_commas(label.JobFiles, ec1), edit_uint64_with_commas(label.JobBytes, ec2), edit_uint64_with_commas(label.StartBlock, ec3), edit_uint64_with_commas(label.EndBlock, ec4), edit_uint64_with_commas(label.StartFile, ec5), edit_uint64_with_commas(label.EndFile, ec6), edit_uint64_with_commas(label.JobErrors, ec7), label.JobStatus); } if (label.VerNum >= 11) { char dt[50]; bstrftime(dt, sizeof(dt), btime_to_utime(label.write_btime)); Pmsg1(-1, _("Date written : %s\n"), dt); } else { dt.julian_day_number = label.write_date; dt.julian_day_fraction = label.write_time; tm_decode(&dt, &tm); Pmsg5(-1, _("Date written : %04d-%02d-%02d at %02d:%02d\n"), tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min); } debug_level = dbl; }
void dump_label_record(DEVICE *dev, DEV_RECORD *rec, bool verbose) { const char *type; int dbl; if (rec->FileIndex == 0 && rec->VolSessionId == 0 && rec->VolSessionTime == 0) { return; } dbl = debug_level; debug_level = 1; switch (rec->FileIndex) { case PRE_LABEL: type = _("Fresh Volume"); break; case VOL_LABEL: type = _("Volume"); break; case SOS_LABEL: type = _("Begin Job Session"); break; case EOS_LABEL: type = _("End Job Session"); break; case EOM_LABEL: type = _("End of Media"); break; case EOT_LABEL: type = _("End of Tape"); break; default: type = _("Unknown"); break; } if (verbose) { switch (rec->FileIndex) { case PRE_LABEL: case VOL_LABEL: unser_volume_label(dev, rec); dump_volume_label(dev); break; case SOS_LABEL: dump_session_label(rec, type); break; case EOS_LABEL: dump_session_label(rec, type); break; case EOM_LABEL: Pmsg7(-1, _("%s Record: File:blk=%u:%u SessId=%d SessTime=%d JobId=%d DataLen=%d\n"), type, dev->file, dev->block_num, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len); break; case EOT_LABEL: Pmsg0(-1, _("End of physical tape.\n")); break; default: Pmsg7(-1, _("%s Record: File:blk=%u:%u SessId=%d SessTime=%d JobId=%d DataLen=%d\n"), type, dev->file, dev->block_num, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len); break; } } else { SESSION_LABEL label; char dt[50]; switch (rec->FileIndex) { case SOS_LABEL: unser_session_label(&label, rec); bstrftimes(dt, sizeof(dt), btime_to_utime(label.write_btime)); Pmsg6(-1, _("%s Record: File:blk=%u:%u SessId=%d SessTime=%d JobId=%d\n"), type, dev->file, dev->block_num, rec->VolSessionId, rec->VolSessionTime, label.JobId); Pmsg4(-1, _(" Job=%s Date=%s Level=%c Type=%c\n"), label.Job, dt, label.JobLevel, label.JobType); break; case EOS_LABEL: char ed1[30], ed2[30]; unser_session_label(&label, rec); bstrftimes(dt, sizeof(dt), btime_to_utime(label.write_btime)); Pmsg6(-1, _("%s Record: File:blk=%u:%u SessId=%d SessTime=%d JobId=%d\n"), type, dev->file, dev->block_num, rec->VolSessionId, rec->VolSessionTime, label.JobId); Pmsg7(-1, _(" Date=%s Level=%c Type=%c Files=%s Bytes=%s Errors=%d Status=%c\n"), dt, label.JobLevel, label.JobType, edit_uint64_with_commas(label.JobFiles, ed1), edit_uint64_with_commas(label.JobBytes, ed2), label.JobErrors, (char)label.JobStatus); break; case EOM_LABEL: case PRE_LABEL: case VOL_LABEL: default: Pmsg7(-1, _("%s Record: File:blk=%u:%u SessId=%d SessTime=%d JobId=%d DataLen=%d\n"), type, dev->file, dev->block_num, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len); break; case EOT_LABEL: break; } } debug_level = dbl; }
/* SM_CHECK_RTN -- Check the buffers and return 1 if OK otherwise 0 */ int sm_check_rtn(const char *fname, int lineno, bool bufdump) { struct abufhead *ap; int bad, badbuf = 0; P(mutex); ap = (struct abufhead *) abqueue.qnext; while (ap != (struct abufhead *)&abqueue) { bad = 0; if (ap != NULL) { if (ap->abq.qnext->qprev != (struct b_queue *)ap) { bad = 0x1; } if (ap->abq.qprev->qnext != (struct b_queue *)ap) { bad |= 0x2; } if (((unsigned char *) ap)[((struct abufhead *)ap)->ablen - 1] != ((((intptr_t) ap) & 0xFF) ^ 0xC5)) { bad |= 0x4; } } else { bad = 0x8; } badbuf |= bad; if (bad) { Pmsg2(0, _("\nDamaged buffers found at %s:%d\n"), get_basename(fname), (uint32_t)lineno); if (bad & 0x1) { Pmsg0(0, _(" discovery of bad prev link.\n")); } if (bad & 0x2) { Pmsg0(0, _(" discovery of bad next link.\n")); } if (bad & 0x4) { Pmsg0(0, _(" discovery of data overrun.\n")); } if (bad & 0x8) { Pmsg0(0, _(" NULL pointer.\n")); } if (!ap) { goto get_out; } Pmsg1(0, _(" Buffer address: %p\n"), ap); if (ap->abfname != NULL) { uint32_t memsize = ap->ablen - (HEAD_SIZE + 1); char errmsg[80]; Pmsg4(0, _("Damaged buffer: %6u bytes allocated at line %d of %s %s\n"), memsize, ap->ablineno, my_name, get_basename(ap->abfname) ); if (bufdump) { unsigned llen = 0; char *cp = ((char *) ap) + HEAD_SIZE; errmsg[0] = EOS; while (memsize) { if (llen >= 16) { strcat(errmsg, "\n"); llen = 0; Pmsg1(0, "%s", errmsg); errmsg[0] = EOS; } if (*cp < 0x20) { sprintf(errmsg + strlen(errmsg), " %02X", (*cp++) & 0xFF); } else { sprintf(errmsg + strlen(errmsg), " %c ", (*cp++) & 0xFF); } llen++; memsize--; } Pmsg1(0, "%s\n", errmsg); } } } ap = (struct abufhead *)ap->abq.qnext; } get_out: V(mutex); return badbuf ? 0 : 1; }