]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Add -c option to pg_dump so that it initializes tables when
authorKern Sibbald <kern@sibbald.com>
Mon, 18 Sep 2006 20:56:21 +0000 (20:56 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 18 Sep 2006 20:56:21 +0000 (20:56 +0000)
     restored.
kes  Fix FirstWritten time on Volume to be obtained from SD so that
     it is the actual time the volume was first written.
kes  Minor Makefile changes.
kes  Handle EBUSY during read(). Improve how EBUSY is handled in write().

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3481 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/cats/make_catalog_backup.in
bacula/src/dird/catreq.c
bacula/src/stored/Makefile.in
bacula/src/stored/askdir.c
bacula/src/stored/block.c
bacula/src/stored/dev.h
bacula/src/version.h
bacula/technotes-1.39

index 6c20a8ebd6287848583509c69225025c6ab4e2fc..8bc30a582b2dc43f26537463cef8c84fe5e916e6 100755 (executable)
@@ -26,10 +26,10 @@ else
   else                       
     if test xpostgresql = x@DB_NAME@ ; then
       if test $# -gt 2; then
-        PGPASSWORD=$3
+       PGPASSWORD=$3
                export PGPASSWORD
       fi
-      exec @SQL_BINDIR@/pg_dump -U $2 $1 >$1.sql
+      exec @SQL_BINDIR@/pg_dump -c -U $2 $1 >$1.sql
     else
       echo ".dump" | @SQL_BINDIR@/sqlite3 $1.db >$1.sql
     fi
index 3dd8a582124f1b3a1bf3c12c77585f8585b837e1..e4dcdd4e5d715ea8cd2b88a411d1c517a5c23886 100644 (file)
@@ -44,7 +44,7 @@ static char Update_media[] = "CatReq Job=%127s UpdateMedia VolName=%s"
    " VolJobs=%u VolFiles=%u VolBlocks=%u VolBytes=%" lld " VolMounts=%u"
    " VolErrors=%u VolWrites=%u MaxVolBytes=%" lld " EndTime=%d VolStatus=%10s"
    " Slot=%d relabel=%d InChanger=%d VolReadTime=%" lld " VolWriteTime=%" lld
-   " VolParts=%u\n";
+   " VolFirstWritten=%" lld " VolParts=%u\n";
 
 static char Create_job_media[] = "CatReq Job=%127s CreateJobMedia "
    " FirstIndex=%u LastIndex=%u StartFile=%u EndFile=%u "
@@ -96,6 +96,7 @@ void catalog_request(JCR *jcr, BSOCK *bs)
    POOLMEM *omsg;
    POOL_DBR pr;
    uint32_t Stripe;
+   utime_t VolFirstWritten;
 
    memset(&mr, 0, sizeof(mr));
    memset(&sdmr, 0, sizeof(sdmr));
@@ -197,7 +198,8 @@ void catalog_request(JCR *jcr, BSOCK *bs)
       &sdmr.VolJobs, &sdmr.VolFiles, &sdmr.VolBlocks, &sdmr.VolBytes,
       &sdmr.VolMounts, &sdmr.VolErrors, &sdmr.VolWrites, &sdmr.MaxVolBytes,
       &sdmr.LastWritten, &sdmr.VolStatus, &sdmr.Slot, &label, &sdmr.InChanger,
-      &sdmr.VolReadTime, &sdmr.VolWriteTime, &sdmr.VolParts) == 18) {
+      &sdmr.VolReadTime, &sdmr.VolWriteTime, &VolFirstWritten, 
+      &sdmr.VolParts) == 19) {
 
       db_lock(jcr->db);
       Dmsg3(400, "Update media %s oldStat=%s newStat=%s\n", sdmr.VolumeName,
@@ -214,7 +216,11 @@ void catalog_request(JCR *jcr, BSOCK *bs)
       }
       /* Set first written time if this is first job */
       if (mr.FirstWritten == 0) {
-         mr.FirstWritten = jcr->start_time;   /* use Job start time as first write */
+         if (VolFirstWritten == 0) {
+            mr.FirstWritten = jcr->start_time;   /* use Job start time as first write */
+         } else {
+            mr.FirstWritten = VolFirstWritten;
+         }
          mr.set_first_written = true;
       }
       /* If we just labeled the tape set time */
index 58d42651df520f67c01e20448bb17d304e252821..1ce5c46d8088c662b2ff2344dead087f11870d97 100644 (file)
@@ -101,7 +101,7 @@ static-bacula-sd: $(SDOBJS) ../lib/libbac.a
        strip $@
 
 btape.o: btape.c
-       echo "Compiling $<"
+       @echo "Compiling $<"
        $(NO_ECHO)$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) \
  -I$(basedir) $(OPENSSL_INC) $(DINCLUDE) $(CFLAGS) $<
 
