Skip to content

Commit

Permalink
stored: Fix device not being closed problem.
Browse files Browse the repository at this point in the history
When we cannot read any volume header from a volume for whatever reason
the current code will not re-open the device when retrying to mount the
next available volume in the DCR::mount_next_write_volume() method. This
fixes the code to explictly do a close on the device when we are
retrying to mount the next volume and its not a tape device and the
device is still open just before we call the autoload_device() function.
  • Loading branch information
mvwieringen committed Nov 6, 2017
1 parent 208a7ac commit c0c2c1a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/stored/mount.c
Expand Up @@ -109,6 +109,7 @@ bool DCR::mount_next_write_volume()
if (dev->must_unload()) {
ask = true; /* ask operator to mount tape */
}

do_unload();
do_swapping(true /*is_writing*/);
do_load(true /*is_writing*/);
Expand All @@ -135,6 +136,18 @@ bool DCR::mount_next_write_volume()
*/
dcr->setVolCatInfo(false); /* out of date when Vols unlocked */

/*
* See if this is a retry of the mounting of the next volume.
* If the device is already open close it first as otherwise we could
* potentially write to an already open device a new volume label.
* This is only interesting for non tape devices.
*/
if (!dev->is_tape()) {
if (retry && dev->is_open()) {
dev->close(dcr);
}
}

switch (autoload_device(dcr, true /* writing */, NULL)) {
case -2:
case -1:
Expand Down

0 comments on commit c0c2c1a

Please sign in to comment.