Skip to content

Commit

Permalink
Revert "Make consecutive tape reads more like writing to tape"
Browse files Browse the repository at this point in the history
This reverts commit 7bf1ea4.

Breaks scsi-crypto.
  • Loading branch information
Marco van Wieringen committed Feb 17, 2015
1 parent 87c3ff6 commit df94226
Showing 1 changed file with 22 additions and 49 deletions.
71 changes: 22 additions & 49 deletions src/stored/acquire.c
Expand Up @@ -178,7 +178,7 @@ bool acquire_device_for_read(DCR *dcr)
if (dev->vol && dev->vol->is_swapping()) {
dev->vol->set_slot(vol->Slot);
Dmsg3(rdbglvl, "swapping: slot=%d Vol=%s dev=%s\n", dev->vol->get_slot(),
dev->vol->vol_name, dev->print_name());
dev->vol->vol_name, dev->print_name());
}

init_device_wait_timers(dcr);
Expand All @@ -187,9 +187,7 @@ bool acquire_device_for_read(DCR *dcr)
dev->is_labeled();
// tape_initially_mounted = tape_previously_mounted;

/*
* Volume info is always needed because of VolParts
*/
/* Volume info is always needed because of VolParts */
Dmsg1(rdbglvl, "dir_get_volume_info vol=%s\n", dcr->VolumeName);
if (!dcr->dir_get_volume_info(GET_VOL_INFO_FOR_READ)) {
Dmsg2(rdbglvl, "dir_get_vol_info failed for vol=%s: %s\n",
Expand All @@ -199,21 +197,11 @@ bool acquire_device_for_read(DCR *dcr)
dev->set_load(); /* set to load volume */

for ( ;; ) {
/*
* If not polling limit retries
*/
/* If not polling limit retries */
if (!dev->poll && retry++ > 10) {
break;
}

/*
* See if we are changing the volume in the device.
* If so we need to force a reread of the tape label.
*/
if (dev->has_cap(CAP_ALWAYSOPEN) && !bstrcmp(dev->VolHdr.VolumeName, dcr->VolumeName)) {
dev->clear_labeled();
}

dev->clear_labeled(); /* force reread of label */
if (job_canceled(jcr)) {
char ed1[50];
Mmsg1(dev->errmsg, _("Job %s canceled.\n"), edit_int64(jcr->JobId, ed1));
Expand All @@ -227,8 +215,9 @@ bool acquire_device_for_read(DCR *dcr)
set_dcr_from_vol(dcr, vol); /* refresh dcr with desired volume info */

/*
* This code ensures that the device is ready for reading. If it is a file,
* it opens it. If it is a tape, it checks the volume name
* This code ensures that the device is ready for
* reading. If it is a file, it opens it.
* If it is a tape, it checks the volume name
*/
Dmsg1(rdbglvl, "stored: open vol=%s\n", dcr->VolumeName);
if (!dev->open(dcr, OPEN_READ_ONLY)) {
Expand All @@ -240,20 +229,9 @@ bool acquire_device_for_read(DCR *dcr)
}
Dmsg1(rdbglvl, "opened dev %s OK\n", dev->print_name());

/*
* See if we are changing the volume in the device.
* If so we need to force a reread of the tape label.
*/
if (dev->has_cap(CAP_ALWAYSOPEN) && bstrcmp(dev->VolHdr.VolumeName, dcr->VolumeName)) {
vol_label_status = VOL_OK;
} else {
/*
* Read Volume Label
*/
Dmsg0(rdbglvl, "calling read-vol-label\n");
vol_label_status = read_dev_volume_label(dcr);
}

/* Read Volume Label */
Dmsg0(rdbglvl, "calling read-vol-label\n");
vol_label_status = read_dev_volume_label(dcr);
switch (vol_label_status) {
case VOL_OK:
Dmsg0(rdbglvl, "Got correct volume.\n");
Expand All @@ -263,8 +241,9 @@ bool acquire_device_for_read(DCR *dcr)
case VOL_IO_ERROR:
Dmsg0(rdbglvl, "IO Error\n");
/*
* Send error message generated by read_dev_volume_label() only when we really had a tape
* mounted. This supresses superfluous error messages when nothing is mounted.
* Send error message generated by read_dev_volume_label()
* only we really had a tape mounted. This supresses superfluous
* error messages when nothing is mounted.
*/
if (tape_previously_mounted) {
Jmsg(jcr, M_WARNING, 0, "Read acquire: %s", jcr->errmsg);
Expand All @@ -278,9 +257,7 @@ bool acquire_device_for_read(DCR *dcr)
}
dev->set_unload(); /* force unload of unwanted tape */
if (!unload_autochanger(dcr, -1)) {
/*
* At least free the device so we can re-open with correct volume
*/
/* at least free the device so we can re-open with correct volume */
dev->close(dcr);
free_volume(dev);
}
Expand All @@ -300,9 +277,7 @@ bool acquire_device_for_read(DCR *dcr)
free_volume(dev);
}

/*
* Call autochanger only once unless ask_sysop called
*/
/* Call autochanger only once unless ask_sysop called */
if (try_autochanger) {
int status;
Dmsg2(rdbglvl, "calling autoload Vol=%s Slot=%d\n",
Expand All @@ -314,17 +289,13 @@ bool acquire_device_for_read(DCR *dcr)
}
}

/*
* Mount a specific volume and no other
*/
/* Mount a specific volume and no other */
Dmsg0(rdbglvl, "calling dir_ask_sysop\n");
if (!dcr->dir_ask_sysop_to_mount_volume(ST_READREADY)) {
goto get_out; /* error return */
}

/*
* Volume info is always needed because of VolParts
*/
/* Volume info is always needed because of VolParts */
Dmsg1(150, "dir_get_volume_info vol=%s\n", dcr->VolumeName);
if (!dcr->dir_get_volume_info(GET_VOL_INFO_FOR_READ)) {
Dmsg2(150, "dir_get_vol_info failed for vol=%s: %s\n",
Expand All @@ -349,14 +320,16 @@ bool acquire_device_for_read(DCR *dcr)
dev->clear_append();
dev->set_read();
jcr->sendJobStatus(JS_Running);
Jmsg(jcr, M_INFO, 0, _("Ready to read from volume \"%s\" on device %s.\n"), dcr->VolumeName, dev->print_name());
Jmsg(jcr, M_INFO, 0, _("Ready to read from volume \"%s\" on device %s.\n"),
dcr->VolumeName, dev->print_name());

get_out:
dev->Lock();
dcr->clear_reserved();
/*
* Normally we are blocked, but in at least one error case above we are not blocked because we
* unsuccessfully tried changing devices.
* Normally we are blocked, but in at least one error case above
* we are not blocked because we unsuccessfully tried changing
* devices.
*/
if (dev->is_blocked()) {
dev->dunblock(DEV_LOCKED);
Expand Down

0 comments on commit df94226

Please sign in to comment.