@@ -110,27 +110,27 @@ btape:    $(TAPEOBJS) ../lib/libbac.a ../cats/libsql.a
  -lsql $(DLIB) -lbac -lm $(LIBS) $(GETTEXT_LIBS) $(OPENSSL_LIBS)
 
 bls.o: bls.c
-       echo "Compiling $<"
+       @echo "Compiling $<"
        $(NO_ECHO)$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) $(PYTHON_INC) -I$(srcdir) \
  -I$(basedir) $(OPENSSL_INC) $(DINCLUDE) $(CFLAGS) $<
 
 bls:   ../findlib/libfind.a $(BLSOBJS) ../lib/libbac.a
-       echo "Compiling $<"
+       @echo "Compiling $<"
        $(NO_ECHO)$(CXX) $(TTOOL_LDFLAGS) $(LDFLAGS) -L../lib -L../findlib -o $@ $(BLSOBJS) $(DLIB) -lfind \
  -lbac -lm $(LIBS) $(GETTEXT_LIBS) $(OPENSSL_LIBS)
 
 bextract.o: bextract.c
-       echo "Compiling $<"
+       @echo "Compiling $<"
        $(NO_ECHO)$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) $(PYTHON_INC) -I$(srcdir) \
  -I$(basedir) $(OPENSSL_INC) $(DINCLUDE) $(CFLAGS) $<
 
 bextract: ../findlib/libfind.a $(BEXTOBJS) ../lib/libbac.a
-       echo "Compiling $<"
+       @echo "Compiling $<"
        $(NO_ECHO)$(CXX) $(TTOOL_LDFLAGS) $(LDFLAGS) -L../lib -L../findlib -o $@ $(BEXTOBJS) $(DLIB) $(FDLIBS) \
  -lfind -lbac -lm $(PYTHON_LIBS) $(LIBS) $(GETTEXT_LIBS) $(OPENSSL_LIBS)
 
 bscan.o: bscan.c
-       echo "Compiling $<"
+       @echo "Compiling $<"
        $(NO_ECHO)$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) $(PYTHON_INC) -I$(srcdir) \
  -I$(basedir) $(OPENSSL_INC) $(DINCLUDE) $(CFLAGS) $<
 
@@ -139,7 +139,7 @@ bscan:      ../findlib/libfind.a $(SCNOBJS) ../cats/libsql.a
  -lsql $(DB_LIBS) $(FDLIBS) -lfind -lbac -lm $(LIBS) $(GETTEXT_LIBS) $(OPENSSL_LIBS)
 
 bcopy.o: bcopy.c
-       echo "Compiling $<"
+       @echo "Compiling $<"
        $(NO_ECHO)$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) \
  -I$(basedir) $(OPENSSL_INC) $(DINCLUDE) $(CFLAGS) $<
 
index 0a549aafae4ad36275fa6f7da0e9b6b2e1510d5b..4b4fb0f12634d674adf69dc8cd61855305948001 100644 (file)
@@ -31,7 +31,7 @@ static char Update_media[] = "CatReq Job=%s UpdateMedia VolName=%s"
    " VolJobs=%u VolFiles=%u VolBlocks=%u VolBytes=%s VolMounts=%u"
    " VolErrors=%u VolWrites=%u MaxVolBytes=%s EndTime=%d VolStatus=%s"
    " Slot=%d relabel=%d InChanger=%d VolReadTime=%s VolWriteTime=%s"
