From f221f04684c8f6660a22d7519ae1c4b8637c0fc4 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 13 Jun 2005 20:58:11 +0000 Subject: [PATCH] - Add more debug code and clarify debug code for DVDs. - Do not save and restore state in open_first_part() since state should be properly set after open_dev(). git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2123 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kes-1.37 | 3 +++ bacula/src/stored/acquire.c | 3 ++- bacula/src/stored/dev.c | 8 ++++++-- bacula/src/stored/dev.h | 2 +- bacula/src/stored/dvd.c | 32 ++++++++++++++------------------ bacula/src/version.h | 4 ++-- 6 files changed, 28 insertions(+), 24 deletions(-) diff --git a/bacula/kes-1.37 b/bacula/kes-1.37 index 72df675cb8..12aec23491 100644 --- a/bacula/kes-1.37 +++ b/bacula/kes-1.37 @@ -5,6 +5,9 @@ General: Changes to 1.37.22: 13Jun05 +- Add more debug code and clarify debug code for DVDs. +- Do not save and restore state in open_first_part() + since state should be properly set after open_dev(). - Make default mandir /usr/share/man - Install Bacula man page. - Implement passing of FileSet Enable VSS to FD. diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 8529b29f6c..a9e676dcdc 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -315,7 +315,8 @@ DCR *acquire_device_for_append(DCR *dcr) init_device_wait_timers(dcr); dev->block(BST_DOING_ACQUIRE); - Dmsg1(190, "acquire_append device is %s\n", dev->is_tape()?"tape":"disk"); + Dmsg1(190, "acquire_append device is %s\n", dev->is_tape()?"tape": + (dev->is_dvd()?"DVD":"disk")); if (dcr->reserved_device) { dev->reserved_device--; diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 227d11f717..d173a932ea 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -427,7 +427,8 @@ static void open_file_device(DEVICE *dev, int mode) return; } - Dmsg2(29, "open_dev: device is disk %s (mode:%d)\n", archive_name.c_str(), mode); + Dmsg3(29, "open_dev: device is %s (mode:%d)\n", dev->is_dvd()?"DVD":"disk", + archive_name.c_str(), mode); dev->openmode = mode; /* @@ -448,6 +449,7 @@ static void open_file_device(DEVICE *dev, int mode) Emsg0(M_ABORT, 0, _("Illegal mode given to open_dev.\n")); } /* If creating file, give 0640 permissions */ + Dmsg2(29, "open(%s, 0x%x, 0640)\n", archive_name.c_str(), dev->mode); if ((dev->fd = open(archive_name.c_str(), dev->mode, 0640)) < 0) { berrno be; dev->dev_errno = errno; @@ -469,7 +471,9 @@ static void open_file_device(DEVICE *dev, int mode) dev->part_size = filestat.st_size; } } - Dmsg4(29, "open_dev: disk fd=%d opened, part=%d/%d, part_size=%u\n", dev->fd, dev->part, dev->num_parts, dev->part_size); + Dmsg5(29, "open_dev: %s fd=%d opened, part=%d/%d, part_size=%u\n", + dev->is_dvd()?"DVD":"disk", dev->fd, dev->part, dev->num_parts, + dev->part_size); if (dev->is_dvd() && (dev->mode != OPEN_READ_ONLY) && (dev->free_space_errno == 0 || dev->num_parts == dev->part)) { update_free_space_dev(dev); diff --git a/bacula/src/stored/dev.h b/bacula/src/stored/dev.h index 2988caf884..689f1a40b6 100644 --- a/bacula/src/stored/dev.h +++ b/bacula/src/stored/dev.h @@ -43,7 +43,7 @@ /* Arguments to open_dev() */ enum { - OPEN_READ_WRITE = 0, + OPEN_READ_WRITE = 1, OPEN_READ_ONLY, OPEN_WRITE_ONLY }; diff --git a/bacula/src/stored/dvd.c b/bacula/src/stored/dvd.c index e95896d6d7..8584820862 100644 --- a/bacula/src/stored/dvd.c +++ b/bacula/src/stored/dvd.c @@ -11,19 +11,14 @@ Copyright (C) 2005 Kern Sibbald This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. + modify it under the terms of the GNU General Public License + version 2 as ammended with additional clauses defined in the + file LICENSE in the main source directory. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + the file LICENSE for additional details. */ @@ -327,6 +322,7 @@ void update_free_space_dev(DEVICE* dev) char* icmd; int timeout; long long int free; + char ed1[50]; icmd = dev->device->free_space_command; @@ -347,7 +343,6 @@ void update_free_space_dev(DEVICE* dev) timeout = 3; while (1) { - char ed1[50]; if (run_program_full_output(ocmd.c_str(), dev->max_open_wait/2, results) == 0) { Dmsg1(100, "Free space program run : %s\n", results); free = str_to_int64(results); @@ -380,7 +375,8 @@ void update_free_space_dev(DEVICE* dev) } free_pool_memory(results); - Dmsg2(29, "update_free_space_dev: free_space=%lld, free_space_errno=%d\n", dev->free_space, dev->free_space_errno); + Dmsg2(29, "update_free_space_dev: free_space=%s, free_space_errno=%d\n", + edit_uint64(dev->free_space, ed1), dev->free_space_errno); return; } @@ -508,25 +504,25 @@ int open_next_part(DEVICE *dev) { * - Close the fd * - Reopen the device */ -int open_first_part(DEVICE *dev) { - int state; - +int open_first_part(DEVICE *dev) +{ Dmsg3(29, "open_first_part %s %s %d\n", dev->dev_name, dev->VolCatInfo.VolCatName, dev->openmode); if (dev->fd >= 0) { close(dev->fd); } - dev->fd = -1; - state = dev->state; dev->state &= ~ST_OPENED; dev->part_start = 0; dev->part = 0; + Dmsg2(50, "Call open_dev(dev, vol=%s, mode=%d", + dev->VolCatInfo.VolCatName, dev->openmode); if (open_dev(dev, dev->VolCatInfo.VolCatName, dev->openmode) < 0) { + Dmsg0(50, "open_dev() failed\n"); return -1; } - dev->state = state; + Dmsg1(50, "Leave open_first_part state=%s\n", dev->is_open()?"open":"not open"); return dev->fd; } diff --git a/bacula/src/version.h b/bacula/src/version.h index 83ca8cb709..e0493d17cd 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION #define VERSION "1.37.22" -#define BDATE "12 June 2005" -#define LSMDATE "12Jun05" +#define BDATE "14 June 2005" +#define LSMDATE "14Jun05" /* Debug flags */ #undef DEBUG -- 2.39.5