From e5befa9d943cd7c578439c6ff166ba708949504f Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 16 Sep 2005 10:43:35 +0000 Subject: [PATCH] - Add code to reservation VOLRES subroutines to try to ensure we don't end up with two Volumes on the same drive. - Simplify the mutex code in VOLRES a bit to reduce the chance of error. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2392 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 24 ++++++++++++++++++++++++ bacula/kes-1.37 | 5 +++++ bacula/src/stored/reserve.c | 31 +++++++++++++++++++++---------- bacula/src/version.h | 4 ++-- 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index e776397371..3a6e5e086c 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -10,6 +10,30 @@ Version 1.37 Kern (see below) Final items for 1.37 before release: 1. Fix bugs - Look at fixing restore status stats in SD. +- Check if ANSI tape labeling works with drive in + read-only mode. + > > btape: label.c:299 write_volume_label() + > > btape: label.c:302 Label type=0 + > > btape: dev.c:648 rewind_dev fd=3 "VTS0" (/dev/tape0) + > > btape: label.c:530 Start create_volume_label() + > > + > > Volume Label: + > > Id : Bacula 1.0 immortal + > > VerNo : 11 + > > VolName : 450340 + > > PrevVolName : + > > VolFile : 0 + > > LabelType : PRE_LABEL + > > LabelSize : 0 + > > PoolName : Default + > > MediaType : VTS + > > PoolType : Backup + > > HostName : sysrmr.eia.doe.gov + > > btape: ansi_label.c:282 Write ANSI label type=2 + > > 15-Sep 13:12 btape: btape Fatal error: ansi_label.c:303 Could not + > > write ANSI VOL1 + > > label. ERR=Bad file descriptor + - Check "update slots=7 scan storage=DLT drive=0" with non-bacula tape in the drive. diff --git a/bacula/kes-1.37 b/bacula/kes-1.37 index be0100f6e4..b5f75ff5b4 100644 --- a/bacula/kes-1.37 +++ b/bacula/kes-1.37 @@ -4,6 +4,11 @@ General: Changes to 1.37.39: +16Sep05 +- Add code to reservation VOLRES subroutines to try to ensure + we don't end up with two Volumes on the same drive. +- Simplify the mutex code in VOLRES a bit to reduce the chance + of error. 15Sep05 - Apply Nicolas' dvd-freespace.in patch. - Make sure SQL table names are not translated. diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index 4543c3a655..d3b1940d71 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -116,22 +116,34 @@ VOLRES *new_volume(DCR *dcr, const char *VolumeName) VOLRES *vol, *nvol; Dmsg1(400, "new_volume %s\n", VolumeName); + P(vol_list_lock); + if (dcr->dev) { + foreach_dlist(vol, vol_list) { + if (vol && vol->dev == dcr->dev) { + vol_list->remove(vol); + if (vol->vol_name) { + free(vol->vol_name); + } + free(vol); + break; + } + } + } vol = (VOLRES *)malloc(sizeof(VOLRES)); memset(vol, 0, sizeof(VOLRES)); vol->vol_name = bstrdup(VolumeName); vol->dev = dcr->dev; vol->dcr = dcr; - P(vol_list_lock); nvol = (VOLRES *)vol_list->binary_insert(vol, my_compare); - V(vol_list_lock); if (nvol != vol) { free(vol->vol_name); free(vol); + vol = NULL; if (dcr->dev) { nvol->dev = dcr->dev; } - return NULL; } + V(vol_list_lock); return vol; } @@ -144,11 +156,11 @@ VOLRES *new_volume(DCR *dcr, const char *VolumeName) VOLRES *find_volume(const char *VolumeName) { VOLRES vol, *fvol; - vol.vol_name = bstrdup(VolumeName); P(vol_list_lock); + vol.vol_name = bstrdup(VolumeName); fvol = (VOLRES *)vol_list->binary_search(&vol, my_compare); - V(vol_list_lock); free(vol.vol_name); + V(vol_list_lock); return fvol; } @@ -162,13 +174,13 @@ bool free_volume(DEVICE *dev) { VOLRES vol, *fvol; + P(vol_list_lock); if (dev->VolHdr.VolumeName[0] == 0) { /* * Our device has no VolumeName listed, but * search the list for any Volume attached to * this device and remove it. */ - P(vol_list_lock); foreach_dlist(fvol, vol_list) { if (fvol && fvol->dev == dev) { vol_list->remove(fvol); @@ -179,21 +191,20 @@ bool free_volume(DEVICE *dev) break; } } - V(vol_list_lock); - return fvol != NULL; + goto bail_out; } Dmsg1(400, "free_volume %s\n", dev->VolHdr.VolumeName); vol.vol_name = bstrdup(dev->VolHdr.VolumeName); - P(vol_list_lock); fvol = (VOLRES *)vol_list->binary_search(&vol, my_compare); if (fvol) { vol_list->remove(fvol); free(fvol->vol_name); free(fvol); } - V(vol_list_lock); free(vol.vol_name); dev->VolHdr.VolumeName[0] = 0; +bail_out: + V(vol_list_lock); return fvol != NULL; } diff --git a/bacula/src/version.h b/bacula/src/version.h index dadaa26092..1c35c38b19 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "1.37.39" -#define BDATE "15 September 2005" -#define LSMDATE "15Sep05" +#define BDATE "16 September 2005" +#define LSMDATE "16Sep05" /* Debug flags */ #undef DEBUG -- 2.39.5