From ec2c86f029e372bd95525922a059f54cc58be4bf Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 19 Jul 2007 08:33:25 +0000 Subject: [PATCH] Ensure that we keep Recycle Pool when moving Scratch volumes. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5198 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/cats/sql_list.c | 17 +++++++++-------- bacula/src/dird/next_vol.c | 13 +++++++++---- bacula/technotes-2.1 | 4 +++- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/bacula/src/cats/sql_list.c b/bacula/src/cats/sql_list.c index 7d572dab4a..25647c8d80 100644 --- a/bacula/src/cats/sql_list.c +++ b/bacula/src/cats/sql_list.c @@ -1,14 +1,7 @@ -/* - * Bacula Catalog Database List records interface routines - * - * Kern Sibbald, March 2000 - * - * Version $Id$ - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2006 Free Software Foundation Europe e.V. + Copyright (C) 2000-2007 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -32,6 +25,14 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * Bacula Catalog Database List records interface routines + * + * Kern Sibbald, March 2000 + * + * Version $Id$ + */ + /* The following is necessary so that we do not include * the dummy external definition of DB. diff --git a/bacula/src/dird/next_vol.c b/bacula/src/dird/next_vol.c index 11a253b8d5..1a4f8b4a7e 100644 --- a/bacula/src/dird/next_vol.c +++ b/bacula/src/dird/next_vol.c @@ -327,7 +327,7 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) { - MEDIA_DBR smr; + MEDIA_DBR smr; /* for searching scratch pool */ POOL_DBR spr, pr; bool ok = false; bool found = false; @@ -371,7 +371,7 @@ bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) * that we can add a Volume. */ memset(&pr, 0, sizeof(pr)); - bstrncpy(pr.Name, jcr->pool->hdr.name, sizeof(pr.Name)); + bstrncpy(pr.Name, jcr->pool->name(), sizeof(pr.Name)); if (!db_get_pool_record(jcr, jcr->db, &pr)) { Jmsg(jcr, M_WARNING, 0, _("Unable to get Pool record: ERR=%s"), @@ -379,9 +379,10 @@ bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) goto bail_out; } + /* Make sure there is room for another volume */ if (pr.MaxVols > 0 && pr.NumVols >= pr.MaxVols) { Jmsg(jcr, M_WARNING, 0, _("Unable add Scratch Volume, Pool \"%s\" full MaxVols=%d\n"), - jcr->pool->hdr.name, pr.MaxVols); + jcr->pool->name(), pr.MaxVols); goto bail_out; } @@ -397,11 +398,15 @@ bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) } /* Set default parameters from current pool */ set_pool_dbr_defaults_in_media_dbr(mr, &pr); + /* * set_pool_dbr_defaults_in_media_dbr set VolStatus to Append, - * we could have Recycled media, + * we could have Recycled media, also, we retain the old + * RecyclePoolId. */ bstrncpy(mr->VolStatus, smr.VolStatus, sizeof(smr.VolStatus)); + mr.RecyclePoolId = smr.RecyclePoolId; + if (!db_update_media_record(jcr, jcr->db, mr)) { Jmsg(jcr, M_WARNING, 0, _("Failed to move Scratch Volume. ERR=%s\n"), db_strerror(jcr->db)); diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index 839294ca76..1d7fd50050 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -2,7 +2,9 @@ General: Release 2.1.28 beta -18Jul08 +19Jul07 +kes Ensure that we keep Recycle Pool when moving Scratch volumes. +18Jul07 kes Update Release notes 17Jul07 ebl fix a bug in get_scratch_volume() report by Andreas Helmcke -- 2.39.5