]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix double mount needed to release drive after unmount
authorKern Sibbald <kern@sibbald.com>
Wed, 7 May 2003 16:24:02 +0000 (16:24 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 7 May 2003 16:24:02 +0000 (16:24 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@496 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/src/lib/parse_conf.c
bacula/src/stored/askdir.c
bacula/src/stored/block.c
bacula/src/stored/btape.c
bacula/src/stored/dev.c
bacula/src/stored/dev.h
bacula/src/stored/dircmd.c
bacula/src/stored/stored_conf.c

index 42cf9f0cf7254d0e65e0927dd31f581892261b75..364860f20d0218e3539f99fe441618c8db7396cd 100644 (file)
@@ -16,6 +16,8 @@ Testing to do: (painful)
 - multiple simultaneous Volumes
 
 For 1.31 release:
+- Check for existence of all new Win32 API's.  See LoadLibrary in 
+  winservice.cpp
 - Fix Dir heartbeat in restore and verify vol.  Be sure to make
   bnet_recv() ignore BNET_HEARTBEAT.
 - Fix problem reported by Christopher McCurdy <cmccurdy@eecis.udel.edu>
index 68e9e67050be9a34ff6d1109c425629c54cc1987..f6387640785670eb0ab8b1c1319e46d208e01d8f 100755 (executable)
@@ -166,9 +166,10 @@ void init_resource(int type, struct res_items *items)
            *(int *)(items[i].value) = items[i].default_value;
         } else if (items[i].handler == store_int64) {
            *(int64_t *)(items[i].value) = items[i].default_value;
-        } else if (items[i].handler == store_size ||
-                   items[i].handler == store_time) {
-           *(uint64_t *)(items[i].value) = items[i].default_value;
+        } else if (items[i].handler == store_size) {
+           *(uint64_t *)(items[i].value) = (uint64_t)items[i].default_value;
+        } else if (items[i].handler == store_time) {
+           *(utime_t *)(items[i].value) = (utime_t)items[i].default_value;
         }
       }
       /* If this triggers, take a look at lib/parse_conf.h */
index 742497727d3c98f4cec3231b26f8b261b35268f6..f3a7a3d14afa99b76c248c10cba38575c76e3a72 100644 (file)
@@ -446,6 +446,7 @@ static int wait_for_sysop(JCR *jcr, DEVICE *dev, int wait_sec)
    time_t start = time(NULL);
    time_t last_heartbeat = 0;
    int stat = 0;
+   int add_wait;
    
    /*
     * Wait requested time (wait_sec).  However, we also wake up every
@@ -453,25 +454,25 @@ static int wait_for_sysop(JCR *jcr, DEVICE *dev, int wait_sec)
     *   to keep stateful firewalls from closing them down while waiting
     *   for the operator.
     */
+   add_wait = wait_sec;
+   if (me->heartbeat_interval && add_wait > me->heartbeat_interval) {
+      add_wait = me->heartbeat_interval;
+   }
    gettimeofday(&tv, &tz);
    timeout.tv_nsec = tv.tv_usec * 1000;
-   if (me->heartbeat_interval) {
-      utime_t hb = me->heartbeat_interval;
-      timeout.tv_sec = tv.tv_sec + (wait_sec > hb ? hb : wait_sec);
-   } else {
-      timeout.tv_sec = tv.tv_sec + wait_sec;
-   }  
+   timeout.tv_sec = tv.tv_sec + add_wait;
 
    P(dev->mutex);
    dev_blocked = dev->dev_blocked;
    dev->dev_blocked = BST_WAITING_FOR_SYSOP; /* indicate waiting for mount */
 
    for ( ; !job_canceled(jcr); ) {
-      int add_wait;
       time_t now;
 
-      Dmsg1(190, "I'm going to sleep on device %s\n", dev->dev_name);
+      Dmsg3(100, "I'm going to sleep on device %s. HB=%d wait=%d\n", dev->dev_name,
+        (int)me->heartbeat_interval, wait_sec);
       stat = pthread_cond_timedwait(&dev->wait_next_vol, &dev->mutex, &timeout);
+      Dmsg1(100, "Wokeup from sleep on device stat=%d\n", stat);
 
       now = time(NULL);
 
@@ -481,7 +482,7 @@ static int wait_for_sysop(JCR *jcr, DEVICE *dev, int wait_sec)
            /* send heartbeats */
            if (jcr->file_bsock) {
               bnet_sig(jcr->file_bsock, BNET_HEARTBEAT);
-               Dmsg0(000, "Send heartbeat to FD.\n");
+               Dmsg0(100, "Send heartbeat to FD.\n");
            }
            if (jcr->dir_bsock) {
               bnet_sig(jcr->dir_bsock, BNET_HEARTBEAT);
@@ -490,30 +491,26 @@ static int wait_for_sysop(JCR *jcr, DEVICE *dev, int wait_sec)
         }
       }
 
