]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/next_vol.c
Update
[bacula/bacula] / bacula / src / dird / next_vol.c
index 2c1dd30ba1236709d738dbdafe195044a7748a6a..5f58db8236d0cba4f02e8593f9c2abbbc9f7fb89 100644 (file)
  *   MEDIA_DBR mr (zeroed out)
  *   create -- whether or not to create a new volume
  */
-int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int create)
+int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, bool create)
 {
    int retry = 0;
    bool ok;
    bool InChanger;
+   STORE *store = jcr->store;
 
    mr->PoolId = jcr->PoolId;
-   bstrncpy(mr->MediaType, jcr->store->media_type, sizeof(mr->MediaType));
+   bstrncpy(mr->MediaType, store->media_type, sizeof(mr->MediaType));
    Dmsg2(120, "CatReq FindMedia: Id=%d, MediaType=%s\n", mr->PoolId, mr->MediaType);
    /*
     * If we are using an Autochanger, restrict Volume 
     *  search to the Autochanger on the first pass 
     */
-   InChanger = jcr->store->autochanger;
+   InChanger = store->autochanger;
    /*
     * Find the Next Volume for Append
     */
@@ -72,23 +73,29 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int create)
         ok = find_recycled_volume(jcr, InChanger, mr);
          Dmsg2(100, "find_recycled_volume %d FW=%d\n", ok, mr->FirstWritten);
         if (!ok) {
-           /*
-            * 3. Try pruning Volumes
+           /* 
+            * 3. Try recycling any purged volume
             */
-           prune_volumes(jcr);  
            ok = recycle_oldest_purged_volume(jcr, InChanger, mr);
-           if (InChanger) {
-              InChanger = false;
-              if (!ok) {
-                 continue;           /* retry again accepting any volume */
-              }
-           }
-            Dmsg2(200, "find_recycled_volume2 %d FW=%d\n", ok, mr->FirstWritten);
-           if (!ok && create) {
+           if (!ok) {
               /*
-                * 4. Try "creating" a new Volume
+               * 4. Try pruning Volumes
                */
-              ok = newVolume(jcr, mr);
+              prune_volumes(jcr);  
+              ok = recycle_oldest_purged_volume(jcr, InChanger, mr);
+              if (InChanger) {
+                 InChanger = false;
+                 if (!ok) {
+                    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);
+              }
            }
         }
 
@@ -214,7 +221,7 @@ bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr)
  *  Returns: on failure - reason = NULL
  *          on success - reason - pointer to reason
  */
-void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, char **reason)
+void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **reason)
 {
    int ok;