From 0cd4b443ac48c1ba69167e9b3d6f1ffb2dafb166 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 3 Apr 2008 16:15:24 +0000 Subject: [PATCH] Separate unload_dev() from unload_other_device() in autochanger.c git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6735 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 43 ++++++--------------------------- bacula/src/stored/autochanger.c | 34 +++++++++++++++++--------- bacula/src/stored/protos.h | 1 + bacula/technotes-2.3 | 8 ++++++ 4 files changed, 38 insertions(+), 48 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index f78e655e78..61affa3457 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -71,40 +71,6 @@ Professional Needs: Priority: ================ -Tom Ivar Helbekkmo -> There's definitely something fishy in the recording of start and -> end blocks in the JOBMEDIA table. -> - If several jobs start spooling at the same time, they will all get the -> current tape position noted as the StartFile/StartBlock for the job. -> If they end up despooling to the file that was current when they -> started spooling, this is what will end up in the JOBMEDIA table. If -> there is a file change before they despool, the setting of NewFile in -> the dcr structure will fix this up later, but the "start of session" -> label is already in the spool file, of course, so it holds the wrong -> information anyway. -> -> - If the job is longer than the maximum spool size, it will get its -> first spool session despooled, and then start spooling again after the -> first despooling is over. The last blocks despooled to tape from the -> first session will not have been recorded, but they will be flushed -> later, when the next session despools. However, if another job has -> been despooling while this one is spooling its second round, the -> session label written to the spool file at its close will cause the -> EndFile/Endblock to be set to wherever the tape is at that time. When -> the dangling record is flushed to JOBMEDIA, it gets this wrong -> information. Both session labels in the spool file will be wrong, -> too, of course, because they reflect the state of the tape during -> spooling, not during despooling. -> -> I would have to study the code much more closely to work out what's the -> proper fix -- but it seems clear that it should involve creating the -> session labels only when something is actually written to the archive -> device, not during spooling. I'm tempted to try making do_append_data() -> not create session labels if we're spooling, and add the making of them -> to despool_data() in stored/spool.c. Sound reasonable? -=========== - - - Re-check new dcr->reserved_volume - Softlinks that point to non-existent file are not restored in restore all, but are restored if the file is individually selected. BUG! @@ -116,6 +82,8 @@ Tom Ivar Helbekkmo - Implement unmount of USB volumes. - Use "./config no-idea no-mdc2 no-rc5" on building OpenSSL for Win32 to avoid patent problems. +- Implement multiple jobid specification for the cancel command, + similar to what is permitted on the update slots command. - Implement Bacula plugins -- design API - modify pruning to keep a fixed number of versions of a file, if requested. @@ -123,8 +91,6 @@ Tom Ivar Helbekkmo i.e. cd /foo/bar/foo/bar -> if a customer mails me the path to a certain file, its faster to enter the specified directory -- Fix bpipe.c so that it does not modify results pointer. - ***FIXME*** calling sequence should be changed. - Make tree walk routines like cd, ls, ... more user friendly by handling spaces better. === rate design @@ -1834,6 +1800,8 @@ Block Position: 0 in only one catalog -- currently Pools are "global". - Add TLS to bat (should be done). === Duplicate jobs === +- Done, but implemented somewhat differently than described below!!! + hese apply only to backup jobs. 1. Allow Duplicate Jobs = Yes | No | Higher (Yes) @@ -1909,3 +1877,6 @@ DuplicateJobs { } === +- Fix bpipe.c so that it does not modify results pointer. + ***FIXME*** calling sequence should be changed. + diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index 07596604de..1a22132784 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -380,14 +380,9 @@ bool unload_autochanger(DCR *dcr, int loaded) static bool unload_other_drive(DCR *dcr, int slot) { DEVICE *dev = NULL; - DEVICE *save_dev; - JCR *jcr = dcr->jcr; - int save_slot; - uint32_t timeout = dcr->device->max_changer_wait; - bool ok = true; + bool found = false; AUTOCHANGER *changer = dcr->dev->device->changer_res; DEVRES *device; - bool found = false; int retries = 0; /* wait for device retries */ if (!changer) { @@ -421,12 +416,27 @@ static bool unload_other_drive(DCR *dcr, int slot) } break; } + return unload_dev(dcr, dev); +} + +bool unload_dev(DCR *dcr, DEVICE *dev) +{ + JCR *jcr = dcr->jcr; + bool ok = true; + uint32_t timeout = dcr->device->max_changer_wait; + AUTOCHANGER *changer = dcr->dev->device->changer_res; + DEVICE *save_dev; + int save_slot; + + if (!changer) { + return false; + } dev->dlock(); if (dev->is_busy()) { Jmsg(jcr, M_WARNING, 0, _("Volume \"%s\" is in use by device %s\n"), dcr->VolumeName, dev->print_name()); Dmsg4(100, "Vol %s for dev=%s is busy dev=%s slot=%d\n", - dcr->VolumeName, dcr->dev->print_name(), dev->print_name(), slot); + dcr->VolumeName, dcr->dev->print_name(), dev->print_name(), dev->Slot); Dmsg2(100, "num_writ=%d reserv=%d\n", dev->num_writers, dev->reserved_device); dev->dunlock(); return false; @@ -437,15 +447,15 @@ static bool unload_other_drive(DCR *dcr, int slot) lock_changer(dcr); Jmsg(jcr, M_INFO, 0, _("3307 Issuing autochanger \"unload slot %d, drive %d\" command.\n"), - slot, dev->drive_index); + dev->Slot, dev->drive_index); Dmsg2(100, "Issuing autochanger \"unload slot %d, drive %d\" command.\n", - slot, dev->drive_index); + dev->Slot, dev->drive_index); save_dev = dcr->dev; dcr->dev = dev; save_slot = dcr->VolCatInfo.Slot; - dcr->VolCatInfo.Slot = slot; + dcr->VolCatInfo.Slot = dev->Slot; changer_cmd = edit_device_codes(dcr, changer_cmd, dcr->device->changer_command, "unload"); dev->close(); @@ -459,10 +469,10 @@ static bool unload_other_drive(DCR *dcr, int slot) berrno be; be.set_errno(stat); Jmsg(jcr, M_INFO, 0, _("3995 Bad autochanger \"unload slot %d, drive %d\": ERR=%s.\n"), - slot, dev->drive_index, be.bstrerror()); + dev->Slot, dev->drive_index, be.bstrerror()); Dmsg3(100, "Bad autochanger \"unload slot %d, drive %d\": ERR=%s.\n", - slot, dev->drive_index, be.bstrerror()); + dev->Slot, dev->drive_index, be.bstrerror()); ok = false; dev->Slot = -1; /* unknown */ } else { diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index c25b1f8d81..b6aca7b9ff 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -68,6 +68,7 @@ bool init_autochangers(); int autoload_device(DCR *dcr, int writing, BSOCK *dir); bool autochanger_cmd(DCR *dcr, BSOCK *dir, const char *cmd); bool unload_autochanger(DCR *dcr, int loaded); +bool unload_dev(DCR *dcr, DEVICE *dev); char *edit_device_codes(DCR *dcr, char *omsg, const char *imsg, const char *cmd); int get_autochanger_loaded_slot(DCR *dcr); diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index a69baf6b68..630b24a323 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -24,6 +24,8 @@ Add long term statistics job table General: +03Apr08 +kes Separate unload_dev() from unload_other_device() in autochanger.c 02Apr08 kes Apply patch from bug #1069 that corrects spurious error messages when ACLs enabled on SGI but no ACL exists. @@ -53,6 +55,12 @@ kes Analysis of JobMedia records by Tom Ivar Helbekkmo 28Mar08 kes Fix handling of JobMedia records during spooling and when a Volume is changed without actually writing data to the Volume. +27Mar08 +kes Rework certain SD locking based on gdb tracebacks of deadlocks + sent by Eric. This code now uses only the volume_lock() rather + than the reservations lock when at EOM and acquiring a new + volume. +kes Ensure only one exit point in several subroutines. 26Mar08 kes Implement bsock code to permit locking. Use the new code in Verify in the FD to prevent the heartbeat thread from disrupting the Verify -- 2.39.5