-      /* Check if we blocked the device */
-      if (dev->dev_blocked == BST_WAITING_FOR_SYSOP) {
-        if (stat != ETIMEDOUT) {     /* we blocked the device */
-           break;                    /* on error return */
-        }
-        if (now - start >= wait_sec) {  /* on exceeding wait time return */
-           break;
-        }
-        add_wait = wait_sec - (now - start);
-        if (me->heartbeat_interval && add_wait > me->heartbeat_interval) {
-           add_wait = me->heartbeat_interval;
-        }
-      } else {                       /* Oops someone else has it blocked now */
-        add_wait = 10;               /* hang around until he releases it */
+      if (dev->dev_blocked == BST_MOUNT) {   /* mount request ? */
+        stat = 0;
+        break;
+      }
+
+      if (stat != ETIMEDOUT) {    /* we blocked the device */
+        break;                    /* on error return */
+      }
+      if (now - start >= wait_sec) {  /* on exceeding wait time return */
+         Dmsg0(100, "Exceed wait time.\n");
+        break;
+      }
+      add_wait = wait_sec - (now - start);
+      if (me->heartbeat_interval && add_wait > me->heartbeat_interval) {
+        add_wait = me->heartbeat_interval;
       }
-      /*        
-       * Note, if dev_blocked is not BST_WAITING FOR_SYSOP,
-       *  someone other than us has blocked the device (probably the
-       *  user via the Console program), so we continue waiting
-       *  until he releases the device back to us.
-       */
       gettimeofday(&tv, &tz);
       timeout.tv_nsec = tv.tv_usec * 1000;
       timeout.tv_sec = tv.tv_sec + add_wait; /* additional wait */
+      Dmsg1(100, "Additional wait %d sec.\n", add_wait);
    }
 
    dev->dev_blocked = dev_blocked;
index 7de8be29c7a311914f40b838a64f2091ac9629de..b438b38d519a0888bbb69a8182522c34eb279eb6 100644 (file)
@@ -545,7 +545,7 @@ reread:
       Mmsg2(&dev->errmsg,  _("Block length %u is greater than buffer %u. Attempting recovery.\n"),
         block->block_len, block->buf_len);
       Emsg0(M_WARNING, 0, dev->errmsg);
-      Dmsg1(000, "%s", dev->errmsg);
+      Pmsg1(000, "%s", dev->errmsg);
       /* Attempt to reposition to re-read the block */
       if (dev->state & ST_TAPE) {
          Dmsg0(100, "Backspace record for reread.\n");
@@ -562,7 +562,7 @@ reread:
       }
       Mmsg1(&dev->errmsg, _("Resetting buffer size to %u bytes.\n"), block->block_len);
       Emsg0(M_WARNING, 0, dev->errmsg);
-      Dmsg1(000, "%s", dev->errmsg);
+      Pmsg1(000, "%s", dev->errmsg);
       /* Set new block length */
       dev->max_block_size = block->block_len;
       block->buf_len = block->block_len;
