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));
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);
break;
}
free_block(block);
-#ifndef NEW_LOCK
return_device_lock(dev, &hold);
-#endif
return stat;
}
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;
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) {
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));