From 495460e08127544c76c0037fe252c40308dbab15 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 5 Jul 2008 13:37:12 +0000 Subject: [PATCH] kes Apply Eric's patch to ensure that autoprune does not return a Volume not in the autochanger unless requested to do so. kes Correct bat restore display of multiple drives. This fixes bug #1117. kes Do find_a_volume() each time an unload is done. This fixes the failure of maxvol2-test. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7321 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/autoprune.c | 25 ++++++++++++++++++++++--- bacula/technotes-2.5 | 7 +++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/bacula/src/dird/autoprune.c b/bacula/src/dird/autoprune.c index 63e8138a5e..8f6f400faf 100644 --- a/bacula/src/dird/autoprune.c +++ b/bacula/src/dird/autoprune.c @@ -96,7 +96,7 @@ bool prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr) POOL_MEM query(PM_MESSAGE); UAContext *ua; bool ok = false; - char ed1[50], ed2[100]; + char ed1[50], ed2[100], ed3[50]; POOL_DBR spr; Dmsg1(050, "Prune volumes PoolId=%d\n", jcr->jr.PoolId); @@ -138,10 +138,18 @@ bool prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr) * RecyclePoolId is the current pool or the scratch pool */ const char *select = "SELECT DISTINCT MediaId,LastWritten FROM Media WHERE " - "(PoolId=%s OR RecyclePoolId IN (%s)) AND MediaType='%s' " + "(PoolId=%s OR RecyclePoolId IN (%s)) AND MediaType='%s' %s" "ORDER BY LastWritten ASC,MediaId"; - Mmsg(query, select, ed1, ed2, mr->MediaType); + if (InChanger) { + char changer[100]; + /* Ensure it is in this autochanger */ + bsnprintf(changer, sizeof(changer), "AND InChanger=1 AND StorageId=%s ", + edit_int64(mr->StorageId, ed3)); + Mmsg(query, select, ed1, ed2, mr->MediaType, changer); + } else { + 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)) { @@ -176,6 +184,17 @@ bool prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr) prune_list.num_ids = 0; /* reset count */ } ok = is_volume_purged(ua, &lmr); + + /* + * Check if this volume is available (InChanger + StorageId) + * If not, just skip this volume and try the next one + */ + if (ok && InChanger) { + if (!lmr.InChanger || (lmr.StorageId != mr->StorageId)) { + ok = false; /* skip this volume, ie not loadable */ + } + } + /* * If purged and not moved to another Pool, * then we stop pruning and take this volume. diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 236aee1588..c3a38ab2d8 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -30,6 +30,13 @@ vtape driver General: +05Jul08 +kes Apply Eric's patch to ensure that autoprune does not return + a Volume not in the autochanger unless requested to do so. +kes Correct bat restore display of multiple drives. This fixes + bug #1117. +kes Do find_a_volume() each time an unload is done. This + fixes the failure of maxvol2-test. 04Jul08 kes Add some SD debug code. kes Do find_a_volume() each time an unload is done. -- 2.39.5