From: <ke...@us...> - 2008-08-26 13:14:33
|
Revision: 7508 http://bacula.svn.sourceforge.net/bacula/?rev=7508&view=rev Author: kerns Date: 2008-08-26 13:14:38 +0000 (Tue, 26 Aug 2008) Log Message: ----------- Attempt to fix bug #1128 InChanger flag cleared during Migration job when reading from one autochanger and writing to another. Modified Paths: -------------- branches/Branch-2.4/bacula/src/cats/sql_update.c branches/Branch-2.4/bacula/src/dird/catreq.c branches/Branch-2.4/bacula/src/dird/dird.c branches/Branch-2.4/bacula/src/version.h branches/Branch-2.4/bacula/technotes-2.4 Added Paths: ----------- branches/Branch-2.4/bacula/patches/2.4.2-inchanger.patch Added: branches/Branch-2.4/bacula/patches/2.4.2-inchanger.patch =================================================================== --- branches/Branch-2.4/bacula/patches/2.4.2-inchanger.patch (rev 0) +++ branches/Branch-2.4/bacula/patches/2.4.2-inchanger.patch 2008-08-26 13:14:38 UTC (rev 7508) @@ -0,0 +1,100 @@ + + Attempt to fix bug #1128 InChanger flag cleared during Migration + job when reading from one autochanger and writing to another. + Testing is needed. + Apply this patch to Bacula version 2.4.2 with: + + cd <bacula-source> + patch -p0 <2.4.2-inchanger.patch + ./configure <your options> + make + ... + make install + + +Index: src/dird/catreq.c +=================================================================== +--- src/dird/catreq.c (revision 7507) ++++ src/dird/catreq.c (working copy) +@@ -83,7 +83,7 @@ + jcr->MediaId = mr->MediaId; + pm_strcpy(jcr->VolumeName, mr->VolumeName); + bash_spaces(mr->VolumeName); +- stat = bnet_fsend(sd, OK_media, mr->VolumeName, mr->VolJobs, ++ stat = sd->fsend(OK_media, mr->VolumeName, mr->VolJobs, + mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1), + mr->VolMounts, mr->VolErrors, mr->VolWrites, + edit_uint64(mr->MaxVolBytes, ed2), +@@ -266,11 +266,22 @@ + } + } + Dmsg2(400, "Update media: BefVolJobs=%u After=%u\n", mr.VolJobs, sdmr.VolJobs); ++ + /* Check if the volume has been written by the job, + * and update the LastWritten field if needed */ + if (mr.VolBlocks != sdmr.VolBlocks) { + mr.LastWritten = sdmr.LastWritten; + } ++ ++ /* ++ * Update to point to the last device used to write the Volume. ++ * However, do so only if we are writing the tape, i.e. ++ * the number of VolWrites has increased. ++ */ ++ if (jcr->wstore && jcr->wstore->StorageId && sdmr.VolWrites > mr.VolWrites) { ++ mr.StorageId = jcr->wstore->StorageId; ++ } ++ + /* Copy updated values to original media record */ + mr.VolJobs = sdmr.VolJobs; + mr.VolFiles = sdmr.VolFiles; +@@ -285,14 +296,6 @@ + mr.VolWriteTime = sdmr.VolWriteTime; + mr.VolParts = sdmr.VolParts; + bstrncpy(mr.VolStatus, sdmr.VolStatus, sizeof(mr.VolStatus)); +- /* +- * Update to point to the last device used to write the Volume. +- * However, do so only if we are writing the tape, i.e. +- * the number of VolBlocks has increased. +- */ +- if (jcr->wstore && jcr->wstore->StorageId && mr.VolBlocks != sdmr.VolBlocks) { +- mr.StorageId = jcr->wstore->StorageId; +- } + + Dmsg2(400, "db_update_media_record. Stat=%s Vol=%s\n", mr.VolStatus, mr.VolumeName); + /* +Index: src/dird/dird.c +=================================================================== +--- src/dird/dird.c (revision 7507) ++++ src/dird/dird.c (working copy) +@@ -914,6 +914,7 @@ + db_create_storage_record(NULL, db, &sr); + store->StorageId = sr.StorageId; /* set storage Id */ + if (!sr.created) { /* if not created, update it */ ++ sr.AutoChanger = store->autochanger; + db_update_storage_record(NULL, db, &sr); + } + +Index: src/cats/sql_update.c +=================================================================== +--- src/cats/sql_update.c (revision 7507) ++++ src/cats/sql_update.c (working copy) +@@ -1,7 +1,7 @@ + /* + Bacula® - The Network Backup Solution + +- Copyright (C) 2000-2007 Free Software Foundation Europe e.V. ++ Copyright (C) 2000-2008 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. +@@ -445,7 +445,8 @@ + db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) + { + char ed1[50], ed2[50]; +- if (mr->InChanger != 0 && mr->Slot != 0) { ++ if (mr->InChanger != 0 && mr->Slot != 0 && mr->StorageId != 0 && ++ mr->MediaId != 0) { + Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE " + "Slot=%d AND StorageId=%s AND MediaId!=%s", + mr->Slot, Modified: branches/Branch-2.4/bacula/src/cats/sql_update.c =================================================================== --- branches/Branch-2.4/bacula/src/cats/sql_update.c 2008-08-26 13:00:32 UTC (rev 7507) +++ branches/Branch-2.4/bacula/src/cats/sql_update.c 2008-08-26 13:14:38 UTC (rev 7508) @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + Copyright (C) 2000-2008 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -445,7 +445,8 @@ db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) { char ed1[50], ed2[50]; - if (mr->InChanger != 0 && mr->Slot != 0) { + if (mr->InChanger != 0 && mr->Slot != 0 && mr->StorageId != 0 && + mr->MediaId != 0) { Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE " "Slot=%d AND StorageId=%s AND MediaId!=%s", mr->Slot, Modified: branches/Branch-2.4/bacula/src/dird/catreq.c =================================================================== --- branches/Branch-2.4/bacula/src/dird/catreq.c 2008-08-26 13:00:32 UTC (rev 7507) +++ branches/Branch-2.4/bacula/src/dird/catreq.c 2008-08-26 13:14:38 UTC (rev 7508) @@ -83,7 +83,7 @@ jcr->MediaId = mr->MediaId; pm_strcpy(jcr->VolumeName, mr->VolumeName); bash_spaces(mr->VolumeName); - stat = bnet_fsend(sd, OK_media, mr->VolumeName, mr->VolJobs, + stat = sd->fsend(OK_media, mr->VolumeName, mr->VolJobs, mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1), mr->VolMounts, mr->VolErrors, mr->VolWrites, edit_uint64(mr->MaxVolBytes, ed2), @@ -266,11 +266,22 @@ } } Dmsg2(400, "Update media: BefVolJobs=%u After=%u\n", mr.VolJobs, sdmr.VolJobs); + /* Check if the volume has been written by the job, * and update the LastWritten field if needed */ if (mr.VolBlocks != sdmr.VolBlocks) { mr.LastWritten = sdmr.LastWritten; } + + /* + * Update to point to the last device used to write the Volume. + * However, do so only if we are writing the tape, i.e. + * the number of VolWrites has increased. + */ + if (jcr->wstore && jcr->wstore->StorageId && sdmr.VolWrites > mr.VolWrites) { + mr.StorageId = jcr->wstore->StorageId; + } + /* Copy updated values to original media record */ mr.VolJobs = sdmr.VolJobs; mr.VolFiles = sdmr.VolFiles; @@ -285,14 +296,6 @@ mr.VolWriteTime = sdmr.VolWriteTime; mr.VolParts = sdmr.VolParts; bstrncpy(mr.VolStatus, sdmr.VolStatus, sizeof(mr.VolStatus)); - /* - * Update to point to the last device used to write the Volume. - * However, do so only if we are writing the tape, i.e. - * the number of VolBlocks has increased. - */ - if (jcr->wstore && jcr->wstore->StorageId && mr.VolBlocks != sdmr.VolBlocks) { - mr.StorageId = jcr->wstore->StorageId; - } Dmsg2(400, "db_update_media_record. Stat=%s Vol=%s\n", mr.VolStatus, mr.VolumeName); /* Modified: branches/Branch-2.4/bacula/src/dird/dird.c =================================================================== --- branches/Branch-2.4/bacula/src/dird/dird.c 2008-08-26 13:00:32 UTC (rev 7507) +++ branches/Branch-2.4/bacula/src/dird/dird.c 2008-08-26 13:14:38 UTC (rev 7508) @@ -914,6 +914,7 @@ db_create_storage_record(NULL, db, &sr); store->StorageId = sr.StorageId; /* set storage Id */ if (!sr.created) { /* if not created, update it */ + sr.AutoChanger = store->autochanger; db_update_storage_record(NULL, db, &sr); } Modified: branches/Branch-2.4/bacula/src/version.h =================================================================== --- branches/Branch-2.4/bacula/src/version.h 2008-08-26 13:00:32 UTC (rev 7507) +++ branches/Branch-2.4/bacula/src/version.h 2008-08-26 13:14:38 UTC (rev 7508) @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.4.3" -#define BDATE "24 August 2008" -#define LSMDATE "24Aug08" +#define BDATE "26 August 2008" +#define LSMDATE "26Aug08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ Modified: branches/Branch-2.4/bacula/technotes-2.4 =================================================================== --- branches/Branch-2.4/bacula/technotes-2.4 2008-08-26 13:00:32 UTC (rev 7507) +++ branches/Branch-2.4/bacula/technotes-2.4 2008-08-26 13:14:38 UTC (rev 7508) @@ -1,6 +1,9 @@ Technical notes on version 2.4 General: +26Aug08 +kes Attempt to fix bug #1128 InChanger flag cleared during Migration + job when reading from one autochanger and writing to another. 24Aug08 kes Add more information to SD acquire.c INFO messages. kes Fix NULL Volume name error when reading and the drive must This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |