[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bacula-devel] Patch: Migration media table update wrong source storage


Abstract:
---------
Migration jobs may update table media.storage attribute of source
volume with value of target volume.


Impact:
-------
Any subsequent restore from that source volume may fail due to media
mismatch.
The reason why this went undetected seems to be that usually
migration is used to empty the source volume, so there will be no 
more restores from it.


Comment:
--------
I am not very happy with that fix. It lacks transparency and does
not follow an object-oriented approach.
I have also not checked the various implications and relations of
the involved variables under any configuration beyond the one I am
using. In short: it just fixes my problem.


Patch:
------
--- src/dird/catreq.c.orig      Fri Oct 26 19:19:39 2007
+++ src/dird/catreq.c   Sun Feb 10 04:28:54 2008
@@ -271,6 +271,13 @@
       if (mr.VolBlocks != sdmr.VolBlocks) {
          mr.LastWritten = sdmr.LastWritten;
       }
+      if (jcr->wstore && jcr->wstore->StorageId) {
+         /* On migrate check if volume has been written, otherwise
+          * the read volume would also (wrongly) updated */
+         if (jcr->JobType != JT_MIGRATE || mr.VolBlocks != sdmr.VolBlocks) {
+            mr.StorageId = jcr->wstore->StorageId;
+         }
+      }
       /* Copy updated values to original media record */
       mr.VolJobs      = sdmr.VolJobs;
       mr.VolFiles     = sdmr.VolFiles;
@@ -285,9 +292,6 @@
       mr.VolWriteTime = sdmr.VolWriteTime;
       mr.VolParts     = sdmr.VolParts;
       bstrncpy(mr.VolStatus, sdmr.VolStatus, sizeof(mr.VolStatus));
-      if (jcr->wstore && jcr->wstore->StorageId) {
-         mr.StorageId = jcr->wstore->StorageId;
-      }
 
       Dmsg2(400, "db_update_media_record. Stat=%s Vol=%s\n", mr.VolStatus, mr.VolumeName);
       /*

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bacula-devel mailing list
Bacula-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/bacula-devel


This mailing list archive is a service of Copilotco.