-   " VolParts=%u\n";
+   " VolFirstWritten=%s VolParts=%u\n";
 static char Create_job_media[] = "CatReq Job=%s CreateJobMedia"
    " FirstIndex=%u LastIndex=%u StartFile=%u EndFile=%u"
    " StartBlock=%u EndBlock=%u Copy=%d Strip=%d\n";
@@ -282,7 +282,7 @@ bool dir_update_volume_info(DCR *dcr, bool label)
    BSOCK *dir = jcr->dir_bsock;
    DEVICE *dev = dcr->dev;
    time_t LastWritten = time(NULL);
-   char ed1[50], ed2[50], ed3[50], ed4[50];
+   char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50];
    VOLUME_CAT_INFO *vol = &dev->VolCatInfo;
    int InChanger;
    POOL_MEM VolumeName;
@@ -320,6 +320,7 @@ bool dir_update_volume_info(DCR *dcr, bool label)
       InChanger,                      /* bool in structure */
       edit_uint64(vol->VolReadTime, ed3),
       edit_uint64(vol->VolWriteTime, ed4),
+      edit_uint64(vol->VolFirstWritten, ed5),
       vol->VolCatParts);
     Dmsg1(100, ">dird: %s", dir->msg);
 
index 2b6221567378fe1477a2ac28cde5373c09d6e9af..89410716a71d7769558dc8e103377464e0f6db1d 100644 (file)
@@ -513,15 +513,16 @@ bool write_block_to_dev(DCR *dcr)
     *  I/O errors, or from the OS telling us it is busy.
     */ 
    int retry = 0;
+   errno = 0;
    do {
+      if ((retry > 0 && errno == EBUSY) || retry > 10) {
+         bmicrosleep(0, 50000);    /* pause a bit if busy or lots of errors */
+      }
       if (dev->is_tape()) {
          stat = tape_write(dev->fd, block->buf, (size_t)wlen);
       } else {
          stat = write(dev->fd, block->buf, (size_t)wlen);
       }
-      if (retry > 10) {
-         bmicrosleep(0, 100000);    /* pause a bit if lots of errors */
-      }
    } while (stat == -1 && (errno == EBUSY || errno == EIO) && retry++ < 30);
 
 #ifdef DEBUG_BLOCK_ZEROING
@@ -544,6 +545,7 @@ bool write_block_to_dev(DCR *dcr)
             dev->dev_errno = ENOSPC;        /* out of space */
          }
          if (dev->dev_errno != ENOSPC) {
+            dev->VolCatInfo.VolCatErrors++;
             Jmsg4(jcr, M_ERROR, 0, _("Write error at %u:%u on device %s. ERR=%s.\n"),
                dev->file, dev->block_num, dev->print_name(), be.strerror());
          }
@@ -907,7 +909,7 @@ bool read_block_from_dev(DCR *dcr, bool check_block_numbers)
       return false;
    }
    looping = 0;
