From 92f1ba57cdd31e4b66afaad4f6f5bf626528fce1 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 25 Mar 2007 13:11:55 +0000 Subject: [PATCH] Implement code to turn off pruning in obtaining the next volume. Pruning is turned off for the status dir command, but turned on for SD requests and for the list nextvolume command. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4411 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/catreq.c | 2 +- bacula/src/dird/dird.h | 26 ++++++++++++++++++-------- bacula/src/dird/next_vol.c | 9 ++++++--- bacula/src/dird/protos.h | 3 ++- bacula/src/dird/ua_output.c | 2 +- bacula/src/dird/ua_status.c | 2 +- bacula/src/version.h | 4 ++-- bacula/technotes-2.1 | 4 ++++ 8 files changed, 35 insertions(+), 17 deletions(-) diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index 443daa6ea0..3e3800ec48 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -141,7 +141,7 @@ void catalog_request(JCR *jcr, BSOCK *bs) if (ok) { mr.PoolId = pr.PoolId; mr.StorageId = jcr->wstore->StorageId; - ok = find_next_volume_for_append(jcr, &mr, index, true /*permit create new vol*/); + ok = find_next_volume_for_append(jcr, &mr, index, fnv_create_vol, fnv_prune); Dmsg3(050, "find_media ok=%d idx=%d vol=%s\n", ok, index, mr.VolumeName); } /* diff --git a/bacula/src/dird/dird.h b/bacula/src/dird/dird.h index 0dccce803f..c0b5393e92 100644 --- a/bacula/src/dird/dird.h +++ b/bacula/src/dird/dird.h @@ -1,14 +1,7 @@ -/* - * Includes specific to the Director - * - * Kern Sibbald, December MM - * - * 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,13 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * Includes specific to the Director + * + * Kern Sibbald, December MM + * + * Version $Id$ + */ #include "lib/runscript.h" #include "dird_conf.h" @@ -67,4 +67,14 @@ struct del_ctx { int tot_ids; /* total to process */ }; +/* Flags for find_next_volume_for_append() */ +enum { + fnv_create_vol = true, + fnv_no_create_vol = false, + fnv_prune = true, + fnv_no_prune = false +}; + + + #include "protos.h" diff --git a/bacula/src/dird/next_vol.c b/bacula/src/dird/next_vol.c index 0540e080b8..460afbd99a 100644 --- a/bacula/src/dird/next_vol.c +++ b/bacula/src/dird/next_vol.c @@ -51,7 +51,8 @@ static bool get_scratch_volume(JCR *jcr, MEDIA_DBR *mr, bool InChanger); * MEDIA_DBR mr with PoolId set * create -- whether or not to create a new volume */ -int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, bool create) +int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, + bool create, bool prune) { int retry = 0; bool ok; @@ -94,7 +95,9 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, bool create) * 4. Try pruning Volumes */ Dmsg0(150, "Call prune_volumes\n"); - prune_volumes(jcr, mr); + if (prune) { + prune_volumes(jcr, mr); + } ok = recycle_oldest_purged_volume(jcr, InChanger, mr); if (!ok) { Dmsg4(050, "after prune volumes_vol ok=%d index=%d InChanger=%d Vstat=%s\n", @@ -134,7 +137,7 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, bool create) /* Find oldest volume to recycle */ ok = db_find_next_volume(jcr, jcr->db, -1, InChanger, mr); Dmsg1(400, "Find oldest=%d\n", ok); - if (ok) { + if (ok && prune) { UAContext *ua; Dmsg0(400, "Try purge.\n"); /* diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index ceec824345..0d34d664a4 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -148,7 +148,8 @@ extern int bget_dirmsg(BSOCK *bs); extern void wait_for_storage_daemon_termination(JCR *jcr); /* next_vol.c */ -int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, bool create); +int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, + bool create, bool purge); bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr); void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **reason); diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index 72a4ef9ed0..e6d77d67eb 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -481,7 +481,7 @@ static bool list_nextvol(UAContext *ua, int ndays) mr.PoolId = jcr->jr.PoolId; get_job_storage(&store, job, run); mr.StorageId = store.store->StorageId; - if (!find_next_volume_for_append(jcr, &mr, 1, false/*no create*/)) { + if (!find_next_volume_for_append(jcr, &mr, 1, fnv_no_create_vol, fnv_prune)) { bsendmsg(ua, _("Could not find next Volume for Job %s (%s, %s).\n"), job->hdr.name, pr.Name, level_to_str(run->level)); } else { diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 3b7c04c878..a99280d286 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -402,7 +402,7 @@ static void prt_runtime(UAContext *ua, sched_pkt *sp) mr.StorageId = sp->store->StorageId; jcr->wstore = sp->store; Dmsg0(250, "call find_next_volume_for_append\n"); - ok = find_next_volume_for_append(jcr, &mr, 1, false/*no create*/); + ok = find_next_volume_for_append(jcr, &mr, 1, fnv_no_create_vol, fnv_no_prune); } if (!ok) { bstrncpy(mr.VolumeName, "*unknown*", sizeof(mr.VolumeName)); diff --git a/bacula/src/version.h b/bacula/src/version.h index 0633a26d94..b9ad4da1f8 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.1.6" -#define BDATE "24 March 2007" -#define LSMDATE "24Mar07" +#define BDATE "25 March 2007" +#define LSMDATE "25Mar07" #define PROG_COPYRIGHT "Copyright (C) %d-2007 Free Software Foundation Europe e.V.\n" #define BYEAR "2007" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index 3eb85e702e..46934cb502 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,6 +1,10 @@ Technical notes on version 2.1 General: +25Mar07 +kes Implement code to turn off pruning in obtaining the next volume. + Pruning is turned off for the status dir command, but turned on + for SD requests and for the list nextvolume command. 24Mar07 kes Correct Qmsg() that was not updated correctly when committing a previous change (probably the recent TLS patch). -- 2.39.5