]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/dircmd.c
Add Bytes/Blocks read by SD during restore
[bacula/bacula] / bacula / src / stored / dircmd.c
index aa0f57f581b3f32c917cec093a8290f533bf003e..a62a3157361f30c7b608f09617579b4d65c4fd25 100644 (file)
@@ -371,7 +371,7 @@ static void label_volume_if_ok(JCR *jcr, DEVICE *dev, char *oldname,
    for ( ; !(dev->state & ST_OPENED); ) {
        if (open_dev(dev, jcr->VolumeName, READ_WRITE) < 0) {
          if (dev->dev_errno == EAGAIN || dev->dev_errno == EBUSY) {
-            sleep(30);
+            bmicrosleep(30, 0);
          }
           bnet_fsend(dir, _("3910 Unable to open device %s. ERR=%s\n"), 
             dev_name(dev), strerror_dev(dev));
@@ -431,11 +431,9 @@ static int read_label(JCR *jcr, DEVICE *dev)
    int stat;
    BSOCK *dir = jcr->dir_bsock;
    DEV_BLOCK *block;
-#ifndef NEW_LOCK
    bsteal_lock_t hold;
    
    steal_device_lock(dev, &hold, BST_DOING_ACQUIRE);
-#endif
    
    jcr->VolumeName[0] = 0;
    block = new_block(dev);
@@ -452,9 +450,7 @@ static int read_label(JCR *jcr, DEVICE *dev)
         break;
    }
    free_block(block);
-#ifndef NEW_LOCK
    return_device_lock(dev, &hold);
-#endif
    return stat;
 }
 
@@ -491,7 +487,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 +505,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) {
@@ -709,15 +706,27 @@ static int status_cmd(JCR *jcr)
                bnet_fsend(user, _("Device %s open but no Bacula volume is mounted.\n"), dev_name(dev));
            }
            send_blocked_status(jcr, dev);
-           bpb = dev->VolCatInfo.VolCatBlocks;
-           if (bpb <= 0) {
-              bpb = 1;
+           if (dev->state & ST_APPEND) {
+              bpb = dev->VolCatInfo.VolCatBlocks;
+              if (bpb <= 0) {
+                 bpb = 1;
+              }
+              bpb = dev->VolCatInfo.VolCatBytes / bpb;
+               bnet_fsend(user, _("    Total Bytes=%s Blocks=%s Bytes/block=%s\n"),
+                 edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, b1),
+                 edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2), 
+                 edit_uint64_with_commas(bpb, b3));
+           } else {  /* reading */
+              bpb = dev->VolCatInfo.VolCatReads;
+              if (bpb <= 0) {
+                 bpb = 1;
+              }
+              bpb = dev->VolCatInfo.VolCatRBytes / bpb;
+               bnet_fsend(user, _("    Total Bytes Read=%s Blocks Read=%s Bytes/block=%s\n"),
+                 edit_uint64_with_commas(dev->VolCatInfo.VolCatRBytes, b1),
+                 edit_uint64_with_commas(dev->VolCatInfo.VolCatReads, b2), 
+                 edit_uint64_with_commas(bpb, b3));
            }
-           bpb = dev->VolCatInfo.VolCatBytes / bpb;
-            bnet_fsend(user, _("    Total Bytes=%s Blocks=%s Bytes/block=%s\n"),
-              edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, b1),
-              edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2), 
-              edit_uint64_with_commas(bpb, b3));
             bnet_fsend(user, _("    Positioned at File=%s Block=%s\n"), 
               edit_uint64_with_commas(dev->file, b1),
               edit_uint64_with_commas(dev->block_num, b2));