From: Kern Sibbald Date: Thu, 10 Jan 2008 15:18:49 +0000 (+0000) Subject: Update new reservations changes X-Git-Tag: Release-7.0.0~5139 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3de2cdf51ffd6ce70483ad87fc4ef336ce3f5310;p=bacula%2Fbacula Update new reservations changes git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6272 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/inc_conf.c b/bacula/src/dird/inc_conf.c index 658c2f29d2..dcf757622c 100644 --- a/bacula/src/dird/inc_conf.c +++ b/bacula/src/dird/inc_conf.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + Copyright (C) 2000-2008 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. diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 45517b8db5..64d83e0cc5 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -506,6 +506,7 @@ bool release_device(DCR *dcr) dev->clear_read(); /* clear read bit */ Dmsg0(100, "dir_update_vol_info. Release0\n"); dir_update_volume_info(dcr, false, false); /* send Volume info to Director */ + volume_unused(dcr); } else if (dev->num_writers > 0) { /* @@ -526,6 +527,7 @@ bool release_device(DCR *dcr) if (!dev->num_writers && dev->can_write() && dev->block_num > 0) { dev->weof(1); write_ansi_ibm_labels(dcr, ANSI_EOF_LABEL, dev->VolHdr.VolumeName); + volume_unused(dcr); } if (!dev->at_weot()) { dev->VolCatInfo.VolCatFiles = dev->file; /* set number of files */ diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index a3594fe54b..a7b631a831 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -549,6 +549,7 @@ static bool read_label(DCR *dcr) ok = false; break; } + volume_unused(dcr); give_back_device_lock(dev, &hold); return ok; } diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index d02d83f7d8..d27dd7ea00 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -257,6 +257,7 @@ int read_dev_volume_label(DCR *dcr) return VOL_OK; bail_out: + volume_unused(dcr); /* mark volume "released" */ empty_block(block); dev->rewind(dcr); Dmsg1(150, "return %d\n", stat); @@ -316,6 +317,7 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, empty_block(dcr->block); if (relabel) { + volume_unused(dcr); /* mark current volume unused */ /* Truncate device */ if (!dev->truncate(dcr)) { goto bail_out; @@ -453,6 +455,7 @@ bool rewrite_volume_label(DCR *dcr, bool recycle) return false; } if (recycle) { + volume_unused(dcr); /* mark volume unused */ if (!dev->truncate(dcr)) { Jmsg2(jcr, M_FATAL, 0, _("Truncate error on device %s: ERR=%s\n"), dev->print_name(), dev->print_errmsg()); diff --git a/bacula/src/stored/read_record.c b/bacula/src/stored/read_record.c index 6be9c15d5c..4190d11848 100644 --- a/bacula/src/stored/read_record.c +++ b/bacula/src/stored/read_record.c @@ -82,6 +82,7 @@ bool read_records(DCR *dcr, DEV_RECORD *trec = new_record(); Jmsg(jcr, M_INFO, 0, _("End of Volume at file %u on device %s, Volume \"%s\"\n"), dev->file, dev->print_name(), dcr->VolumeName); + volume_unused(dcr); /* mark volume unused */ if (!mount_cb(dcr)) { Jmsg(jcr, M_INFO, 0, _("End of all volumes.\n")); ok = false; /* Stop everything */ diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index 269be5104c..369921cbb5 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -337,8 +337,15 @@ VOLRES *reserve_volume(DCR *dcr, const char *VolumeName) */ if (strcmp(vol->vol_name, VolumeName) == 0) { Dmsg1(dbglvl, "=== OK, vol=%s on device. set not released.\n", VolumeName); + vol->released = false; /* retake vol if released previously */ goto get_out; /* Volume already on this device */ } else { + /* Don't release a volume if it is in use */ + if (!vol->released) { + Dmsg1(dbglvl, "Cannot free vol=%s. It is not released.\n", vol->vol_name); + vol = NULL; /* vol in use */ + goto get_out; + } Dmsg2(dbglvl, "reserve_vol free vol=%s at %p\n", vol->vol_name, vol->vol_name); unload_autochanger(dcr, -1); /* unload the volume */ free_volume(dev); @@ -471,9 +478,10 @@ void unreserve_device(DCR *dcr) Jmsg1(dcr->jcr, M_ERROR, 0, _("Hey! num_writers=%d!!!!\n"), dev->num_writers); dev->num_writers = 0; } + if (dev->reserved_device == 0 && dev->num_writers == 0) { + volume_unused(dcr); + } } - - volume_unused(dcr); } /* @@ -496,11 +504,13 @@ bool volume_unused(DCR *dcr) return false; } +#ifdef xxx if (dev->is_busy()) { Dmsg1(dbglvl, "vol_unused: busy on %s\n", dev->print_name()); debug_list_volumes("dev busy cannot unreserve_volume"); return false; } +#endif #ifdef xxx if (dev->num_writers > 0 || dev->reserved_device > 0) { ASSERT(0); @@ -1158,6 +1168,8 @@ static int reserve_device(RCTX &rctx) Dmsg1(dbglvl, "looking for Volume=%s\n", rctx.VolumeName); } else { Dmsg0(dbglvl, "No next volume found\n"); + rctx.have_volume = false; + rctx.VolumeName[0] = 0; /* * If there is at least one volume that is valid and in use, * but we get here, check if we are running with prefers @@ -1189,8 +1201,6 @@ static int reserve_device(RCTX &rctx) } goto bail_out; } - rctx.have_volume = false; - rctx.VolumeName[0] = 0; } } } else {