From 9c33382c65ec665cb9deaa6db4e587a03a59c2f0 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 3 Sep 2004 17:14:54 +0000 Subject: [PATCH] - Apply Mike Acar's suggestion when looking for the next volume to check purged volumes for recycling before doing a purge. - Make some improvements to CDROM disk. - Take another crack at ignoring drive open() errors during polling. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1579 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/next_vol.c | 32 +++++++++++++++++++------------- bacula/src/stored/device.c | 27 +++++++++++++++------------ bacula/src/stored/protos.h | 4 ++-- bacula/src/version.h | 4 ++-- 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/bacula/src/dird/next_vol.c b/bacula/src/dird/next_vol.c index 687d85cdf8..0f95284cb0 100644 --- a/bacula/src/dird/next_vol.c +++ b/bacula/src/dird/next_vol.c @@ -72,23 +72,29 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, bool create) ok = find_recycled_volume(jcr, InChanger, mr); Dmsg2(100, "find_recycled_volume %d FW=%d\n", ok, mr->FirstWritten); if (!ok) { - /* - * 3. Try pruning Volumes + /* + * 3. Try recycling any purged volume */ - prune_volumes(jcr); ok = recycle_oldest_purged_volume(jcr, InChanger, mr); - if (InChanger) { - InChanger = false; - if (!ok) { - continue; /* retry again accepting any volume */ - } - } - Dmsg2(200, "find_recycled_volume2 %d FW=%d\n", ok, mr->FirstWritten); - if (!ok && create) { + if (!ok) { /* - * 4. Try "creating" a new Volume + * 4. Try pruning Volumes */ - ok = newVolume(jcr, mr); + prune_volumes(jcr); + ok = recycle_oldest_purged_volume(jcr, InChanger, mr); + if (InChanger) { + InChanger = false; + if (!ok) { + continue; /* retry again accepting any volume */ + } + } + Dmsg2(200, "find_recycled_volume2 %d FW=%d\n", ok, mr->FirstWritten); + if (!ok && create) { + /* + * 5. Try "creating" a new Volume + */ + ok = newVolume(jcr, mr); + } } } diff --git a/bacula/src/stored/device.c b/bacula/src/stored/device.c index 7951195422..8b4f39be4d 100644 --- a/bacula/src/stored/device.c +++ b/bacula/src/stored/device.c @@ -260,14 +260,14 @@ void set_new_file_parameters(DCR *dcr) * that we can get the filename; the device_name for * a file is the directory only. * - * Retuns: 0 on failure - * 1 on success + * Returns: false on failure + * true on success */ -int first_open_device(DEVICE *dev) +bool first_open_device(DEVICE *dev) { Dmsg0(120, "start open_output_device()\n"); if (!dev) { - return 0; + return false; } lock_device(dev); @@ -276,7 +276,7 @@ int first_open_device(DEVICE *dev) if (!dev_is_tape(dev)) { Dmsg0(129, "Device is file, deferring open.\n"); unlock_device(dev); - return 1; + return true; } if (!(dev->state & ST_OPENED)) { @@ -290,19 +290,19 @@ int first_open_device(DEVICE *dev) if (open_dev(dev, NULL, mode) < 0) { Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg); unlock_device(dev); - return 0; + return false; } } Dmsg1(129, "open_dev %s OK\n", dev_name(dev)); unlock_device(dev); - return 1; + return true; } /* * Make sure device is open, if not do so */ -int open_device(JCR *jcr, DEVICE *dev) +bool open_device(JCR *jcr, DEVICE *dev) { /* Open device */ if (!(dev_state(dev, ST_OPENED))) { @@ -313,12 +313,15 @@ int open_device(JCR *jcr, DEVICE *dev) mode = OPEN_READ_WRITE; } if (open_dev(dev, jcr->VolCatInfo.VolCatName, mode) < 0) { - Jmsg2(jcr, M_FATAL, 0, _("Unable to open device %s. ERR=%s\n"), - dev_name(dev), strerror_dev(dev)); - return 0; + /* If polling, ignore the error */ + if (!dev->poll) { + Jmsg2(jcr, M_FATAL, 0, _("Unable to open device %s. ERR=%s\n"), + dev_name(dev), strerror_dev(dev)); + } + return false; } } - return 1; + return true; } void dev_lock(DEVICE *dev) diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index e8aacfd714..6898968a29 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -119,8 +119,8 @@ uint32_t dev_file(DEVICE *dev); bool dev_is_tape(DEVICE *dev); /* From device.c */ -int open_device(JCR *jcr, DEVICE *dev); -int first_open_device(DEVICE *dev); +bool open_device(JCR *jcr, DEVICE *dev); +bool first_open_device(DEVICE *dev); bool fixup_device_block_write_error(DCR *dcr, DEV_BLOCK *block); void _lock_device(const char *file, int line, DEVICE *dev); void _unlock_device(const char *file, int line, DEVICE *dev); diff --git a/bacula/src/version.h b/bacula/src/version.h index d14993f0c1..81a4f94f2f 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION #define VERSION "1.35.3" -#define BDATE "02 September 2004" -#define LSMDATE "02Sep04" +#define BDATE "03 September 2004" +#define LSMDATE "03Sep04" /* Debug flags */ #undef DEBUG -- 2.39.2