index c3e961b445b9781121f290a9cf5de529545ad2f5..e121d642f4cc605c65790e844758961f2f733d26 100644 (file)
@@ -1221,7 +1221,7 @@ This may take a long time. I.e. hours! ...\n\n");
         stream_to_ascii(rec.Stream, rec.FileIndex), rec.data_len);
    }
    if (stop > 0) {
-      Dmsg0(000, "Write_end_session_label()\n");
+      Dmsg0(100, "Write_end_session_label()\n");
       /* Create Job status for end of session label */
       if (!job_canceled(jcr) && ok) {
         set_jcr_job_status(jcr, JS_Terminated);
index 961406119344f61f7676522e4f97a4242c6009cd..86799f5f538fb98f41543f258f7f6c685c0a6f2d 100644 (file)
@@ -485,7 +485,7 @@ int update_pos_dev(DEVICE *dev)
       dev->file_addr = 0;
       pos = lseek(dev->fd, (off_t)0, SEEK_CUR);
       if (pos < 0) {
-         Dmsg1(000, "Seek error: ERR=%s\n", strerror(dev->dev_errno));
+         Pmsg1(000, "Seek error: ERR=%s\n", strerror(dev->dev_errno));
         dev->dev_errno = errno;
          Mmsg2(&dev->errmsg, _("lseek error on %s. ERR=%s.\n"),
            dev->dev_name, strerror(dev->dev_errno));
index ffcd90781ec69e68bab049cd69accae79c49fd44..4bcc54b7781a5f2d6dce169dc64775ece7de7d68 100644 (file)
 #define BST_DOING_ACQUIRE     3       /* Opening/validating/moving tape */
 #define BST_WRITING_LABEL     4       /* Labeling a tape */  
 #define BST_UNMOUNTED_WAITING_FOR_SYSOP 5 /* Closed by user during mount request */
+#define BST_MOUNT             6       /* Mount request */
 
 /* Volume Catalog Information structure definition */
 typedef struct s_volume_catalog_info {
index 344fdb5108b0242dbc12c8f8c3e4210cf9d59395..08d653d7705cda5d1b829734afa2210ec3acdce1 100644 (file)
@@ -491,7 +491,8 @@ static int mount_cmd(JCR *jcr)
            DEV_BLOCK *block;
            case BST_WAITING_FOR_SYSOP:
               /* Someone is waiting, wake him */
-               Dmsg0(90, "Waiting for mount attempt to wake thread\n");
+               Dmsg0(100, "Waiting for mount. Attempting to wake thread\n");
+              dev->dev_blocked = BST_MOUNT;
               pthread_cond_signal(&dev->wait_next_vol);
                bnet_fsend(dir, "3001 OK mount. Device=%s\n", dev->dev_name);
               break;
@@ -508,12 +509,12 @@ static int mount_cmd(JCR *jcr)
               read_dev_volume_label(jcr, dev, block);
               free_block(block);
               if (dev->dev_blocked == BST_UNMOUNTED) {
-                  Dmsg0(90, "Unmounted unblocking device\n");
+                  Dmsg0(100, "Unmounted. Unblocking device\n");
                  read_label(jcr, dev);
                  unblock_device(dev);
               } else {
-                  Dmsg0(90, "Unmounted waiting for mount attempt to wake thread\n");
-                 dev->dev_blocked = BST_WAITING_FOR_SYSOP;
+                  Dmsg0(100, "Unmounted waiting for mount. Attempting to wake thread\n");
+                 dev->dev_blocked = BST_MOUNT;
                  pthread_cond_signal(&dev->wait_next_vol);
               }
               if (dev->state & ST_LABEL) {
index 6012cec0128349aab7fc1aeb05289ef3178dbdcd..c3c8240d61b791d83fa55b85e2e5a69079ba552e 100644 (file)
@@ -149,9 +149,10 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ...
          sendit(sock, "Director: name=%s\n", res->res_dir.hdr.name);
         break;
       case R_STORAGE:
-         sendit(sock, "Storage: name=%s SDaddr=%s SDport=%d SDDport=%d\n",
-           res->res_store.hdr.name, res->res_store.SDaddr, 
-           res->res_store.SDport, res->res_store.SDDport);
+         sendit(sock, "Storage: name=%s SDaddr=%s SDport=%d SDDport=%d HB=%s\n",
+           res->res_store.hdr.name, NPRT(res->res_store.SDaddr),
+           res->res_store.SDport, res->res_store.SDDport,
+           edit_utime(res->res_store.heartbeat_interval, buf));
         break;
       case R_DEVICE:
          sendit(sock, "Device: name=%s MediaType=%s Device=%s\n",