-   Dmsg1(200, "Full read() in read_block_from_device() len=%d\n",
+   Dmsg1(200, "Full read in read_block_from_device() len=%d\n",
          block->buf_len);
 reread:
    if (looping > 1) {
@@ -948,25 +950,20 @@ reread:
    }
    
    retry = 0;
+   errno = 0;
    do {
-//    uint32_t *bp = (uint32_t *)block->buf;
-//    Pmsg3(000, "Read %p %u at %llu\n", block->buf, block->buf_len, lseek(dev->fd, 0, SEEK_CUR));
-
+      if ((retry > 0 && errno == EBUSY) || retry > 10) {
+         bmicrosleep(0, 50000);    /* pause a bit if busy or lots of errors */
+      }
       if (dev->is_tape()) {
          stat = tape_read(dev->fd, block->buf, (size_t)block->buf_len);
       } else {
          stat = read(dev->fd, block->buf, (size_t)block->buf_len);
       }
-
-//    Pmsg8(000, "stat=%d Csum=%u blen=%u bnum=%u %c%c%c%c\n",stat, bp[0],bp[1],bp[2],
-//      block->buf[12],block->buf[13],block->buf[14],block->buf[15]);
-
-      if (retry == 1) {
-         dev->VolCatInfo.VolCatErrors++;
-      }
-   } while (stat == -1 && (errno == EINTR || errno == EIO) && retry++ < 11);
+   } while (stat == -1 && (errno == EBUSY || errno == EINTR || errno == EIO) && retry++ < 30);
    if (stat < 0) {
       berrno be;
+      dev->VolCatInfo.VolCatErrors++;
       dev->clrerror(-1);
       Dmsg1(200, "Read device got: ERR=%s\n", be.strerror());
       block->read_len = 0;
@@ -1070,6 +1067,9 @@ reread:
 
    dev->VolCatInfo.VolCatBytes += block->block_len;
    dev->VolCatInfo.VolCatBlocks++;
+   if (dev->VolCatInfo.VolFirstWritten == 0) {
+      dev->VolCatInfo.VolFirstWritten = time(NULL);    /* Set first written time */
+   }
    dev->EndBlock = dev->block_num;
    dev->EndFile  = dev->file;
    dev->block_num++;
index 0408fc52067a72a67e4a2b70b1ddec81e98f6d61..94292171e69e105c598b05dea8108e245acfaf29 100644 (file)
@@ -163,13 +163,14 @@ struct VOLUME_CAT_INFO {
    uint32_t EndBlock;                 /* Last block number */
    int32_t  LabelType;                /* Bacula/ANSI/IBM */
    int32_t  Slot;                     /* >0=Slot loaded, 0=nothing, -1=unknown */
-   bool     InChanger;                /* Set if vol in current magazine */
+   utime_t  VolFirstWritten;          /* Time of first write */
    uint32_t VolCatMaxJobs;            /* Maximum Jobs to write to volume */
    uint32_t VolCatMaxFiles;           /* Maximum files to write to volume */
    uint64_t VolCatMaxBytes;           /* Max bytes to write to volume */
    uint64_t VolCatCapacityBytes;      /* capacity estimate */
    uint64_t VolReadTime;              /* time spent reading */
    uint64_t VolWriteTime;             /* time spent writing this Volume */
+   bool     InChanger;                /* Set if vol in current magazine */
    char VolCatStatus[20];             /* Volume status */
    char VolCatName[MAX_NAME_LENGTH];  /* Desired volume to mount */
 };
index 81466038197ef5fe437d4b6780ed1b8d4c5ddaec..9e11c1eecd322e6ca9c5d2ebc76c970bebd1215b 100644 (file)
@@ -4,8 +4,8 @@
 
 #undef  VERSION
 #define VERSION "1.39.23"
-#define BDATE   "16 September 2006"
-#define LSMDATE "16Sep06"
+#define BDATE   "18 September 2006"
+#define LSMDATE "18Sep06"
 #define BYEAR "2006"       /* year for copyright messages in progs */
 
 /* Debug flags */
index ae47b580b7ec7862aa63d31fdbb7c4d6d4c73ebf..25364a31f81b7a286293d46b97fb5b587f733b8d 100644 (file)
@@ -2,6 +2,12 @@
 
 General:
 18Sep06
+kes  Add -c option to pg_dump so that it initializes tables when   
+     restored.
+kes  Fix FirstWritten time on Volume to be obtained from SD so that
+     it is the actual time the volume was first written.
+kes  Minor Makefile changes.
+kes  Handle EBUSY during read(). Improve how EBUSY is handled in write().
 ebl  Add yes keyword to prune/purge command
 16Sep06
 kes  Correct a test in block.c that prevented restore of a DVD from