From: Kern Sibbald Date: Thu, 7 Jul 2005 22:38:36 +0000 (+0000) Subject: - Remove temp file created in mtx-changer script. X-Git-Tag: Release-7.0.0~8652 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0d8d32d9333f9ec74a364e3c2de597d2207a57e5;p=bacula%2Fbacula - Remove temp file created in mtx-changer script. - Make fsf_dev() into a class method. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2179 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index 4b44aa4931..b64e7e9d02 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -137,6 +137,45 @@ Maybe in 1.37: - Bug: if a job is manually scheduled to run later, it does not appear in any status report and cannot be cancelled. +==== Keeping track of deleted files ==== + My "trick" for keeping track of deletions is the following. + Assuming the user turns on this option, after all the files + have been backed up, but before the job has terminated, the + FD will make a pass through all the files and send their + names to the DIR (*exactly* the same as what a Verify job + currently does). This will probably be done at the same + time the files are being sent to the SD avoiding a second + pass. The DIR will then compare that to what is stored in + the catalog. Any files in the catalog but not in what the + FD sent will receive a catalog File entry that indicates + that at that point in time the file was deleted. + + During a restore, any file initially picked up by some + backup (Full, ...) then subsequently having a File entry + marked "delete" will be removed from the tree, so will not + be restored. If a file with the same name is later OK it + will be inserted in the tree -- this already happens. All + will be consistent except for possible changes during the + running of the FD. + + Since I'm on the subject, some of you may be wondering what + the utility of the in memory tree is if you are going to + restore everything (at least it comes up from time to time + on the list). Well, it is still *very* useful because it + allows only the last item found for a particular filename + (full path) to be entered into the tree, and thus if a file + is backed up 10 times, only the last copy will be restored. + I recently (last Friday) restored a complete directory, and + the Full and all the Differential and Incremental backups + spanned 3 Volumes. The first Volume was not even mounted + because all the files had been updated and hence backed up + since the Full backup was made. In this case, the tree + saved me a *lot* of time. + + Make sure this information is stored on the tape too so + that it can be restored directly from the tape. +===== + Regression tests: - Add Pool/Storage override regression test. - Add delete JobId to regression. diff --git a/bacula/kes-1.37 b/bacula/kes-1.37 index 13c4b5fcb9..2145391535 100644 --- a/bacula/kes-1.37 +++ b/bacula/kes-1.37 @@ -4,6 +4,9 @@ General: Changes to 1.37.28: +07Jul05 +- Remove temp file created in mtx-changer script. +- Make fsf_dev() into a class method. 06Jul05 - Modify mtx-changer.in script to return slot:barcode for Volumes that are loaded in the drives. diff --git a/bacula/scripts/mtx-changer.in b/bacula/scripts/mtx-changer.in index 70703816eb..c153426f28 100644 --- a/bacula/scripts/mtx-changer.in +++ b/bacula/scripts/mtx-changer.in @@ -133,6 +133,7 @@ case $cmd in rtn=$? cat ${TMPDIR}/mtx.$$ | grep " *Storage Element [0-9]*:.*Full" | awk "{print \$3 \$4}" | sed "s/Full *\(:VolumeTag=\)*//" cat ${TMPDIR}/mtx.$$ | grep "^Data Transfer Element [0-9]*:Full (Storage Element [0-9]" | awk '{printf "%s:%s\n",$7,$10}' + rm -f ${TMPDIR}/mtx.$$ 2>&1 >/dev/null # # If you have a VXA PacketLoader and the above does not work, try # turning it off and enabling the following line. @@ -146,7 +147,7 @@ case $cmd in rtn=$? cat ${TMPDIR}/mtx.$$ | grep "^Data Transfer Element $drive:Full" | awk "{print \$7}" cat ${TMPDIR}/mtx.$$ | grep "^Data Transfer Element $drive:Empty" | awk "{print 0}" - rm -f ${TMPDIR}/mtx.$$ + rm -f ${TMPDIR}/mtx.$$ 2>&1 >/dev/null exit $rtn ;; diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index 92582eafee..ef67e8924d 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -1267,7 +1267,7 @@ static int fsf_test() test_again: rewindcmd(); Pmsg0(0, _("Now forward spacing 1 file.\n")); - if (!fsf_dev(dev, 1)) { + if (!dev->fsf(1)) { Pmsg1(0, "Bad status from fsr. ERR=%s\n", strerror_dev(dev)); goto bail_out; } @@ -1279,7 +1279,7 @@ test_again: } Pmsg0(0, _("Now forward spacing 2 files.\n")); - if (!fsf_dev(dev, 2)) { + if (!dev->fsf(2)) { Pmsg1(0, "Bad status from fsr. ERR=%s\n", strerror_dev(dev)); goto bail_out; } @@ -1292,7 +1292,7 @@ test_again: rewindcmd(); Pmsg0(0, _("Now forward spacing 4 files.\n")); - if (!fsf_dev(dev, 4)) { + if (!dev->fsf(4)) { Pmsg1(0, "Bad status from fsr. ERR=%s\n", strerror_dev(dev)); goto bail_out; } @@ -1310,7 +1310,7 @@ test_again: Pmsg0(-1, "\n"); Pmsg0(0, _("Now forward spacing 1 more file.\n")); - if (!fsf_dev(dev, 1)) { + if (!dev->fsf(1)) { Pmsg1(0, "Bad status from fsr. ERR=%s\n", strerror_dev(dev)); } Pmsg2(-1, _("We should be in file 5. I am at file %d. This is %s\n"), @@ -1458,7 +1458,7 @@ static void fsfcmd() if (num <= 0) { num = 1; } - if (!fsf_dev(dev, num)) { + if (!dev->fsf(num)) { Pmsg1(0, "Bad status from fsf. ERR=%s\n", strerror_dev(dev)); return; } diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index ebdd6779bd..1948907947 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -700,7 +700,7 @@ eod_dev(DEVICE *dev) } #if defined (__digital__) && defined (__unix__) - return fsf_dev(dev, dev->VolCatInfo.VolCatFiles); + return dev->fsf(dev->VolCatInfo.VolCatFiles); #endif Dmsg0(29, "eod_dev\n"); @@ -791,8 +791,8 @@ eod_dev(DEVICE *dev) int file_num; for (file_num=dev->file; !dev->at_eot(); file_num++) { Dmsg0(200, "eod_dev: doing fsf 1\n"); - if (!fsf_dev(dev, 1)) { - Dmsg0(200, "fsf_dev error.\n"); + if (!dev->fsf(1)) { + Dmsg0(200, "fsf error.\n"); return false; } /* @@ -801,7 +801,7 @@ eod_dev(DEVICE *dev) */ if (file_num == (int)dev->file) { struct mtget mt_stat; - Dmsg1(100, "fsf_dev did not advance from file %d\n", file_num); + Dmsg1(100, "fsf did not advance from file %d\n", file_num); if (dev_get_os_pos(dev, &mt_stat)) { Dmsg2(100, "Adjust file from %d to %d\n", dev->file , mt_stat.mt_fileno); dev->set_ateof(); @@ -1069,34 +1069,33 @@ bool offline_or_rewind_dev(DEVICE *dev) * Returns: true on success * false on failure */ -bool -fsf_dev(DEVICE *dev, int num) +bool DEVICE::fsf(int num) { struct mtget mt_stat; struct mtop mt_com; int stat = 0; - if (dev->fd < 0) { - dev->dev_errno = EBADF; - Mmsg0(dev->errmsg, _("Bad call to fsf_dev. Device not open\n")); - Emsg0(M_FATAL, 0, dev->errmsg); + if (fd < 0) { + dev_errno = EBADF; + Mmsg0(errmsg, _("Bad call to fsf_dev. Device not open\n")); + Emsg0(M_FATAL, 0, errmsg); return false; } - if (!dev->is_tape()) { + if (!is_tape()) { return true; } - if (dev->state & ST_EOT) { - dev->dev_errno = 0; - Mmsg1(dev->errmsg, _("Device %s at End of Tape.\n"), dev->print_name()); + if (at_eot()) { + dev_errno = 0; + Mmsg1(errmsg, _("Device %s at End of Tape.\n"), print_name()); return false; } - if (dev->state & ST_EOF) { + if (at_eof()) { Dmsg0(200, "ST_EOF set on entry to FSF\n"); } - Dmsg0(100, "fsf_dev\n"); - dev->block_num = 0; + Dmsg0(100, "fsf\n"); + block_num = 0; /* * If Fast forward space file is set, then we * use MTFSF to forward space and MTIOCGET @@ -1104,23 +1103,23 @@ fsf_dev(DEVICE *dev, int num) * the SCSI driver will ensure that we do not * forward space past the end of the medium. */ - if (dev_cap(dev, CAP_FSF) && dev_cap(dev, CAP_MTIOCGET) && dev_cap(dev, CAP_FASTFSF)) { + if (dev_cap(this, CAP_FSF) && dev_cap(this, CAP_MTIOCGET) && dev_cap(this, CAP_FASTFSF)) { mt_com.mt_op = MTFSF; mt_com.mt_count = num; - stat = ioctl(dev->fd, MTIOCTOP, (char *)&mt_com); - if (stat < 0 || !dev_get_os_pos(dev, &mt_stat)) { + stat = ioctl(fd, MTIOCTOP, (char *)&mt_com); + if (stat < 0 || !dev_get_os_pos(this, &mt_stat)) { berrno be; - dev->state |= ST_EOT; + set_eot(); Dmsg0(200, "Set ST_EOT\n"); - clrerror_dev(dev, MTFSF); - Mmsg2(dev->errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"), - dev->print_name(), be.strerror()); - Dmsg1(200, "%s", dev->errmsg); + clrerror_dev(this, MTFSF); + Mmsg2(errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"), + print_name(), be.strerror()); + Dmsg1(200, "%s", errmsg); return false; } Dmsg2(200, "fsf file=%d block=%d\n", mt_stat.mt_fileno, mt_stat.mt_blkno); - dev->set_ateof(); - dev->file = mt_stat.mt_fileno; + set_ateof(); + file = mt_stat.mt_fileno; return true; /* @@ -1130,64 +1129,65 @@ fsf_dev(DEVICE *dev, int num) * is the only way we can be sure that we don't read * two consecutive EOF marks, which means End of Data. */ - } else if (dev_cap(dev, CAP_FSF)) { + } else if (dev_cap(this, CAP_FSF)) { POOLMEM *rbuf; int rbuf_len; Dmsg0(200, "FSF has cap_fsf\n"); - if (dev->max_block_size == 0) { + if (max_block_size == 0) { rbuf_len = DEFAULT_BLOCK_SIZE; } else { - rbuf_len = dev->max_block_size; + rbuf_len = max_block_size; } rbuf = get_memory(rbuf_len); mt_com.mt_op = MTFSF; mt_com.mt_count = 1; - while (num-- && !(dev->state & ST_EOT)) { + while (num-- && !at_eot()) { Dmsg0(100, "Doing read before fsf\n"); - if ((stat = read(dev->fd, (char *)rbuf, rbuf_len)) < 0) { + if ((stat = read(fd, (char *)rbuf, rbuf_len)) < 0) { if (errno == ENOMEM) { /* tape record exceeds buf len */ stat = rbuf_len; /* This is OK */ } else { berrno be; - dev->state |= ST_EOT; - clrerror_dev(dev, -1); - Dmsg2(100, "Set ST_EOT read errno=%d. ERR=%s\n", dev->dev_errno, + set_eot(); + clrerror_dev(this, -1); + Dmsg2(100, "Set ST_EOT read errno=%d. ERR=%s\n", dev_errno, be.strerror()); - Mmsg2(dev->errmsg, _("read error on %s. ERR=%s.\n"), - dev->print_name(), be.strerror()); - Dmsg1(100, "%s", dev->errmsg); + Mmsg2(errmsg, _("read error on %s. ERR=%s.\n"), + print_name(), be.strerror()); + Dmsg1(100, "%s", errmsg); break; } } if (stat == 0) { /* EOF */ - update_pos_dev(dev); - Dmsg1(100, "End of File mark from read. File=%d\n", dev->file+1); + update_pos_dev(this); + Dmsg1(100, "End of File mark from read. File=%d\n", file+1); /* Two reads of zero means end of tape */ - if (dev->state & ST_EOF) { - dev->state |= ST_EOT; + if (at_eof()) { + set_eot(); Dmsg0(100, "Set ST_EOT\n"); break; } else { - dev->set_ateof(); + set_ateof(); continue; } } else { /* Got data */ - dev->state &= ~(ST_EOF|ST_EOT); + clear_eot(); + clear_eof(); } Dmsg0(100, "Doing MTFSF\n"); - stat = ioctl(dev->fd, MTIOCTOP, (char *)&mt_com); + stat = ioctl(fd, MTIOCTOP, (char *)&mt_com); if (stat < 0) { /* error => EOT */ berrno be; - dev->state |= ST_EOT; + set_eot(); Dmsg0(100, "Set ST_EOT\n"); - clrerror_dev(dev, MTFSF); - Mmsg2(dev->errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"), - dev->print_name(), be.strerror()); + clrerror_dev(this, MTFSF); + Mmsg2(errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"), + print_name(), be.strerror()); Dmsg0(100, "Got < 0 for MTFSF\n"); - Dmsg1(100, "%s", dev->errmsg); + Dmsg1(100, "%s", errmsg); } else { - dev->set_ateof(); + set_ateof(); } } free_memory(rbuf); @@ -1197,24 +1197,24 @@ fsf_dev(DEVICE *dev, int num) */ } else { Dmsg0(200, "Doing FSR for FSF\n"); - while (num-- && !(dev->state & ST_EOT)) { - dev->fsr(INT32_MAX); /* returns -1 on EOF or EOT */ + while (num-- && !at_eot()) { + fsr(INT32_MAX); /* returns -1 on EOF or EOT */ } - if (dev->state & ST_EOT) { - dev->dev_errno = 0; - Mmsg1(dev->errmsg, _("Device %s at End of Tape.\n"), dev->print_name()); + if (at_eot()) { + dev_errno = 0; + Mmsg1(errmsg, _("Device %s at End of Tape.\n"), print_name()); stat = -1; } else { stat = 0; } } - update_pos_dev(dev); + update_pos_dev(this); Dmsg1(200, "Return %d from FSF\n", stat); - if (dev->state & ST_EOF) + if (at_eof()) Dmsg0(200, "ST_EOF set on exit FSF\n"); - if (dev->state & ST_EOT) + if (at_eot()) Dmsg0(200, "ST_EOT set on exit FSF\n"); - Dmsg1(200, "Return from FSF file=%d\n", dev->file); + Dmsg1(200, "Return from FSF file=%d\n", file); return stat == 0; } @@ -1399,7 +1399,7 @@ reposition_dev(DEVICE *dev, uint32_t file, uint32_t block) } if (file > dev->file) { Dmsg1(100, "fsf %d\n", file-dev->file); - if (!fsf_dev(dev, file-dev->file)) { + if (!dev->fsf(file-dev->file)) { Dmsg1(100, "fsf failed! ERR=%s\n", strerror_dev(dev)); return false; } @@ -1410,7 +1410,7 @@ reposition_dev(DEVICE *dev, uint32_t file, uint32_t block) Dmsg0(100, "bsf_dev 1\n"); bsf_dev(dev, 1); Dmsg0(100, "fsf_dev 1\n"); - fsf_dev(dev, 1); + dev->fsf(1); Dmsg2(100, "wanted_blk=%d at_blk=%d\n", block, dev->block_num); } if (dev_cap(dev, CAP_POSITIONBLOCKS) && block > dev->block_num) { diff --git a/bacula/src/stored/dev.h b/bacula/src/stored/dev.h index 19a9599a99..74b18a1baf 100644 --- a/bacula/src/stored/dev.h +++ b/bacula/src/stored/dev.h @@ -285,6 +285,7 @@ public: dev_blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP); }; bool weof() { return !weof_dev(this, 1); }; bool fsr(int num); /* in dev.c */ + bool fsf(int num); /* in dev.c */ bool rewind() { return rewind_dev(this); }; const char *strerror() const; const char *archive_name() const; diff --git a/bacula/src/version.h b/bacula/src/version.h index 0a50102e8c..a9b40e5fad 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION #define VERSION "1.37.28" -#define BDATE "06 July 2005" -#define LSMDATE "06Jul05" +#define BDATE "07 July 2005" +#define LSMDATE "07Jul05" /* Debug flags */ #undef DEBUG