]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix bug #1208. Inappropriate Volume purging
authorKern Sibbald <kern@sibbald.com>
Tue, 23 Dec 2008 15:50:58 +0000 (15:50 +0000)
committerKern Sibbald <kern@sibbald.com>
Tue, 23 Dec 2008 15:50:58 +0000 (15:50 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.4@8240 91ce42f0-d328-0410-95d8-f526ca767f89

12 files changed:
bacula/src/stored/acquire.c
bacula/src/stored/askdir.c
bacula/src/stored/bcopy.c
bacula/src/stored/bextract.c
bacula/src/stored/block.c
bacula/src/stored/bls.c
bacula/src/stored/bscan.c
bacula/src/stored/btape.c
bacula/src/stored/label.c
bacula/src/stored/protos.h
bacula/src/stored/spool.c
bacula/technotes-2.4

index d02010bf83a86285c6283b8d7aee5a7a65849f21..8357cb8017fe51691c51c3849ab07102cba5eb7f 100644 (file)
@@ -451,7 +451,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 */
index c6b72b12506257e8ac5be74f00fee20ec4edcf34..e88d0a10e72d145f29606ef245e53aaff0d7d1f6 100644 (file)
@@ -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,18 +398,31 @@ 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(1000, "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));
-    Dmsg1(100, ">dird %s", dir->msg);
+   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");
       Jmsg(jcr, M_FATAL, 0, _("Error creating JobMedia record: ERR=%s\n"),
index 836a43415daaec53940c2a0f5efa507bdeefa68d..3b1aa80f2b62ada44db0292af49f03584fd19ff8 100644 (file)
@@ -358,7 +358,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;}
index 45fc89110c5db1fe3b569ad2631677f303948f6f..5b841190b2408ba364e58feb40ed60ba4172fa1b 100644 (file)
@@ -482,7 +482,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;}
index 5efc332669f878680dc1585a0a2cc6f80ec77757..7f1a99baabaa7490574a4e30154cbe436d6f4155 100644 (file)
@@ -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;
@@ -719,7 +719,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;
        goto bail_out;
@@ -795,7 +795,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;
index 46a824e060b606b28cee54d6e85855a13b2fda1d..84501e1da7f245e0de0469b67f358477adbd588a 100644 (file)
@@ -446,7 +446,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;}
index 157287c0b999d4ffa229491cafaf0f38810f9ee0..b21bfb5e9742f6ad8e0351da1a3d3109e2d435c6 100644 (file)
@@ -1286,7 +1286,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;}
index aa55a7ba0924ab0c464527a3d98fe44749b78306..55b20090c83fd8dd6eee4d5b9eea8da29fdac9be 100644 (file)
@@ -2661,7 +2661,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;
index 1c2d0083604423c769c346f4993fc77b4b45fc69..23d296bb8ee01e36fc926ef9def8f41380cb40f3 100644 (file)
@@ -435,7 +435,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
  */
@@ -522,6 +523,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;
index f666c6fd8ba1b593709e3fdcdad58c1b79cc7535..6800f6769b4f22f1d3bc6faf55d251bcac6e26a5 100644 (file)
@@ -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);
 
index 6e18b12a85d6fda05274e34ed047dbab6c223467..0242f848d877782eaee1d6e22505284d40436301 100644 (file)
@@ -299,7 +299,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 */
index 95fc9cdcf85545152bc7e2dae1346ba27f0ae17e..99b01468caf71bb8342cb2536c17c4dba46a9541 100644 (file)
@@ -1,6 +1,8 @@
               Technical notes on version 2.4
 
 General:
+23Dec08
+kes  Fix bug #1208. Inappropriate Volume purging.
 22Dec08
 kes  Modify sql_update.c to edit zeros rather than NULL in unset
      fields. This should fix bug #1206, where apparently the user