From: Kern Sibbald Date: Tue, 26 Aug 2008 13:15:58 +0000 (+0000) Subject: Attempt to fix bug #1128 InChanger flag cleared during Migration X-Git-Tag: Release-3.0.0~1062 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=18f2007e7e2a4c4a02c77dc1923b796b133f7252;p=bacula%2Fbacula Attempt to fix bug #1128 InChanger flag cleared during Migration job when reading from one autochanger and writing to another. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7509 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/patches/2.4.2-inchanger.patch b/bacula/patches/2.4.2-inchanger.patch new file mode 100644 index 0000000000..5b3e566f0a --- /dev/null +++ b/bacula/patches/2.4.2-inchanger.patch @@ -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 + patch -p0 <2.4.2-inchanger.patch + ./configure + 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, diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index a729a2cc1c..530cec8539 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -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. @@ -195,8 +195,8 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr, bool stats_enabled) if (stat && stats_enabled) { Mmsg(mdb->cmd, - "INSERT INTO JobStat (SELECT * FROM Job WHERE JobId=%s)", - edit_int64(jr->JobId, ed3)); + "INSERT INTO JobStat (SELECT * FROM Job WHERE JobId=%s)", + edit_int64(jr->JobId, ed3)); INSERT_DB(jcr, mdb, mdb->cmd); /* TODO: get a message ? */ } db_unlock(mdb); @@ -459,7 +459,8 @@ void 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, diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index b406767fea..b1504fe86c 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -83,7 +83,7 @@ static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr 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), @@ -267,6 +267,7 @@ void catalog_request(JCR *jcr, BSOCK *bs) } } 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. @@ -274,6 +275,16 @@ void catalog_request(JCR *jcr, BSOCK *bs) if (mr.VolBlocks != sdmr.VolBlocks && VolLastWritten != 0) { mr.LastWritten = VolLastWritten; } + + /* + * 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; @@ -292,14 +303,6 @@ void catalog_request(JCR *jcr, BSOCK *bs) if (sdmr.VolWriteTime >= 0) { mr.VolWriteTime = sdmr.VolWriteTime; } - /* - * 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); /* diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index 959d33466c..79c06d2324 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -936,6 +936,7 @@ static bool check_catalog() 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); } diff --git a/bacula/src/version.h b/bacula/src/version.h index 8c26f18b75..aa8a862a54 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.5.3" -#define BDATE "21 Aug 2008" -#define LSMDATE "21Aug08" +#define BDATE "26 Aug 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 */ diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 5883c75d53..82ad9bc321 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -32,6 +32,10 @@ separator in console (!$%&'()*+,-/:;<>?[]^`{|}~) General: +26Aug08 +kes Attempt to fix bug #1128 InChanger flag cleared during Migration + job when reading from one autochanger and writing to another. +kes Minor tweaks (copyright dates convert to use method instead of bnet). 21Aug08 kes Fix NULL Volume error when reading (or Migration or VBackup) must switch drives when no tape is mounted.