From e31a910d5b9830338298a058819cf3ad38553cfd Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 13 Oct 2006 09:01:26 +0000 Subject: [PATCH] kes Apply the three patches from Richard Mortimer. bacula-reposition.patch, bacula-tape-reopen.patch, and bacula-eod.patch. This corrects tape positioning on older devices, and also a problem with btape. kes Apply fix from bug report #696 where writing to a FIFO does not work due to a dumb typo. kes Unlock the tape door before the file descriptor is released. This should fix lots of somewhat subtle failures when using an autochanger. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3551 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/stored/btape.c | 4 +++- bacula/src/stored/dev.c | 22 ++++++++++++++++------ bacula/technotes-1.39 | 9 +++++++++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index 6ebe43b620..3cd41fa656 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -1533,7 +1533,9 @@ static void wrcmd() DEV_RECORD *rec = dcr->rec; int i; - open_the_device(); + if (!dev->is_open()) { + open_the_device(); + } sm_check(__FILE__, __LINE__, false); empty_block(block); if (verbose > 1) { diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 70c083417d..c0cc13822d 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -118,7 +118,7 @@ init_dev(JCR *jcr, DEVRES *device) } else if (S_ISCHR(statp.st_mode)) { device->dev_type = B_TAPE_DEV; } else if (S_ISFIFO(statp.st_mode)) { - device->dev_type = B_FILE_DEV; + device->dev_type = B_FIFO_DEV; } else if (!(device->cap_bits & CAP_REQMOUNT)) { Jmsg2(jcr, M_ERROR, 0, _("%s is an unknown device type. Must be tape or directory\n" " or have RequiresMount=yes for DVD. st_mode=%x\n"), @@ -942,12 +942,12 @@ bool DEVICE::eod(DCR *dcr) /* * Avoid infinite loop by ensuring we advance. */ - if (file_num == (int)file) { + if (!at_eot() && file_num == (int)file) { struct mtget mt_stat; Dmsg1(100, "fsf did not advance from file %d\n", file_num); set_ateof(); if (dev_get_os_pos(this, &mt_stat)) { - Dmsg2(100, "Adjust file from %d to %d\n", file , mt_stat.mt_fileno); + Dmsg2(100, "Adjust file from %d to %d\n", file_num, mt_stat.mt_fileno); file = mt_stat.mt_fileno; } break; @@ -1584,8 +1584,7 @@ bool DEVICE::reposition(DCR *dcr, uint32_t rfile, uint32_t rblock) } /* After this point, we are tape only */ - Dmsg4(100, "reposition from %u:%u to %u:%u\n", - file, block_num, rfile, rblock); + Dmsg4(100, "reposition from %u:%u to %u:%u\n", file, block_num, rfile, rblock); if (rfile < file) { Dmsg0(100, "Rewind\n"); if (!rewind(NULL)) { @@ -1612,6 +1611,17 @@ bool DEVICE::reposition(DCR *dcr, uint32_t rfile, uint32_t rblock) /* Ignore errors as Bacula can read to the correct block */ Dmsg1(100, "fsr %d\n", rblock-block_num); return fsr(rblock-block_num); + } else { + while (rblock > block_num) { + if (!read_block_from_dev(dcr, NO_BLOCK_NUMBER_CHECK)) { + berrno be; + dev_errno = errno; + Dmsg2(30, "Failed to find requested block on %s: ERR=%s", + print_name(), be.strerror()); + return false; + } + Dmsg2(300, "moving forward wanted_blk=%d at_blk=%d\n", rblock, block_num); + } } return true; } @@ -1834,8 +1844,8 @@ void DEVICE::close() switch (dev_type) { case B_TAPE_DEV: - tape_close(fd); unlock_door(); + tape_close(fd); break; default: ::close(fd); diff --git a/bacula/technotes-1.39 b/bacula/technotes-1.39 index f17f9edbf3..54fcfe8b9f 100644 --- a/bacula/technotes-1.39 +++ b/bacula/technotes-1.39 @@ -1,6 +1,15 @@ Technical notes on version 1.39 General: +12Oct06 +kes Apply the three patches from Richard Mortimer. + bacula-reposition.patch, bacula-tape-reopen.patch, and + bacula-eod.patch. This corrects tape positioning on older devices, + and also a problem with btape. +kes Apply fix from bug report #696 where writing to a FIFO does not + work due to a dumb typo. +kes Unlock the tape door before the file descriptor is released. This + should fix lots of somewhat subtle failures when using an autochanger. 11Oct06 kes Correct mtx-changer bug that I introduced in a recent commit, and pointed out by Robert Nelson -- thanks. -- 2.39.5