]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/spool.c
kes When applying a storage override, release all previous storage
[bacula/bacula] / bacula / src / stored / spool.c
index ee26ee7a869af19b7f2bd84bd8d68823f279cc47..e86672efb2ee66e27a4cb64807962cc713c6bcd7 100644 (file)
@@ -7,8 +7,8 @@
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
    modify it under the terms of version two of the GNU General Public
-   License as published by the Free Software Foundation plus additions
-   that are listed in the file LICENSE.
+   License as published by the Free Software Foundation and included
+   in the file LICENSE.
 
    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -81,6 +81,8 @@ void list_spool_stats(void sendit(const char *msg, int len, void *sarg), void *a
    POOL_MEM msg(PM_MESSAGE);
    int len;
 
+   len = Mmsg(msg, _("Spooling statistics:\n"));
+
    if (spool_stats.data_jobs || spool_stats.max_data_size) {
       len = Mmsg(msg, _("Data spooling: %u active jobs, %s bytes; %u total jobs, %s max bytes/job.\n"),
          spool_stats.data_jobs, edit_uint64_with_commas(spool_stats.data_size, ed1),
@@ -97,6 +99,8 @@ void list_spool_stats(void sendit(const char *msg, int len, void *sarg), void *a
    
       sendit(msg.c_str(), len, arg);
    }
+   len = Mmsg(msg, "====\n");
+   sendit(msg.c_str(), len, arg);
 }
 
 bool begin_data_spool(DCR *dcr)
@@ -234,10 +238,14 @@ static bool despool_data(DCR *dcr, bool commit)
    }
    dcr->despool_wait = true;
    dcr->spooling = false;
-   dcr->dev->r_dlock();
+   /*
+    * We work with device blocked, but not locked so that
+    *  other threads -- e.g. reservations can lock the device
+    *  structure.
+    */
+   dcr->dblock(BST_DESPOOLING);
    dcr->despool_wait = false;
    dcr->despooling = true;
-   dcr->dev_locked = true;
 
    /*
     * This is really quite kludgy and should be fixed some time.
@@ -253,9 +261,8 @@ static bool despool_data(DCR *dcr, bool commit)
    rdev->max_block_size = dcr->dev->max_block_size;
    rdev->min_block_size = dcr->dev->min_block_size;
    rdev->device = dcr->dev->device;
-   rdcr = new_dcr(jcr, rdev);
+   rdcr = new_dcr(jcr, NULL, rdev);
    rdcr->spool_fd = dcr->spool_fd;
-   rdcr->jcr = jcr;                   /* set a valid jcr */
    block = dcr->block;                /* save block */
    dcr->block = rdcr->block;          /* make read and write block the same */
 
@@ -330,10 +337,16 @@ static bool despool_data(DCR *dcr, bool commit)
    free(rdev);
    dcr->spooling = true;           /* turn on spooling again */
    dcr->despooling = false;
+   /* 
+    * We are done, so unblock the device, but if we have done a 
+    *  commit, leave it locked so that the job cleanup does not
+    *  need to wait to release the device (no re-acquire of the lock).
+    */
+   dcr->dlock();
+   unblock_device(dcr->dev);
    /* If doing a commit, leave the device locked -- unlocked in release_device() */
    if (!commit) {
-      dcr->dev_locked = false;
-      dcr->dev->dunlock();
+      dcr->dunlock();
    }
    return ok;
 }
@@ -674,6 +687,6 @@ bool close_attr_spool_file(JCR *jcr, BSOCK *bs)
    unlink(name);
    free_pool_memory(name);
    bs->m_spool_fd = NULL;
-   bs->m_spool = false;
+   bs->clear_spooling();
    return true;
 }