]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/migrate.c
Ensure that StorageId is updated after write
[bacula/bacula] / bacula / src / dird / migrate.c
index 0dcc866dcc46fd746a64f4b6d29a8d0c08d4a52c..519392114562c1242ab90d61f3d6f5aabfbd5c24 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2004-2010 Free Software Foundation Europe e.V.
+   Copyright (C) 2004-2012 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.
@@ -238,8 +238,9 @@ bool do_migration_init(JCR *jcr)
 /*
  * set_migration_next_pool() called by do_migration_init()
  * at differents stages.
- * The  idea here is tofactorize the NextPool's search code and
- * to permit do_migration_init() to return with NextPool set in jcr struct.
+ * The  idea here is to make a common subroutine for the 
+ *   NextPool's search code and to permit do_migration_init() 
+ *   to return with NextPool set in jcr struct.
  */
 static bool set_migration_next_pool(JCR *jcr, POOL **retpool)
 {
@@ -667,6 +668,7 @@ static int getJob_to_migrate(JCR *jcr)
    struct tm tm;
    char dt[MAX_TIME_LENGTH];
    int count = 0;
+   int limit = 99;           /* limit + 1 is max jobs to start */
 
    ids.list = get_pool_memory(PM_MESSAGE);
    ids.list[0] = 0;
@@ -850,6 +852,10 @@ static int getJob_to_migrate(JCR *jcr)
          jcr->get_ActionName(1), ids.list);
 
       Dmsg2(dbglevel, "Before loop count=%d ids=%s\n", ids.count, ids.list);
+      /*
+       * Note: to not over load the system, limit the number
+       *  of new jobs started to 100 (see limit above)
+       */
       for (int i=1; i < (int)ids.count; i++) {
          JobId = 0;
          stat = get_next_jobid_from_list(&p, &JobId);
@@ -862,8 +868,12 @@ static int getJob_to_migrate(JCR *jcr)
             goto ok_out;
          }
          jcr->MigrateJobId = JobId;
-         start_migration_job(jcr);
-         Dmsg0(dbglevel, "Back from start_migration_job\n");
+         /* Don't start any more when limit reaches zero */
+         limit--;
+         if (limit > 0) {
+            start_migration_job(jcr);
+            Dmsg0(dbglevel, "Back from start_migration_job\n");
+         }
       }
    
       /* Now get the last JobId and handle it in the current job */
@@ -1140,7 +1150,6 @@ void migration_cleanup(JCR *jcr, int TermCode)
 
    Dmsg2(100, "Enter migrate_cleanup %d %c\n", TermCode, TermCode);
    update_job_end(jcr, TermCode);
-   memset(&mr, 0, sizeof(mr));
 
    /* 
     * Check if we actually did something.