static char Get_Vol_Info[] = "CatReq Job=%127s GetVolInfo VolName=%127s write=%d\n";
static char Update_media[] = "CatReq Job=%127s UpdateMedia VolName=%s"
- " VolJobs=%u VolFiles=%u VolBlocks=%u VolBytes=%" lld " VolMounts=%u"
- " VolErrors=%u VolWrites=%u MaxVolBytes=%" lld " EndTime=%d VolStatus=%10s"
- " Slot=%d relabel=%d InChanger=%d VolReadTime=%" lld " VolWriteTime=%" lld
- " VolFirstWritten=%" lld " VolParts=%u\n";
+ " VolJobs=%u VolFiles=%u VolBlocks=%u VolBytes=%lld VolMounts=%u"
+ " VolErrors=%u VolWrites=%u MaxVolBytes=%lld EndTime=%lld VolStatus=%10s"
+ " Slot=%d relabel=%d InChanger=%d VolReadTime=%lld VolWriteTime=%lld"
+ " VolFirstWritten=%lld VolParts=%u\n";
static char Create_job_media[] = "CatReq Job=%127s CreateJobMedia "
" FirstIndex=%u LastIndex=%u StartFile=%u EndFile=%u "
uint32_t Stripe;
uint64_t MediaId;
utime_t VolFirstWritten;
+ utime_t VolLastWritten;
memset(&mr, 0, sizeof(mr));
memset(&sdmr, 0, sizeof(sdmr));
} else if (sscanf(bs->msg, Update_media, &Job, &sdmr.VolumeName,
&sdmr.VolJobs, &sdmr.VolFiles, &sdmr.VolBlocks, &sdmr.VolBytes,
&sdmr.VolMounts, &sdmr.VolErrors, &sdmr.VolWrites, &sdmr.MaxVolBytes,
- &sdmr.LastWritten, &sdmr.VolStatus, &sdmr.Slot, &label, &sdmr.InChanger,
+ &VolLastWritten, &sdmr.VolStatus, &sdmr.Slot, &label, &sdmr.InChanger,
&sdmr.VolReadTime, &sdmr.VolWriteTime, &VolFirstWritten,
&sdmr.VolParts) == 19) {
}
}
Dmsg2(400, "Update media: BefVolJobs=%u After=%u\n", mr.VolJobs, sdmr.VolJobs);
+ /* Check if the volume has been written by the job,
+ * and update the LastWritten field if needed */
+ if (mr.VolBlocks != sdmr.VolBlocks && VolLastWritten != 0) {
+ mr.LastWritten = VolLastWritten;
+ }
/* Copy updated values to original media record */
mr.VolJobs = sdmr.VolJobs;
mr.VolFiles = sdmr.VolFiles;
mr.VolMounts = sdmr.VolMounts;
mr.VolErrors = sdmr.VolErrors;
mr.VolWrites = sdmr.VolWrites;
- mr.LastWritten = sdmr.LastWritten;
mr.Slot = sdmr.Slot;
mr.InChanger = sdmr.InChanger;
mr.VolReadTime = sdmr.VolReadTime;
jcr->NumWriteVolumes = 1;
}
dev->VolCatInfo.VolCatJobs++; /* increment number of jobs on vol */
- dir_update_volume_info(dcr, false); /* send Volume info to Director */
+ dir_update_volume_info(dcr, false, false); /* send Volume info to Director */
dev->dlock();
if (dcr->reserved_device) {
dev->reserved_device--;
if (dev->can_read()) {
dev->clear_read(); /* clear read bit */
Dmsg0(100, "dir_update_vol_info. Release0\n");
- dir_update_volume_info(dcr, false); /* send Volume info to Director */
+ dir_update_volume_info(dcr, false, false); /* send Volume info to Director */
} else if (dev->num_writers > 0) {
/*
dev->VolCatInfo.VolCatFiles = dev->file; /* set number of files */
/* Note! do volume update before close, which zaps VolCatInfo */
Dmsg0(100, "dir_update_vol_info. Release0\n");
- dir_update_volume_info(dcr, false); /* send Volume info to Director */
+ dir_update_volume_info(dcr, false, false); /* send Volume info to Director */
}
}
static char Get_Vol_Info[] = "CatReq Job=%s GetVolInfo VolName=%s write=%d\n";
static char Update_media[] = "CatReq Job=%s UpdateMedia VolName=%s"
" VolJobs=%u VolFiles=%u VolBlocks=%u VolBytes=%s VolMounts=%u"
- " VolErrors=%u VolWrites=%u MaxVolBytes=%s EndTime=%d VolStatus=%s"
+ " VolErrors=%u VolWrites=%u MaxVolBytes=%s EndTime=%s VolStatus=%s"
" Slot=%d relabel=%d InChanger=%d VolReadTime=%s VolWriteTime=%s"
" VolFirstWritten=%s VolParts=%u\n";
static char Create_job_media[] = "CatReq Job=%s CreateJobMedia"
* back to the director. The information comes from the
* dev record.
*/
-bool dir_update_volume_info(DCR *dcr, bool label)
+bool dir_update_volume_info(DCR *dcr, bool label, bool update_LastWritten)
{
JCR *jcr = dcr->jcr;
BSOCK *dir = jcr->dir_bsock;
DEVICE *dev = dcr->dev;
- time_t LastWritten = time(NULL);
VOLUME_CAT_INFO *vol = &dev->VolCatInfo;
- char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50];
+ char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50], ed6[50];
int InChanger;
bool ok = false;
POOL_MEM VolumeName;
if (label) {
bstrncpy(vol->VolCatStatus, "Append", sizeof(vol->VolCatStatus));
}
+// if (update_LastWritten) {
+ vol->VolLastWritten = time(NULL);
+// }
pm_strcpy(VolumeName, vol->VolCatName);
bash_spaces(VolumeName);
InChanger = vol->InChanger;
vol->VolCatBlocks, edit_uint64(vol->VolCatBytes, ed1),
vol->VolCatMounts, vol->VolCatErrors,
vol->VolCatWrites, edit_uint64(vol->VolCatMaxBytes, ed2),
- LastWritten, vol->VolCatStatus, vol->Slot, label,
+ edit_uint64(vol->VolLastWritten, ed6),
+ vol->VolCatStatus, vol->Slot, label,
InChanger, /* bool in structure */
edit_int64(vol->VolReadTime, ed3),
edit_int64(vol->VolWriteTime, ed4),
/* Dummies to replace askdir.c */
bool dir_find_next_appendable_volume(DCR *dcr) { return 1;}
-bool dir_update_volume_info(DCR *dcr, bool relabel) { return 1; }
+bool dir_update_volume_info(DCR *dcr, bool relabel, bool update_LastWritten) { return 1; }
bool dir_create_jobmedia_record(DCR *dcr) { return 1; }
bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) { return 1; }
bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec) { return 1;}
/* Dummies to replace askdir.c */
bool dir_find_next_appendable_volume(DCR *dcr) { return 1;}
-bool dir_update_volume_info(DCR *dcr, bool relabel) { return 1; }
+bool dir_update_volume_info(DCR *dcr, bool relabel, bool update_LastWritten) { return 1; }
bool dir_create_jobmedia_record(DCR *dcr) { return 1; }
bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) { return 1; }
bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec) { return 1;}
dev->VolCatInfo.VolCatParts = dev->num_dvd_parts;
}
- if (!dir_update_volume_info(dcr, false)) {
+ if (!dir_update_volume_info(dcr, false, true)) {
ok = false;
}
Dmsg1(100, "dir_update_volume_info terminate writing -- %s\n", ok?"OK":"ERROR");
return false;
}
dev->VolCatInfo.VolCatFiles = dev->file;
- if (!dir_update_volume_info(dcr, false)) {
+ if (!dir_update_volume_info(dcr, false, false)) {
Dmsg0(190, "Error from update_vol_info.\n");
terminate_writing_volume(dcr);
dev->dev_errno = EIO;
dev->VolCatInfo.VolCatParts = dev->num_dvd_parts;
- if (!dir_update_volume_info(dcr, false)) {
+ if (!dir_update_volume_info(dcr, false, false)) {
Dmsg0(190, "Error from update_vol_info.\n");
dev->dev_errno = EIO;
return false;
/* Dummies to replace askdir.c */
bool dir_find_next_appendable_volume(DCR *dcr) { return 1;}
-bool dir_update_volume_info(DCR *dcr, bool relabel) { return 1; }
+bool dir_update_volume_info(DCR *dcr, bool relabel, bool update_LastWritten) { return 1; }
bool dir_create_jobmedia_record(DCR *dcr) { return 1; }
bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) { return 1; }
bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec) { return 1;}
/* Dummies to replace askdir.c */
bool dir_find_next_appendable_volume(DCR *dcr) { return 1;}
-bool dir_update_volume_info(DCR *dcr, bool relabel) { return 1; }
+bool dir_update_volume_info(DCR *dcr, bool relabel, bool update_LastWritten) { return 1; }
bool dir_create_jobmedia_record(DCR *dcr) { return 1; }
bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) { return 1; }
bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec) { return 1;}
bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec) { return 1;}
bool dir_send_job_status(JCR *jcr) {return 1;}
-bool dir_update_volume_info(DCR *dcr, bool relabel)
+bool dir_update_volume_info(DCR *dcr, bool relabel, bool update_LastWritten)
{
return 1;
}
btime_t VolWriteTime; /* time spent writing this Volume */
int64_t VolMediaId; /* MediaId */
utime_t VolFirstWritten; /* Time of first write */
+ utime_t VolLastWritten; /* Time of last write */
bool InChanger; /* Set if vol in current magazine */
char VolCatStatus[20]; /* Volume status */
char VolCatName[MAX_NAME_LENGTH]; /* Desired volume to mount */
dev->dlock(); /* lock again */
dev->VolCatInfo.VolCatJobs++; /* increment number of jobs on vol */
- dir_update_volume_info(dcr, false); /* send Volume info to Director */
+ dir_update_volume_info(dcr, false, false); /* send Volume info to Director */
Jmsg(jcr, M_INFO, 0, _("New volume \"%s\" mounted on device %s at %s.\n"),
dcr->VolumeName, dev->print_name(), bstrftime(dt, sizeof(dt), time(NULL)));
-/*
- *
- * dvd.c -- Routines specific to DVD devices (and
- * possibly other removable hard media).
- *
- * Nicolas Boichat, MMV
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2005-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2005-2007 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ *
+ * dvd.c -- Routines specific to DVD devices (and
+ * possibly other removable hard media).
+ *
+ * Nicolas Boichat, MMV
+ *
+ * Version $Id$
+ */
#include "bacula.h"
#include "stored.h"
dcr->VolCatInfo.VolCatBytes = 0;
/* Update catalog */
- if (!dir_update_volume_info(dcr, false)) {
+ if (!dir_update_volume_info(dcr, false, true)) {
return false;
}
}
Dmsg0(150, "dir_update_vol_info. Set Append\n");
bstrncpy(dev->VolCatInfo.VolCatStatus, "Append", sizeof(dev->VolCatInfo.VolCatStatus));
- if (!dir_update_volume_info(dcr, true)) { /* indicate doing relabel */
+ if (!dir_update_volume_info(dcr, true, true)) { /* indicate doing relabel */
return false;
}
if (recycle) {
}
dev->VolCatInfo.VolCatMounts++; /* Update mounts */
Dmsg1(150, "update volinfo mounts=%d\n", dev->VolCatInfo.VolCatMounts);
- if (!dir_update_volume_info(dcr, false)) {
+ if (!dir_update_volume_info(dcr, false, false)) {
return false;
}
Dmsg0(150, "dir_update_vol_info. Set Append\n");
/* Copy Director's info into the device info */
dev->VolCatInfo = dcr->VolCatInfo; /* structure assignment */
- if (!dir_update_volume_info(dcr, true)) { /* indicate tape labeled */
+ if (!dir_update_volume_info(dcr, true, true)) { /* indicate tape labeled */
return try_error;
}
Jmsg(dcr->jcr, M_INFO, 0, _("Labeled new Volume \"%s\" on device %s.\n"),
dev->VolCatInfo = dcr->VolCatInfo; /* structure assignment */
bstrncpy(dev->VolCatInfo.VolCatStatus, "Error", sizeof(dev->VolCatInfo.VolCatStatus));
Dmsg0(150, "dir_update_vol_info. Set Error.\n");
- dir_update_volume_info(dcr, false);
+ dir_update_volume_info(dcr, false, false);
}
/*
dcr->VolCatInfo.InChanger = false;
dev->VolCatInfo.InChanger = false;
Dmsg0(400, "update vol info in mount\n");
- dir_update_volume_info(dcr, true); /* set new status */
+ dir_update_volume_info(dcr, true, false); /* set new status */
}
/*
};
bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw);
bool dir_find_next_appendable_volume(DCR *dcr);
-bool dir_update_volume_info(DCR *dcr, bool label);
+bool dir_update_volume_info(DCR *dcr, bool label, bool update_LastWritten);
bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr);
bool dir_ask_sysop_to_mount_volume(DCR *dcr);
bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec);
#undef VERSION
#define VERSION "2.3.6"
-#define BDATE "19 October 2007"
-#define LSMDATE "19Oct07"
+#define BDATE "04 November 2007"
+#define LSMDATE "04Nov07"
#define PROG_COPYRIGHT "Copyright (C) %d-2007 Free Software Foundation Europe e.V.\n"
#define BYEAR "2007" /* year for copyright messages in progs */
General:
04Nov07
+kes Cleanup of code in SD that sets the LastWritten date. This doesn't
+ really change anything, but is the beginning of doing it *right*.
+ To do it completely right the LastWritten date must be passed to
+ the SD, but it is not yet done.
kes Minor tweaks to some bat restore SQL.
kes This patch fixes bug #1003 where putting the message output from
a Verify job into the catalog results in a recursive loop. The problem