]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/spool.c
- Simplify code in askdir.c that waits for creating an appendable
[bacula/bacula] / bacula / src / stored / spool.c
index 8724854b9456a731c4039aeb6d92db00aa870c6f..cd73dea27b6df7b41a0e040d8df0c1cfd43f6054 100644 (file)
@@ -9,19 +9,14 @@
    Copyright (C) 2004-2005 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public
-   License along with this program; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
@@ -71,13 +66,13 @@ void list_spool_stats(BSOCK *bs)
 {
    char ed1[30], ed2[30];
    if (spool_stats.data_jobs || spool_stats.max_data_size) {
-      bnet_fsend(bs, "Data spooling: %u active jobs, %s bytes; %u total jobs, %s max bytes/job.\n",
+      bnet_fsend(bs, _("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),
          spool_stats.total_data_jobs,
          edit_uint64_with_commas(spool_stats.max_data_size, ed2));
    }
    if (spool_stats.attr_jobs || spool_stats.max_attr_size) {
-      bnet_fsend(bs, "Attr spooling: %u active jobs, %s bytes; %u total jobs, %s max bytes.\n",
+      bnet_fsend(bs, _("Attr spooling: %u active jobs, %s bytes; %u total jobs, %s max bytes.\n"),
          spool_stats.attr_jobs, edit_uint64_with_commas(spool_stats.attr_size, ed1),
          spool_stats.total_attr_jobs,
          edit_uint64_with_commas(spool_stats.max_attr_size, ed2));
@@ -119,7 +114,7 @@ bool commit_data_spool(DCR *dcr)
       Dmsg0(100, "Committing spooled data\n");
       stat = despool_data(dcr, true /*commit*/);
       if (!stat) {
-         Pmsg1(000, "Bad return from despool WroteVol=%d\n", dcr->WroteVol);
+         Dmsg1(100, _("Bad return from despool WroteVol=%d\n"), dcr->WroteVol);
          close_data_spool_file(dcr);
          return false;
       }
@@ -136,7 +131,7 @@ static void make_unique_data_spool_filename(DCR *dcr, POOLMEM **name)
    } else {
       dir = working_directory;
    }
-   Mmsg(name, "%s/%s.data.spool.%s.%s", dir, my_name, dcr->jcr->Job, 
+   Mmsg(name, "%s/%s.data.%s.%s.spool", dir, my_name, dcr->jcr->Job, 
         dcr->device->hdr.name);
 }
 
@@ -169,12 +164,12 @@ static bool close_data_spool_file(DCR *dcr)
    P(mutex);
    spool_stats.data_jobs--;
    spool_stats.total_data_jobs++;
-   if (spool_stats.data_size < dcr->spool_size) {
+   if (spool_stats.data_size < dcr->job_spool_size) {
       spool_stats.data_size = 0;
    } else {
-      spool_stats.data_size -= dcr->spool_size;
+      spool_stats.data_size -= dcr->job_spool_size;
    }
-   dcr->spool_size = 0;
+   dcr->job_spool_size = 0;
    V(mutex);
 
    make_unique_data_spool_filename(dcr, &name);
@@ -200,9 +195,15 @@ static bool despool_data(DCR *dcr, bool commit)
    char ec1[50];
 
    Dmsg0(100, "Despooling data\n");
-   Jmsg(jcr, M_INFO, 0, _("%s spooled data to Volume. Despooling %s bytes ...\n"),
-        commit?"Committing":"Writing",
-        edit_uint64_with_commas(jcr->dcr->spool_size, ec1));
+   if (commit) {
+      Jmsg(jcr, M_INFO, 0, _("Committing spooled data to Volume \"%s\". Despooling %s bytes ...\n"),
+         jcr->dcr->VolumeName,
+         edit_uint64_with_commas(jcr->dcr->job_spool_size, ec1));
+   }
+   else {
+      Jmsg(jcr, M_INFO, 0, _("Writing spooled data to Volume. Despooling %s bytes ...\n"),
+         edit_uint64_with_commas(jcr->dcr->job_spool_size, ec1));
+   }
    dcr->spooling = false;
    lock_device(dcr->dev);
    dcr->dev_locked = true;
@@ -256,20 +257,20 @@ static bool despool_data(DCR *dcr, bool commit)
       berrno be;
       Jmsg(dcr->jcr, M_ERROR, 0, _("Ftruncate spool file failed: ERR=%s\n"),
          be.strerror());
-      Pmsg1(000, "Bad return from ftruncate. ERR=%s\n", be.strerror());
+      Pmsg1(000, _("Bad return from ftruncate. ERR=%s\n"), be.strerror());
       ok = false;
    }
 
    P(mutex);
-   if (spool_stats.data_size < dcr->spool_size) {
+   if (spool_stats.data_size < dcr->job_spool_size) {
       spool_stats.data_size = 0;
    } else {
-      spool_stats.data_size -= dcr->spool_size;
+      spool_stats.data_size -= dcr->job_spool_size;
    }
    V(mutex);
    P(dcr->dev->spool_mutex);
-   dcr->dev->spool_size -= dcr->spool_size;
-   dcr->spool_size = 0;               /* zap size in input dcr */
+   dcr->dev->spool_size -= dcr->job_spool_size;
+   dcr->job_spool_size = 0;            /* zap size in input dcr */
    V(dcr->dev->spool_mutex);
    free_memory(rdev->dev_name);
    free_pool_memory(rdev->errmsg);
@@ -308,21 +309,21 @@ static int read_block_from_spool_file(DCR *dcr)
          Jmsg(dcr->jcr, M_FATAL, 0, _("Spool header read error. ERR=%s\n"),
               be.strerror());
       } else {
-         Pmsg2(000, "Spool read error. Wanted %u bytes, got %u\n", rlen, stat);
-         Jmsg2(dcr->jcr, M_FATAL, 0, _("Spool header read error. Wanted %u bytes, got %u\n"), rlen, stat);
+         Pmsg2(000, _("Spool read error. Wanted %u bytes, got %d\n"), rlen, stat);
+         Jmsg2(dcr->jcr, M_FATAL, 0, _("Spool header read error. Wanted %u bytes, got %d\n"), rlen, stat);
       }
       return RB_ERROR;
    }
    rlen = hdr.len;
    if (rlen > block->buf_len) {
-      Pmsg2(000, "Spool block too big. Max %u bytes, got %u\n", block->buf_len, rlen);
+      Pmsg2(000, _("Spool block too big. Max %u bytes, got %u\n"), block->buf_len, rlen);
       Jmsg2(dcr->jcr, M_FATAL, 0, _("Spool block too big. Max %u bytes, got %u\n"), block->buf_len, rlen);
       return RB_ERROR;
    }
    stat = read(dcr->spool_fd, (char *)block->buf, (size_t)rlen);
    if (stat != (ssize_t)rlen) {
-      Pmsg2(000, "Spool data read error. Wanted %u bytes, got %u\n", rlen, stat);
-      Jmsg2(dcr->jcr, M_FATAL, 0, _("Spool data read error. Wanted %u bytes, got %u\n"), rlen, stat);
+      Pmsg2(000, _("Spool data read error. Wanted %u bytes, got %d\n"), rlen, stat);
+      Jmsg2(dcr->jcr, M_FATAL, 0, _("Spool data read error. Wanted %u bytes, got %d\n"), rlen, stat);
       return RB_ERROR;
    }
    /* Setup write pointers */
@@ -356,9 +357,9 @@ bool write_block_to_spool_file(DCR *dcr)
    hlen = sizeof(spool_hdr);
    wlen = block->binbuf;
    P(dcr->dev->spool_mutex);
-   dcr->spool_size += hlen + wlen;
+   dcr->job_spool_size += hlen + wlen;
    dcr->dev->spool_size += hlen + wlen;
-   if ((dcr->max_spool_size > 0 && dcr->spool_size >= dcr->max_spool_size) ||
+   if ((dcr->max_job_spool_size > 0 && dcr->job_spool_size >= dcr->max_job_spool_size) ||
        (dcr->dev->max_spool_size > 0 && dcr->dev->spool_size >= dcr->dev->max_spool_size)) {
       despool = true;
    }
@@ -374,19 +375,19 @@ bool write_block_to_spool_file(DCR *dcr)
       char ec1[30], ec2[30], ec3[30], ec4[30];
       Dmsg4(100, "Despool in write_block_to_spool_file max_size=%s size=%s "
             "max_job_size=%s job_size=%s\n",
-            edit_uint64_with_commas(dcr->max_spool_size, ec1),
-            edit_uint64_with_commas(dcr->spool_size, ec2),
+            edit_uint64_with_commas(dcr->max_job_spool_size, ec1),
+            edit_uint64_with_commas(dcr->job_spool_size, ec2),
             edit_uint64_with_commas(dcr->dev->max_spool_size, ec3),
             edit_uint64_with_commas(dcr->dev->spool_size, ec4));
 #endif
       Jmsg(dcr->jcr, M_INFO, 0, _("User specified spool size reached.\n"));
       if (!despool_data(dcr, false)) {
-         Pmsg0(000, "Bad return from despool in write_block.\n");
+         Pmsg0(000, _("Bad return from despool in write_block.\n"));
          return false;
       }
       /* Despooling cleared these variables so reset them */
       P(dcr->dev->spool_mutex);
-      dcr->spool_size += hlen + wlen;
+      dcr->job_spool_size += hlen + wlen;
       dcr->dev->spool_size += hlen + wlen;
       V(dcr->dev->spool_mutex);
       Jmsg(dcr->jcr, M_INFO, 0, _("Spooling data again ...\n"));
@@ -568,7 +569,7 @@ bail_out:
 
 static void make_unique_spool_filename(JCR *jcr, POOLMEM **name, int fd)
 {
-   Mmsg(name, "%s/%s.attr.spool.%s.%d", working_directory, my_name,
+   Mmsg(name, "%s/%s.attr.%s.%d.spool", working_directory, my_name,
       jcr->Job, fd);
 }