From 87e42efbf16f1c9cb3811133dbb161187f676692 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Tue, 23 Dec 2008 13:28:03 +0000 Subject: [PATCH] Fix bug #1208 git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8235 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/stored/acquire.c | 2 +- bacula/src/stored/askdir.c | 27 ++++++++++++++++++++------- bacula/src/stored/bcopy.c | 2 +- bacula/src/stored/bextract.c | 2 +- bacula/src/stored/block.c | 6 +++--- bacula/src/stored/bls.c | 2 +- bacula/src/stored/bscan.c | 2 +- bacula/src/stored/btape.c | 2 +- bacula/src/stored/label.c | 4 +++- bacula/src/stored/protos.h | 2 +- bacula/src/stored/spool.c | 2 +- bacula/src/version.h | 4 ++-- bacula/technotes-2.5 | 2 ++ 13 files changed, 38 insertions(+), 21 deletions(-) diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index f4203cd395..06c280efd8 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -452,7 +452,7 @@ bool release_device(DCR *dcr) Dmsg2(200, "dir_create_jobmedia. Release vol=%s dev=%s\n", dev->VolCatInfo.VolCatName, dev->print_name()); if (!dev->at_weot() && !dir_create_jobmedia_record(dcr)) { - Jmsg(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), + Jmsg2(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), dcr->VolCatInfo.VolCatName, jcr->Job); } /* If no more writers, and no errors, and wrote something, write an EOF */ diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index 276a5020cf..9b492c22e4 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -387,7 +387,7 @@ bail_out: /* * After writing a Volume, create the JobMedia record. */ -bool dir_create_jobmedia_record(DCR *dcr) +bool dir_create_jobmedia_record(DCR *dcr, bool zero) { JCR *jcr = dcr->jcr; BSOCK *dir = jcr->dir_bsock; @@ -398,17 +398,30 @@ bool dir_create_jobmedia_record(DCR *dcr) return true; } + /* Throw out records where FI is zero -- i.e. nothing done */ + if (!zero && dcr->VolFirstIndex == 0 && + (dcr->StartBlock != 0 || dcr->EndBlock != 0)) { + Dmsg0(000, "JobMedia problem FI=0 StartBlock!=0\n"); + return true; + } + if (!dcr->WroteVol) { return true; /* nothing written to tape */ } dcr->WroteVol = false; - dir->fsend(Create_job_media, jcr->Job, - dcr->VolFirstIndex, dcr->VolLastIndex, - dcr->StartFile, dcr->EndFile, - dcr->StartBlock, dcr->EndBlock, - dcr->Copy, dcr->Stripe, - edit_uint64(dcr->VolMediaId, ed1)); + if (zero) { + /* Send dummy place holder to avoid purging */ + dir->fsend(Create_job_media, jcr->Job, + 0 , 0, 0, 0, 0, 0, 0, 0, edit_uint64(dcr->VolMediaId, ed1)); + } else { + dir->fsend(Create_job_media, jcr->Job, + dcr->VolFirstIndex, dcr->VolLastIndex, + dcr->StartFile, dcr->EndFile, + dcr->StartBlock, dcr->EndBlock, + dcr->Copy, dcr->Stripe, + edit_uint64(dcr->VolMediaId, ed1)); + } Dmsg1(100, ">dird %s", dir->msg); if (dir->recv() <= 0) { Dmsg0(190, "create_jobmedia error bnet_recv\n"); diff --git a/bacula/src/stored/bcopy.c b/bacula/src/stored/bcopy.c index fbb35120e5..c249c6e136 100644 --- a/bacula/src/stored/bcopy.c +++ b/bacula/src/stored/bcopy.c @@ -362,7 +362,7 @@ static void get_session_record(DEVICE *dev, DEV_RECORD *rec, SESSION_LABEL *sess /* Dummies to replace askdir.c */ bool dir_find_next_appendable_volume(DCR *dcr) { 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_create_jobmedia_record(DCR *dcr, bool zero) { 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_send_job_status(JCR *jcr) {return 1;} diff --git a/bacula/src/stored/bextract.c b/bacula/src/stored/bextract.c index c3a86d1580..1a8c67f542 100644 --- a/bacula/src/stored/bextract.c +++ b/bacula/src/stored/bextract.c @@ -501,7 +501,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) /* Dummies to replace askdir.c */ bool dir_find_next_appendable_volume(DCR *dcr) { 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_create_jobmedia_record(DCR *dcr, bool zero) { 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_send_job_status(JCR *jcr) {return 1;} diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index fef281595c..97dac7ca57 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -365,7 +365,7 @@ bool write_block_to_device(DCR *dcr) /* Create a jobmedia record for this job */ if (!dir_create_jobmedia_record(dcr)) { dev->dev_errno = EIO; - Jmsg(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), + Jmsg2(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), dcr->VolCatInfo.VolCatName, jcr->Job); set_new_volume_parameters(dcr); stat = false; @@ -724,7 +724,7 @@ static bool terminate_writing_volume(DCR *dcr) if (!dir_create_jobmedia_record(dcr)) { Dmsg0(190, "Error from create JobMedia\n"); dev->dev_errno = EIO; - Jmsg(dcr->jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), + Jmsg2(dcr->jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), dcr->VolCatInfo.VolCatName, dcr->jcr->Job); ok = false; } @@ -798,7 +798,7 @@ static bool do_new_file_bookkeeping(DCR *dcr) if (!dir_create_jobmedia_record(dcr)) { Dmsg0(190, "Error from create_job_media.\n"); dev->dev_errno = EIO; - Jmsg(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), + Jmsg2(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), dcr->VolCatInfo.VolCatName, jcr->Job); terminate_writing_volume(dcr); dev->dev_errno = EIO; diff --git a/bacula/src/stored/bls.c b/bacula/src/stored/bls.c index a86c09943c..b5b936b0ea 100644 --- a/bacula/src/stored/bls.c +++ b/bacula/src/stored/bls.c @@ -453,7 +453,7 @@ static void get_session_record(DEVICE *dev, DEV_RECORD *rec, SESSION_LABEL *sess /* Dummies to replace askdir.c */ bool dir_find_next_appendable_volume(DCR *dcr) { 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_create_jobmedia_record(DCR *dcr, bool zero) { 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_send_job_status(JCR *jcr) {return 1;} diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index 9aca445fa6..7d6b546ee7 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -1312,7 +1312,7 @@ static JCR *create_jcr(JOB_DBR *jr, DEV_RECORD *rec, uint32_t JobId) /* Dummies to replace askdir.c */ bool dir_find_next_appendable_volume(DCR *dcr) { 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_create_jobmedia_record(DCR *dcr, bool zero) { 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_send_job_status(JCR *jcr) {return 1;} diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index 1908cbda05..d6f77f0f34 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -2668,7 +2668,7 @@ bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw writing) return 1; } -bool dir_create_jobmedia_record(DCR *dcr) +bool dir_create_jobmedia_record(DCR *dcr, bool zero) { dcr->WroteVol = false; return 1; diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index 881bf95096..b4274059bd 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -414,7 +414,8 @@ bail_out: /* * Write a volume label. This is ONLY called if we have a valid Bacula - * label of type PRE_LABEL; + * label of type PRE_LABEL or we are recyling an existing Volume. + * * Returns: true if OK * false if unable to write it */ @@ -501,6 +502,7 @@ bool rewrite_volume_label(DCR *dcr, bool recycle) if (recycle) { dev->VolCatInfo.VolCatMounts++; dev->VolCatInfo.VolCatRecycles++; + dir_create_jobmedia_record(dcr, true); } else { dev->VolCatInfo.VolCatMounts = 1; dev->VolCatInfo.VolCatRecycles = 0; diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index ac2ab67461..b511bea0cc 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -55,7 +55,7 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr); bool dir_ask_sysop_to_mount_volume(DCR *dcr, int mode); bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec); bool dir_send_job_status(JCR *jcr); -bool dir_create_jobmedia_record(DCR *dcr); +bool dir_create_jobmedia_record(DCR *dcr, bool zero=false); bool dir_update_device(JCR *jcr, DEVICE *dev); bool dir_update_changer(JCR *jcr, AUTOCHANGER *changer); diff --git a/bacula/src/stored/spool.c b/bacula/src/stored/spool.c index bbd2f8601f..7e6246a0fb 100644 --- a/bacula/src/stored/spool.c +++ b/bacula/src/stored/spool.c @@ -303,7 +303,7 @@ static bool despool_data(DCR *dcr, bool commit) } if (!dir_create_jobmedia_record(dcr)) { - Jmsg(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), + Jmsg2(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), dcr->VolCatInfo.VolCatName, jcr->Job); } /* Set new file/block parameters for current dcr */ diff --git a/bacula/src/version.h b/bacula/src/version.h index 672ea20f3d..3caa71de7f 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.5.26" -#define BDATE "21 December 2008" -#define LSMDATE "21Dec08" +#define BDATE "23 December 2008" +#define LSMDATE "23Dec08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index f6cf7f6ecd..2c7450697d 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -10,6 +10,8 @@ filepattern (restore with regex in bsr) mixed priorities General: +23Dec08 +kes Fix bug #1208 20Dec08 ebl Work on copy jobs - Add "list copies" command -- 2.39.5