From 291a3038f74c5c20ba7c97820096e30bf1a6cd78 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Tue, 11 Mar 2008 09:15:20 +0000 Subject: [PATCH] Rework dir_find_next_appendable_volume to make a bit more effort to find a suitable volume before giving up. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6580 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/stored/askdir.c | 37 ++++++++++++++----------------------- bacula/src/version.h | 4 ++-- bacula/technotes-2.3 | 3 +++ 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index a6767897be..6d1d2ce823 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -252,20 +252,19 @@ bool dir_find_next_appendable_volume(DCR *dcr) { JCR *jcr = dcr->jcr; BSOCK *dir = jcr->dir_bsock; - bool found = false; Dmsg2(200, "dir_find_next_appendable_volume: reserved=%d Vol=%s\n", dcr->reserved_device, dcr->VolumeName); /* - * Try the twenty oldest or most available volumes. Note, + * Try the fourty oldest or most available volumes. Note, * the most available could already be mounted on another * drive, so we continue looking for a not in use Volume. */ lock_reservations(); P(vol_info_mutex); dcr->volume_in_use = false; - for (int vol_index=1; vol_index < 20; vol_index++) { + for (int vol_index=1; vol_index < 40; vol_index++) { bash_spaces(dcr->media_type); bash_spaces(dcr->pool_name); dir->fsend(Find_media, jcr->Job, vol_index, dcr->pool_name, dcr->media_type); @@ -275,33 +274,26 @@ bool dir_find_next_appendable_volume(DCR *dcr) bool ok = do_get_volume_info(dcr); if (ok) { if (!is_volume_in_use(dcr)) { - found = true; - break; + Dmsg0(400, "dir_find_next_appendable_volume return true\n"); + if (reserve_volume(dcr, dcr->VolumeName) == 0) { + Dmsg2(100, "Could not reserve volume %s on %s\n", dcr->VolumeName, + dcr->dev->print_name()); + continue; + } + V(vol_info_mutex); + unlock_reservations(); + return true; } else { Dmsg1(100, "Volume %s is in use.\n", dcr->VolumeName); dcr->volume_in_use = true; continue; } - } else { - Dmsg2(100, "No vol. index %d return false. dev=%s\n", vol_index, - dcr->dev->print_name()); - found = false; - break; } - } - if (found) { - Dmsg0(400, "dir_find_next_appendable_volume return true\n"); - if (reserve_volume(dcr, dcr->VolumeName) == 0) { - Dmsg2(100, "Could not reserve volume %s on %s\n", dcr->VolumeName, - dcr->dev->print_name()); - goto bail_out; - } - V(vol_info_mutex); - unlock_reservations(); - return true; + Dmsg2(100, "No vol. index %d return false. dev=%s\n", vol_index, + dcr->dev->print_name()); + break; } -bail_out: dcr->VolumeName[0] = 0; V(vol_info_mutex); unlock_reservations(); @@ -534,7 +526,6 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) return false; } Dmsg1(100, "Someone woke me for device %s\n", dev->print_name()); - break; } set_jcr_job_status(jcr, JS_Running); dir_send_job_status(jcr); diff --git a/bacula/src/version.h b/bacula/src/version.h index 18e2237179..0999616fac 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.3.12" -#define BDATE "09 March 2008" -#define LSMDATE "09Mar08" +#define BDATE "11 March 2008" +#define LSMDATE "11Mar08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index c8de57138b..077d8d7dce 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -1,6 +1,9 @@ Technical notes on version 2.3 General: +11Mar08 +kes Rework dir_find_next_appendable_volume to make a bit more effort + to find a suitable volume before giving up. 10Mar08 kes Make ask_sysop_to_create... to return if waken from wait. This helps get out of blocked conditions. -- 2.39.5