From df54456851265e598671d59825ea819a47a0591b Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 7 Jul 2007 14:19:37 +0000 Subject: [PATCH] kes Correct a problem when selecting a scratch volume and moving it to another pool that lost some columns. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5128 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/autoprune.c | 8 +++++++- bacula/src/dird/next_vol.c | 14 ++++++++++---- bacula/technotes-2.1 | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/bacula/src/dird/autoprune.c b/bacula/src/dird/autoprune.c index 75359508c0..9a91eb44e7 100644 --- a/bacula/src/dird/autoprune.c +++ b/bacula/src/dird/autoprune.c @@ -126,6 +126,7 @@ bool prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr) } else { ed2[0] = 0; } + Dmsg1(050, "Scratch pool=%s\n", ed2); /* * ed2 ends up with scratch poolid and current poolid or * just current poolid if there is no scratch pool @@ -150,17 +151,20 @@ bool prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr) Mmsg(query, select, ed1, ed2, mr->MediaType, ""); } + Dmsg1(050, "query=%s\n", query.c_str()); if (!db_get_query_dbids(ua->jcr, ua->db, query, ids)) { Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); goto bail_out; } + Dmsg1(050, "num_ids=%d\n", ids.num_ids); + /* Visit each Volume and Prune it until we find one that is purged */ for (i=0; idb, &lmr)) { Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); continue; @@ -189,6 +193,8 @@ bool prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr) mr = &lmr; /* struct copy */ break; } + } else { + Dmsg2(050, "Nothing pruned MediaId=%d Volume=%s\n", (int)lmr.MediaId, lmr.VolumeName); } } diff --git a/bacula/src/dird/next_vol.c b/bacula/src/dird/next_vol.c index da068fc52f..603db2af44 100644 --- a/bacula/src/dird/next_vol.c +++ b/bacula/src/dird/next_vol.c @@ -94,8 +94,8 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, /* * 4. Try pruning Volumes */ - Dmsg0(150, "Call prune_volumes\n"); if (prune) { + Dmsg0(150, "Call prune_volumes\n"); prune_volumes(jcr, InChanger, mr); } ok = recycle_oldest_purged_volume(jcr, InChanger, mr); @@ -401,9 +401,15 @@ static bool get_scratch_volume(JCR *jcr, MEDIA_DBR *mr, bool InChanger) } Jmsg(jcr, M_INFO, 0, _("Using Volume \"%s\" from 'Scratch' pool.\n"), smr.VolumeName); - /* Set new Pool Id in smr record, then copy it to mr */ - smr.PoolId = mr->PoolId; - memcpy(mr, &smr, sizeof(MEDIA_DBR)); + /* + * Get *full* media record to return as db_find_next_volume does + * not return everything . + */ + if (!db_get_media_record(jcr, jcr->db, mr)) { + Jmsg(jcr, M_WARNING, 0, _("Unable to get Volume record: ERR=%s"), + db_strerror(jcr->db)); + goto bail_out; + } /* Set default parameters from current pool */ set_pool_dbr_defaults_in_media_dbr(mr, &pr); /* diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index 837d191eda..5d16077baa 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -2,6 +2,8 @@ General: 07Jul07 +kes Correct a problem when selecting a scratch volume and moving + it to another pool that lost some columns. kes Tweak some code in ua_update.c to use POOL_MEM instead of POOLMEM. kes Enhance Autochanger error messages to include Volume and device name. kes Rework prune_volumes() code to take account of InChanger flag, -- 2.39.5