From d777b026ec5dc4a237812542eb1edf5672c9a177 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 14 Jun 2007 16:54:30 +0000 Subject: [PATCH] kes Do not free a volume on a tape drive until another volume is mounted and read, or the autochanger unloads the volume. This should help the SD re-use volumes that are already mounted, and should fix bug #886. kes Apply patch from user brettedgar that allows gnome2-console include the OpenSSL libraries, and hence work with SSL. Fixes bug #885. kes Apply patch from Lucien Weller that fixes day of week calculation because of DST flag problem. Fixes bug #887. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5012 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/lib/btime.c | 1 + bacula/src/lib/htable.c | 1 - bacula/src/stored/autochanger.c | 2 ++ bacula/src/stored/dev.c | 4 ---- bacula/src/stored/reserve.c | 20 +++++++++++++++++--- bacula/src/version.h | 4 ++-- bacula/technotes-2.1 | 11 ++++++++++- 7 files changed, 32 insertions(+), 11 deletions(-) diff --git a/bacula/src/lib/btime.c b/bacula/src/lib/btime.c index cfa881ed33..f29bf7f117 100644 --- a/bacula/src/lib/btime.c +++ b/bacula/src/lib/btime.c @@ -223,6 +223,7 @@ int tm_woy(time_t stime) tm_yday = tm.tm_yday; tm.tm_mon = 0; tm.tm_mday = 4; + tm.tm_isdst = 0; /* 4 Jan is not DST */ time4 = mktime(&tm); (void)localtime_r(&time4, &tm); fty = 1 - tm.tm_wday; diff --git a/bacula/src/lib/htable.c b/bacula/src/lib/htable.c index b80ed97350..d489e3487c 100644 --- a/bacula/src/lib/htable.c +++ b/bacula/src/lib/htable.c @@ -71,7 +71,6 @@ void htable::hash_index(char *key) /* Multiply by large prime number, take top bits, mask for remainder */ index = ((hash * 1103515249) >> rshift) & mask; Dmsg2(100, "Leave hash_index hash=0x%x index=%d\n", hash, index); - return; } htable::htable(void *item, void *link, int tsize) diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index 88b42cdcec..8f2ac0c00d 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -360,6 +360,7 @@ bool unload_autochanger(DCR *dcr, int loaded) } else { dev->Slot = 0; /* nothing loaded */ } + free_volume(dev); /* Free any volume associated with this drive */ free_pool_memory(changer); unlock_changer(dcr); } @@ -461,6 +462,7 @@ static bool unload_other_drive(DCR *dcr, int slot) dev->Slot = 0; /* nothing loaded */ Dmsg0(100, "Slot unloaded\n"); } + free_volume(dev); /* Free any volume associated with this drive */ unlock_changer(dcr); dev->dunlock(); free_pool_memory(changer_cmd); diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 394fd177ad..77f6cfd62d 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -1856,10 +1856,6 @@ void DEVICE::clrerror(int func) */ void DEVICE::clear_volhdr() { - /* If we have an unused volume associated with this drive, free it */ - if (vol && !is_busy()) { - free_volume(this); - } Dmsg1(100, "Clear volhdr vol=%s\n", VolHdr.VolumeName); memset(&VolHdr, 0, sizeof(VolHdr)); } diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index 429f20cf62..9f301629c0 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -207,8 +207,12 @@ void list_volumes(void sendit(const char *msg, int len, void *sarg), void *arg) lock_volumes(); foreach_dlist(vol, vol_list) { - if (vol->dev) { - len = Mmsg(msg, "%s on device %s\n", vol->vol_name, vol->dev->print_name()); + DEVICE *dev = vol->dev; + if (dev) { + len = Mmsg(msg, "%s on device %s\n", vol->vol_name, dev->print_name()); + sendit(msg.c_str(), len, arg); + len = Mmsg(msg, " Reader=%d writers=%d reserved=%d\n", dev->can_read()?1:0, + dev->num_writers, dev->reserved_device); sendit(msg.c_str(), len, arg); } else { len = Mmsg(msg, "%s no dev\n", vol->vol_name); @@ -453,7 +457,17 @@ bool volume_unused(DCR *dcr) return false; } - return free_volume(dev); + /* + * If this is a tape, we do not free the volume, rather we wait + * until the autoloader unloads it, or until another tape is + * explicitly read in this drive. This allows the SD to remember + * where the tapes are or last were. + */ + if (dev->is_tape()) { + return true; + } else { + return free_volume(dev); + } } /* diff --git a/bacula/src/version.h b/bacula/src/version.h index e737e5fee3..3c12d9a1ae 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.1.14" -#define BDATE "10 June 2007" -#define LSMDATE "10Jun07" +#define BDATE "14 June 2007" +#define LSMDATE "14Jun07" #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 8cf9e3ffaf..2b6dca093b 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,7 +1,16 @@ Technical notes on version 2.1 General: -10Jun08 +14Jun07 +kes Do not free a volume on a tape drive until another volume is + mounted and read, or the autochanger unloads the volume. + This should help the SD re-use volumes that are already mounted, + and should fix bug #886. +kes Apply patch from user brettedgar that allows gnome2-console include + the OpenSSL libraries, and hence work with SSL. Fixes bug #885. +kes Apply patch from Lucien Weller that fixes day of week calculation + because of DST flag problem. Fixes bug #887. +10Jun07 kes Move find_next_appendable_volume() to after acquiring a valid device in reserve.c. This fixes bug #864 -- confirmed by reporter. 09Jun07 -- 2.39.5