]> git.sur5r.net Git - bacula/bacula/commitdiff
- Get next volume from Scratch pool before creating a volume.
authorKern Sibbald <kern@sibbald.com>
Mon, 5 Dec 2005 17:30:37 +0000 (17:30 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 5 Dec 2005 17:30:37 +0000 (17:30 +0000)
- Set new Pool defaults in Vol when moved from Scratch Pool.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2648 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kes-1.39
bacula/src/cats/sql_update.c
bacula/src/dird/next_vol.c
bacula/src/stored/reserve.c

index e3fdfdccc12b43a74b3c6e57bcd299dc27df858e..cc4b51f1c7c6f890bf0ae1c09f3a1aea7f1c15f6 100644 (file)
@@ -5,6 +5,8 @@ General:
 
 Changes to 1.39.2:
 05Dec05
+- Get next volume from Scratch pool before creating a volume.
+- Set new Pool defaults in Vol when moved from Scratch Pool.
 - Remove argument from create_bacula_database for SQLite as it
   caused an error.
 - Add back index code so that two drive autochangers can get
index 9294d3c68c5cd0ee8d0e7a25d1230639a861fce4..5e9f282470a8506989c11b2580c1534c68dc1665 100644 (file)
@@ -291,7 +291,8 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    time_t ttime;
    struct tm tm;
    int stat;
-   char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50];
+   char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50], ed6[50], ed7[50];
+   char ed8[50], ed9[50];
 
 
    Dmsg1(100, "update_media: FirstWritten=%d\n", mr->FirstWritten);
@@ -333,7 +334,8 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
         "VolFiles=%u,VolBlocks=%u,VolBytes=%s,VolMounts=%u,VolErrors=%u,"
         "VolWrites=%u,MaxVolBytes=%s,VolStatus='%s',"
         "Slot=%d,InChanger=%d,VolReadTime=%s,VolWriteTime=%s,VolParts=%d,"
-        "LabelType=%d,StorageId=%s"
+        "LabelType=%d,StorageId=%s,PoolId=%s,VolRetention=%s,VolUseDuration=%s,"
+        "MaxVolJobs=%d,MaxVolFiles=%d,MaxVolBytes=%s"
         " WHERE VolumeName='%s'",
         mr->VolJobs, mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1),
         mr->VolMounts, mr->VolErrors, mr->VolWrites,
@@ -344,6 +346,11 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
         mr->VolParts,
         mr->LabelType,
         edit_int64(mr->StorageId, ed5),
+        edit_int64(mr->PoolId, ed6),
+        edit_uint64(mr->VolRetention, ed7),
+        edit_uint64(mr->VolUseDuration, ed8),
+        mr->MaxVolJobs, mr->MaxVolFiles,
+        edit_uint64(mr->MaxVolBytes, ed9),
         mr->VolumeName);
 
    Dmsg1(400, "%s\n", mdb->cmd);
index 922bb924359354cd1a983b0f2eaf0cd826468c65..d04e55e9b4c432162038eed171d3d061baa5eb0e 100644 (file)
@@ -83,13 +83,6 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, bool create)
                      continue;           /* retry again accepting any volume */
                   }
                }
-               Dmsg2(200, "find_recycled_volume2 %d FW=%d\n", ok, mr->FirstWritten);
-               if (!ok && create) {
-                  /*
-                   * 5. Try "creating" a new Volume
-                   */
-                  ok = newVolume(jcr, mr);
-               }
             }
          }
 
@@ -99,7 +92,7 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, bool create)
             POOLMEM *query;
             char ed1[50], ed2[50];
             /*
-             * 6. Try pulling a volume from the Scratch pool
+             * 5. Try pulling a volume from the Scratch pool
              */ 
              memset(&pr, 0, sizeof(pr));
              bstrncpy(pr.Name, "Scratch", sizeof(pr.Name));
@@ -121,9 +114,29 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, bool create)
                    /* Set new Pool Id in smr record, then copy it to mr */
                    smr.PoolId = mr->PoolId;
                    memcpy(mr, &smr, sizeof(MEDIA_DBR));
+                   memset(&pr, 0, sizeof(pr));
+                   bstrncpy(pr.Name, jcr->pool->hdr.name, sizeof(pr.Name));
+                   /* Set default parameters from current pool */
+                   if (db_get_pool_record(jcr, jcr->db, &pr)) {
+                      set_pool_dbr_defaults_in_media_dbr(mr, &pr);
+                      if (!db_update_media_record(jcr, jcr->db, mr)) {
+                         Jmsg(jcr, M_WARNING, 0, _("Unable to update Volume record: ERR=%s"), 
+                            db_strerror(jcr->db));
+                      }
+                   } else {
+                      Jmsg(jcr, M_WARNING, 0, _("Unable to get Pool record: ERR=%s"), 
+                         db_strerror(jcr->db));
+                   }
                 }
              }
          }
+
+         if (!ok && create) {
+            /*
+             * 6. Try "creating" a new Volume
+             */
+            ok = newVolume(jcr, mr);
+         }
          /*
           *  Look at more drastic ways to find an Appendable Volume
           */
@@ -138,14 +151,14 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, bool create)
                UAContext *ua;
                Dmsg0(400, "Try purge.\n");
                /*
-                * 5.  Try to purging oldest volume only if not UA calling us.
+                * 7.  Try to purging oldest volume only if not UA calling us.
                 */
                ua = new_ua_context(jcr);
                if (jcr->pool->purge_oldest_volume && create) {
                   Jmsg(jcr, M_INFO, 0, _("Purging oldest volume \"%s\"\n"), mr->VolumeName);
                   ok = purge_jobs_from_volume(ua, mr);
                /*
-                * 5. or try recycling the oldest volume
+                * 8. or try recycling the oldest volume
                 */
                } else if (jcr->pool->recycle_oldest_volume) {
                   Jmsg(jcr, M_INFO, 0, _("Pruning oldest volume \"%s\"\n"), mr->VolumeName);
index f852e6f1e5a0327668960730f48ccd96e3816b52..84d40360331e580e1ca67a75bdc65cad5d778d77 100644 (file)
@@ -419,7 +419,7 @@ static bool use_storage_cmd(JCR *jcr)
          }
       }
       /* Look for an exact match all drives */
-      rctx.PreferMountedVols = false;                
+      rctx.PreferMountedVols = true;
       rctx.exact_match = true;
       rctx.available_autochanger = false;
       if ((ok = find_suitable_device_for_job(jcr, rctx))) {