From: Kern Sibbald Date: Mon, 5 Dec 2005 17:30:37 +0000 (+0000) Subject: - Get next volume from Scratch pool before creating a volume. X-Git-Tag: Release-1.38.3~39 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3a4f39bc5ec25a6d147c08029ee49b0a4f2160e4;p=bacula%2Fbacula - Get next volume from Scratch pool before creating a volume. - 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 --- diff --git a/bacula/kes-1.39 b/bacula/kes-1.39 index e3fdfdccc1..cc4b51f1c7 100644 --- a/bacula/kes-1.39 +++ b/bacula/kes-1.39 @@ -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 diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index 9294d3c68c..5e9f282470 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -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); diff --git a/bacula/src/dird/next_vol.c b/bacula/src/dird/next_vol.c index 922bb92435..d04e55e9b4 100644 --- a/bacula/src/dird/next_vol.c +++ b/bacula/src/dird/next_vol.c @@ -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); diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index f852e6f1e5..84d4036033 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -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))) {