From a7a84ed16919fa7c3e1fa4fc51744afdb4dd5db5 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 18 Jul 2002 08:53:14 +0000 Subject: [PATCH] Fully implement AlwaysOpen -- kes18Jul02 git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@62 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/stored/device.c | 29 ++++++++++++++++++++--------- bacula/src/version.h | 4 ++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/bacula/src/stored/device.c b/bacula/src/stored/device.c index cf21a50594..22cd01ca1b 100644 --- a/bacula/src/stored/device.c +++ b/bacula/src/stored/device.c @@ -176,7 +176,10 @@ int release_device(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) Dmsg1(90, "release_device device is %s\n", dev_is_tape(dev)?"tape":"disk"); if (dev->state & ST_READ) { dev->state &= ~ST_READ; /* clear read bit */ - if (!dev_is_tape(dev)) { + if (!dev_is_tape(dev) || !(dev->capabilities & CAP_ALWAYSOPEN)) { + if (dev->capabilities & CAP_OFFLINEUNMOUNT) { + offline_dev(dev); + } close_dev(dev); } /******FIXME**** send read volume usage statistics to director */ @@ -190,10 +193,12 @@ int release_device(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) dev->VolCatInfo.VolCatFiles++; /* increment number of files */ /* Note! do volume update before close, which zaps VolCatInfo */ dir_update_volume_info(jcr, &dev->VolCatInfo, 0); /* send Volume info to Director */ - if (!dev_is_tape(dev)) { + + if (!dev_is_tape(dev) || !(dev->capabilities & CAP_ALWAYSOPEN)) { + if (dev->capabilities & CAP_OFFLINEUNMOUNT) { + offline_dev(dev); + } close_dev(dev); - } else { - Dmsg0(90, "Device is tape leave open in release_device\n"); } } else { dir_create_job_media_record(jcr); @@ -247,8 +252,18 @@ mount_next_vol: memset(&dev->VolHdr, 0, sizeof(dev->VolHdr)); dev->state &= ~ST_LABEL; /* label not yet read */ - /* Rewind device */ + if (!dev_is_tape(dev) || !(dev->capabilities & CAP_ALWAYSOPEN)) { + if (dev->capabilities & CAP_OFFLINEUNMOUNT) { + offline_dev(dev); + } + close_dev(dev); + } + + /* If we have not closed the device, then at least rewind the tape */ if (dev->state & ST_OPENED) { + if (dev->capabilities & CAP_OFFLINEUNMOUNT) { + offline_dev(dev); + } if (!rewind_dev(dev)) { Jmsg2(jcr, M_WARNING, 0, _("Rewind error on device %s. ERR=%s\n"), dev_name(dev), strerror_dev(dev)); @@ -635,10 +650,6 @@ int fixup_device_block_write_error(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) PrevVolName, edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, b1), edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2)); - if (!dev_is_tape(dev)) { /* If file, */ - close_dev(dev); /* yes, close it */ - } - /* Unlock, but leave BLOCKED */ unlock_device(dev); if (!mount_next_volume(jcr, dev, label_blk, 1)) { diff --git a/bacula/src/version.h b/bacula/src/version.h index 5a6f3c2df8..b13c5478aa 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #define VERSION "1.23" #define VSTRING "1" -#define DATE "16 July 2002" -#define LSMDATE "16Jul02" +#define DATE "18 July 2002" +#define LSMDATE "18Jul02" /* Debug flags */ #define DEBUG 1 -- 2.39.5