freebsd-dev/sys/cam/scsi/scsi_sa.c

5882 lines
159 KiB
C
Raw Normal View History

/*-
* Implementation of SCSI Sequential Access Peripheral driver for CAM.
*
* Copyright (c) 1999, 2000 Matthew Jacob
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
* Copyright (c) 2013, 2014, 2015 Spectra Logic Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 2. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
2003-06-10 18:14:05 +00:00
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/queue.h>
#ifdef _KERNEL
#include <sys/systm.h>
#include <sys/kernel.h>
#endif
#include <sys/types.h>
#include <sys/time.h>
#include <sys/bio.h>
#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/mtio.h>
#ifdef _KERNEL
#include <sys/conf.h>
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
#include <sys/sbuf.h>
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
#include <sys/sysctl.h>
#include <sys/taskqueue.h>
#endif
#include <sys/fcntl.h>
#include <sys/devicestat.h>
#ifndef _KERNEL
#include <stdio.h>
#include <string.h>
#endif
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_periph.h>
#include <cam/cam_xpt_periph.h>
#include <cam/cam_debug.h>
#include <cam/scsi/scsi_all.h>
#include <cam/scsi/scsi_message.h>
#include <cam/scsi/scsi_sa.h>
#ifdef _KERNEL
#include <opt_sa.h>
#ifndef SA_IO_TIMEOUT
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
#define SA_IO_TIMEOUT 32
#endif
#ifndef SA_SPACE_TIMEOUT
#define SA_SPACE_TIMEOUT 1 * 60
#endif
#ifndef SA_REWIND_TIMEOUT
#define SA_REWIND_TIMEOUT 2 * 60
#endif
#ifndef SA_ERASE_TIMEOUT
#define SA_ERASE_TIMEOUT 4 * 60
#endif
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
#ifndef SA_REP_DENSITY_TIMEOUT
#define SA_REP_DENSITY_TIMEOUT 90
#endif
#define SCSIOP_TIMEOUT (60 * 1000) /* not an option */
#define IO_TIMEOUT (SA_IO_TIMEOUT * 60 * 1000)
#define REWIND_TIMEOUT (SA_REWIND_TIMEOUT * 60 * 1000)
#define ERASE_TIMEOUT (SA_ERASE_TIMEOUT * 60 * 1000)
#define SPACE_TIMEOUT (SA_SPACE_TIMEOUT * 60 * 1000)
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
#define REP_DENSITY_TIMEOUT (SA_REP_DENSITY_TIMEOUT * 60 * 1000)
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
/*
* Additional options that can be set for config: SA_1FM_AT_EOT
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
*/
#ifndef UNUSED_PARAMETER
#define UNUSED_PARAMETER(x) x = x
#endif
#define QFRLS(ccb) \
if (((ccb)->ccb_h.status & CAM_DEV_QFRZN) != 0) \
cam_release_devq((ccb)->ccb_h.path, 0, 0, 0, FALSE)
/*
* Driver states
*/
static MALLOC_DEFINE(M_SCSISA, "SCSI sa", "SCSI sequential access buffers");
typedef enum {
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
SA_STATE_NORMAL, SA_STATE_ABNORMAL
} sa_state;
#define ccb_pflags ppriv_field0
#define ccb_bp ppriv_ptr1
/* bits in ccb_pflags */
#define SA_POSITION_UPDATED 0x1
typedef enum {
SA_FLAG_OPEN = 0x0001,
SA_FLAG_FIXED = 0x0002,
SA_FLAG_TAPE_LOCKED = 0x0004,
SA_FLAG_TAPE_MOUNTED = 0x0008,
SA_FLAG_TAPE_WP = 0x0010,
SA_FLAG_TAPE_WRITTEN = 0x0020,
SA_FLAG_EOM_PENDING = 0x0040,
SA_FLAG_EIO_PENDING = 0x0080,
SA_FLAG_EOF_PENDING = 0x0100,
SA_FLAG_ERR_PENDING = (SA_FLAG_EOM_PENDING|SA_FLAG_EIO_PENDING|
SA_FLAG_EOF_PENDING),
SA_FLAG_INVALID = 0x0200,
SA_FLAG_COMP_ENABLED = 0x0400,
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
SA_FLAG_COMP_SUPP = 0x0800,
SA_FLAG_COMP_UNSUPP = 0x1000,
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
SA_FLAG_TAPE_FROZEN = 0x2000,
SA_FLAG_PROTECT_SUPP = 0x4000,
SA_FLAG_COMPRESSION = (SA_FLAG_COMP_SUPP|SA_FLAG_COMP_ENABLED|
SA_FLAG_COMP_UNSUPP),
SA_FLAG_SCTX_INIT = 0x8000
} sa_flags;
typedef enum {
SA_MODE_REWIND = 0x00,
SA_MODE_NOREWIND = 0x01,
SA_MODE_OFFLINE = 0x02
} sa_mode;
typedef enum {
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
SA_PARAM_NONE = 0x000,
SA_PARAM_BLOCKSIZE = 0x001,
SA_PARAM_DENSITY = 0x002,
SA_PARAM_COMPRESSION = 0x004,
SA_PARAM_BUFF_MODE = 0x008,
SA_PARAM_NUMBLOCKS = 0x010,
SA_PARAM_WP = 0x020,
SA_PARAM_SPEED = 0x040,
SA_PARAM_DENSITY_EXT = 0x080,
SA_PARAM_LBP = 0x100,
SA_PARAM_ALL = 0x1ff
} sa_params;
typedef enum {
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
SA_QUIRK_NONE = 0x000,
SA_QUIRK_NOCOMP = 0x001, /* Can't deal with compression at all*/
SA_QUIRK_FIXED = 0x002, /* Force fixed mode */
SA_QUIRK_VARIABLE = 0x004, /* Force variable mode */
SA_QUIRK_2FM = 0x008, /* Needs Two File Marks at EOD */
SA_QUIRK_1FM = 0x010, /* No more than 1 File Mark at EOD */
SA_QUIRK_NODREAD = 0x020, /* Don't try and dummy read density */
SA_QUIRK_NO_MODESEL = 0x040, /* Don't do mode select at all */
SA_QUIRK_NO_CPAGE = 0x080, /* Don't use DEVICE COMPRESSION page */
SA_QUIRK_NO_LONG_POS = 0x100 /* No long position information */
} sa_quirks;
#define SA_QUIRK_BIT_STRING \
"\020" \
"\001NOCOMP" \
"\002FIXED" \
"\003VARIABLE" \
"\0042FM" \
"\0051FM" \
"\006NODREAD" \
"\007NO_MODESEL" \
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
"\010NO_CPAGE" \
"\011NO_LONG_POS"
#define SAMODE(z) (dev2unit(z) & 0x3)
#define SA_IS_CTRL(z) (dev2unit(z) & (1 << 4))
#define SA_NOT_CTLDEV 0
#define SA_CTLDEV 1
#define SA_ATYPE_R 0
#define SA_ATYPE_NR 1
#define SA_ATYPE_ER 2
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
#define SA_NUM_ATYPES 3
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
#define SAMINOR(ctl, access) \
((ctl << 4) | (access & 0x3))
struct sa_devs {
struct cdev *ctl_dev;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
struct cdev *r_dev;
struct cdev *nr_dev;
struct cdev *er_dev;
};
#define SASBADDBASE(sb, indent, data, xfmt, name, type, xsize, desc) \
sbuf_printf(sb, "%*s<%s type=\"%s\" size=\"%zd\" " \
"fmt=\"%s\" desc=\"%s\">" #xfmt "</%s>\n", indent, "", \
#name, #type, xsize, #xfmt, desc ? desc : "", data, #name);
#define SASBADDINT(sb, indent, data, fmt, name) \
SASBADDBASE(sb, indent, data, fmt, name, int, sizeof(data), \
NULL)
#define SASBADDINTDESC(sb, indent, data, fmt, name, desc) \
SASBADDBASE(sb, indent, data, fmt, name, int, sizeof(data), \
desc)
#define SASBADDUINT(sb, indent, data, fmt, name) \
SASBADDBASE(sb, indent, data, fmt, name, uint, sizeof(data), \
NULL)
#define SASBADDUINTDESC(sb, indent, data, fmt, name, desc) \
SASBADDBASE(sb, indent, data, fmt, name, uint, sizeof(data), \
desc)
#define SASBADDFIXEDSTR(sb, indent, data, fmt, name) \
SASBADDBASE(sb, indent, data, fmt, name, str, sizeof(data), \
NULL)
#define SASBADDFIXEDSTRDESC(sb, indent, data, fmt, name, desc) \
SASBADDBASE(sb, indent, data, fmt, name, str, sizeof(data), \
desc)
#define SASBADDVARSTR(sb, indent, data, fmt, name, maxlen) \
SASBADDBASE(sb, indent, data, fmt, name, str, maxlen, NULL)
#define SASBADDVARSTRDESC(sb, indent, data, fmt, name, maxlen, desc) \
SASBADDBASE(sb, indent, data, fmt, name, str, maxlen, desc)
#define SASBADDNODE(sb, indent, name) { \
sbuf_printf(sb, "%*s<%s type=\"%s\">\n", indent, "", #name, \
"node"); \
indent += 2; \
}
#define SASBADDNODENUM(sb, indent, name, num) { \
sbuf_printf(sb, "%*s<%s type=\"%s\" num=\"%d\">\n", indent, "", \
#name, "node", num); \
indent += 2; \
}
#define SASBENDNODE(sb, indent, name) { \
indent -= 2; \
sbuf_printf(sb, "%*s</%s>\n", indent, "", #name); \
}
#define SA_DENSITY_TYPES 4
struct sa_prot_state {
int initialized;
uint32_t prot_method;
uint32_t pi_length;
uint32_t lbp_w;
uint32_t lbp_r;
uint32_t rbdp;
};
struct sa_prot_info {
struct sa_prot_state cur_prot_state;
struct sa_prot_state pending_prot_state;
};
/*
* A table mapping protection parameters to their types and values.
*/
struct sa_prot_map {
char *name;
mt_param_set_type param_type;
off_t offset;
uint32_t min_val;
uint32_t max_val;
uint32_t *value;
} sa_prot_table[] = {
{ "prot_method", MT_PARAM_SET_UNSIGNED,
__offsetof(struct sa_prot_state, prot_method),
/*min_val*/ 0, /*max_val*/ 255, NULL },
{ "pi_length", MT_PARAM_SET_UNSIGNED,
__offsetof(struct sa_prot_state, pi_length),
/*min_val*/ 0, /*max_val*/ SA_CTRL_DP_PI_LENGTH_MASK, NULL },
{ "lbp_w", MT_PARAM_SET_UNSIGNED,
__offsetof(struct sa_prot_state, lbp_w),
/*min_val*/ 0, /*max_val*/ 1, NULL },
{ "lbp_r", MT_PARAM_SET_UNSIGNED,
__offsetof(struct sa_prot_state, lbp_r),
/*min_val*/ 0, /*max_val*/ 1, NULL },
{ "rbdp", MT_PARAM_SET_UNSIGNED,
__offsetof(struct sa_prot_state, rbdp),
/*min_val*/ 0, /*max_val*/ 1, NULL }
};
#define SA_NUM_PROT_ENTS nitems(sa_prot_table)
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
#define SA_PROT_ENABLED(softc) ((softc->flags & SA_FLAG_PROTECT_SUPP) \
&& (softc->prot_info.cur_prot_state.initialized != 0) \
&& (softc->prot_info.cur_prot_state.prot_method != 0))
#define SA_PROT_LEN(softc) softc->prot_info.cur_prot_state.pi_length
struct sa_softc {
sa_state state;
sa_flags flags;
sa_quirks quirks;
u_int si_flags;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
struct cam_periph *periph;
struct bio_queue_head bio_queue;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
int queue_count;
struct devstat *device_stats;
struct sa_devs devs;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
int open_count;
int num_devs_to_destroy;
int blk_gran;
int blk_mask;
int blk_shift;
u_int32_t max_blk;
u_int32_t min_blk;
u_int32_t maxio;
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
u_int32_t cpi_maxio;
int allow_io_split;
u_int32_t comp_algorithm;
u_int32_t saved_comp_algorithm;
u_int32_t media_blksize;
u_int32_t last_media_blksize;
u_int32_t media_numblks;
u_int8_t media_density;
u_int8_t speed;
u_int8_t scsi_rev;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
u_int8_t dsreg; /* mtio mt_dsreg, redux */
int buffer_mode;
int filemarks;
union ccb saved_ccb;
int last_resid_was_io;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
uint8_t density_type_bits[SA_DENSITY_TYPES];
int density_info_valid[SA_DENSITY_TYPES];
uint8_t density_info[SA_DENSITY_TYPES][SRDS_MAX_LENGTH];
struct sa_prot_info prot_info;
int sili;
int eot_warn;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
/*
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
* Current position information. -1 means that the given value is
* unknown. fileno and blkno are always calculated. blkno is
* relative to the previous file mark. rep_fileno and rep_blkno
* are as reported by the drive, if it supports the long form
* report for the READ POSITION command. rep_blkno is relative to
* the beginning of the partition.
*
* bop means that the drive is at the beginning of the partition.
* eop means that the drive is between early warning and end of
* partition, inside the current partition.
* bpew means that the position is in a PEWZ (Programmable Early
* Warning Zone)
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
*/
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
daddr_t partition; /* Absolute from BOT */
daddr_t fileno; /* Relative to beginning of partition */
daddr_t blkno; /* Relative to last file mark */
daddr_t rep_blkno; /* Relative to beginning of partition */
daddr_t rep_fileno; /* Relative to beginning of partition */
int bop; /* Beginning of Partition */
int eop; /* End of Partition */
int bpew; /* Beyond Programmable Early Warning */
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
/*
* Latched Error Info
*/
struct {
struct scsi_sense_data _last_io_sense;
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
u_int64_t _last_io_resid;
u_int8_t _last_io_cdb[CAM_MAX_CDBLEN];
struct scsi_sense_data _last_ctl_sense;
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
u_int64_t _last_ctl_resid;
u_int8_t _last_ctl_cdb[CAM_MAX_CDBLEN];
#define last_io_sense errinfo._last_io_sense
#define last_io_resid errinfo._last_io_resid
#define last_io_cdb errinfo._last_io_cdb
#define last_ctl_sense errinfo._last_ctl_sense
#define last_ctl_resid errinfo._last_ctl_resid
#define last_ctl_cdb errinfo._last_ctl_cdb
} errinfo;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
/*
* Misc other flags/state
*/
u_int32_t
: 29,
open_rdonly : 1, /* open read-only */
open_pending_mount : 1, /* open pending mount */
ctrl_mode : 1; /* control device open */
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
struct task sysctl_task;
struct sysctl_ctx_list sysctl_ctx;
struct sysctl_oid *sysctl_tree;
};
struct sa_quirk_entry {
struct scsi_inquiry_pattern inq_pat; /* matching pattern */
sa_quirks quirks; /* specific quirk type */
u_int32_t prefblk; /* preferred blocksize when in fixed mode */
};
static struct sa_quirk_entry sa_quirk_table[] =
{
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "OnStream",
"ADR*", "*"}, SA_QUIRK_FIXED|SA_QUIRK_NODREAD |
SA_QUIRK_1FM|SA_QUIRK_NO_MODESEL, 32768
},
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "ARCHIVE",
"Python 06408*", "*"}, SA_QUIRK_NODREAD, 0
},
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "ARCHIVE",
"Python 25601*", "*"}, SA_QUIRK_NOCOMP|SA_QUIRK_NODREAD, 0
},
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "ARCHIVE",
"Python*", "*"}, SA_QUIRK_NODREAD, 0
},
1998-12-28 19:21:12 +00:00
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "ARCHIVE",
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
"VIPER 150*", "*"}, SA_QUIRK_FIXED|SA_QUIRK_1FM, 512
},
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "ARCHIVE",
"VIPER 2525 25462", "-011"},
SA_QUIRK_NOCOMP|SA_QUIRK_1FM|SA_QUIRK_NODREAD, 0
},
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "ARCHIVE",
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
"VIPER 2525*", "*"}, SA_QUIRK_FIXED|SA_QUIRK_1FM, 1024
},
#if 0
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "HP",
"C15*", "*"}, SA_QUIRK_VARIABLE|SA_QUIRK_NO_CPAGE, 0,
},
#endif
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "HP",
"C56*", "*"}, SA_QUIRK_VARIABLE|SA_QUIRK_2FM, 0
},
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "HP",
"T20*", "*"}, SA_QUIRK_FIXED|SA_QUIRK_1FM, 512
1998-12-28 19:21:12 +00:00
},
1999-01-11 18:26:25 +00:00
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "HP",
"T4000*", "*"}, SA_QUIRK_FIXED|SA_QUIRK_1FM, 512
},
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "HP",
"HP-88780*", "*"}, SA_QUIRK_VARIABLE|SA_QUIRK_2FM, 0
},
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "KENNEDY",
"*", "*"}, SA_QUIRK_VARIABLE|SA_QUIRK_2FM, 0
},
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "M4 DATA",
"123107 SCSI*", "*"}, SA_QUIRK_VARIABLE|SA_QUIRK_2FM, 0
},
{ /* jreynold@primenet.com */
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "Seagate",
"STT8000N*", "*"}, SA_QUIRK_1FM, 0
},
{ /* mike@sentex.net */
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "Seagate",
"STT20000*", "*"}, SA_QUIRK_1FM, 0
},
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "SEAGATE",
"DAT 06241-XXX", "*"}, SA_QUIRK_VARIABLE|SA_QUIRK_2FM, 0
},
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "TANDBERG",
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
" TDC 3600", "U07:"}, SA_QUIRK_NOCOMP|SA_QUIRK_1FM, 512
1999-01-11 18:26:25 +00:00
},
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "TANDBERG",
" TDC 3800", "*"}, SA_QUIRK_NOCOMP|SA_QUIRK_1FM, 512
},
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "TANDBERG",
" TDC 4100", "*"}, SA_QUIRK_NOCOMP|SA_QUIRK_1FM, 512
},
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "TANDBERG",
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
" TDC 4200", "*"}, SA_QUIRK_NOCOMP|SA_QUIRK_1FM, 512
},
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "TANDBERG",
" SLR*", "*"}, SA_QUIRK_1FM, 0
},
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "WANGTEK",
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
"5525ES*", "*"}, SA_QUIRK_FIXED|SA_QUIRK_1FM, 512
},
{
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "WANGTEK",
"51000*", "*"}, SA_QUIRK_FIXED|SA_QUIRK_1FM, 1024
}
};
static d_open_t saopen;
static d_close_t saclose;
static d_strategy_t sastrategy;
static d_ioctl_t saioctl;
static periph_init_t sainit;
static periph_ctor_t saregister;
Fix a problem with the way we handled device invalidation when attaching to a device failed. In theory, the same steps that happen when we get an AC_LOST_DEVICE async notification should have been taken when a driver fails to attach. In practice, that wasn't the case. This only affected the da, cd and ch drivers, but the fix affects all peripheral drivers. There were several possible problems: - In the da driver, we didn't remove the peripheral's softc from the da driver's linked list of softcs. Once the peripheral and softc got removed, we'd get a kernel panic the next time the timeout routine called dasendorderedtag(). - In the da, cd and possibly ch drivers, we didn't remove the peripheral's devstat structure from the devstat queue. Once the peripheral and softc were removed, this could cause a panic if anyone tried to access device statistics. (one component of the linked list wouldn't exist anymore) - In the cd driver, we didn't take the peripheral off the changer run queue if it was scheduled to run. In practice, it's highly unlikely, and maybe impossible that the peripheral would have been on the changer run queue at that stage of the probe process. The fix is: - Add a new peripheral callback function (the "oninvalidate" function) that is called the first time cam_periph_invalidate() is called for a peripheral. - Create new foooninvalidate() routines for each peripheral driver. This routine is always called at splsoftcam(), and contains all the stuff that used to be in the AC_LOST_DEVICE case of the async callback handler. - Move the devstat cleanup call to the destructor/cleanup routines, since some of the drivers do I/O in their close routines. - Make sure that when we're flushing the buffer queue, we traverse it at splbio(). - Add a check for the invalid flag in the pt driver's open routine. Reviewed by: gibbs
1998-10-22 22:16:56 +00:00
static periph_oninv_t saoninvalidate;
static periph_dtor_t sacleanup;
static periph_start_t sastart;
static void saasync(void *callback_arg, u_int32_t code,
struct cam_path *path, void *arg);
static void sadone(struct cam_periph *periph,
union ccb *start_ccb);
static int saerror(union ccb *ccb, u_int32_t cam_flags,
u_int32_t sense_flags);
2000-10-31 22:34:51 +00:00
static int samarkswanted(struct cam_periph *);
static int sacheckeod(struct cam_periph *periph);
static int sagetparams(struct cam_periph *periph,
sa_params params_to_get,
u_int32_t *blocksize, u_int8_t *density,
u_int32_t *numblocks, int *buff_mode,
u_int8_t *write_protect, u_int8_t *speed,
int *comp_supported, int *comp_enabled,
u_int32_t *comp_algorithm,
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
sa_comp_t *comp_page,
struct scsi_control_data_prot_subpage
*prot_page, int dp_size,
int prot_changeable);
static int sasetprot(struct cam_periph *periph,
struct sa_prot_state *new_prot);
static int sasetparams(struct cam_periph *periph,
sa_params params_to_set,
u_int32_t blocksize, u_int8_t density,
u_int32_t comp_algorithm,
u_int32_t sense_flags);
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
static int sasetsili(struct cam_periph *periph,
struct mtparamset *ps, int num_params);
static int saseteotwarn(struct cam_periph *periph,
struct mtparamset *ps, int num_params);
static void safillprot(struct sa_softc *softc, int *indent,
struct sbuf *sb);
static void sapopulateprots(struct sa_prot_state *cur_state,
struct sa_prot_map *new_table,
int table_ents);
static struct sa_prot_map *safindprotent(char *name, struct sa_prot_map *table,
int table_ents);
static int sasetprotents(struct cam_periph *periph,
struct mtparamset *ps, int num_params);
static struct sa_param_ent *safindparament(struct mtparamset *ps);
static int saparamsetlist(struct cam_periph *periph,
struct mtsetlist *list, int need_copy);
static int saextget(struct cdev *dev, struct cam_periph *periph,
struct sbuf *sb, struct mtextget *g);
static int saparamget(struct sa_softc *softc, struct sbuf *sb);
static void saprevent(struct cam_periph *periph, int action);
static int sarewind(struct cam_periph *periph);
static int saspace(struct cam_periph *periph, int count,
scsi_space_code code);
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
static void sadevgonecb(void *arg);
static void sasetupdev(struct sa_softc *softc, struct cdev *dev);
static int samount(struct cam_periph *, int, struct cdev *);
static int saretension(struct cam_periph *periph);
static int sareservereleaseunit(struct cam_periph *periph,
int reserve);
static int saloadunload(struct cam_periph *periph, int load);
static int saerase(struct cam_periph *periph, int longerase);
static int sawritefilemarks(struct cam_periph *periph,
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
int nmarks, int setmarks, int immed);
static int sagetpos(struct cam_periph *periph);
static int sardpos(struct cam_periph *periph, int, u_int32_t *);
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
static int sasetpos(struct cam_periph *periph, int,
struct mtlocate *);
static void safilldenstypesb(struct sbuf *sb, int *indent,
uint8_t *buf, int buf_len,
int is_density);
static void safilldensitysb(struct sa_softc *softc, int *indent,
struct sbuf *sb);
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
#ifndef SA_DEFAULT_IO_SPLIT
#define SA_DEFAULT_IO_SPLIT 0
#endif
static int sa_allow_io_split = SA_DEFAULT_IO_SPLIT;
/*
* Tunable to allow the user to set a global allow_io_split value. Note
* that this WILL GO AWAY in FreeBSD 11.0. Silently splitting the I/O up
* is bad behavior, because it hides the true tape block size from the
* application.
*/
static SYSCTL_NODE(_kern_cam, OID_AUTO, sa, CTLFLAG_RD, 0,
"CAM Sequential Access Tape Driver");
SYSCTL_INT(_kern_cam_sa, OID_AUTO, allow_io_split, CTLFLAG_RDTUN,
&sa_allow_io_split, 0, "Default I/O split value");
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
static struct periph_driver sadriver =
{
sainit, "sa",
TAILQ_HEAD_INITIALIZER(sadriver.units), /* generation */ 0
};
PERIPHDRIVER_DECLARE(sa, sadriver);
/* For 2.2-stable support */
#ifndef D_TAPE
#define D_TAPE 0
#endif
static struct cdevsw sa_cdevsw = {
.d_version = D_VERSION,
.d_open = saopen,
.d_close = saclose,
.d_read = physread,
.d_write = physwrite,
.d_ioctl = saioctl,
.d_strategy = sastrategy,
.d_name = "sa",
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
.d_flags = D_TAPE | D_TRACKCLOSE,
};
static int
saopen(struct cdev *dev, int flags, int fmt, struct thread *td)
{
struct cam_periph *periph;
struct sa_softc *softc;
int error;
periph = (struct cam_periph *)dev->si_drv1;
if (cam_periph_acquire(periph) != CAM_REQ_CMP) {
return (ENXIO);
}
cam_periph_lock(periph);
softc = (struct sa_softc *)periph->softc;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO,
("saopen(%s): softc=0x%x\n", devtoname(dev), softc->flags));
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
if (SA_IS_CTRL(dev)) {
softc->ctrl_mode = 1;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->open_count++;
cam_periph_unlock(periph);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
return (0);
}
if ((error = cam_periph_hold(periph, PRIBIO|PCATCH)) != 0) {
cam_periph_unlock(periph);
cam_periph_release(periph);
return (error);
}
if (softc->flags & SA_FLAG_OPEN) {
error = EBUSY;
} else if (softc->flags & SA_FLAG_INVALID) {
error = ENXIO;
} else {
/*
* Preserve whether this is a read_only open.
*/
softc->open_rdonly = (flags & O_RDWR) == O_RDONLY;
/*
* The function samount ensures media is loaded and ready.
* It also does a device RESERVE if the tape isn't yet mounted.
*
* If the mount fails and this was a non-blocking open,
* make this a 'open_pending_mount' action.
*/
error = samount(periph, flags, dev);
if (error && (flags & O_NONBLOCK)) {
softc->flags |= SA_FLAG_OPEN;
softc->open_pending_mount = 1;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->open_count++;
cam_periph_unhold(periph);
cam_periph_unlock(periph);
return (0);
}
}
if (error) {
cam_periph_unhold(periph);
cam_periph_unlock(periph);
cam_periph_release(periph);
return (error);
}
saprevent(periph, PR_PREVENT);
softc->flags |= SA_FLAG_OPEN;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->open_count++;
cam_periph_unhold(periph);
cam_periph_unlock(periph);
return (error);
}
static int
saclose(struct cdev *dev, int flag, int fmt, struct thread *td)
{
struct cam_periph *periph;
struct sa_softc *softc;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
int mode, error, writing, tmp, i;
int closedbits = SA_FLAG_OPEN;
mode = SAMODE(dev);
periph = (struct cam_periph *)dev->si_drv1;
cam_periph_lock(periph);
softc = (struct sa_softc *)periph->softc;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO,
("saclose(%s): softc=0x%x\n", devtoname(dev), softc->flags));
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
softc->open_rdonly = 0;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
if (SA_IS_CTRL(dev)) {
softc->ctrl_mode = 0;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->open_count--;
cam_periph_unlock(periph);
cam_periph_release(periph);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
return (0);
}
if (softc->open_pending_mount) {
softc->flags &= ~SA_FLAG_OPEN;
softc->open_pending_mount = 0;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->open_count--;
cam_periph_unlock(periph);
cam_periph_release(periph);
return (0);
}
if ((error = cam_periph_hold(periph, PRIBIO)) != 0) {
cam_periph_unlock(periph);
return (error);
}
/*
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
* Were we writing the tape?
*/
writing = (softc->flags & SA_FLAG_TAPE_WRITTEN) != 0;
/*
* See whether or not we need to write filemarks. If this
* fails, we probably have to assume we've lost tape
* position.
*/
error = sacheckeod(periph);
if (error) {
xpt_print(periph->path,
"failed to write terminating filemark(s)\n");
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
softc->flags |= SA_FLAG_TAPE_FROZEN;
}
/*
* Whatever we end up doing, allow users to eject tapes from here on.
*/
saprevent(periph, PR_ALLOW);
/*
* Decide how to end...
*/
if ((softc->flags & SA_FLAG_TAPE_MOUNTED) == 0) {
closedbits |= SA_FLAG_TAPE_FROZEN;
} else switch (mode) {
case SA_MODE_OFFLINE:
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
/*
* An 'offline' close is an unconditional release of
* frozen && mount conditions, irrespective of whether
* these operations succeeded. The reason for this is
* to allow at least some kind of programmatic way
* around our state getting all fouled up. If somebody
* issues an 'offline' command, that will be allowed
* to clear state.
*/
(void) sarewind(periph);
(void) saloadunload(periph, FALSE);
closedbits |= SA_FLAG_TAPE_MOUNTED|SA_FLAG_TAPE_FROZEN;
break;
case SA_MODE_REWIND:
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
/*
* If the rewind fails, return an error- if anyone cares,
* but not overwriting any previous error.
*
* We don't clear the notion of mounted here, but we do
* clear the notion of frozen if we successfully rewound.
*/
tmp = sarewind(periph);
if (tmp) {
if (error != 0)
error = tmp;
} else {
closedbits |= SA_FLAG_TAPE_FROZEN;
}
break;
case SA_MODE_NOREWIND:
/*
* If we're not rewinding/unloading the tape, find out
* whether we need to back up over one of two filemarks
* we wrote (if we wrote two filemarks) so that appends
* from this point on will be sane.
*/
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (error == 0 && writing && (softc->quirks & SA_QUIRK_2FM)) {
tmp = saspace(periph, -1, SS_FILEMARKS);
if (tmp) {
xpt_print(periph->path, "unable to backspace "
"over one of double filemarks at end of "
"tape\n");
xpt_print(periph->path, "it is possible that "
"this device needs a SA_QUIRK_1FM quirk set"
"for it\n");
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
softc->flags |= SA_FLAG_TAPE_FROZEN;
}
}
break;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
default:
xpt_print(periph->path, "unknown mode 0x%x in saclose\n", mode);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
/* NOTREACHED */
break;
}
/*
* We wish to note here that there are no more filemarks to be written.
*/
softc->filemarks = 0;
softc->flags &= ~SA_FLAG_TAPE_WRITTEN;
/*
* And we are no longer open for business.
*/
softc->flags &= ~closedbits;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->open_count--;
/*
* Invalidate any density information that depends on having tape
* media in the drive.
*/
for (i = 0; i < SA_DENSITY_TYPES; i++) {
if (softc->density_type_bits[i] & SRDS_MEDIA)
softc->density_info_valid[i] = 0;
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
/*
* Inform users if tape state if frozen....
*/
if (softc->flags & SA_FLAG_TAPE_FROZEN) {
xpt_print(periph->path, "tape is now frozen- use an OFFLINE, "
"REWIND or MTEOM command to clear this state.\n");
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
}
/* release the device if it is no longer mounted */
if ((softc->flags & SA_FLAG_TAPE_MOUNTED) == 0)
sareservereleaseunit(periph, FALSE);
cam_periph_unhold(periph);
cam_periph_unlock(periph);
cam_periph_release(periph);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
return (error);
}
/*
* Actually translate the requested transfer into one the physical driver
* can understand. The transfer is described by a buf and will include
* only one physical transfer.
*/
static void
sastrategy(struct bio *bp)
{
struct cam_periph *periph;
struct sa_softc *softc;
bp->bio_resid = bp->bio_bcount;
if (SA_IS_CTRL(bp->bio_dev)) {
biofinish(bp, NULL, EINVAL);
return;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
}
periph = (struct cam_periph *)bp->bio_dev->si_drv1;
cam_periph_lock(periph);
softc = (struct sa_softc *)periph->softc;
Fix a problem with the way we handled device invalidation when attaching to a device failed. In theory, the same steps that happen when we get an AC_LOST_DEVICE async notification should have been taken when a driver fails to attach. In practice, that wasn't the case. This only affected the da, cd and ch drivers, but the fix affects all peripheral drivers. There were several possible problems: - In the da driver, we didn't remove the peripheral's softc from the da driver's linked list of softcs. Once the peripheral and softc got removed, we'd get a kernel panic the next time the timeout routine called dasendorderedtag(). - In the da, cd and possibly ch drivers, we didn't remove the peripheral's devstat structure from the devstat queue. Once the peripheral and softc were removed, this could cause a panic if anyone tried to access device statistics. (one component of the linked list wouldn't exist anymore) - In the cd driver, we didn't take the peripheral off the changer run queue if it was scheduled to run. In practice, it's highly unlikely, and maybe impossible that the peripheral would have been on the changer run queue at that stage of the probe process. The fix is: - Add a new peripheral callback function (the "oninvalidate" function) that is called the first time cam_periph_invalidate() is called for a peripheral. - Create new foooninvalidate() routines for each peripheral driver. This routine is always called at splsoftcam(), and contains all the stuff that used to be in the AC_LOST_DEVICE case of the async callback handler. - Move the devstat cleanup call to the destructor/cleanup routines, since some of the drivers do I/O in their close routines. - Make sure that when we're flushing the buffer queue, we traverse it at splbio(). - Add a check for the invalid flag in the pt driver's open routine. Reviewed by: gibbs
1998-10-22 22:16:56 +00:00
if (softc->flags & SA_FLAG_INVALID) {
cam_periph_unlock(periph);
biofinish(bp, NULL, ENXIO);
return;
Fix a problem with the way we handled device invalidation when attaching to a device failed. In theory, the same steps that happen when we get an AC_LOST_DEVICE async notification should have been taken when a driver fails to attach. In practice, that wasn't the case. This only affected the da, cd and ch drivers, but the fix affects all peripheral drivers. There were several possible problems: - In the da driver, we didn't remove the peripheral's softc from the da driver's linked list of softcs. Once the peripheral and softc got removed, we'd get a kernel panic the next time the timeout routine called dasendorderedtag(). - In the da, cd and possibly ch drivers, we didn't remove the peripheral's devstat structure from the devstat queue. Once the peripheral and softc were removed, this could cause a panic if anyone tried to access device statistics. (one component of the linked list wouldn't exist anymore) - In the cd driver, we didn't take the peripheral off the changer run queue if it was scheduled to run. In practice, it's highly unlikely, and maybe impossible that the peripheral would have been on the changer run queue at that stage of the probe process. The fix is: - Add a new peripheral callback function (the "oninvalidate" function) that is called the first time cam_periph_invalidate() is called for a peripheral. - Create new foooninvalidate() routines for each peripheral driver. This routine is always called at splsoftcam(), and contains all the stuff that used to be in the AC_LOST_DEVICE case of the async callback handler. - Move the devstat cleanup call to the destructor/cleanup routines, since some of the drivers do I/O in their close routines. - Make sure that when we're flushing the buffer queue, we traverse it at splbio(). - Add a check for the invalid flag in the pt driver's open routine. Reviewed by: gibbs
1998-10-22 22:16:56 +00:00
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (softc->flags & SA_FLAG_TAPE_FROZEN) {
cam_periph_unlock(periph);
biofinish(bp, NULL, EPERM);
return;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
}
/*
* This should actually never occur as the write(2)
* system call traps attempts to write to a read-only
* file descriptor.
*/
if (bp->bio_cmd == BIO_WRITE && softc->open_rdonly) {
cam_periph_unlock(periph);
biofinish(bp, NULL, EBADF);
return;
}
if (softc->open_pending_mount) {
int error = samount(periph, 0, bp->bio_dev);
if (error) {
cam_periph_unlock(periph);
biofinish(bp, NULL, ENXIO);
return;
}
saprevent(periph, PR_PREVENT);
softc->open_pending_mount = 0;
}
/*
* If it's a null transfer, return immediately
*/
if (bp->bio_bcount == 0) {
cam_periph_unlock(periph);
biodone(bp);
return;
}
/* valid request? */
if (softc->flags & SA_FLAG_FIXED) {
/*
* Fixed block device. The byte count must
* be a multiple of our block size.
*/
if (((softc->blk_mask != ~0) &&
((bp->bio_bcount & softc->blk_mask) != 0)) ||
((softc->blk_mask == ~0) &&
((bp->bio_bcount % softc->min_blk) != 0))) {
xpt_print(periph->path, "Invalid request. Fixed block "
"device requests must be a multiple of %d bytes\n",
softc->min_blk);
cam_periph_unlock(periph);
biofinish(bp, NULL, EINVAL);
return;
}
} else if ((bp->bio_bcount > softc->max_blk) ||
(bp->bio_bcount < softc->min_blk) ||
(bp->bio_bcount & softc->blk_mask) != 0) {
xpt_print_path(periph->path);
printf("Invalid request. Variable block "
"device requests must be ");
if (softc->blk_mask != 0) {
printf("a multiple of %d ", (0x1 << softc->blk_gran));
}
printf("between %d and %d bytes\n", softc->min_blk,
softc->max_blk);
cam_periph_unlock(periph);
biofinish(bp, NULL, EINVAL);
return;
}
/*
* Place it at the end of the queue.
*/
bioq_insert_tail(&softc->bio_queue, bp);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
softc->queue_count++;
#if 0
CAM_DEBUG(periph->path, CAM_DEBUG_INFO,
("sastrategy: queuing a %ld %s byte %s\n", bp->bio_bcount,
(softc->flags & SA_FLAG_FIXED)? "fixed" : "variable",
(bp->bio_cmd == BIO_READ)? "read" : "write"));
#endif
if (softc->queue_count > 1) {
CAM_DEBUG(periph->path, CAM_DEBUG_INFO,
("sastrategy: queue count now %d\n", softc->queue_count));
}
/*
* Schedule ourselves for performing the work.
*/
xpt_schedule(periph, CAM_PRIORITY_NORMAL);
cam_periph_unlock(periph);
return;
}
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
static int
sasetsili(struct cam_periph *periph, struct mtparamset *ps, int num_params)
{
uint32_t sili_blocksize;
struct sa_softc *softc;
int error;
error = 0;
softc = (struct sa_softc *)periph->softc;
if (ps->value_type != MT_PARAM_SET_SIGNED) {
snprintf(ps->error_str, sizeof(ps->error_str),
"sili is a signed parameter");
goto bailout;
}
if ((ps->value.value_signed < 0)
|| (ps->value.value_signed > 1)) {
snprintf(ps->error_str, sizeof(ps->error_str),
"invalid sili value %jd", (intmax_t)ps->value.value_signed);
goto bailout_error;
}
/*
* We only set the SILI flag in variable block
* mode. You'll get a check condition in fixed
* block mode if things don't line up in any case.
*/
if (softc->flags & SA_FLAG_FIXED) {
snprintf(ps->error_str, sizeof(ps->error_str),
"can't set sili bit in fixed block mode");
goto bailout_error;
}
if (softc->sili == ps->value.value_signed)
goto bailout;
if (ps->value.value_signed == 1)
sili_blocksize = 4;
else
sili_blocksize = 0;
error = sasetparams(periph, SA_PARAM_BLOCKSIZE,
sili_blocksize, 0, 0, SF_QUIET_IR);
if (error != 0) {
snprintf(ps->error_str, sizeof(ps->error_str),
"sasetparams() returned error %d", error);
goto bailout_error;
}
softc->sili = ps->value.value_signed;
bailout:
ps->status = MT_PARAM_STATUS_OK;
return (error);
bailout_error:
ps->status = MT_PARAM_STATUS_ERROR;
if (error == 0)
error = EINVAL;
return (error);
}
static int
saseteotwarn(struct cam_periph *periph, struct mtparamset *ps, int num_params)
{
struct sa_softc *softc;
int error;
error = 0;
softc = (struct sa_softc *)periph->softc;
if (ps->value_type != MT_PARAM_SET_SIGNED) {
snprintf(ps->error_str, sizeof(ps->error_str),
"eot_warn is a signed parameter");
ps->status = MT_PARAM_STATUS_ERROR;
goto bailout;
}
if ((ps->value.value_signed < 0)
|| (ps->value.value_signed > 1)) {
snprintf(ps->error_str, sizeof(ps->error_str),
"invalid eot_warn value %jd\n",
(intmax_t)ps->value.value_signed);
ps->status = MT_PARAM_STATUS_ERROR;
goto bailout;
}
softc->eot_warn = ps->value.value_signed;
ps->status = MT_PARAM_STATUS_OK;
bailout:
if (ps->status != MT_PARAM_STATUS_OK)
error = EINVAL;
return (error);
}
static void
safillprot(struct sa_softc *softc, int *indent, struct sbuf *sb)
{
int tmpint;
SASBADDNODE(sb, *indent, protection);
if (softc->flags & SA_FLAG_PROTECT_SUPP)
tmpint = 1;
else
tmpint = 0;
SASBADDINTDESC(sb, *indent, tmpint, %d, protection_supported,
"Set to 1 if protection information is supported");
if ((tmpint != 0)
&& (softc->prot_info.cur_prot_state.initialized != 0)) {
struct sa_prot_state *prot;
prot = &softc->prot_info.cur_prot_state;
SASBADDUINTDESC(sb, *indent, prot->prot_method, %u,
prot_method, "Current Protection Method");
SASBADDUINTDESC(sb, *indent, prot->pi_length, %u,
pi_length, "Length of Protection Information");
SASBADDUINTDESC(sb, *indent, prot->lbp_w, %u,
lbp_w, "Check Protection on Writes");
SASBADDUINTDESC(sb, *indent, prot->lbp_r, %u,
lbp_r, "Check and Include Protection on Reads");
SASBADDUINTDESC(sb, *indent, prot->rbdp, %u,
rbdp, "Transfer Protection Information for RECOVER "
"BUFFERED DATA command");
}
SASBENDNODE(sb, *indent, protection);
}
static void
sapopulateprots(struct sa_prot_state *cur_state, struct sa_prot_map *new_table,
int table_ents)
{
int i;
bcopy(sa_prot_table, new_table, min(table_ents * sizeof(*new_table),
sizeof(sa_prot_table)));
table_ents = min(table_ents, SA_NUM_PROT_ENTS);
for (i = 0; i < table_ents; i++)
new_table[i].value = (uint32_t *)((uint8_t *)cur_state +
new_table[i].offset);
return;
}
static struct sa_prot_map *
safindprotent(char *name, struct sa_prot_map *table, int table_ents)
{
char *prot_name = "protection.";
int i, prot_len;
prot_len = strlen(prot_name);
/*
* This shouldn't happen, but we check just in case.
*/
if (strncmp(name, prot_name, prot_len) != 0)
goto bailout;
for (i = 0; i < table_ents; i++) {
if (strcmp(&name[prot_len], table[i].name) != 0)
continue;
return (&table[i]);
}
bailout:
return (NULL);
}
static int
sasetprotents(struct cam_periph *periph, struct mtparamset *ps, int num_params)
{
struct sa_softc *softc;
struct sa_prot_map prot_ents[SA_NUM_PROT_ENTS];
struct sa_prot_state new_state;
int error;
int i;
softc = (struct sa_softc *)periph->softc;
error = 0;
/*
* Make sure that this tape drive supports protection information.
* Otherwise we can't set anything.
*/
if ((softc->flags & SA_FLAG_PROTECT_SUPP) == 0) {
snprintf(ps[0].error_str, sizeof(ps[0].error_str),
"Protection information is not supported for this device");
ps[0].status = MT_PARAM_STATUS_ERROR;
goto bailout;
}
/*
* We can't operate with physio(9) splitting enabled, because there
* is no way to insure (especially in variable block mode) that
* what the user writes (with a checksum block at the end) will
* make it into the sa(4) driver intact.
*/
if ((softc->si_flags & SI_NOSPLIT) == 0) {
snprintf(ps[0].error_str, sizeof(ps[0].error_str),
"Protection information cannot be enabled with I/O "
"splitting");
ps[0].status = MT_PARAM_STATUS_ERROR;
goto bailout;
}
/*
* Take the current cached protection state and use that as the
* basis for our new entries.
*/
bcopy(&softc->prot_info.cur_prot_state, &new_state, sizeof(new_state));
/*
* Populate the table mapping property names to pointers into the
* state structure.
*/
sapopulateprots(&new_state, prot_ents, SA_NUM_PROT_ENTS);
/*
* For each parameter the user passed in, make sure the name, type
* and value are valid.
*/
for (i = 0; i < num_params; i++) {
struct sa_prot_map *ent;
ent = safindprotent(ps[i].value_name, prot_ents,
SA_NUM_PROT_ENTS);
if (ent == NULL) {
ps[i].status = MT_PARAM_STATUS_ERROR;
snprintf(ps[i].error_str, sizeof(ps[i].error_str),
"Invalid protection entry name %s",
ps[i].value_name);
error = EINVAL;
goto bailout;
}
if (ent->param_type != ps[i].value_type) {
ps[i].status = MT_PARAM_STATUS_ERROR;
snprintf(ps[i].error_str, sizeof(ps[i].error_str),
"Supplied type %d does not match actual type %d",
ps[i].value_type, ent->param_type);
error = EINVAL;
goto bailout;
}
if ((ps[i].value.value_unsigned < ent->min_val)
|| (ps[i].value.value_unsigned > ent->max_val)) {
ps[i].status = MT_PARAM_STATUS_ERROR;
snprintf(ps[i].error_str, sizeof(ps[i].error_str),
"Value %ju is outside valid range %u - %u",
(uintmax_t)ps[i].value.value_unsigned, ent->min_val,
ent->max_val);
error = EINVAL;
goto bailout;
}
*(ent->value) = ps[i].value.value_unsigned;
}
/*
* Actually send the protection settings to the drive.
*/
error = sasetprot(periph, &new_state);
if (error != 0) {
for (i = 0; i < num_params; i++) {
ps[i].status = MT_PARAM_STATUS_ERROR;
snprintf(ps[i].error_str, sizeof(ps[i].error_str),
"Unable to set parameter, see dmesg(8)");
}
goto bailout;
}
/*
* Let the user know that his settings were stored successfully.
*/
for (i = 0; i < num_params; i++)
ps[i].status = MT_PARAM_STATUS_OK;
bailout:
return (error);
}
/*
* Entry handlers generally only handle a single entry. Node handlers will
* handle a contiguous range of parameters to set in a single call.
*/
typedef enum {
SA_PARAM_TYPE_ENTRY,
SA_PARAM_TYPE_NODE
} sa_param_type;
struct sa_param_ent {
char *name;
sa_param_type param_type;
int (*set_func)(struct cam_periph *periph, struct mtparamset *ps,
int num_params);
} sa_param_table[] = {
{"sili", SA_PARAM_TYPE_ENTRY, sasetsili },
{"eot_warn", SA_PARAM_TYPE_ENTRY, saseteotwarn },
{"protection.", SA_PARAM_TYPE_NODE, sasetprotents }
};
static struct sa_param_ent *
safindparament(struct mtparamset *ps)
{
unsigned int i;
for (i = 0; i < nitems(sa_param_table); i++){
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
/*
* For entries, we compare all of the characters. For
* nodes, we only compare the first N characters. The node
* handler will decode the rest.
*/
if (sa_param_table[i].param_type == SA_PARAM_TYPE_ENTRY) {
if (strcmp(ps->value_name, sa_param_table[i].name) != 0)
continue;
} else {
if (strncmp(ps->value_name, sa_param_table[i].name,
strlen(sa_param_table[i].name)) != 0)
continue;
}
return (&sa_param_table[i]);
}
return (NULL);
}
/*
* Go through a list of parameters, coalescing contiguous parameters with
* the same parent node into a single call to a set_func.
*/
static int
saparamsetlist(struct cam_periph *periph, struct mtsetlist *list,
int need_copy)
{
int i, contig_ents;
int error;
struct mtparamset *params, *first;
struct sa_param_ent *first_ent;
error = 0;
params = NULL;
if (list->num_params == 0)
/* Nothing to do */
goto bailout;
/*
* Verify that the user has the correct structure size.
*/
if ((list->num_params * sizeof(struct mtparamset)) !=
list->param_len) {
xpt_print(periph->path, "%s: length of params %d != "
"sizeof(struct mtparamset) %zd * num_params %d\n",
__func__, list->param_len, sizeof(struct mtparamset),
list->num_params);
error = EINVAL;
goto bailout;
}
if (need_copy != 0) {
/*
* XXX KDM will dropping the lock cause an issue here?
*/
cam_periph_unlock(periph);
params = malloc(list->param_len, M_SCSISA, M_WAITOK | M_ZERO);
error = copyin(list->params, params, list->param_len);
cam_periph_lock(periph);
if (error != 0)
goto bailout;
} else {
params = list->params;
}
contig_ents = 0;
first = NULL;
first_ent = NULL;
for (i = 0; i < list->num_params; i++) {
struct sa_param_ent *ent;
ent = safindparament(&params[i]);
if (ent == NULL) {
snprintf(params[i].error_str,
sizeof(params[i].error_str),
"%s: cannot find parameter %s", __func__,
params[i].value_name);
params[i].status = MT_PARAM_STATUS_ERROR;
break;
}
if (first != NULL) {
if (first_ent == ent) {
/*
* We're still in a contiguous list of
* parameters that can be handled by one
* node handler.
*/
contig_ents++;
continue;
} else {
error = first_ent->set_func(periph, first,
contig_ents);
first = NULL;
first_ent = NULL;
contig_ents = 0;
if (error != 0) {
error = 0;
break;
}
}
}
if (ent->param_type == SA_PARAM_TYPE_NODE) {
first = &params[i];
first_ent = ent;
contig_ents = 1;
} else {
error = ent->set_func(periph, &params[i], 1);
if (error != 0) {
error = 0;
break;
}
}
}
if (first != NULL)
first_ent->set_func(periph, first, contig_ents);
bailout:
if (need_copy != 0) {
if (error != EFAULT) {
cam_periph_unlock(periph);
copyout(params, list->params, list->param_len);
cam_periph_lock(periph);
}
free(params, M_SCSISA);
}
return (error);
}
static int
sagetparams_common(struct cdev *dev, struct cam_periph *periph)
{
struct sa_softc *softc;
u_int8_t write_protect;
int comp_enabled, comp_supported, error;
softc = (struct sa_softc *)periph->softc;
if (softc->open_pending_mount)
return (0);
/* The control device may issue getparams() if there are no opens. */
if (SA_IS_CTRL(dev) && (softc->flags & SA_FLAG_OPEN) != 0)
return (0);
error = sagetparams(periph, SA_PARAM_ALL, &softc->media_blksize,
&softc->media_density, &softc->media_numblks, &softc->buffer_mode,
&write_protect, &softc->speed, &comp_supported, &comp_enabled,
&softc->comp_algorithm, NULL, NULL, 0, 0);
if (error)
return (error);
if (write_protect)
softc->flags |= SA_FLAG_TAPE_WP;
else
softc->flags &= ~SA_FLAG_TAPE_WP;
softc->flags &= ~SA_FLAG_COMPRESSION;
if (comp_supported) {
if (softc->saved_comp_algorithm == 0)
softc->saved_comp_algorithm =
softc->comp_algorithm;
softc->flags |= SA_FLAG_COMP_SUPP;
if (comp_enabled)
softc->flags |= SA_FLAG_COMP_ENABLED;
} else
softc->flags |= SA_FLAG_COMP_UNSUPP;
return (0);
}
#define PENDING_MOUNT_CHECK(softc, periph, dev) \
if (softc->open_pending_mount) { \
error = samount(periph, 0, dev); \
if (error) { \
break; \
} \
saprevent(periph, PR_PREVENT); \
softc->open_pending_mount = 0; \
}
static int
saioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
{
struct cam_periph *periph;
struct sa_softc *softc;
scsi_space_code spaceop;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
int didlockperiph = 0;
int mode;
int error = 0;
mode = SAMODE(dev);
error = 0; /* shut up gcc */
spaceop = 0; /* shut up gcc */
periph = (struct cam_periph *)dev->si_drv1;
cam_periph_lock(periph);
softc = (struct sa_softc *)periph->softc;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
/*
* Check for control mode accesses. We allow MTIOCGET and
* MTIOCERRSTAT (but need to be the only one open in order
* to clear latched status), and MTSETBSIZE, MTSETDNSTY
* and MTCOMP (but need to be the only one accessing this
* device to run those).
*/
if (SA_IS_CTRL(dev)) {
switch (cmd) {
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
case MTIOCGETEOTMODEL:
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
case MTIOCGET:
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
case MTIOCEXTGET:
case MTIOCPARAMGET:
case MTIOCRBLIM:
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
break;
case MTIOCERRSTAT:
/*
* If the periph isn't already locked, lock it
* so our MTIOCERRSTAT can reset latched error stats.
*
* If the periph is already locked, skip it because
* we're just getting status and it'll be up to the
* other thread that has this device open to do
* an MTIOCERRSTAT that would clear latched status.
*/
if ((periph->flags & CAM_PERIPH_LOCKED) == 0) {
error = cam_periph_hold(periph, PRIBIO|PCATCH);
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
if (error != 0) {
cam_periph_unlock(periph);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
return (error);
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
}
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
didlockperiph = 1;
}
break;
case MTIOCTOP:
{
struct mtop *mt = (struct mtop *) arg;
/*
* Check to make sure it's an OP we can perform
* with no media inserted.
*/
switch (mt->mt_op) {
case MTSETBSIZ:
case MTSETDNSTY:
case MTCOMP:
mt = NULL;
/* FALLTHROUGH */
default:
break;
}
if (mt != NULL) {
break;
}
/* FALLTHROUGH */
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
case MTIOCSETEOTMODEL:
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
/*
* We need to acquire the peripheral here rather
* than at open time because we are sharing writable
* access to data structures.
*/
error = cam_periph_hold(periph, PRIBIO|PCATCH);
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
if (error != 0) {
cam_periph_unlock(periph);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
return (error);
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
}
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
didlockperiph = 1;
break;
default:
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
cam_periph_unlock(periph);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
return (EINVAL);
}
}
/*
* Find the device that the user is talking about
*/
switch (cmd) {
case MTIOCGET:
{
struct mtget *g = (struct mtget *)arg;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
error = sagetparams_common(dev, periph);
if (error)
break;
bzero(g, sizeof(struct mtget));
g->mt_type = MT_ISAR;
if (softc->flags & SA_FLAG_COMP_UNSUPP) {
g->mt_comp = MT_COMP_UNSUPP;
g->mt_comp0 = MT_COMP_UNSUPP;
g->mt_comp1 = MT_COMP_UNSUPP;
g->mt_comp2 = MT_COMP_UNSUPP;
g->mt_comp3 = MT_COMP_UNSUPP;
} else {
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if ((softc->flags & SA_FLAG_COMP_ENABLED) == 0) {
g->mt_comp = MT_COMP_DISABLED;
} else {
g->mt_comp = softc->comp_algorithm;
}
g->mt_comp0 = softc->comp_algorithm;
g->mt_comp1 = softc->comp_algorithm;
g->mt_comp2 = softc->comp_algorithm;
g->mt_comp3 = softc->comp_algorithm;
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
g->mt_density = softc->media_density;
g->mt_density0 = softc->media_density;
g->mt_density1 = softc->media_density;
g->mt_density2 = softc->media_density;
g->mt_density3 = softc->media_density;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
g->mt_blksiz = softc->media_blksize;
g->mt_blksiz0 = softc->media_blksize;
g->mt_blksiz1 = softc->media_blksize;
g->mt_blksiz2 = softc->media_blksize;
g->mt_blksiz3 = softc->media_blksize;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
g->mt_fileno = softc->fileno;
g->mt_blkno = softc->blkno;
g->mt_dsreg = (short) softc->dsreg;
/*
* Yes, we know that this is likely to overflow
*/
if (softc->last_resid_was_io) {
if ((g->mt_resid = (short) softc->last_io_resid) != 0) {
if (SA_IS_CTRL(dev) == 0 || didlockperiph) {
softc->last_io_resid = 0;
}
}
} else {
if ((g->mt_resid = (short)softc->last_ctl_resid) != 0) {
if (SA_IS_CTRL(dev) == 0 || didlockperiph) {
softc->last_ctl_resid = 0;
}
}
}
error = 0;
break;
}
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
case MTIOCEXTGET:
case MTIOCPARAMGET:
{
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
struct mtextget *g = (struct mtextget *)arg;
char *tmpstr2;
struct sbuf *sb;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
/*
* Report drive status using an XML format.
*/
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
/*
* XXX KDM will dropping the lock cause any problems here?
*/
cam_periph_unlock(periph);
sb = sbuf_new(NULL, NULL, g->alloc_len, SBUF_FIXEDLEN);
if (sb == NULL) {
g->status = MT_EXT_GET_ERROR;
snprintf(g->error_str, sizeof(g->error_str),
"Unable to allocate %d bytes for status info",
g->alloc_len);
cam_periph_lock(periph);
goto extget_bailout;
}
cam_periph_lock(periph);
if (cmd == MTIOCEXTGET)
error = saextget(dev, periph, sb, g);
else
error = saparamget(softc, sb);
if (error != 0)
goto extget_bailout;
error = sbuf_finish(sb);
if (error == ENOMEM) {
g->status = MT_EXT_GET_NEED_MORE_SPACE;
error = 0;
} else if (error != 0) {
g->status = MT_EXT_GET_ERROR;
snprintf(g->error_str, sizeof(g->error_str),
"Error %d returned from sbuf_finish()", error);
} else
g->status = MT_EXT_GET_OK;
error = 0;
tmpstr2 = sbuf_data(sb);
g->fill_len = strlen(tmpstr2) + 1;
cam_periph_unlock(periph);
error = copyout(tmpstr2, g->status_xml, g->fill_len);
cam_periph_lock(periph);
extget_bailout:
sbuf_delete(sb);
break;
}
case MTIOCPARAMSET:
{
struct mtsetlist list;
struct mtparamset *ps = (struct mtparamset *)arg;
bzero(&list, sizeof(list));
list.num_params = 1;
list.param_len = sizeof(*ps);
list.params = ps;
error = saparamsetlist(periph, &list, /*need_copy*/ 0);
break;
}
case MTIOCSETLIST:
{
struct mtsetlist *list = (struct mtsetlist *)arg;
error = saparamsetlist(periph, list, /*need_copy*/ 1);
break;
}
case MTIOCERRSTAT:
{
struct scsi_tape_errors *sep =
&((union mterrstat *)arg)->scsi_errstat;
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE,
("saioctl: MTIOCERRSTAT\n"));
bzero(sep, sizeof(*sep));
sep->io_resid = softc->last_io_resid;
bcopy((caddr_t) &softc->last_io_sense, sep->io_sense,
sizeof (sep->io_sense));
bcopy((caddr_t) &softc->last_io_cdb, sep->io_cdb,
sizeof (sep->io_cdb));
sep->ctl_resid = softc->last_ctl_resid;
bcopy((caddr_t) &softc->last_ctl_sense, sep->ctl_sense,
sizeof (sep->ctl_sense));
bcopy((caddr_t) &softc->last_ctl_cdb, sep->ctl_cdb,
sizeof (sep->ctl_cdb));
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
if ((SA_IS_CTRL(dev) == 0 && !softc->open_pending_mount) ||
didlockperiph)
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
bzero((caddr_t) &softc->errinfo,
sizeof (softc->errinfo));
error = 0;
break;
}
case MTIOCTOP:
{
struct mtop *mt;
int count;
PENDING_MOUNT_CHECK(softc, periph, dev);
mt = (struct mtop *)arg;
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE,
("saioctl: op=0x%x count=0x%x\n",
mt->mt_op, mt->mt_count));
count = mt->mt_count;
switch (mt->mt_op) {
case MTWEOF: /* write an end-of-file marker */
2000-10-31 22:34:51 +00:00
/*
* We don't need to clear the SA_FLAG_TAPE_WRITTEN
* flag because by keeping track of filemarks
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
* we have last written we know whether or not
2000-10-31 22:34:51 +00:00
* we need to write more when we close the device.
*/
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
error = sawritefilemarks(periph, count, FALSE, FALSE);
break;
case MTWEOFI:
/* write an end-of-file marker without waiting */
error = sawritefilemarks(periph, count, FALSE, TRUE);
break;
case MTWSS: /* write a setmark */
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
error = sawritefilemarks(periph, count, TRUE, FALSE);
break;
case MTBSR: /* backward space record */
case MTFSR: /* forward space record */
case MTBSF: /* backward space file */
case MTFSF: /* forward space file */
case MTBSS: /* backward space setmark */
case MTFSS: /* forward space setmark */
case MTEOD: /* space to end of recorded medium */
{
int nmarks;
spaceop = SS_FILEMARKS;
nmarks = softc->filemarks;
error = sacheckeod(periph);
if (error) {
xpt_print(periph->path,
"EOD check prior to spacing failed\n");
softc->flags |= SA_FLAG_EIO_PENDING;
break;
}
nmarks -= softc->filemarks;
switch(mt->mt_op) {
case MTBSR:
count = -count;
/* FALLTHROUGH */
case MTFSR:
spaceop = SS_BLOCKS;
break;
case MTBSF:
count = -count;
/* FALLTHROUGH */
case MTFSF:
break;
case MTBSS:
count = -count;
/* FALLTHROUGH */
case MTFSS:
spaceop = SS_SETMARKS;
break;
case MTEOD:
spaceop = SS_EOD;
count = 0;
nmarks = 0;
break;
default:
error = EINVAL;
break;
}
if (error)
break;
nmarks = softc->filemarks;
/*
* XXX: Why are we checking again?
*/
error = sacheckeod(periph);
if (error)
break;
nmarks -= softc->filemarks;
error = saspace(periph, count - nmarks, spaceop);
/*
* At this point, clear that we've written the tape
* and that we've written any filemarks. We really
* don't know what the applications wishes to do next-
* the sacheckeod's will make sure we terminated the
* tape correctly if we'd been writing, but the next
* action the user application takes will set again
* whether we need to write filemarks.
*/
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
softc->flags &=
~(SA_FLAG_TAPE_WRITTEN|SA_FLAG_TAPE_FROZEN);
softc->filemarks = 0;
break;
}
case MTREW: /* rewind */
PENDING_MOUNT_CHECK(softc, periph, dev);
(void) sacheckeod(periph);
error = sarewind(periph);
/* see above */
softc->flags &=
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
~(SA_FLAG_TAPE_WRITTEN|SA_FLAG_TAPE_FROZEN);
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
softc->flags &= ~SA_FLAG_ERR_PENDING;
softc->filemarks = 0;
break;
case MTERASE: /* erase */
PENDING_MOUNT_CHECK(softc, periph, dev);
error = saerase(periph, count);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
softc->flags &=
~(SA_FLAG_TAPE_WRITTEN|SA_FLAG_TAPE_FROZEN);
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
softc->flags &= ~SA_FLAG_ERR_PENDING;
break;
case MTRETENS: /* re-tension tape */
PENDING_MOUNT_CHECK(softc, periph, dev);
error = saretension(periph);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
softc->flags &=
~(SA_FLAG_TAPE_WRITTEN|SA_FLAG_TAPE_FROZEN);
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
softc->flags &= ~SA_FLAG_ERR_PENDING;
break;
case MTOFFL: /* rewind and put the drive offline */
PENDING_MOUNT_CHECK(softc, periph, dev);
(void) sacheckeod(periph);
/* see above */
softc->flags &= ~SA_FLAG_TAPE_WRITTEN;
softc->filemarks = 0;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
error = sarewind(periph);
/* clear the frozen flag anyway */
softc->flags &= ~SA_FLAG_TAPE_FROZEN;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
/*
* Be sure to allow media removal before ejecting.
*/
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
saprevent(periph, PR_ALLOW);
if (error == 0) {
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
error = saloadunload(periph, FALSE);
if (error == 0) {
softc->flags &= ~SA_FLAG_TAPE_MOUNTED;
}
}
break;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
case MTLOAD:
error = saloadunload(periph, TRUE);
break;
case MTNOP: /* no operation, sets status only */
case MTCACHE: /* enable controller cache */
case MTNOCACHE: /* disable controller cache */
error = 0;
break;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
case MTSETBSIZ: /* Set block size for device */
PENDING_MOUNT_CHECK(softc, periph, dev);
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
if ((softc->sili != 0)
&& (count != 0)) {
xpt_print(periph->path, "Can't enter fixed "
"block mode with SILI enabled\n");
error = EINVAL;
break;
}
error = sasetparams(periph, SA_PARAM_BLOCKSIZE, count,
0, 0, 0);
if (error == 0) {
softc->last_media_blksize =
softc->media_blksize;
softc->media_blksize = count;
if (count) {
softc->flags |= SA_FLAG_FIXED;
if (powerof2(count)) {
softc->blk_shift =
ffs(count) - 1;
softc->blk_mask = count - 1;
} else {
softc->blk_mask = ~0;
softc->blk_shift = 0;
}
/*
* Make the user's desire 'persistent'.
*/
softc->quirks &= ~SA_QUIRK_VARIABLE;
softc->quirks |= SA_QUIRK_FIXED;
} else {
softc->flags &= ~SA_FLAG_FIXED;
if (softc->max_blk == 0) {
softc->max_blk = ~0;
}
softc->blk_shift = 0;
if (softc->blk_gran != 0) {
softc->blk_mask =
softc->blk_gran - 1;
} else {
softc->blk_mask = 0;
}
/*
* Make the user's desire 'persistent'.
*/
softc->quirks |= SA_QUIRK_VARIABLE;
softc->quirks &= ~SA_QUIRK_FIXED;
}
}
break;
case MTSETDNSTY: /* Set density for device and mode */
PENDING_MOUNT_CHECK(softc, periph, dev);
if (count > UCHAR_MAX) {
error = EINVAL;
break;
} else {
error = sasetparams(periph, SA_PARAM_DENSITY,
0, count, 0, 0);
}
break;
case MTCOMP: /* enable compression */
PENDING_MOUNT_CHECK(softc, periph, dev);
/*
* Some devices don't support compression, and
* don't like it if you ask them for the
* compression page.
*/
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
if ((softc->quirks & SA_QUIRK_NOCOMP) ||
(softc->flags & SA_FLAG_COMP_UNSUPP)) {
error = ENODEV;
break;
}
error = sasetparams(periph, SA_PARAM_COMPRESSION,
0, 0, count, SF_NO_PRINT);
break;
default:
error = EINVAL;
}
break;
}
case MTIOCIEOT:
case MTIOCEEOT:
error = 0;
break;
case MTIOCRDSPOS:
PENDING_MOUNT_CHECK(softc, periph, dev);
error = sardpos(periph, 0, (u_int32_t *) arg);
break;
case MTIOCRDHPOS:
PENDING_MOUNT_CHECK(softc, periph, dev);
error = sardpos(periph, 1, (u_int32_t *) arg);
break;
case MTIOCSLOCATE:
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
case MTIOCHLOCATE: {
struct mtlocate locate_info;
int hard;
bzero(&locate_info, sizeof(locate_info));
locate_info.logical_id = *((uint32_t *)arg);
if (cmd == MTIOCSLOCATE)
hard = 0;
else
hard = 1;
PENDING_MOUNT_CHECK(softc, periph, dev);
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
error = sasetpos(periph, hard, &locate_info);
break;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
}
case MTIOCEXTLOCATE:
PENDING_MOUNT_CHECK(softc, periph, dev);
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
error = sasetpos(periph, /*hard*/ 0, (struct mtlocate *)arg);
softc->flags &=
~(SA_FLAG_TAPE_WRITTEN|SA_FLAG_TAPE_FROZEN);
softc->flags &= ~SA_FLAG_ERR_PENDING;
softc->filemarks = 0;
break;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
case MTIOCGETEOTMODEL:
error = 0;
if (softc->quirks & SA_QUIRK_1FM)
mode = 1;
else
mode = 2;
*((u_int32_t *) arg) = mode;
break;
case MTIOCSETEOTMODEL:
error = 0;
switch (*((u_int32_t *) arg)) {
case 1:
softc->quirks &= ~SA_QUIRK_2FM;
softc->quirks |= SA_QUIRK_1FM;
break;
case 2:
softc->quirks &= ~SA_QUIRK_1FM;
softc->quirks |= SA_QUIRK_2FM;
break;
default:
error = EINVAL;
break;
}
break;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
case MTIOCRBLIM: {
struct mtrblim *rblim;
rblim = (struct mtrblim *)arg;
rblim->granularity = softc->blk_gran;
rblim->min_block_length = softc->min_blk;
rblim->max_block_length = softc->max_blk;
break;
}
default:
error = cam_periph_ioctl(periph, cmd, arg, saerror);
break;
}
/*
* Check to see if we cleared a frozen state
*/
if (error == 0 && (softc->flags & SA_FLAG_TAPE_FROZEN)) {
switch(cmd) {
case MTIOCRDSPOS:
case MTIOCRDHPOS:
case MTIOCSLOCATE:
case MTIOCHLOCATE:
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
/*
* XXX KDM look at this.
*/
softc->fileno = (daddr_t) -1;
softc->blkno = (daddr_t) -1;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->rep_blkno = (daddr_t) -1;
softc->rep_fileno = (daddr_t) -1;
softc->partition = (daddr_t) -1;
softc->flags &= ~SA_FLAG_TAPE_FROZEN;
xpt_print(periph->path,
"tape state now unfrozen.\n");
break;
default:
break;
}
}
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
if (didlockperiph) {
cam_periph_unhold(periph);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
}
cam_periph_unlock(periph);
return (error);
}
static void
sainit(void)
{
cam_status status;
/*
* Install a global async callback.
*/
status = xpt_register_async(AC_FOUND_DEVICE, saasync, NULL, NULL);
if (status != CAM_REQ_CMP) {
printf("sa: Failed to attach master async callback "
"due to status 0x%x!\n", status);
}
}
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
static void
sadevgonecb(void *arg)
{
struct cam_periph *periph;
struct mtx *mtx;
struct sa_softc *softc;
periph = (struct cam_periph *)arg;
softc = (struct sa_softc *)periph->softc;
mtx = cam_periph_mtx(periph);
mtx_lock(mtx);
softc->num_devs_to_destroy--;
if (softc->num_devs_to_destroy == 0) {
int i;
/*
* When we have gotten all of our callbacks, we will get
* no more close calls from devfs. So if we have any
* dangling opens, we need to release the reference held
* for that particular context.
*/
for (i = 0; i < softc->open_count; i++)
cam_periph_release_locked(periph);
softc->open_count = 0;
/*
* Release the reference held for devfs, all of our
* instances are gone now.
*/
cam_periph_release_locked(periph);
}
/*
* We reference the lock directly here, instead of using
* cam_periph_unlock(). The reason is that the final call to
* cam_periph_release_locked() above could result in the periph
* getting freed. If that is the case, dereferencing the periph
* with a cam_periph_unlock() call would cause a page fault.
*/
mtx_unlock(mtx);
}
Fix a problem with the way we handled device invalidation when attaching to a device failed. In theory, the same steps that happen when we get an AC_LOST_DEVICE async notification should have been taken when a driver fails to attach. In practice, that wasn't the case. This only affected the da, cd and ch drivers, but the fix affects all peripheral drivers. There were several possible problems: - In the da driver, we didn't remove the peripheral's softc from the da driver's linked list of softcs. Once the peripheral and softc got removed, we'd get a kernel panic the next time the timeout routine called dasendorderedtag(). - In the da, cd and possibly ch drivers, we didn't remove the peripheral's devstat structure from the devstat queue. Once the peripheral and softc were removed, this could cause a panic if anyone tried to access device statistics. (one component of the linked list wouldn't exist anymore) - In the cd driver, we didn't take the peripheral off the changer run queue if it was scheduled to run. In practice, it's highly unlikely, and maybe impossible that the peripheral would have been on the changer run queue at that stage of the probe process. The fix is: - Add a new peripheral callback function (the "oninvalidate" function) that is called the first time cam_periph_invalidate() is called for a peripheral. - Create new foooninvalidate() routines for each peripheral driver. This routine is always called at splsoftcam(), and contains all the stuff that used to be in the AC_LOST_DEVICE case of the async callback handler. - Move the devstat cleanup call to the destructor/cleanup routines, since some of the drivers do I/O in their close routines. - Make sure that when we're flushing the buffer queue, we traverse it at splbio(). - Add a check for the invalid flag in the pt driver's open routine. Reviewed by: gibbs
1998-10-22 22:16:56 +00:00
static void
saoninvalidate(struct cam_periph *periph)
{
struct sa_softc *softc;
softc = (struct sa_softc *)periph->softc;
/*
* De-register any async callbacks.
*/
xpt_register_async(0, saasync, periph, periph->path);
Fix a problem with the way we handled device invalidation when attaching to a device failed. In theory, the same steps that happen when we get an AC_LOST_DEVICE async notification should have been taken when a driver fails to attach. In practice, that wasn't the case. This only affected the da, cd and ch drivers, but the fix affects all peripheral drivers. There were several possible problems: - In the da driver, we didn't remove the peripheral's softc from the da driver's linked list of softcs. Once the peripheral and softc got removed, we'd get a kernel panic the next time the timeout routine called dasendorderedtag(). - In the da, cd and possibly ch drivers, we didn't remove the peripheral's devstat structure from the devstat queue. Once the peripheral and softc were removed, this could cause a panic if anyone tried to access device statistics. (one component of the linked list wouldn't exist anymore) - In the cd driver, we didn't take the peripheral off the changer run queue if it was scheduled to run. In practice, it's highly unlikely, and maybe impossible that the peripheral would have been on the changer run queue at that stage of the probe process. The fix is: - Add a new peripheral callback function (the "oninvalidate" function) that is called the first time cam_periph_invalidate() is called for a peripheral. - Create new foooninvalidate() routines for each peripheral driver. This routine is always called at splsoftcam(), and contains all the stuff that used to be in the AC_LOST_DEVICE case of the async callback handler. - Move the devstat cleanup call to the destructor/cleanup routines, since some of the drivers do I/O in their close routines. - Make sure that when we're flushing the buffer queue, we traverse it at splbio(). - Add a check for the invalid flag in the pt driver's open routine. Reviewed by: gibbs
1998-10-22 22:16:56 +00:00
softc->flags |= SA_FLAG_INVALID;
/*
* Return all queued I/O with ENXIO.
* XXX Handle any transactions queued to the card
* with XPT_ABORT_CCB.
*/
bioq_flush(&softc->bio_queue, NULL, ENXIO);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
softc->queue_count = 0;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
/*
* Tell devfs that all of our devices have gone away, and ask for a
* callback when it has cleaned up its state.
*/
destroy_dev_sched_cb(softc->devs.ctl_dev, sadevgonecb, periph);
destroy_dev_sched_cb(softc->devs.r_dev, sadevgonecb, periph);
destroy_dev_sched_cb(softc->devs.nr_dev, sadevgonecb, periph);
destroy_dev_sched_cb(softc->devs.er_dev, sadevgonecb, periph);
Fix a problem with the way we handled device invalidation when attaching to a device failed. In theory, the same steps that happen when we get an AC_LOST_DEVICE async notification should have been taken when a driver fails to attach. In practice, that wasn't the case. This only affected the da, cd and ch drivers, but the fix affects all peripheral drivers. There were several possible problems: - In the da driver, we didn't remove the peripheral's softc from the da driver's linked list of softcs. Once the peripheral and softc got removed, we'd get a kernel panic the next time the timeout routine called dasendorderedtag(). - In the da, cd and possibly ch drivers, we didn't remove the peripheral's devstat structure from the devstat queue. Once the peripheral and softc were removed, this could cause a panic if anyone tried to access device statistics. (one component of the linked list wouldn't exist anymore) - In the cd driver, we didn't take the peripheral off the changer run queue if it was scheduled to run. In practice, it's highly unlikely, and maybe impossible that the peripheral would have been on the changer run queue at that stage of the probe process. The fix is: - Add a new peripheral callback function (the "oninvalidate" function) that is called the first time cam_periph_invalidate() is called for a peripheral. - Create new foooninvalidate() routines for each peripheral driver. This routine is always called at splsoftcam(), and contains all the stuff that used to be in the AC_LOST_DEVICE case of the async callback handler. - Move the devstat cleanup call to the destructor/cleanup routines, since some of the drivers do I/O in their close routines. - Make sure that when we're flushing the buffer queue, we traverse it at splbio(). - Add a check for the invalid flag in the pt driver's open routine. Reviewed by: gibbs
1998-10-22 22:16:56 +00:00
}
static void
sacleanup(struct cam_periph *periph)
{
Fix a problem with the way we handled device invalidation when attaching to a device failed. In theory, the same steps that happen when we get an AC_LOST_DEVICE async notification should have been taken when a driver fails to attach. In practice, that wasn't the case. This only affected the da, cd and ch drivers, but the fix affects all peripheral drivers. There were several possible problems: - In the da driver, we didn't remove the peripheral's softc from the da driver's linked list of softcs. Once the peripheral and softc got removed, we'd get a kernel panic the next time the timeout routine called dasendorderedtag(). - In the da, cd and possibly ch drivers, we didn't remove the peripheral's devstat structure from the devstat queue. Once the peripheral and softc were removed, this could cause a panic if anyone tried to access device statistics. (one component of the linked list wouldn't exist anymore) - In the cd driver, we didn't take the peripheral off the changer run queue if it was scheduled to run. In practice, it's highly unlikely, and maybe impossible that the peripheral would have been on the changer run queue at that stage of the probe process. The fix is: - Add a new peripheral callback function (the "oninvalidate" function) that is called the first time cam_periph_invalidate() is called for a peripheral. - Create new foooninvalidate() routines for each peripheral driver. This routine is always called at splsoftcam(), and contains all the stuff that used to be in the AC_LOST_DEVICE case of the async callback handler. - Move the devstat cleanup call to the destructor/cleanup routines, since some of the drivers do I/O in their close routines. - Make sure that when we're flushing the buffer queue, we traverse it at splbio(). - Add a check for the invalid flag in the pt driver's open routine. Reviewed by: gibbs
1998-10-22 22:16:56 +00:00
struct sa_softc *softc;
softc = (struct sa_softc *)periph->softc;
cam_periph_unlock(periph);
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
if ((softc->flags & SA_FLAG_SCTX_INIT) != 0
&& sysctl_ctx_free(&softc->sysctl_ctx) != 0)
xpt_print(periph->path, "can't remove sysctl context\n");
cam_periph_lock(periph);
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
devstat_remove_entry(softc->device_stats);
free(softc, M_SCSISA);
}
static void
saasync(void *callback_arg, u_int32_t code,
struct cam_path *path, void *arg)
{
struct cam_periph *periph;
periph = (struct cam_periph *)callback_arg;
switch (code) {
case AC_FOUND_DEVICE:
{
struct ccb_getdev *cgd;
cam_status status;
cgd = (struct ccb_getdev *)arg;
if (cgd == NULL)
break;
Separate the parallel scsi knowledge out of the core of the XPT, and modularize it so that new transports can be created. Add a transport for SATA Add a periph+protocol layer for ATA Add a driver for AHCI-compliant hardware. Add a maxio field to CAM so that drivers can advertise their max I/O capability. Modify various drivers so that they are insulated from the value of MAXPHYS. The new ATA/SATA code supports AHCI-compliant hardware, and will override the classic ATA driver if it is loaded as a module at boot time or compiled into the kernel. The stack now support NCQ (tagged queueing) for increased performance on modern SATA drives. It also supports port multipliers. ATA drives are accessed via 'ada' device nodes. ATAPI drives are accessed via 'cd' device nodes. They can all be enumerated and manipulated via camcontrol, just like SCSI drives. SCSI commands are not translated to their ATA equivalents; ATA native commands are used throughout the entire stack, including camcontrol. See the camcontrol manpage for further details. Testing this code may require that you update your fstab, and possibly modify your BIOS to enable AHCI functionality, if available. This code is very experimental at the moment. The userland ABI/API has changed, so applications will need to be recompiled. It may change further in the near future. The 'ada' device name may also change as more infrastructure is completed in this project. The goal is to eventually put all CAM busses and devices until newbus, allowing for interesting topology and management options. Few functional changes will be seen with existing SCSI/SAS/FC drivers, though the userland ABI has still changed. In the future, transports specific modules for SAS and FC may appear in order to better support the topologies and capabilities of these technologies. The modularization of CAM and the addition of the ATA/SATA modules is meant to break CAM out of the mold of being specific to SCSI, letting it grow to be a framework for arbitrary transports and protocols. It also allows drivers to be written to support discrete hardware without jeopardizing the stability of non-related hardware. While only an AHCI driver is provided now, a Silicon Image driver is also in the works. Drivers for ICH1-4, ICH5-6, PIIX, classic IDE, and any other hardware is possible and encouraged. Help with new transports is also encouraged. Submitted by: scottl, mav Approved by: re
2009-07-10 08:18:08 +00:00
if (cgd->protocol != PROTO_SCSI)
break;
if (SID_QUAL(&cgd->inq_data) != SID_QUAL_LU_CONNECTED)
break;
if (SID_TYPE(&cgd->inq_data) != T_SEQUENTIAL)
break;
/*
* Allocate a peripheral instance for
* this device and start the probe
* process.
*/
Fix a problem with the way we handled device invalidation when attaching to a device failed. In theory, the same steps that happen when we get an AC_LOST_DEVICE async notification should have been taken when a driver fails to attach. In practice, that wasn't the case. This only affected the da, cd and ch drivers, but the fix affects all peripheral drivers. There were several possible problems: - In the da driver, we didn't remove the peripheral's softc from the da driver's linked list of softcs. Once the peripheral and softc got removed, we'd get a kernel panic the next time the timeout routine called dasendorderedtag(). - In the da, cd and possibly ch drivers, we didn't remove the peripheral's devstat structure from the devstat queue. Once the peripheral and softc were removed, this could cause a panic if anyone tried to access device statistics. (one component of the linked list wouldn't exist anymore) - In the cd driver, we didn't take the peripheral off the changer run queue if it was scheduled to run. In practice, it's highly unlikely, and maybe impossible that the peripheral would have been on the changer run queue at that stage of the probe process. The fix is: - Add a new peripheral callback function (the "oninvalidate" function) that is called the first time cam_periph_invalidate() is called for a peripheral. - Create new foooninvalidate() routines for each peripheral driver. This routine is always called at splsoftcam(), and contains all the stuff that used to be in the AC_LOST_DEVICE case of the async callback handler. - Move the devstat cleanup call to the destructor/cleanup routines, since some of the drivers do I/O in their close routines. - Make sure that when we're flushing the buffer queue, we traverse it at splbio(). - Add a check for the invalid flag in the pt driver's open routine. Reviewed by: gibbs
1998-10-22 22:16:56 +00:00
status = cam_periph_alloc(saregister, saoninvalidate,
sacleanup, sastart,
Merge CAM locking changes from the projects/camlock branch to radically reduce lock congestion and improve SMP scalability of the SCSI/ATA stack, preparing the ground for the coming next GEOM direct dispatch support. Replace big per-SIM locks with bunch of smaller ones: - per-LUN locks to protect device and peripheral drivers state; - per-target locks to protect list of LUNs on target; - per-bus locks to protect reference counting; - per-send queue locks to protect queue of CCBs to be sent; - per-done queue locks to protect queue of completed CCBs; - remaining per-SIM locks now protect only HBA driver internals. While holding LUN lock it is allowed (while not recommended for performance reasons) to take SIM lock. The opposite acquisition order is forbidden. All the other locks are leaf locks, that can be taken anywhere, but should not be cascaded. Many functions, such as: xpt_action(), xpt_done(), xpt_async(), xpt_create_path(), etc. are no longer require (but allow) SIM lock to be held. To keep compatibility and solve cases where SIM lock can't be dropped, all xpt_async() calls in addition to xpt_done() calls are queued to completion threads for async processing in clean environment without SIM lock held. Instead of single CAM SWI thread, used for commands completion processing before, use multiple (depending on number of CPUs) threads. Load balanced between them using "hash" of the device B:T:L address. HBA drivers that can drop SIM lock during completion processing and have sufficient number of completion threads to efficiently scale to multiple CPUs can use new function xpt_done_direct() to avoid extra context switch. Make ahci(4) driver to use this mechanism depending on hardware setup. Sponsored by: iXsystems, Inc. MFC after: 2 months
2013-10-21 12:00:26 +00:00
"sa", CAM_PERIPH_BIO, path,
saasync, AC_FOUND_DEVICE, cgd);
if (status != CAM_REQ_CMP
&& status != CAM_REQ_INPROG)
printf("saasync: Unable to probe new device "
"due to status 0x%x\n", status);
break;
}
default:
cam_periph_async(periph, code, path, arg);
break;
}
}
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
static void
sasetupdev(struct sa_softc *softc, struct cdev *dev)
{
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
dev->si_iosize_max = softc->maxio;
dev->si_flags |= softc->si_flags;
/*
* Keep a count of how many non-alias devices we have created,
* so we can make sure we clean them all up on shutdown. Aliases
* are cleaned up when we destroy the device they're an alias for.
*/
if ((dev->si_flags & SI_ALIAS) == 0)
softc->num_devs_to_destroy++;
}
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
static void
sasysctlinit(void *context, int pending)
{
struct cam_periph *periph;
struct sa_softc *softc;
char tmpstr[80], tmpstr2[80];
periph = (struct cam_periph *)context;
/*
* If the periph is invalid, no need to setup the sysctls.
*/
if (periph->flags & CAM_PERIPH_INVALID)
goto bailout;
softc = (struct sa_softc *)periph->softc;
snprintf(tmpstr, sizeof(tmpstr), "CAM SA unit %d", periph->unit_number);
snprintf(tmpstr2, sizeof(tmpstr2), "%u", periph->unit_number);
sysctl_ctx_init(&softc->sysctl_ctx);
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->flags |= SA_FLAG_SCTX_INIT;
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx,
SYSCTL_STATIC_CHILDREN(_kern_cam_sa), OID_AUTO, tmpstr2,
CTLFLAG_RD, 0, tmpstr);
if (softc->sysctl_tree == NULL)
goto bailout;
SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "allow_io_split", CTLFLAG_RDTUN | CTLFLAG_NOFETCH,
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
&softc->allow_io_split, 0, "Allow Splitting I/O");
SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "maxio", CTLFLAG_RD,
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
&softc->maxio, 0, "Maximum I/O size");
SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "cpi_maxio", CTLFLAG_RD,
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
&softc->cpi_maxio, 0, "Maximum Controller I/O size");
bailout:
/*
* Release the reference that was held when this task was enqueued.
*/
cam_periph_release(periph);
}
static cam_status
saregister(struct cam_periph *periph, void *arg)
{
struct sa_softc *softc;
struct ccb_getdev *cgd;
struct ccb_pathinq cpi;
struct make_dev_args args;
caddr_t match;
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
char tmpstr[80];
int error;
cgd = (struct ccb_getdev *)arg;
if (cgd == NULL) {
printf("saregister: no getdev CCB, can't register device\n");
return (CAM_REQ_CMP_ERR);
}
softc = (struct sa_softc *)
malloc(sizeof (*softc), M_SCSISA, M_NOWAIT | M_ZERO);
if (softc == NULL) {
printf("saregister: Unable to probe new device. "
"Unable to allocate softc\n");
return (CAM_REQ_CMP_ERR);
}
softc->scsi_rev = SID_ANSI_REV(&cgd->inq_data);
softc->state = SA_STATE_NORMAL;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->fileno = (daddr_t) -1;
softc->blkno = (daddr_t) -1;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->rep_fileno = (daddr_t) -1;
softc->rep_blkno = (daddr_t) -1;
softc->partition = (daddr_t) -1;
softc->bop = -1;
softc->eop = -1;
softc->bpew = -1;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
bioq_init(&softc->bio_queue);
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->periph = periph;
periph->softc = softc;
/*
* See if this device has any quirks.
*/
match = cam_quirkmatch((caddr_t)&cgd->inq_data,
(caddr_t)sa_quirk_table,
nitems(sa_quirk_table),
sizeof(*sa_quirk_table), scsi_inquiry_match);
if (match != NULL) {
softc->quirks = ((struct sa_quirk_entry *)match)->quirks;
softc->last_media_blksize =
((struct sa_quirk_entry *)match)->prefblk;
} else
softc->quirks = SA_QUIRK_NONE;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
/*
* Long format data for READ POSITION was introduced in SSC, which
* was after SCSI-2. (Roughly equivalent to SCSI-3.) If the drive
* reports that it is SCSI-2 or older, it is unlikely to support
* long position data, but it might. Some drives from that era
* claim to be SCSI-2, but do support long position information.
* So, instead of immediately disabling long position information
* for SCSI-2 devices, we'll try one pass through sagetpos(), and
* then disable long position information if we get an error.
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
*/
if (cgd->inq_data.version <= SCSI_REV_CCS)
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->quirks |= SA_QUIRK_NO_LONG_POS;
if (cgd->inq_data.spc3_flags & SPC3_SID_PROTECT) {
struct ccb_dev_advinfo cdai;
struct scsi_vpd_extended_inquiry_data ext_inq;
bzero(&ext_inq, sizeof(ext_inq));
xpt_setup_ccb(&cdai.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
cdai.ccb_h.func_code = XPT_DEV_ADVINFO;
cdai.flags = CDAI_FLAG_NONE;
cdai.buftype = CDAI_TYPE_EXT_INQ;
cdai.bufsiz = sizeof(ext_inq);
cdai.buf = (uint8_t *)&ext_inq;
xpt_action((union ccb *)&cdai);
if ((cdai.ccb_h.status & CAM_DEV_QFRZN) != 0)
cam_release_devq(cdai.ccb_h.path, 0, 0, 0, FALSE);
if ((cdai.ccb_h.status == CAM_REQ_CMP)
&& (ext_inq.flags1 & SVPD_EID_SA_SPT_LBP))
softc->flags |= SA_FLAG_PROTECT_SUPP;
}
bzero(&cpi, sizeof(cpi));
xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
cpi.ccb_h.func_code = XPT_PATH_INQ;
xpt_action((union ccb *)&cpi);
/*
* The SA driver supports a blocksize, but we don't know the
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
* blocksize until we media is inserted. So, set a flag to
* indicate that the blocksize is unavailable right now.
*/
cam_periph_unlock(periph);
softc->device_stats = devstat_new_entry("sa", periph->unit_number, 0,
DEVSTAT_BS_UNAVAILABLE, SID_TYPE(&cgd->inq_data) |
XPORT_DEVSTAT_TYPE(cpi.transport), DEVSTAT_PRIORITY_TAPE);
/*
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
* Load the default value that is either compiled in, or loaded
* in the global kern.cam.sa.allow_io_split tunable.
*/
softc->allow_io_split = sa_allow_io_split;
/*
* Load a per-instance tunable, if it exists. NOTE that this
* tunable WILL GO AWAY in FreeBSD 11.0.
*/
snprintf(tmpstr, sizeof(tmpstr), "kern.cam.sa.%u.allow_io_split",
periph->unit_number);
TUNABLE_INT_FETCH(tmpstr, &softc->allow_io_split);
/*
* If maxio isn't set, we fall back to DFLTPHYS. Otherwise we take
* the smaller of cpi.maxio or MAXPHYS.
*/
if (cpi.maxio == 0)
softc->maxio = DFLTPHYS;
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
else if (cpi.maxio > MAXPHYS)
softc->maxio = MAXPHYS;
else
softc->maxio = cpi.maxio;
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
/*
* Record the controller's maximum I/O size so we can report it to
* the user later.
*/
softc->cpi_maxio = cpi.maxio;
/*
* By default we tell physio that we do not want our I/O split.
* The user needs to have a 1:1 mapping between the size of his
* write to a tape character device and the size of the write
* that actually goes down to the drive.
*/
if (softc->allow_io_split == 0)
softc->si_flags = SI_NOSPLIT;
else
softc->si_flags = 0;
TASK_INIT(&softc->sysctl_task, 0, sasysctlinit, periph);
/*
* If the SIM supports unmapped I/O, let physio know that we can
* handle unmapped buffers.
*/
if (cpi.hba_misc & PIM_UNMAPPED)
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
softc->si_flags |= SI_UNMAPPED;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
/*
* Acquire a reference to the periph before we create the devfs
* instances for it. We'll release this reference once the devfs
* instances have been freed.
*/
if (cam_periph_acquire(periph) != CAM_REQ_CMP) {
xpt_print(periph->path, "%s: lost periph during "
"registration!\n", __func__);
cam_periph_lock(periph);
return (CAM_REQ_CMP_ERR);
}
make_dev_args_init(&args);
args.mda_devsw = &sa_cdevsw;
args.mda_si_drv1 = softc->periph;
args.mda_uid = UID_ROOT;
args.mda_gid = GID_OPERATOR;
args.mda_mode = 0660;
args.mda_unit = SAMINOR(SA_CTLDEV, SA_ATYPE_R);
error = make_dev_s(&args, &softc->devs.ctl_dev, "%s%d.ctl",
periph->periph_name, periph->unit_number);
if (error != 0) {
cam_periph_lock(periph);
return (CAM_REQ_CMP_ERR);
}
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
sasetupdev(softc, softc->devs.ctl_dev);
args.mda_unit = SAMINOR(SA_NOT_CTLDEV, SA_ATYPE_R);
error = make_dev_s(&args, &softc->devs.r_dev, "%s%d",
periph->periph_name, periph->unit_number);
if (error != 0) {
cam_periph_lock(periph);
return (CAM_REQ_CMP_ERR);
}
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
sasetupdev(softc, softc->devs.r_dev);
args.mda_unit = SAMINOR(SA_NOT_CTLDEV, SA_ATYPE_NR);
error = make_dev_s(&args, &softc->devs.nr_dev, "n%s%d",
periph->periph_name, periph->unit_number);
if (error != 0) {
cam_periph_lock(periph);
return (CAM_REQ_CMP_ERR);
}
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
sasetupdev(softc, softc->devs.nr_dev);
args.mda_unit = SAMINOR(SA_NOT_CTLDEV, SA_ATYPE_ER);
error = make_dev_s(&args, &softc->devs.er_dev, "e%s%d",
periph->periph_name, periph->unit_number);
if (error != 0) {
cam_periph_lock(periph);
return (CAM_REQ_CMP_ERR);
}
sasetupdev(softc, softc->devs.er_dev);
2007-04-19 18:14:33 +00:00
cam_periph_lock(periph);
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->density_type_bits[0] = 0;
softc->density_type_bits[1] = SRDS_MEDIA;
softc->density_type_bits[2] = SRDS_MEDIUM_TYPE;
softc->density_type_bits[3] = SRDS_MEDIUM_TYPE | SRDS_MEDIA;
Add support to physio(9) for devices that don't want I/O split and configure sa(4) to request no I/O splitting by default. For tape devices, the user needs to be able to clearly understand what blocksize is actually being used when writing to a tape device. The previous behavior of physio(9) was that it would split up any I/O that was too large for the device, or too large to fit into MAXPHYS. This means that if, for instance, the user wrote a 1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write would be split into 8 128K chunks. This would be done without informing the user. This has suboptimal effects, especially when trying to communicate status to the user. In the event of an error writing to a tape (e.g. physical end of tape) in the middle of a 1MB block that has been split into 8 pieces, the user could have the first two 128K pieces written successfully, the third returned with an error, and the last 5 returned with 0 bytes written. If the user is using a standard write(2) system call, all he will see is the ENOSPC error. He won't have a clue how much actually got written. (With a writev(2) system call, he should be able to determine how much got written in addition to the error.) The solution is to prevent physio(9) from splitting the I/O. The new cdev flag, SI_NOSPLIT, tells physio that the driver does not want I/O to be split beforehand. Although the sa(4) driver now enables SI_NOSPLIT by default, that can be disabled by two loader tunables for now. It will not be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split allows the user to configure I/O splitting for all sa(4) driver instances. kern.cam.sa.%d.allow_io_split allows the user to configure I/O splitting for a specific sa(4) instance. There are also now three sa(4) driver sysctl variables that let the users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows the maximum I/O size allowed by kernel configuration parameters (e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller. kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by the controller. Note that a better long term solution would be to implement support for chaining buffers, so that that MAXPHYS is no longer a limiting factor for I/O size to tape and disk devices. At that point, the controller and the tape drive would become the limiting factors. sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a driver to tell physio not to split up I/O. sys/param.h: Bump __FreeBSD_version to 1000049 for the addition of the SI_NOSPLIT cdev flag. kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return any I/O that is larger than si_iosize_max or MAXPHYS, has more than one segment, or would have to be split because of misalignment with EFBIG. (File too large). In the event of an error, print a console message to give the user a clue about what happened. scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created for the sa(4) driver by default. Add tunables to control whether we allow I/O splitting in physio(9). Explain in the comments that allowing I/O splitting will be deprecated for the sa(4) driver in FreeBSD 11.0. Add sysctl variables to display the maximum I/O size we can do (which could be further limited by read block limits) and the maximum I/O size that the controller can do. Limit our maximum I/O size (recorded in the cdev's si_iosize_max) by MAXPHYS. This isn't strictly necessary, because physio(9) will limit it to MAXPHYS, but it will provide some clarity for the application. Record the controller's maximum I/O size reported in the Path Inquiry CCB. sa.4: Document the block size behavior, and explain that the option of allowing physio(9) to split the I/O will disappear in FreeBSD 11.0. Sponsored by: Spectra Logic
2013-08-24 04:52:22 +00:00
/*
* Bump the peripheral refcount for the sysctl thread, in case we
* get invalidated before the thread has a chance to run.
*/
cam_periph_acquire(periph);
taskqueue_enqueue(taskqueue_thread, &softc->sysctl_task);
/*
* Add an async callback so that we get
* notified if this device goes away.
*/
xpt_register_async(AC_LOST_DEVICE, saasync, periph, periph->path);
xpt_announce_periph(periph, NULL);
xpt_announce_quirks(periph, softc->quirks, SA_QUIRK_BIT_STRING);
return (CAM_REQ_CMP);
}
static void
sastart(struct cam_periph *periph, union ccb *start_ccb)
{
struct sa_softc *softc;
softc = (struct sa_softc *)periph->softc;
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sastart\n"));
switch (softc->state) {
case SA_STATE_NORMAL:
{
/* Pull a buffer from the queue and get going on it */
struct bio *bp;
/*
* See if there is a buf with work for us to do..
*/
bp = bioq_first(&softc->bio_queue);
Merge CAM locking changes from the projects/camlock branch to radically reduce lock congestion and improve SMP scalability of the SCSI/ATA stack, preparing the ground for the coming next GEOM direct dispatch support. Replace big per-SIM locks with bunch of smaller ones: - per-LUN locks to protect device and peripheral drivers state; - per-target locks to protect list of LUNs on target; - per-bus locks to protect reference counting; - per-send queue locks to protect queue of CCBs to be sent; - per-done queue locks to protect queue of completed CCBs; - remaining per-SIM locks now protect only HBA driver internals. While holding LUN lock it is allowed (while not recommended for performance reasons) to take SIM lock. The opposite acquisition order is forbidden. All the other locks are leaf locks, that can be taken anywhere, but should not be cascaded. Many functions, such as: xpt_action(), xpt_done(), xpt_async(), xpt_create_path(), etc. are no longer require (but allow) SIM lock to be held. To keep compatibility and solve cases where SIM lock can't be dropped, all xpt_async() calls in addition to xpt_done() calls are queued to completion threads for async processing in clean environment without SIM lock held. Instead of single CAM SWI thread, used for commands completion processing before, use multiple (depending on number of CPUs) threads. Load balanced between them using "hash" of the device B:T:L address. HBA drivers that can drop SIM lock during completion processing and have sufficient number of completion threads to efficiently scale to multiple CPUs can use new function xpt_done_direct() to avoid extra context switch. Make ahci(4) driver to use this mechanism depending on hardware setup. Sponsored by: iXsystems, Inc. MFC after: 2 months
2013-10-21 12:00:26 +00:00
if (bp == NULL) {
xpt_release_ccb(start_ccb);
} else if ((softc->flags & SA_FLAG_ERR_PENDING) != 0) {
struct bio *done_bp;
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
again:
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
softc->queue_count--;
bioq_remove(&softc->bio_queue, bp);
bp->bio_resid = bp->bio_bcount;
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
done_bp = bp;
if ((softc->flags & SA_FLAG_EOM_PENDING) != 0) {
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
/*
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
* We have two different behaviors for
* writes when we hit either Early Warning
* or the PEWZ (Programmable Early Warning
* Zone). The default behavior is that
* for all writes that are currently
* queued after the write where we saw the
* early warning, we will return the write
* with the residual equal to the count.
* i.e. tell the application that 0 bytes
* were written.
*
* The alternate behavior, which is enabled
* when eot_warn is set, is that in
* addition to setting the residual equal
* to the count, we will set the error
* to ENOSPC.
*
* In either case, once queued writes are
* cleared out, we clear the error flag
* (see below) and the application is free to
* attempt to write more.
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
*/
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
if (softc->eot_warn != 0) {
bp->bio_flags |= BIO_ERROR;
bp->bio_error = ENOSPC;
} else
bp->bio_error = 0;
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
} else if ((softc->flags & SA_FLAG_EOF_PENDING) != 0) {
/*
* This can only happen if we're reading
* in fixed length mode. In this case,
* we dump the rest of the list the
* same way.
*/
bp->bio_error = 0;
if (bioq_first(&softc->bio_queue) != NULL) {
biodone(done_bp);
goto again;
}
} else if ((softc->flags & SA_FLAG_EIO_PENDING) != 0) {
bp->bio_error = EIO;
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
bp->bio_flags |= BIO_ERROR;
}
bp = bioq_first(&softc->bio_queue);
/*
* Only if we have no other buffers queued up
* do we clear the pending error flag.
*/
if (bp == NULL)
softc->flags &= ~SA_FLAG_ERR_PENDING;
CAM_DEBUG(periph->path, CAM_DEBUG_INFO,
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
("sastart- ERR_PENDING now 0x%x, bp is %sNULL, "
"%d more buffers queued up\n",
(softc->flags & SA_FLAG_ERR_PENDING),
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
(bp != NULL)? "not " : " ", softc->queue_count));
xpt_release_ccb(start_ccb);
biodone(done_bp);
} else {
u_int32_t length;
bioq_remove(&softc->bio_queue, bp);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
softc->queue_count--;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
length = bp->bio_bcount;
if ((softc->flags & SA_FLAG_FIXED) != 0) {
if (softc->blk_shift != 0) {
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
length = length >> softc->blk_shift;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
} else if (softc->media_blksize != 0) {
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
length = length / softc->media_blksize;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
} else {
bp->bio_error = EIO;
xpt_print(periph->path, "zero blocksize"
" for FIXED length writes?\n");
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
biodone(bp);
break;
}
#if 0
CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_INFO,
("issuing a %d fixed record %s\n",
length, (bp->bio_cmd == BIO_READ)? "read" :
"write"));
#endif
} else {
#if 0
CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_INFO,
("issuing a %d variable byte %s\n",
length, (bp->bio_cmd == BIO_READ)? "read" :
"write"));
#endif
}
devstat_start_transaction_bio(softc->device_stats, bp);
/*
* Some people have theorized that we should
* suppress illegal length indication if we are
* running in variable block mode so that we don't
* have to request sense every time our requested
* block size is larger than the written block.
* The residual information from the ccb allows
* us to identify this situation anyway. The only
* problem with this is that we will not get
* information about blocks that are larger than
* our read buffer unless we set the block size
* in the mode page to something other than 0.
*
* I believe that this is a non-issue. If user apps
* don't adjust their read size to match our record
* size, that's just life. Anyway, the typical usage
* would be to issue, e.g., 64KB reads and occasionally
* have to do deal with 512 byte or 1KB intermediate
* records.
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
*
* That said, though, we now support setting the
* SILI bit on reads, and we set the blocksize to 4
* bytes when we do that. This gives us
* compatibility with software that wants this,
* although the only real difference between that
* and not setting the SILI bit on reads is that we
* won't get a check condition on reads where our
* request size is larger than the block on tape.
* That probably only makes a real difference in
* non-packetized SCSI, where you have to go back
* to the drive to request sense and thus incur
* more latency.
*/
softc->dsreg = (bp->bio_cmd == BIO_READ)?
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
MTIO_DSREG_RD : MTIO_DSREG_WR;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
scsi_sa_read_write(&start_ccb->csio, 0, sadone,
MSG_SIMPLE_Q_TAG, (bp->bio_cmd == BIO_READ ?
SCSI_RW_READ : SCSI_RW_WRITE) |
((bp->bio_flags & BIO_UNMAPPED) != 0 ?
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
SCSI_RW_BIO : 0), softc->sili,
(softc->flags & SA_FLAG_FIXED) != 0, length,
(bp->bio_flags & BIO_UNMAPPED) != 0 ? (void *)bp :
bp->bio_data, bp->bio_bcount, SSD_FULL_SIZE,
IO_TIMEOUT);
start_ccb->ccb_h.ccb_pflags &= ~SA_POSITION_UPDATED;
start_ccb->ccb_h.ccb_bp = bp;
bp = bioq_first(&softc->bio_queue);
xpt_action(start_ccb);
}
if (bp != NULL) {
/* Have more work to do, so ensure we stay scheduled */
xpt_schedule(periph, CAM_PRIORITY_NORMAL);
}
break;
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
case SA_STATE_ABNORMAL:
default:
panic("state 0x%x in sastart", softc->state);
break;
}
}
static void
sadone(struct cam_periph *periph, union ccb *done_ccb)
{
struct sa_softc *softc;
struct ccb_scsiio *csio;
struct bio *bp;
int error;
softc = (struct sa_softc *)periph->softc;
csio = &done_ccb->csio;
softc->dsreg = MTIO_DSREG_REST;
bp = (struct bio *)done_ccb->ccb_h.ccb_bp;
error = 0;
if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
if ((error = saerror(done_ccb, 0, 0)) == ERESTART) {
/*
* A retry was scheduled, so just return.
*/
return;
}
}
if (error == EIO) {
/*
* Catastrophic error. Mark the tape as frozen
* (we no longer know tape position).
*
* Return all queued I/O with EIO, and unfreeze
* our queue so that future transactions that
* attempt to fix this problem can get to the
* device.
*
*/
softc->flags |= SA_FLAG_TAPE_FROZEN;
bioq_flush(&softc->bio_queue, NULL, EIO);
}
if (error != 0) {
bp->bio_resid = bp->bio_bcount;
bp->bio_error = error;
bp->bio_flags |= BIO_ERROR;
/*
* In the error case, position is updated in saerror.
*/
} else {
bp->bio_resid = csio->resid;
bp->bio_error = 0;
if (csio->resid != 0) {
bp->bio_flags |= BIO_ERROR;
}
if (bp->bio_cmd == BIO_WRITE) {
softc->flags |= SA_FLAG_TAPE_WRITTEN;
softc->filemarks = 0;
}
if (!(csio->ccb_h.ccb_pflags & SA_POSITION_UPDATED) &&
(softc->blkno != (daddr_t) -1)) {
if ((softc->flags & SA_FLAG_FIXED) != 0) {
u_int32_t l;
if (softc->blk_shift != 0) {
l = bp->bio_bcount >>
softc->blk_shift;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
} else {
l = bp->bio_bcount /
softc->media_blksize;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
}
softc->blkno += (daddr_t) l;
} else {
softc->blkno++;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
}
}
}
/*
* If we had an error (immediate or pending),
* release the device queue now.
*/
if (error || (softc->flags & SA_FLAG_ERR_PENDING))
cam_release_devq(done_ccb->ccb_h.path, 0, 0, 0, 0);
if (error || bp->bio_resid) {
CAM_DEBUG(periph->path, CAM_DEBUG_INFO,
("error %d resid %ld count %ld\n", error,
bp->bio_resid, bp->bio_bcount));
}
biofinish(bp, softc->device_stats, 0);
xpt_release_ccb(done_ccb);
}
/*
* Mount the tape (make sure it's ready for I/O).
*/
static int
samount(struct cam_periph *periph, int oflags, struct cdev *dev)
{
struct sa_softc *softc;
union ccb *ccb;
int error;
/*
* oflags can be checked for 'kind' of open (read-only check) - later
* dev can be checked for a control-mode or compression open - later
*/
UNUSED_PARAMETER(oflags);
UNUSED_PARAMETER(dev);
softc = (struct sa_softc *)periph->softc;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
/*
* This should determine if something has happend since the last
* open/mount that would invalidate the mount. We do *not* want
* to retry this command- we just want the status. But we only
* do this if we're mounted already- if we're not mounted,
* we don't care about the unit read state and can instead use
* this opportunity to attempt to reserve the tape unit.
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
*/
if (softc->flags & SA_FLAG_TAPE_MOUNTED) {
ccb = cam_periph_getccb(periph, 1);
scsi_test_unit_ready(&ccb->csio, 0, sadone,
MSG_SIMPLE_Q_TAG, SSD_FULL_SIZE, IO_TIMEOUT);
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
softc->device_stats);
if (error == ENXIO) {
softc->flags &= ~SA_FLAG_TAPE_MOUNTED;
scsi_test_unit_ready(&ccb->csio, 0, sadone,
MSG_SIMPLE_Q_TAG, SSD_FULL_SIZE, IO_TIMEOUT);
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
softc->device_stats);
} else if (error) {
/*
* We don't need to freeze the tape because we
* will now attempt to rewind/load it.
*/
softc->flags &= ~SA_FLAG_TAPE_MOUNTED;
if (CAM_DEBUGGED(periph->path, CAM_DEBUG_INFO)) {
xpt_print(periph->path,
"error %d on TUR in samount\n", error);
}
}
} else {
error = sareservereleaseunit(periph, TRUE);
if (error) {
return (error);
}
ccb = cam_periph_getccb(periph, 1);
scsi_test_unit_ready(&ccb->csio, 0, sadone,
MSG_SIMPLE_Q_TAG, SSD_FULL_SIZE, IO_TIMEOUT);
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
softc->device_stats);
}
if ((softc->flags & SA_FLAG_TAPE_MOUNTED) == 0) {
struct scsi_read_block_limits_data *rblim = NULL;
int comp_enabled, comp_supported;
u_int8_t write_protect, guessing = 0;
/*
* Clear out old state.
*/
softc->flags &= ~(SA_FLAG_TAPE_WP|SA_FLAG_TAPE_WRITTEN|
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
SA_FLAG_ERR_PENDING|SA_FLAG_COMPRESSION);
softc->filemarks = 0;
/*
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
* *Very* first off, make sure we're loaded to BOT.
*/
scsi_load_unload(&ccb->csio, 2, sadone, MSG_SIMPLE_Q_TAG, FALSE,
FALSE, FALSE, 1, SSD_FULL_SIZE, REWIND_TIMEOUT);
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
softc->device_stats);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
/*
* In case this doesn't work, do a REWIND instead
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
*/
if (error) {
scsi_rewind(&ccb->csio, 2, sadone, MSG_SIMPLE_Q_TAG,
FALSE, SSD_FULL_SIZE, REWIND_TIMEOUT);
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
softc->device_stats);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
}
if (error) {
xpt_release_ccb(ccb);
goto exit;
}
/*
* Do a dummy test read to force access to the
* media so that the drive will really know what's
* there. We actually don't really care what the
* blocksize on tape is and don't expect to really
* read a full record.
*/
rblim = (struct scsi_read_block_limits_data *)
malloc(8192, M_SCSISA, M_NOWAIT);
if (rblim == NULL) {
xpt_print(periph->path, "no memory for test read\n");
xpt_release_ccb(ccb);
error = ENOMEM;
goto exit;
}
if ((softc->quirks & SA_QUIRK_NODREAD) == 0) {
scsi_sa_read_write(&ccb->csio, 0, sadone,
MSG_SIMPLE_Q_TAG, 1, FALSE, 0, 8192,
(void *) rblim, 8192, SSD_FULL_SIZE,
IO_TIMEOUT);
(void) cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
softc->device_stats);
scsi_rewind(&ccb->csio, 1, sadone, MSG_SIMPLE_Q_TAG,
FALSE, SSD_FULL_SIZE, REWIND_TIMEOUT);
Rewrite of the CAM error recovery code. Some of the major changes include: - The SCSI error handling portion of cam_periph_error() has been broken out into a number of subfunctions to better modularize the code that handles the hierarchy of SCSI errors. As a result, the code is now much easier to read. - String handling and error printing has been significantly revamped. We now use sbufs to do string formatting instead of using printfs (for the kernel) and snprintf/strncat (for userland) as before. There is a new catchall error printing routine, cam_error_print() and its string-based counterpart, cam_error_string() that allow the kernel and userland applications to pass in a CCB and have errors printed out properly, whether or not they're SCSI errors. Among other things, this helped eliminate a fair amount of duplicate code in camcontrol. We now print out more information than before, including the CAM status and SCSI status and the error recovery action taken to remedy the problem. - sbufs are now available in userland, via libsbuf. This change was necessary since most of the error printing code is shared between libcam and the kernel. - A new transfer settings interface is included in this checkin. This code is #ifdef'ed out, and is primarily intended to aid discussion with HBA driver authors on the final form the interface should take. There is example code in the ahc(4) driver that implements the HBA driver side of the new interface. The new transfer settings code won't be enabled until we're ready to switch all HBA drivers over to the new interface. src/Makefile.inc1, lib/Makefile: Add libsbuf. It must be built before libcam, since libcam uses sbuf routines. libcam/Makefile: libcam now depends on libsbuf. libsbuf/Makefile: Add a makefile for libsbuf. This pulls in the sbuf sources from sys/kern. bsd.libnames.mk: Add LIBSBUF. camcontrol/Makefile: Add -lsbuf. Since camcontrol is statically linked, we can't depend on the dynamic linker to pull in libsbuf. camcontrol.c: Use cam_error_print() instead of checking for CAM_SCSI_STATUS_ERROR on every failed CCB. sbuf.9: Change the prototypes for sbuf_cat() and sbuf_cpy() so that the source string is now a const char *. This is more in line wth the standard system string functions, and helps eliminate warnings when dealing with a const source buffer. Fix a typo. cam.c: Add description strings for the various CAM error status values, as well as routines to look up those strings. Add new cam_error_string() and cam_error_print() routines for userland and the kernel. cam.h: Add a new CAM flag, CAM_RETRY_SELTO. Add enumerated types for the various options available with cam_error_print() and cam_error_string(). cam_ccb.h: Add new transfer negotiation structures/types. Change inq_len in the ccb_getdev structure to be "reserved". This field has never been filled in, and will be removed when we next bump the CAM version. cam_debug.h: Fix typo. cam_periph.c: Modularize cam_periph_error(). The SCSI error handling part of cam_periph_error() is now in camperiphscsistatuserror() and camperiphscsisenseerror(). In cam_periph_lock(), increase the reference count on the periph while we wait for our lock attempt to succeed so that the periph won't go away while we're sleeping. cam_xpt.c: Add new transfer negotiation code. (ifdefed out) Add a new function, xpt_path_string(). This is a string/sbuf analog to xpt_print_path(). scsi_all.c: Revamp string handing and error printing code. We now use sbufs for much of the string formatting code. More of that code is shared between userland the kernel. scsi_all.h: Get rid of SS_TURSTART, it wasn't terribly useful in the first place. Add a new error action, SS_REQSENSE. (Send a request sense and then retry the command.) This is useful when the controller hasn't performed autosense for some reason. Change the default actions around a bit. scsi_cd.c, scsi_da.c, scsi_pt.c, scsi_ses.c: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Selection timeouts shouldn't be covered by a sense flag. scsi_pass.[ch]: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Get rid of the last vestiges of a read/write interface. libkern/bsearch.c, sys/libkern.h, conf/files: Add bsearch.c, which is needed for some of the new table lookup routines. aic7xxx_freebsd.c: Define AHC_NEW_TRAN_SETTINGS if CAM_NEW_TRAN_CODE is defined. sbuf.h, subr_sbuf.c: Add the appropriate #ifdefs so sbufs can compile and run in userland. Change sbuf_printf() to use vsnprintf() instead of kvprintf(), which is only available in the kernel. Change the source string for sbuf_cpy() and sbuf_cat() to be a const char *. Add __BEGIN_DECLS and __END_DECLS around function prototypes since they're now exported to userland. kdump/mkioctls: Include stdio.h before cam.h since cam.h now includes a function with a FILE * argument. Submitted by: gibbs (mostly) Reviewed by: jdp, marcel (libsbuf makefile changes) Reviewed by: des (sbuf changes) Reviewed by: ken
2001-03-27 05:45:52 +00:00
error = cam_periph_runccb(ccb, saerror, CAM_RETRY_SELTO,
SF_NO_PRINT | SF_RETRY_UA,
softc->device_stats);
if (error) {
xpt_print(periph->path,
"unable to rewind after test read\n");
xpt_release_ccb(ccb);
goto exit;
}
}
/*
* Next off, determine block limits.
*/
scsi_read_block_limits(&ccb->csio, 5, sadone, MSG_SIMPLE_Q_TAG,
rblim, SSD_FULL_SIZE, SCSIOP_TIMEOUT);
Rewrite of the CAM error recovery code. Some of the major changes include: - The SCSI error handling portion of cam_periph_error() has been broken out into a number of subfunctions to better modularize the code that handles the hierarchy of SCSI errors. As a result, the code is now much easier to read. - String handling and error printing has been significantly revamped. We now use sbufs to do string formatting instead of using printfs (for the kernel) and snprintf/strncat (for userland) as before. There is a new catchall error printing routine, cam_error_print() and its string-based counterpart, cam_error_string() that allow the kernel and userland applications to pass in a CCB and have errors printed out properly, whether or not they're SCSI errors. Among other things, this helped eliminate a fair amount of duplicate code in camcontrol. We now print out more information than before, including the CAM status and SCSI status and the error recovery action taken to remedy the problem. - sbufs are now available in userland, via libsbuf. This change was necessary since most of the error printing code is shared between libcam and the kernel. - A new transfer settings interface is included in this checkin. This code is #ifdef'ed out, and is primarily intended to aid discussion with HBA driver authors on the final form the interface should take. There is example code in the ahc(4) driver that implements the HBA driver side of the new interface. The new transfer settings code won't be enabled until we're ready to switch all HBA drivers over to the new interface. src/Makefile.inc1, lib/Makefile: Add libsbuf. It must be built before libcam, since libcam uses sbuf routines. libcam/Makefile: libcam now depends on libsbuf. libsbuf/Makefile: Add a makefile for libsbuf. This pulls in the sbuf sources from sys/kern. bsd.libnames.mk: Add LIBSBUF. camcontrol/Makefile: Add -lsbuf. Since camcontrol is statically linked, we can't depend on the dynamic linker to pull in libsbuf. camcontrol.c: Use cam_error_print() instead of checking for CAM_SCSI_STATUS_ERROR on every failed CCB. sbuf.9: Change the prototypes for sbuf_cat() and sbuf_cpy() so that the source string is now a const char *. This is more in line wth the standard system string functions, and helps eliminate warnings when dealing with a const source buffer. Fix a typo. cam.c: Add description strings for the various CAM error status values, as well as routines to look up those strings. Add new cam_error_string() and cam_error_print() routines for userland and the kernel. cam.h: Add a new CAM flag, CAM_RETRY_SELTO. Add enumerated types for the various options available with cam_error_print() and cam_error_string(). cam_ccb.h: Add new transfer negotiation structures/types. Change inq_len in the ccb_getdev structure to be "reserved". This field has never been filled in, and will be removed when we next bump the CAM version. cam_debug.h: Fix typo. cam_periph.c: Modularize cam_periph_error(). The SCSI error handling part of cam_periph_error() is now in camperiphscsistatuserror() and camperiphscsisenseerror(). In cam_periph_lock(), increase the reference count on the periph while we wait for our lock attempt to succeed so that the periph won't go away while we're sleeping. cam_xpt.c: Add new transfer negotiation code. (ifdefed out) Add a new function, xpt_path_string(). This is a string/sbuf analog to xpt_print_path(). scsi_all.c: Revamp string handing and error printing code. We now use sbufs for much of the string formatting code. More of that code is shared between userland the kernel. scsi_all.h: Get rid of SS_TURSTART, it wasn't terribly useful in the first place. Add a new error action, SS_REQSENSE. (Send a request sense and then retry the command.) This is useful when the controller hasn't performed autosense for some reason. Change the default actions around a bit. scsi_cd.c, scsi_da.c, scsi_pt.c, scsi_ses.c: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Selection timeouts shouldn't be covered by a sense flag. scsi_pass.[ch]: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Get rid of the last vestiges of a read/write interface. libkern/bsearch.c, sys/libkern.h, conf/files: Add bsearch.c, which is needed for some of the new table lookup routines. aic7xxx_freebsd.c: Define AHC_NEW_TRAN_SETTINGS if CAM_NEW_TRAN_CODE is defined. sbuf.h, subr_sbuf.c: Add the appropriate #ifdefs so sbufs can compile and run in userland. Change sbuf_printf() to use vsnprintf() instead of kvprintf(), which is only available in the kernel. Change the source string for sbuf_cpy() and sbuf_cat() to be a const char *. Add __BEGIN_DECLS and __END_DECLS around function prototypes since they're now exported to userland. kdump/mkioctls: Include stdio.h before cam.h since cam.h now includes a function with a FILE * argument. Submitted by: gibbs (mostly) Reviewed by: jdp, marcel (libsbuf makefile changes) Reviewed by: des (sbuf changes) Reviewed by: ken
2001-03-27 05:45:52 +00:00
error = cam_periph_runccb(ccb, saerror, CAM_RETRY_SELTO,
SF_NO_PRINT | SF_RETRY_UA, softc->device_stats);
Rewrite of the CAM error recovery code. Some of the major changes include: - The SCSI error handling portion of cam_periph_error() has been broken out into a number of subfunctions to better modularize the code that handles the hierarchy of SCSI errors. As a result, the code is now much easier to read. - String handling and error printing has been significantly revamped. We now use sbufs to do string formatting instead of using printfs (for the kernel) and snprintf/strncat (for userland) as before. There is a new catchall error printing routine, cam_error_print() and its string-based counterpart, cam_error_string() that allow the kernel and userland applications to pass in a CCB and have errors printed out properly, whether or not they're SCSI errors. Among other things, this helped eliminate a fair amount of duplicate code in camcontrol. We now print out more information than before, including the CAM status and SCSI status and the error recovery action taken to remedy the problem. - sbufs are now available in userland, via libsbuf. This change was necessary since most of the error printing code is shared between libcam and the kernel. - A new transfer settings interface is included in this checkin. This code is #ifdef'ed out, and is primarily intended to aid discussion with HBA driver authors on the final form the interface should take. There is example code in the ahc(4) driver that implements the HBA driver side of the new interface. The new transfer settings code won't be enabled until we're ready to switch all HBA drivers over to the new interface. src/Makefile.inc1, lib/Makefile: Add libsbuf. It must be built before libcam, since libcam uses sbuf routines. libcam/Makefile: libcam now depends on libsbuf. libsbuf/Makefile: Add a makefile for libsbuf. This pulls in the sbuf sources from sys/kern. bsd.libnames.mk: Add LIBSBUF. camcontrol/Makefile: Add -lsbuf. Since camcontrol is statically linked, we can't depend on the dynamic linker to pull in libsbuf. camcontrol.c: Use cam_error_print() instead of checking for CAM_SCSI_STATUS_ERROR on every failed CCB. sbuf.9: Change the prototypes for sbuf_cat() and sbuf_cpy() so that the source string is now a const char *. This is more in line wth the standard system string functions, and helps eliminate warnings when dealing with a const source buffer. Fix a typo. cam.c: Add description strings for the various CAM error status values, as well as routines to look up those strings. Add new cam_error_string() and cam_error_print() routines for userland and the kernel. cam.h: Add a new CAM flag, CAM_RETRY_SELTO. Add enumerated types for the various options available with cam_error_print() and cam_error_string(). cam_ccb.h: Add new transfer negotiation structures/types. Change inq_len in the ccb_getdev structure to be "reserved". This field has never been filled in, and will be removed when we next bump the CAM version. cam_debug.h: Fix typo. cam_periph.c: Modularize cam_periph_error(). The SCSI error handling part of cam_periph_error() is now in camperiphscsistatuserror() and camperiphscsisenseerror(). In cam_periph_lock(), increase the reference count on the periph while we wait for our lock attempt to succeed so that the periph won't go away while we're sleeping. cam_xpt.c: Add new transfer negotiation code. (ifdefed out) Add a new function, xpt_path_string(). This is a string/sbuf analog to xpt_print_path(). scsi_all.c: Revamp string handing and error printing code. We now use sbufs for much of the string formatting code. More of that code is shared between userland the kernel. scsi_all.h: Get rid of SS_TURSTART, it wasn't terribly useful in the first place. Add a new error action, SS_REQSENSE. (Send a request sense and then retry the command.) This is useful when the controller hasn't performed autosense for some reason. Change the default actions around a bit. scsi_cd.c, scsi_da.c, scsi_pt.c, scsi_ses.c: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Selection timeouts shouldn't be covered by a sense flag. scsi_pass.[ch]: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Get rid of the last vestiges of a read/write interface. libkern/bsearch.c, sys/libkern.h, conf/files: Add bsearch.c, which is needed for some of the new table lookup routines. aic7xxx_freebsd.c: Define AHC_NEW_TRAN_SETTINGS if CAM_NEW_TRAN_CODE is defined. sbuf.h, subr_sbuf.c: Add the appropriate #ifdefs so sbufs can compile and run in userland. Change sbuf_printf() to use vsnprintf() instead of kvprintf(), which is only available in the kernel. Change the source string for sbuf_cpy() and sbuf_cat() to be a const char *. Add __BEGIN_DECLS and __END_DECLS around function prototypes since they're now exported to userland. kdump/mkioctls: Include stdio.h before cam.h since cam.h now includes a function with a FILE * argument. Submitted by: gibbs (mostly) Reviewed by: jdp, marcel (libsbuf makefile changes) Reviewed by: des (sbuf changes) Reviewed by: ken
2001-03-27 05:45:52 +00:00
xpt_release_ccb(ccb);
if (error != 0) {
/*
* If it's less than SCSI-2, READ BLOCK LIMITS is not
* a MANDATORY command. Anyway- it doesn't matter-
* we can proceed anyway.
*/
softc->blk_gran = 0;
softc->max_blk = ~0;
softc->min_blk = 0;
} else {
Rewrite of the CAM error recovery code. Some of the major changes include: - The SCSI error handling portion of cam_periph_error() has been broken out into a number of subfunctions to better modularize the code that handles the hierarchy of SCSI errors. As a result, the code is now much easier to read. - String handling and error printing has been significantly revamped. We now use sbufs to do string formatting instead of using printfs (for the kernel) and snprintf/strncat (for userland) as before. There is a new catchall error printing routine, cam_error_print() and its string-based counterpart, cam_error_string() that allow the kernel and userland applications to pass in a CCB and have errors printed out properly, whether or not they're SCSI errors. Among other things, this helped eliminate a fair amount of duplicate code in camcontrol. We now print out more information than before, including the CAM status and SCSI status and the error recovery action taken to remedy the problem. - sbufs are now available in userland, via libsbuf. This change was necessary since most of the error printing code is shared between libcam and the kernel. - A new transfer settings interface is included in this checkin. This code is #ifdef'ed out, and is primarily intended to aid discussion with HBA driver authors on the final form the interface should take. There is example code in the ahc(4) driver that implements the HBA driver side of the new interface. The new transfer settings code won't be enabled until we're ready to switch all HBA drivers over to the new interface. src/Makefile.inc1, lib/Makefile: Add libsbuf. It must be built before libcam, since libcam uses sbuf routines. libcam/Makefile: libcam now depends on libsbuf. libsbuf/Makefile: Add a makefile for libsbuf. This pulls in the sbuf sources from sys/kern. bsd.libnames.mk: Add LIBSBUF. camcontrol/Makefile: Add -lsbuf. Since camcontrol is statically linked, we can't depend on the dynamic linker to pull in libsbuf. camcontrol.c: Use cam_error_print() instead of checking for CAM_SCSI_STATUS_ERROR on every failed CCB. sbuf.9: Change the prototypes for sbuf_cat() and sbuf_cpy() so that the source string is now a const char *. This is more in line wth the standard system string functions, and helps eliminate warnings when dealing with a const source buffer. Fix a typo. cam.c: Add description strings for the various CAM error status values, as well as routines to look up those strings. Add new cam_error_string() and cam_error_print() routines for userland and the kernel. cam.h: Add a new CAM flag, CAM_RETRY_SELTO. Add enumerated types for the various options available with cam_error_print() and cam_error_string(). cam_ccb.h: Add new transfer negotiation structures/types. Change inq_len in the ccb_getdev structure to be "reserved". This field has never been filled in, and will be removed when we next bump the CAM version. cam_debug.h: Fix typo. cam_periph.c: Modularize cam_periph_error(). The SCSI error handling part of cam_periph_error() is now in camperiphscsistatuserror() and camperiphscsisenseerror(). In cam_periph_lock(), increase the reference count on the periph while we wait for our lock attempt to succeed so that the periph won't go away while we're sleeping. cam_xpt.c: Add new transfer negotiation code. (ifdefed out) Add a new function, xpt_path_string(). This is a string/sbuf analog to xpt_print_path(). scsi_all.c: Revamp string handing and error printing code. We now use sbufs for much of the string formatting code. More of that code is shared between userland the kernel. scsi_all.h: Get rid of SS_TURSTART, it wasn't terribly useful in the first place. Add a new error action, SS_REQSENSE. (Send a request sense and then retry the command.) This is useful when the controller hasn't performed autosense for some reason. Change the default actions around a bit. scsi_cd.c, scsi_da.c, scsi_pt.c, scsi_ses.c: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Selection timeouts shouldn't be covered by a sense flag. scsi_pass.[ch]: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Get rid of the last vestiges of a read/write interface. libkern/bsearch.c, sys/libkern.h, conf/files: Add bsearch.c, which is needed for some of the new table lookup routines. aic7xxx_freebsd.c: Define AHC_NEW_TRAN_SETTINGS if CAM_NEW_TRAN_CODE is defined. sbuf.h, subr_sbuf.c: Add the appropriate #ifdefs so sbufs can compile and run in userland. Change sbuf_printf() to use vsnprintf() instead of kvprintf(), which is only available in the kernel. Change the source string for sbuf_cpy() and sbuf_cat() to be a const char *. Add __BEGIN_DECLS and __END_DECLS around function prototypes since they're now exported to userland. kdump/mkioctls: Include stdio.h before cam.h since cam.h now includes a function with a FILE * argument. Submitted by: gibbs (mostly) Reviewed by: jdp, marcel (libsbuf makefile changes) Reviewed by: des (sbuf changes) Reviewed by: ken
2001-03-27 05:45:52 +00:00
if (softc->scsi_rev >= SCSI_REV_SPC) {
softc->blk_gran = RBL_GRAN(rblim);
} else {
softc->blk_gran = 0;
}
/*
* We take max_blk == min_blk to mean a default to
* fixed mode- but note that whatever we get out of
* sagetparams below will actually determine whether
* we are actually *in* fixed mode.
*/
softc->max_blk = scsi_3btoul(rblim->maximum);
softc->min_blk = scsi_2btoul(rblim->minimum);
}
/*
* Next, perform a mode sense to determine
* current density, blocksize, compression etc.
*/
error = sagetparams(periph, SA_PARAM_ALL,
&softc->media_blksize,
&softc->media_density,
&softc->media_numblks,
&softc->buffer_mode, &write_protect,
&softc->speed, &comp_supported,
&comp_enabled, &softc->comp_algorithm,
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
NULL, NULL, 0, 0);
if (error != 0) {
/*
* We could work a little harder here. We could
* adjust our attempts to get information. It
* might be an ancient tape drive. If someone
* nudges us, we'll do that.
*/
goto exit;
}
/*
* If no quirk has determined that this is a device that is
* preferred to be in fixed or variable mode, now is the time
* to find out.
*/
if ((softc->quirks & (SA_QUIRK_FIXED|SA_QUIRK_VARIABLE)) == 0) {
guessing = 1;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
/*
* This could be expensive to find out. Luckily we
* only need to do this once. If we start out in
* 'default' mode, try and set ourselves to one
* of the densities that would determine a wad
* of other stuff. Go from highest to lowest.
*/
if (softc->media_density == SCSI_DEFAULT_DENSITY) {
int i;
static u_int8_t ctry[] = {
SCSI_DENSITY_HALFINCH_PE,
SCSI_DENSITY_HALFINCH_6250C,
SCSI_DENSITY_HALFINCH_6250,
SCSI_DENSITY_HALFINCH_1600,
SCSI_DENSITY_HALFINCH_800,
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
SCSI_DENSITY_QIC_4GB,
SCSI_DENSITY_QIC_2GB,
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
SCSI_DENSITY_QIC_525_320,
SCSI_DENSITY_QIC_150,
SCSI_DENSITY_QIC_120,
SCSI_DENSITY_QIC_24,
SCSI_DENSITY_QIC_11_9TRK,
SCSI_DENSITY_QIC_11_4TRK,
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
SCSI_DENSITY_QIC_1320,
SCSI_DENSITY_QIC_3080,
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
0
};
for (i = 0; ctry[i]; i++) {
error = sasetparams(periph,
SA_PARAM_DENSITY, 0, ctry[i],
0, SF_NO_PRINT);
if (error == 0) {
softc->media_density = ctry[i];
break;
}
}
}
switch (softc->media_density) {
case SCSI_DENSITY_QIC_11_4TRK:
case SCSI_DENSITY_QIC_11_9TRK:
case SCSI_DENSITY_QIC_24:
case SCSI_DENSITY_QIC_120:
case SCSI_DENSITY_QIC_150:
case SCSI_DENSITY_QIC_525_320:
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
case SCSI_DENSITY_QIC_1320:
case SCSI_DENSITY_QIC_3080:
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
softc->quirks &= ~SA_QUIRK_2FM;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->quirks |= SA_QUIRK_FIXED|SA_QUIRK_1FM;
softc->last_media_blksize = 512;
break;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
case SCSI_DENSITY_QIC_4GB:
case SCSI_DENSITY_QIC_2GB:
softc->quirks &= ~SA_QUIRK_2FM;
softc->quirks |= SA_QUIRK_FIXED|SA_QUIRK_1FM;
softc->last_media_blksize = 1024;
break;
default:
softc->last_media_blksize =
softc->media_blksize;
softc->quirks |= SA_QUIRK_VARIABLE;
break;
}
}
/*
* If no quirk has determined that this is a device that needs
* to have 2 Filemarks at EOD, now is the time to find out.
*/
if ((softc->quirks & SA_QUIRK_2FM) == 0) {
switch (softc->media_density) {
case SCSI_DENSITY_HALFINCH_800:
case SCSI_DENSITY_HALFINCH_1600:
case SCSI_DENSITY_HALFINCH_6250:
case SCSI_DENSITY_HALFINCH_6250C:
case SCSI_DENSITY_HALFINCH_PE:
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
softc->quirks &= ~SA_QUIRK_1FM;
softc->quirks |= SA_QUIRK_2FM;
break;
default:
break;
}
}
/*
* Now validate that some info we got makes sense.
*/
if ((softc->max_blk < softc->media_blksize) ||
(softc->min_blk > softc->media_blksize &&
softc->media_blksize)) {
xpt_print(periph->path,
"BLOCK LIMITS (%d..%d) could not match current "
"block settings (%d)- adjusting\n", softc->min_blk,
softc->max_blk, softc->media_blksize);
softc->max_blk = softc->min_blk =
softc->media_blksize;
}
/*
* Now put ourselves into the right frame of mind based
* upon quirks...
*/
tryagain:
/*
* If we want to be in FIXED mode and our current blocksize
* is not equal to our last blocksize (if nonzero), try and
* set ourselves to this last blocksize (as the 'preferred'
* block size). The initial quirkmatch at registry sets the
* initial 'last' blocksize. If, for whatever reason, this
* 'last' blocksize is zero, set the blocksize to 512,
* or min_blk if that's larger.
*/
if ((softc->quirks & SA_QUIRK_FIXED) &&
(softc->quirks & SA_QUIRK_NO_MODESEL) == 0 &&
(softc->media_blksize != softc->last_media_blksize)) {
softc->media_blksize = softc->last_media_blksize;
if (softc->media_blksize == 0) {
softc->media_blksize = 512;
if (softc->media_blksize < softc->min_blk) {
softc->media_blksize = softc->min_blk;
}
}
error = sasetparams(periph, SA_PARAM_BLOCKSIZE,
softc->media_blksize, 0, 0, SF_NO_PRINT);
if (error) {
xpt_print(periph->path,
"unable to set fixed blocksize to %d\n",
softc->media_blksize);
goto exit;
}
}
if ((softc->quirks & SA_QUIRK_VARIABLE) &&
(softc->media_blksize != 0)) {
softc->last_media_blksize = softc->media_blksize;
softc->media_blksize = 0;
error = sasetparams(periph, SA_PARAM_BLOCKSIZE,
0, 0, 0, SF_NO_PRINT);
if (error) {
/*
* If this fails and we were guessing, just
* assume that we got it wrong and go try
* fixed block mode. Don't even check against
* density code at this point.
*/
if (guessing) {
softc->quirks &= ~SA_QUIRK_VARIABLE;
softc->quirks |= SA_QUIRK_FIXED;
if (softc->last_media_blksize == 0)
softc->last_media_blksize = 512;
goto tryagain;
}
xpt_print(periph->path,
"unable to set variable blocksize\n");
goto exit;
}
}
/*
* Now that we have the current block size,
* set up some parameters for sastart's usage.
*/
if (softc->media_blksize) {
softc->flags |= SA_FLAG_FIXED;
if (powerof2(softc->media_blksize)) {
softc->blk_shift =
ffs(softc->media_blksize) - 1;
softc->blk_mask = softc->media_blksize - 1;
} else {
softc->blk_mask = ~0;
softc->blk_shift = 0;
}
} else {
/*
* The SCSI-3 spec allows 0 to mean "unspecified".
* The SCSI-1 spec allows 0 to mean 'infinite'.
*
* Either works here.
*/
if (softc->max_blk == 0) {
softc->max_blk = ~0;
}
softc->blk_shift = 0;
if (softc->blk_gran != 0) {
softc->blk_mask = softc->blk_gran - 1;
} else {
softc->blk_mask = 0;
}
}
if (write_protect)
softc->flags |= SA_FLAG_TAPE_WP;
if (comp_supported) {
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
if (softc->saved_comp_algorithm == 0)
softc->saved_comp_algorithm =
softc->comp_algorithm;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
softc->flags |= SA_FLAG_COMP_SUPP;
if (comp_enabled)
softc->flags |= SA_FLAG_COMP_ENABLED;
} else
softc->flags |= SA_FLAG_COMP_UNSUPP;
if ((softc->buffer_mode == SMH_SA_BUF_MODE_NOBUF) &&
(softc->quirks & SA_QUIRK_NO_MODESEL) == 0) {
error = sasetparams(periph, SA_PARAM_BUFF_MODE, 0,
0, 0, SF_NO_PRINT);
if (error == 0) {
softc->buffer_mode = SMH_SA_BUF_MODE_SIBUF;
} else {
xpt_print(periph->path,
"unable to set buffered mode\n");
}
error = 0; /* not an error */
}
if (error == 0) {
softc->flags |= SA_FLAG_TAPE_MOUNTED;
}
exit:
if (rblim != NULL)
2007-05-14 21:48:53 +00:00
free(rblim, M_SCSISA);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
if (error != 0) {
softc->dsreg = MTIO_DSREG_NIL;
} else {
softc->fileno = softc->blkno = 0;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->rep_fileno = softc->rep_blkno = -1;
softc->partition = 0;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_REST;
}
#ifdef SA_1FM_AT_EOD
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if ((softc->quirks & SA_QUIRK_2FM) == 0)
softc->quirks |= SA_QUIRK_1FM;
#else
if ((softc->quirks & SA_QUIRK_1FM) == 0)
softc->quirks |= SA_QUIRK_2FM;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
#endif
} else
xpt_release_ccb(ccb);
/*
* If we return an error, we're not mounted any more,
* so release any device reservation.
*/
if (error != 0) {
(void) sareservereleaseunit(periph, FALSE);
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
} else {
/*
* Clear I/O residual.
*/
softc->last_io_resid = 0;
softc->last_ctl_resid = 0;
}
return (error);
}
2000-10-31 22:34:51 +00:00
/*
* How many filemarks do we need to write if we were to terminate the
* tape session right now? Note that this can be a negative number
*/
static int
2000-10-31 22:34:51 +00:00
samarkswanted(struct cam_periph *periph)
{
int markswanted;
struct sa_softc *softc;
softc = (struct sa_softc *)periph->softc;
markswanted = 0;
if ((softc->flags & SA_FLAG_TAPE_WRITTEN) != 0) {
markswanted++;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (softc->quirks & SA_QUIRK_2FM)
markswanted++;
}
2000-10-31 22:34:51 +00:00
markswanted -= softc->filemarks;
return (markswanted);
}
static int
sacheckeod(struct cam_periph *periph)
{
int error;
int markswanted;
markswanted = samarkswanted(periph);
2000-10-31 22:34:51 +00:00
if (markswanted > 0) {
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
error = sawritefilemarks(periph, markswanted, FALSE, FALSE);
} else {
error = 0;
}
return (error);
}
static int
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
saerror(union ccb *ccb, u_int32_t cflgs, u_int32_t sflgs)
{
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
static const char *toobig =
"%d-byte tape record bigger than supplied buffer\n";
struct cam_periph *periph;
struct sa_softc *softc;
struct ccb_scsiio *csio;
struct scsi_sense_data *sense;
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
uint64_t resid = 0;
int64_t info = 0;
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
cam_status status;
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
int error_code, sense_key, asc, ascq, error, aqvalid, stream_valid;
int sense_len;
uint8_t stream_bits;
periph = xpt_path_periph(ccb->ccb_h.path);
softc = (struct sa_softc *)periph->softc;
csio = &ccb->csio;
sense = &csio->sense_data;
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
sense_len = csio->sense_len - csio->sense_resid;
scsi_extract_sense_len(sense, sense_len, &error_code, &sense_key,
&asc, &ascq, /*show_errors*/ 1);
if (asc != -1 && ascq != -1)
aqvalid = 1;
else
aqvalid = 0;
if (scsi_get_stream_info(sense, sense_len, NULL, &stream_bits) == 0)
stream_valid = 1;
else
stream_valid = 0;
error = 0;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
status = csio->ccb_h.status & CAM_STATUS_MASK;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
/*
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
* Calculate/latch up, any residuals... We do this in a funny 2-step
* so we can print stuff here if we have CAM_DEBUG enabled for this
* unit.
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
*/
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
if (status == CAM_SCSI_STATUS_ERROR) {
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
if (scsi_get_sense_info(sense, sense_len, SSD_DESC_INFO, &resid,
&info) == 0) {
if ((softc->flags & SA_FLAG_FIXED) != 0)
resid *= softc->media_blksize;
} else {
resid = csio->dxfer_len;
info = resid;
if ((softc->flags & SA_FLAG_FIXED) != 0) {
if (softc->media_blksize)
info /= softc->media_blksize;
}
}
if (csio->cdb_io.cdb_bytes[0] == SA_READ ||
csio->cdb_io.cdb_bytes[0] == SA_WRITE) {
bcopy((caddr_t) sense, (caddr_t) &softc->last_io_sense,
sizeof (struct scsi_sense_data));
bcopy(csio->cdb_io.cdb_bytes, softc->last_io_cdb,
(int) csio->cdb_len);
softc->last_io_resid = resid;
softc->last_resid_was_io = 1;
} else {
bcopy((caddr_t) sense, (caddr_t) &softc->last_ctl_sense,
sizeof (struct scsi_sense_data));
bcopy(csio->cdb_io.cdb_bytes, softc->last_ctl_cdb,
(int) csio->cdb_len);
softc->last_ctl_resid = resid;
softc->last_resid_was_io = 0;
}
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("CDB[0]=0x%x Key 0x%x "
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
"ASC/ASCQ 0x%x/0x%x CAM STATUS 0x%x flags 0x%x resid %jd "
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
"dxfer_len %d\n", csio->cdb_io.cdb_bytes[0] & 0xff,
sense_key, asc, ascq, status,
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
(stream_valid) ? stream_bits : 0, (intmax_t)resid,
csio->dxfer_len));
} else {
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
CAM_DEBUG(periph->path, CAM_DEBUG_INFO,
("Cam Status 0x%x\n", status));
}
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
switch (status) {
case CAM_REQ_CMP:
return (0);
case CAM_SCSI_STATUS_ERROR:
/*
* If a read/write command, we handle it here.
*/
Merge CAM locking changes from the projects/camlock branch to radically reduce lock congestion and improve SMP scalability of the SCSI/ATA stack, preparing the ground for the coming next GEOM direct dispatch support. Replace big per-SIM locks with bunch of smaller ones: - per-LUN locks to protect device and peripheral drivers state; - per-target locks to protect list of LUNs on target; - per-bus locks to protect reference counting; - per-send queue locks to protect queue of CCBs to be sent; - per-done queue locks to protect queue of completed CCBs; - remaining per-SIM locks now protect only HBA driver internals. While holding LUN lock it is allowed (while not recommended for performance reasons) to take SIM lock. The opposite acquisition order is forbidden. All the other locks are leaf locks, that can be taken anywhere, but should not be cascaded. Many functions, such as: xpt_action(), xpt_done(), xpt_async(), xpt_create_path(), etc. are no longer require (but allow) SIM lock to be held. To keep compatibility and solve cases where SIM lock can't be dropped, all xpt_async() calls in addition to xpt_done() calls are queued to completion threads for async processing in clean environment without SIM lock held. Instead of single CAM SWI thread, used for commands completion processing before, use multiple (depending on number of CPUs) threads. Load balanced between them using "hash" of the device B:T:L address. HBA drivers that can drop SIM lock during completion processing and have sufficient number of completion threads to efficiently scale to multiple CPUs can use new function xpt_done_direct() to avoid extra context switch. Make ahci(4) driver to use this mechanism depending on hardware setup. Sponsored by: iXsystems, Inc. MFC after: 2 months
2013-10-21 12:00:26 +00:00
if (csio->cdb_io.cdb_bytes[0] == SA_READ ||
csio->cdb_io.cdb_bytes[0] == SA_WRITE) {
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
break;
}
/*
* If this was just EOM/EOP, Filemark, Setmark or ILI detected
* on a non read/write command, we assume it's not an error
* and propagate the residule and return.
*/
if ((aqvalid && asc == 0 && ascq > 0 && ascq <= 5) ||
(aqvalid == 0 && sense_key == SSD_KEY_NO_SENSE)) {
csio->resid = resid;
QFRLS(ccb);
return (0);
}
/*
* Otherwise, we let the common code handle this.
*/
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
return (cam_periph_error(ccb, cflgs, sflgs, &softc->saved_ccb));
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
/*
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
* XXX: To Be Fixed
* We cannot depend upon CAM honoring retry counts for these.
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
*/
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
case CAM_SCSI_BUS_RESET:
case CAM_BDR_SENT:
if (ccb->ccb_h.retry_count <= 0) {
return (EIO);
}
/* FALLTHROUGH */
default:
return (cam_periph_error(ccb, cflgs, sflgs, &softc->saved_ccb));
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
}
/*
* Handle filemark, end of tape, mismatched record sizes....
* From this point out, we're only handling read/write cases.
* Handle writes && reads differently.
*/
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (csio->cdb_io.cdb_bytes[0] == SA_WRITE) {
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
if (sense_key == SSD_KEY_VOLUME_OVERFLOW) {
csio->resid = resid;
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
error = ENOSPC;
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
} else if ((stream_valid != 0) && (stream_bits & SSD_EOM)) {
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
softc->flags |= SA_FLAG_EOM_PENDING;
/*
* Grotesque as it seems, the few times
* I've actually seen a non-zero resid,
* the tape drive actually lied and had
* written all the data!.
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
*/
csio->resid = 0;
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
} else {
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
csio->resid = resid;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (sense_key == SSD_KEY_BLANK_CHECK) {
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
if (softc->quirks & SA_QUIRK_1FM) {
error = 0;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
softc->flags |= SA_FLAG_EOM_PENDING;
} else {
error = EIO;
}
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
} else if ((stream_valid != 0) && (stream_bits & SSD_FILEMARK)){
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
if (softc->flags & SA_FLAG_FIXED) {
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
error = -1;
softc->flags |= SA_FLAG_EOF_PENDING;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
}
/*
* Unconditionally, if we detected a filemark on a read,
* mark that we've run moved a file ahead.
*/
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
if (softc->fileno != (daddr_t) -1) {
softc->fileno++;
softc->blkno = 0;
csio->ccb_h.ccb_pflags |= SA_POSITION_UPDATED;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
}
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
}
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
/*
* Incorrect Length usually applies to read, but can apply to writes.
*/
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
if (error == 0 && (stream_valid != 0) && (stream_bits & SSD_ILI)) {
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (info < 0) {
xpt_print(csio->ccb_h.path, toobig,
csio->dxfer_len - info);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
csio->resid = csio->dxfer_len;
error = EIO;
} else {
csio->resid = resid;
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
if (softc->flags & SA_FLAG_FIXED) {
softc->flags |= SA_FLAG_EIO_PENDING;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
}
/*
* Bump the block number if we hadn't seen a filemark.
* Do this independent of errors (we've moved anyway).
*/
Add descriptor sense support to CAM, and honor sense residuals properly in CAM. Desriptor sense is a new sense data format that originated in SPC-3. Among other things, it allows for an 8-byte info field, which is necessary to pass back block numbers larger than 4 bytes. This change adds a number of new functions to scsi_all.c (and therefore libcam) that abstract out most access to sense data. This includes a bump of CAM_VERSION, because the CCB ABI has changed. Userland programs that use the CAM pass(4) driver will need to be recompiled. camcontrol.c: Change uses of scsi_extract_sense() to use scsi_extract_sense_len(). Use scsi_get_sks() instead of accessing sense key specific data directly. scsi_modes: Update the control mode page to the latest version (SPC-4). scsi_cmds.c, scsi_target.c: Change references to struct scsi_sense_data to struct scsi_sense_data_fixed. This should be changed to allow the user to specify fixed or descriptor sense, and then use scsi_set_sense_data() to build the sense data. ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data manually. cam_periph.c: Use scsi_extract_sense_len() instead of using scsi_extract_sense() or accessing sense data directly. cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of struct scsi_sense_data from 32 to 252 bytes changes the size of struct ccb_scsiio, but not the size of union ccb. So the version must be bumped to prevent structure mis-matches. scsi_all.h: Lots of updated SCSI sense data and other structures. Add function prototypes for the new sense data functions. Take out the inline implementation of scsi_extract_sense(). It is now too large to put in a header file. Add macros to calculate whether fields are present and filled in fixed and descriptor sense data scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry data, and we'll assume a direct access device in that case. Changed the SCSI RESERVED sense key name and description to COMPLETED, as it is now defined in the spec. Change the error recovery action for a number of read errors to prevent lots of retries when the drive has said that the block isn't accessible. This speeds up reconstruction of the block by any RAID software running on top of the drive (e.g. ZFS). In scsi_sense_desc(), allow for invalid sense key numbers. This allows calling this routine without checking the input values first. Change scsi_error_action() to use scsi_extract_sense_len(), and handle things when invalid asc/ascq values are encountered. Add a new routine, scsi_desc_iterate(), that will call the supplied function for every descriptor in descriptor format sense data. Add scsi_set_sense_data(), and scsi_set_sense_data_va(), which build descriptor and fixed format sense data. They currently default to fixed format sense data. Add a number of scsi_get_*() functions, which get different types of sense data fields from either fixed or descriptor format sense data, if the data is present. Add a number of scsi_*_sbuf() functions, which print formatted versions of various sense data fields. These functions work for either fixed or descriptor sense. Add a number of scsi_sense_*_sbuf() functions, which have a standard calling interface and print the indicated field. These functions take descriptors only. Add scsi_sense_desc_sbuf(), which will print a formatted version of the given sense descriptor. Pull out a majority of the scsi_sense_sbuf() function and put it into scsi_sense_only_sbuf(). This allows callers that don't use struct ccb_scsiio to easily utilize the printing routines. Revamp that function to handle descriptor sense and use the new sense fetching and printing routines. Move scsi_extract_sense() into scsi_all.c, and implement it in terms of the new function, scsi_extract_sense_len(). The _len() version takes a length (which should be the sense length - residual) and can indicate which fields are present and valid in the sense data. Add a couple of new scsi_get_*() routines to get the sense key, asc, and ascq only. mly.c: Rename struct scsi_sense_data to struct scsi_sense_data_fixed. sbp_targ.c: Use the new sense fetching routines to get sense data instead of accessing it directly. sbp.c: Change the firewire/SCSI sense data transformation code to use struct scsi_sense_data_fixed instead of struct scsi_sense_data. This should be changed later to use scsi_set_sense_data(). ciss.c: Calculate the sense residual properly. Use scsi_get_sense_key() to fetch the sense key. mps_sas.c, mpt_cam.c: Set the sense residual properly. iir.c: Use scsi_set_sense_data() instead of building sense data by hand. iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data directly. umass.c: Use scsi_set_sense_data() to build sense data. Grab the sense key using scsi_get_sense_key(). Calculate the sense residual properly. isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key values. Calculate and set the sense residual. MFC after: 3 days Sponsored by: Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
if ((stream_valid == 0) ||
(stream_bits & SSD_FILEMARK) == 0) {
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (softc->blkno != (daddr_t) -1) {
softc->blkno++;
csio->ccb_h.ccb_pflags |=
SA_POSITION_UPDATED;
}
}
}
}
2001-07-30 00:22:57 +00:00
Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. Clear residual counts after a successful samount (the user doesn't care that we got an N-kbyte residual on our test read). Change a lot of error handling code. 1. If we end up in saerror, check more carefully about the kind of error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write command, we'll be handling this in saerror. If it isn't a read/write command, check to see whether this is just an EOM/EOP check condition- if it is, just set residual and return normally. A residual and then a NO SENSE check condiftion with the ASC of 0 and ASCQ of between 1 and 4 are normal 'signifying' events, not errors per se, and we shouldn't give the command to cam_periph_error to do something relatively unpredictable with. 2. If we get a Bus Reset, had a BDR sent, or get the cam status of CAM_REQUEUE_REQ, check the retry count on the command. The default error handler, cam_periph_error, doesn't honor retry count in these cases. This may change in the future, but for now, make sure we set EIO and return without calling cam_periph_error if the retry count for the command with an error is zero. 3. Clean up the pending error case goop and handle cases more sensibly. The rules are: If command was a Write: If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is propagated and we set ENOSPC as the error. Else if we got an EOM condition- just mark EOM pending. And set a residual of zero. For the longest time I was just propagating residual from the sense data- but my tape comparison tests were always failing because all drives I tested with actually *do* write the data anyway- the EOM (early warning) condition occurred *prior* to all of the data going out to media- that is, it was still buffered by the drive. This case is described in SCSI-2, 10.2.14, paragraph #d for the meaning of 'information field'. A better fix for this would be to issue a WFM command of zero to cause the drive to flush any buffered data, but this would require a fairly extensive rewrite. Else if the command was a READ: If we got a SSD_KEY_BLANK_CHECK- If we have a One Filemark EOT model- mark EOM as pending, otherwise set EIO as the erorr. Else if we found a Filemark- If we're in Fixed Block mode- mark EOF pending. If we had an ILI (Incorrect Length Indicator)- If the residual is less than zero, whine about tape record being too big for user's buffer, otherwise if we were in Fixed Block mode, mark EIO as pending. All 'pending' conditions mean that the command in question completes without error indication. It had succeeded, but a signifying event occurred during its execution which will apply to the *next* command that would be exexcuted. Except for the one EOM case above, we always propagate residual. Now, way back in sastart- if we notice any of the PENDING bits set, we don't run the command we've just pulled off the wait queue. Instead, we then figure out it's disposition based upon a previous command's association with a signifying event. If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete the command with residual set to the request count (not data moved, but no error). We continue on. If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in Fixed Block mode- in which case we traverse all waiting buffers (which we can get in fixed block mode because physio has split things up) and mark them all as no error, but no data moved and complete them. If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error and complete it. Then we clear all of the pending state bits- we're done. MFC after: 4 weeks
2001-08-30 16:25:24 +00:00
if (error <= 0) {
/*
* Unfreeze the queue if frozen as we're not returning anything
* to our waiters that would indicate an I/O error has occurred
* (yet).
*/
QFRLS(ccb);
error = 0;
}
return (error);
}
static int
sagetparams(struct cam_periph *periph, sa_params params_to_get,
u_int32_t *blocksize, u_int8_t *density, u_int32_t *numblocks,
int *buff_mode, u_int8_t *write_protect, u_int8_t *speed,
int *comp_supported, int *comp_enabled, u_int32_t *comp_algorithm,
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
sa_comp_t *tcs, struct scsi_control_data_prot_subpage *prot_page,
int dp_size, int prot_changeable)
{
union ccb *ccb;
void *mode_buffer;
struct scsi_mode_header_6 *mode_hdr;
struct scsi_mode_blk_desc *mode_blk;
int mode_buffer_len;
struct sa_softc *softc;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
u_int8_t cpage;
int error;
cam_status status;
softc = (struct sa_softc *)periph->softc;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
ccb = cam_periph_getccb(periph, 1);
if (softc->quirks & SA_QUIRK_NO_CPAGE)
cpage = SA_DEVICE_CONFIGURATION_PAGE;
else
cpage = SA_DATA_COMPRESSION_PAGE;
retry:
mode_buffer_len = sizeof(*mode_hdr) + sizeof(*mode_blk);
if (params_to_get & SA_PARAM_COMPRESSION) {
if (softc->quirks & SA_QUIRK_NOCOMP) {
*comp_supported = FALSE;
params_to_get &= ~SA_PARAM_COMPRESSION;
} else
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
mode_buffer_len += sizeof (sa_comp_t);
}
2007-06-16 18:13:26 +00:00
/* XXX Fix M_NOWAIT */
mode_buffer = malloc(mode_buffer_len, M_SCSISA, M_NOWAIT | M_ZERO);
if (mode_buffer == NULL) {
xpt_release_ccb(ccb);
return (ENOMEM);
}
mode_hdr = (struct scsi_mode_header_6 *)mode_buffer;
mode_blk = (struct scsi_mode_blk_desc *)&mode_hdr[1];
/* it is safe to retry this */
scsi_mode_sense(&ccb->csio, 5, sadone, MSG_SIMPLE_Q_TAG, FALSE,
SMS_PAGE_CTRL_CURRENT, (params_to_get & SA_PARAM_COMPRESSION) ?
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
cpage : SMS_VENDOR_SPECIFIC_PAGE, mode_buffer, mode_buffer_len,
SSD_FULL_SIZE, SCSIOP_TIMEOUT);
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
softc->device_stats);
status = ccb->ccb_h.status & CAM_STATUS_MASK;
if (error == EINVAL && (params_to_get & SA_PARAM_COMPRESSION) != 0) {
/*
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
* Hmm. Let's see if we can try another page...
* If we've already done that, give up on compression
* for this device and remember this for the future
* and attempt the request without asking for compression
* info.
*/
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (cpage == SA_DATA_COMPRESSION_PAGE) {
cpage = SA_DEVICE_CONFIGURATION_PAGE;
goto retry;
}
softc->quirks |= SA_QUIRK_NOCOMP;
2007-05-14 21:48:53 +00:00
free(mode_buffer, M_SCSISA);
goto retry;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
} else if (status == CAM_SCSI_STATUS_ERROR) {
/* Tell the user about the fatal error. */
scsi_sense_print(&ccb->csio);
goto sagetparamsexit;
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
/*
* If the user only wants the compression information, and
* the device doesn't send back the block descriptor, it's
* no big deal. If the user wants more than just
* compression, though, and the device doesn't pass back the
* block descriptor, we need to send another mode sense to
* get the block descriptor.
*/
if ((mode_hdr->blk_desc_len == 0) &&
(params_to_get & SA_PARAM_COMPRESSION) &&
(params_to_get & ~(SA_PARAM_COMPRESSION))) {
/*
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
* Decrease the mode buffer length by the size of
* the compression page, to make sure the data
* there doesn't get overwritten.
*/
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
mode_buffer_len -= sizeof (sa_comp_t);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
/*
* Now move the compression page that we presumably
* got back down the memory chunk a little bit so
* it doesn't get spammed.
*/
bcopy(&mode_hdr[0], &mode_hdr[1], sizeof (sa_comp_t));
bzero(&mode_hdr[0], sizeof (mode_hdr[0]));
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
/*
* Now, we issue another mode sense and just ask
* for the block descriptor, etc.
*/
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
scsi_mode_sense(&ccb->csio, 2, sadone, MSG_SIMPLE_Q_TAG, FALSE,
SMS_PAGE_CTRL_CURRENT, SMS_VENDOR_SPECIFIC_PAGE,
mode_buffer, mode_buffer_len, SSD_FULL_SIZE,
SCSIOP_TIMEOUT);
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
softc->device_stats);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (error != 0)
goto sagetparamsexit;
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (params_to_get & SA_PARAM_BLOCKSIZE)
*blocksize = scsi_3btoul(mode_blk->blklen);
if (params_to_get & SA_PARAM_NUMBLOCKS)
*numblocks = scsi_3btoul(mode_blk->nblocks);
if (params_to_get & SA_PARAM_BUFF_MODE)
*buff_mode = mode_hdr->dev_spec & SMH_SA_BUF_MODE_MASK;
if (params_to_get & SA_PARAM_DENSITY)
*density = mode_blk->density;
if (params_to_get & SA_PARAM_WP)
*write_protect = (mode_hdr->dev_spec & SMH_SA_WP)? TRUE : FALSE;
if (params_to_get & SA_PARAM_SPEED)
*speed = mode_hdr->dev_spec & SMH_SA_SPEED_MASK;
if (params_to_get & SA_PARAM_COMPRESSION) {
sa_comp_t *ntcs = (sa_comp_t *) &mode_blk[1];
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (cpage == SA_DATA_COMPRESSION_PAGE) {
struct scsi_data_compression_page *cp = &ntcs->dcomp;
*comp_supported =
(cp->dce_and_dcc & SA_DCP_DCC)? TRUE : FALSE;
*comp_enabled =
(cp->dce_and_dcc & SA_DCP_DCE)? TRUE : FALSE;
*comp_algorithm = scsi_4btoul(cp->comp_algorithm);
} else {
struct scsi_dev_conf_page *cp = &ntcs->dconf;
/*
* We don't really know whether this device supports
* Data Compression if the algorithm field is
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
* zero. Just say we do.
*/
*comp_supported = TRUE;
*comp_enabled =
(cp->sel_comp_alg != SA_COMP_NONE)? TRUE : FALSE;
*comp_algorithm = cp->sel_comp_alg;
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (tcs != NULL)
bcopy(ntcs, tcs, sizeof (sa_comp_t));
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
}
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
if ((params_to_get & SA_PARAM_DENSITY_EXT)
&& (softc->scsi_rev >= SCSI_REV_SPC)) {
int i;
for (i = 0; i < SA_DENSITY_TYPES; i++) {
scsi_report_density_support(&ccb->csio,
/*retries*/ 1,
/*cbfcnp*/ sadone,
/*tag_action*/ MSG_SIMPLE_Q_TAG,
/*media*/ softc->density_type_bits[i] & SRDS_MEDIA,
/*medium_type*/ softc->density_type_bits[i] &
SRDS_MEDIUM_TYPE,
/*data_ptr*/ softc->density_info[i],
/*length*/ sizeof(softc->density_info[i]),
/*sense_len*/ SSD_FULL_SIZE,
/*timeout*/ REP_DENSITY_TIMEOUT);
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
softc->device_stats);
status = ccb->ccb_h.status & CAM_STATUS_MASK;
/*
* Some tape drives won't support this command at
* all, but hopefully we'll minimize that with the
* check for SPC or greater support above. If they
* don't support the default report (neither the
* MEDIA or MEDIUM_TYPE bits set), then there is
* really no point in continuing on to look for
* other reports.
*/
if ((error != 0)
|| (status != CAM_REQ_CMP)) {
error = 0;
softc->density_info_valid[i] = 0;
if (softc->density_type_bits[i] == 0)
break;
else
continue;
}
softc->density_info_valid[i] = ccb->csio.dxfer_len -
ccb->csio.resid;
}
}
/*
* Get logical block protection parameters if the drive supports it.
*/
if ((params_to_get & SA_PARAM_LBP)
&& (softc->flags & SA_FLAG_PROTECT_SUPP)) {
struct scsi_mode_header_10 *mode10_hdr;
struct scsi_control_data_prot_subpage *dp_page;
struct scsi_mode_sense_10 *cdb;
struct sa_prot_state *prot;
int dp_len, returned_len;
if (dp_size == 0)
dp_size = sizeof(*dp_page);
dp_len = sizeof(*mode10_hdr) + dp_size;
mode10_hdr = malloc(dp_len, M_SCSISA, M_NOWAIT | M_ZERO);
if (mode10_hdr == NULL) {
error = ENOMEM;
goto sagetparamsexit;
}
scsi_mode_sense_len(&ccb->csio,
/*retries*/ 5,
/*cbfcnp*/ sadone,
/*tag_action*/ MSG_SIMPLE_Q_TAG,
/*dbd*/ TRUE,
/*page_code*/ (prot_changeable == 0) ?
SMS_PAGE_CTRL_CURRENT :
SMS_PAGE_CTRL_CHANGEABLE,
/*page*/ SMS_CONTROL_MODE_PAGE,
/*param_buf*/ (uint8_t *)mode10_hdr,
/*param_len*/ dp_len,
/*minimum_cmd_size*/ 10,
/*sense_len*/ SSD_FULL_SIZE,
/*timeout*/ SCSIOP_TIMEOUT);
/*
* XXX KDM we need to be able to set the subpage in the
* fill function.
*/
cdb = (struct scsi_mode_sense_10 *)ccb->csio.cdb_io.cdb_bytes;
cdb->subpage = SA_CTRL_DP_SUBPAGE_CODE;
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
softc->device_stats);
if (error != 0) {
free(mode10_hdr, M_SCSISA);
goto sagetparamsexit;
}
status = ccb->ccb_h.status & CAM_STATUS_MASK;
if (status != CAM_REQ_CMP) {
error = EINVAL;
free(mode10_hdr, M_SCSISA);
goto sagetparamsexit;
}
/*
* The returned data length at least has to be long enough
* for us to look at length in the mode page header.
*/
returned_len = ccb->csio.dxfer_len - ccb->csio.resid;
if (returned_len < sizeof(mode10_hdr->data_length)) {
error = EINVAL;
free(mode10_hdr, M_SCSISA);
goto sagetparamsexit;
}
returned_len = min(returned_len,
sizeof(mode10_hdr->data_length) +
scsi_2btoul(mode10_hdr->data_length));
dp_page = (struct scsi_control_data_prot_subpage *)
&mode10_hdr[1];
/*
* We also have to have enough data to include the prot_bits
* in the subpage.
*/
if (returned_len < (sizeof(*mode10_hdr) +
__offsetof(struct scsi_control_data_prot_subpage, prot_bits)
+ sizeof(dp_page->prot_bits))) {
error = EINVAL;
free(mode10_hdr, M_SCSISA);
goto sagetparamsexit;
}
prot = &softc->prot_info.cur_prot_state;
prot->prot_method = dp_page->prot_method;
prot->pi_length = dp_page->pi_length &
SA_CTRL_DP_PI_LENGTH_MASK;
prot->lbp_w = (dp_page->prot_bits & SA_CTRL_DP_LBP_W) ? 1 :0;
prot->lbp_r = (dp_page->prot_bits & SA_CTRL_DP_LBP_R) ? 1 :0;
prot->rbdp = (dp_page->prot_bits & SA_CTRL_DP_RBDP) ? 1 :0;
prot->initialized = 1;
if (prot_page != NULL)
bcopy(dp_page, prot_page, min(sizeof(*prot_page),
sizeof(*dp_page)));
free(mode10_hdr, M_SCSISA);
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (CAM_DEBUGGED(periph->path, CAM_DEBUG_INFO)) {
int idx;
char *xyz = mode_buffer;
xpt_print_path(periph->path);
printf("Mode Sense Data=");
for (idx = 0; idx < mode_buffer_len; idx++)
printf(" 0x%02x", xyz[idx] & 0xff);
printf("\n");
}
sagetparamsexit:
xpt_release_ccb(ccb);
2007-05-14 21:48:53 +00:00
free(mode_buffer, M_SCSISA);
return (error);
}
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
/*
* Set protection information to the pending protection information stored
* in the softc.
*/
static int
sasetprot(struct cam_periph *periph, struct sa_prot_state *new_prot)
{
struct sa_softc *softc;
struct scsi_control_data_prot_subpage *dp_page, *dp_changeable;
struct scsi_mode_header_10 *mode10_hdr, *mode10_changeable;
union ccb *ccb;
uint8_t current_speed;
size_t dp_size, dp_page_length;
int dp_len, buff_mode;
int error;
softc = (struct sa_softc *)periph->softc;
mode10_hdr = NULL;
mode10_changeable = NULL;
ccb = NULL;
/*
* Start off with the size set to the actual length of the page
* that we have defined.
*/
dp_size = sizeof(*dp_changeable);
dp_page_length = dp_size -
__offsetof(struct scsi_control_data_prot_subpage, prot_method);
retry_length:
dp_len = sizeof(*mode10_changeable) + dp_size;
mode10_changeable = malloc(dp_len, M_SCSISA, M_NOWAIT | M_ZERO);
if (mode10_changeable == NULL) {
error = ENOMEM;
goto bailout;
}
dp_changeable =
(struct scsi_control_data_prot_subpage *)&mode10_changeable[1];
/*
* First get the data protection page changeable parameters mask.
* We need to know which parameters the drive supports changing.
* We also need to know what the drive claims that its page length
* is. The reason is that IBM drives in particular are very picky
* about the page length. They want it (the length set in the
* page structure itself) to be 28 bytes, and they want the
* parameter list length specified in the mode select header to be
* 40 bytes. So, to work with IBM drives as well as any other tape
* drive, find out what the drive claims the page length is, and
* make sure that we match that.
*/
error = sagetparams(periph, SA_PARAM_SPEED | SA_PARAM_LBP,
NULL, NULL, NULL, &buff_mode, NULL, &current_speed, NULL, NULL,
NULL, NULL, dp_changeable, dp_size, /*prot_changeable*/ 1);
if (error != 0)
goto bailout;
if (scsi_2btoul(dp_changeable->length) > dp_page_length) {
dp_page_length = scsi_2btoul(dp_changeable->length);
dp_size = dp_page_length +
__offsetof(struct scsi_control_data_prot_subpage,
prot_method);
free(mode10_changeable, M_SCSISA);
mode10_changeable = NULL;
goto retry_length;
}
mode10_hdr = malloc(dp_len, M_SCSISA, M_NOWAIT | M_ZERO);
if (mode10_hdr == NULL) {
error = ENOMEM;
goto bailout;
}
dp_page = (struct scsi_control_data_prot_subpage *)&mode10_hdr[1];
/*
* Now grab the actual current settings in the page.
*/
error = sagetparams(periph, SA_PARAM_SPEED | SA_PARAM_LBP,
NULL, NULL, NULL, &buff_mode, NULL, &current_speed, NULL, NULL,
NULL, NULL, dp_page, dp_size, /*prot_changeable*/ 0);
if (error != 0)
goto bailout;
/* These two fields need to be 0 for MODE SELECT */
scsi_ulto2b(0, mode10_hdr->data_length);
mode10_hdr->medium_type = 0;
/* We are not including a block descriptor */
scsi_ulto2b(0, mode10_hdr->blk_desc_len);
mode10_hdr->dev_spec = current_speed;
/* if set, set single-initiator buffering mode */
if (softc->buffer_mode == SMH_SA_BUF_MODE_SIBUF) {
mode10_hdr->dev_spec |= SMH_SA_BUF_MODE_SIBUF;
}
/*
* For each field, make sure that the drive allows changing it
* before bringing in the user's setting.
*/
if (dp_changeable->prot_method != 0)
dp_page->prot_method = new_prot->prot_method;
if (dp_changeable->pi_length & SA_CTRL_DP_PI_LENGTH_MASK) {
dp_page->pi_length &= ~SA_CTRL_DP_PI_LENGTH_MASK;
dp_page->pi_length |= (new_prot->pi_length &
SA_CTRL_DP_PI_LENGTH_MASK);
}
if (dp_changeable->prot_bits & SA_CTRL_DP_LBP_W) {
if (new_prot->lbp_w)
dp_page->prot_bits |= SA_CTRL_DP_LBP_W;
else
dp_page->prot_bits &= ~SA_CTRL_DP_LBP_W;
}
if (dp_changeable->prot_bits & SA_CTRL_DP_LBP_R) {
if (new_prot->lbp_r)
dp_page->prot_bits |= SA_CTRL_DP_LBP_R;
else
dp_page->prot_bits &= ~SA_CTRL_DP_LBP_R;
}
if (dp_changeable->prot_bits & SA_CTRL_DP_RBDP) {
if (new_prot->rbdp)
dp_page->prot_bits |= SA_CTRL_DP_RBDP;
else
dp_page->prot_bits &= ~SA_CTRL_DP_RBDP;
}
ccb = cam_periph_getccb(periph, 1);
scsi_mode_select_len(&ccb->csio,
/*retries*/ 5,
/*cbfcnp*/ sadone,
/*tag_action*/ MSG_SIMPLE_Q_TAG,
/*scsi_page_fmt*/ TRUE,
/*save_pages*/ FALSE,
/*param_buf*/ (uint8_t *)mode10_hdr,
/*param_len*/ dp_len,
/*minimum_cmd_size*/ 10,
/*sense_len*/ SSD_FULL_SIZE,
/*timeout*/ SCSIOP_TIMEOUT);
error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats);
if (error != 0)
goto bailout;
if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
error = EINVAL;
goto bailout;
}
/*
* The operation was successful. We could just copy the settings
* the user requested, but just in case the drive ignored some of
* our settings, let's ask for status again.
*/
error = sagetparams(periph, SA_PARAM_SPEED | SA_PARAM_LBP,
NULL, NULL, NULL, &buff_mode, NULL, &current_speed, NULL, NULL,
NULL, NULL, dp_page, dp_size, 0);
bailout:
if (ccb != NULL)
xpt_release_ccb(ccb);
free(mode10_hdr, M_SCSISA);
free(mode10_changeable, M_SCSISA);
return (error);
}
/*
* The purpose of this function is to set one of four different parameters
* for a tape drive:
* - blocksize
* - density
* - compression / compression algorithm
* - buffering mode
*
* The assumption is that this will be called from saioctl(), and therefore
* from a process context. Thus the waiting malloc calls below. If that
* assumption ever changes, the malloc calls should be changed to be
* NOWAIT mallocs.
*
* Any or all of the four parameters may be set when this function is
* called. It should handle setting more than one parameter at once.
*/
static int
sasetparams(struct cam_periph *periph, sa_params params_to_set,
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
u_int32_t blocksize, u_int8_t density, u_int32_t calg,
u_int32_t sense_flags)
{
struct sa_softc *softc;
u_int32_t current_blocksize;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
u_int32_t current_calg;
u_int8_t current_density;
u_int8_t current_speed;
int comp_enabled, comp_supported;
void *mode_buffer;
int mode_buffer_len;
struct scsi_mode_header_6 *mode_hdr;
struct scsi_mode_blk_desc *mode_blk;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
sa_comp_t *ccomp, *cpage;
int buff_mode;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
union ccb *ccb = NULL;
int error;
softc = (struct sa_softc *)periph->softc;
ccomp = malloc(sizeof (sa_comp_t), M_SCSISA, M_NOWAIT);
if (ccomp == NULL)
return (ENOMEM);
/*
* Since it doesn't make sense to set the number of blocks, or
* write protection, we won't try to get the current value. We
* always want to get the blocksize, so we can set it back to the
* proper value.
*/
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
error = sagetparams(periph,
params_to_set | SA_PARAM_BLOCKSIZE | SA_PARAM_SPEED,
&current_blocksize, &current_density, NULL, &buff_mode, NULL,
&current_speed, &comp_supported, &comp_enabled,
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
&current_calg, ccomp, NULL, 0, 0);
if (error != 0) {
2007-05-14 21:48:53 +00:00
free(ccomp, M_SCSISA);
return (error);
}
mode_buffer_len = sizeof(*mode_hdr) + sizeof(*mode_blk);
if (params_to_set & SA_PARAM_COMPRESSION)
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
mode_buffer_len += sizeof (sa_comp_t);
mode_buffer = malloc(mode_buffer_len, M_SCSISA, M_NOWAIT | M_ZERO);
if (mode_buffer == NULL) {
free(ccomp, M_SCSISA);
return (ENOMEM);
}
mode_hdr = (struct scsi_mode_header_6 *)mode_buffer;
mode_blk = (struct scsi_mode_blk_desc *)&mode_hdr[1];
ccb = cam_periph_getccb(periph, 1);
retry:
if (params_to_set & SA_PARAM_COMPRESSION) {
if (mode_blk) {
cpage = (sa_comp_t *)&mode_blk[1];
} else {
cpage = (sa_comp_t *)&mode_hdr[1];
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
bcopy(ccomp, cpage, sizeof (sa_comp_t));
cpage->hdr.pagecode &= ~0x80;
} else
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
cpage = NULL;
/*
* If the caller wants us to set the blocksize, use the one they
* pass in. Otherwise, use the blocksize we got back from the
* mode select above.
*/
if (mode_blk) {
if (params_to_set & SA_PARAM_BLOCKSIZE)
scsi_ulto3b(blocksize, mode_blk->blklen);
else
scsi_ulto3b(current_blocksize, mode_blk->blklen);
/*
* Set density if requested, else preserve old density.
* SCSI_SAME_DENSITY only applies to SCSI-2 or better
* devices, else density we've latched up in our softc.
*/
if (params_to_set & SA_PARAM_DENSITY) {
mode_blk->density = density;
} else if (softc->scsi_rev > SCSI_REV_CCS) {
mode_blk->density = SCSI_SAME_DENSITY;
} else {
mode_blk->density = softc->media_density;
}
}
/*
* For mode selects, these two fields must be zero.
*/
mode_hdr->data_length = 0;
mode_hdr->medium_type = 0;
/* set the speed to the current value */
mode_hdr->dev_spec = current_speed;
/* if set, set single-initiator buffering mode */
if (softc->buffer_mode == SMH_SA_BUF_MODE_SIBUF) {
mode_hdr->dev_spec |= SMH_SA_BUF_MODE_SIBUF;
}
if (mode_blk)
mode_hdr->blk_desc_len = sizeof(struct scsi_mode_blk_desc);
else
mode_hdr->blk_desc_len = 0;
/*
* First, if the user wants us to set the compression algorithm or
* just turn compression on, check to make sure that this drive
* supports compression.
*/
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (params_to_set & SA_PARAM_COMPRESSION) {
/*
* If the compression algorithm is 0, disable compression.
* If the compression algorithm is non-zero, enable
* compression and set the compression type to the
* specified compression algorithm, unless the algorithm is
* MT_COMP_ENABLE. In that case, we look at the
* compression algorithm that is currently set and if it is
* non-zero, we leave it as-is. If it is zero, and we have
* saved a compression algorithm from a time when
* compression was enabled before, set the compression to
* the saved value.
*/
switch (ccomp->hdr.pagecode & ~0x80) {
case SA_DEVICE_CONFIGURATION_PAGE:
{
struct scsi_dev_conf_page *dcp = &cpage->dconf;
if (calg == 0) {
dcp->sel_comp_alg = SA_COMP_NONE;
break;
}
if (calg != MT_COMP_ENABLE) {
dcp->sel_comp_alg = calg;
} else if (dcp->sel_comp_alg == SA_COMP_NONE &&
softc->saved_comp_algorithm != 0) {
dcp->sel_comp_alg = softc->saved_comp_algorithm;
}
break;
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
case SA_DATA_COMPRESSION_PAGE:
if (ccomp->dcomp.dce_and_dcc & SA_DCP_DCC) {
struct scsi_data_compression_page *dcp = &cpage->dcomp;
if (calg == 0) {
/*
* Disable compression, but leave the
* decompression and the capability bit
* alone.
*/
dcp->dce_and_dcc = SA_DCP_DCC;
dcp->dde_and_red |= SA_DCP_DDE;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
break;
}
/* enable compression && decompression */
dcp->dce_and_dcc = SA_DCP_DCE | SA_DCP_DCC;
dcp->dde_and_red |= SA_DCP_DDE;
/*
* If there, use compression algorithm from caller.
* Otherwise, if there's a saved compression algorithm
* and there is no current algorithm, use the saved
* algorithm. Else parrot back what we got and hope
* for the best.
*/
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (calg != MT_COMP_ENABLE) {
scsi_ulto4b(calg, dcp->comp_algorithm);
scsi_ulto4b(calg, dcp->decomp_algorithm);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
} else if (scsi_4btoul(dcp->comp_algorithm) == 0 &&
softc->saved_comp_algorithm != 0) {
scsi_ulto4b(softc->saved_comp_algorithm,
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
dcp->comp_algorithm);
scsi_ulto4b(softc->saved_comp_algorithm,
dcp->decomp_algorithm);
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
break;
}
/*
* Compression does not appear to be supported-
* at least via the DATA COMPRESSION page. It
* would be too much to ask us to believe that
* the page itself is supported, but incorrectly
* reports an ability to manipulate data compression,
* so we'll assume that this device doesn't support
* compression. We can just fall through for that.
*/
/* FALLTHROUGH */
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
default:
/*
* The drive doesn't seem to support compression,
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
* so turn off the set compression bit.
*/
params_to_set &= ~SA_PARAM_COMPRESSION;
xpt_print(periph->path,
"device does not seem to support compression\n");
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
/*
* If that was the only thing the user wanted us to set,
* clean up allocated resources and return with
* 'operation not supported'.
*/
if (params_to_set == SA_PARAM_NONE) {
2007-05-14 21:48:53 +00:00
free(mode_buffer, M_SCSISA);
xpt_release_ccb(ccb);
return (ENODEV);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
}
/*
* That wasn't the only thing the user wanted us to set.
* So, decrease the stated mode buffer length by the
* size of the compression mode page.
*/
mode_buffer_len -= sizeof(sa_comp_t);
}
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
/* It is safe to retry this operation */
scsi_mode_select(&ccb->csio, 5, sadone, MSG_SIMPLE_Q_TAG,
(params_to_set & SA_PARAM_COMPRESSION)? TRUE : FALSE,
FALSE, mode_buffer, mode_buffer_len, SSD_FULL_SIZE, SCSIOP_TIMEOUT);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
error = cam_periph_runccb(ccb, saerror, 0,
sense_flags, softc->device_stats);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (CAM_DEBUGGED(periph->path, CAM_DEBUG_INFO)) {
int idx;
char *xyz = mode_buffer;
xpt_print_path(periph->path);
printf("Err%d, Mode Select Data=", error);
for (idx = 0; idx < mode_buffer_len; idx++)
printf(" 0x%02x", xyz[idx] & 0xff);
printf("\n");
}
if (error) {
/*
* If we can, try without setting density/blocksize.
*/
if (mode_blk) {
if ((params_to_set &
(SA_PARAM_DENSITY|SA_PARAM_BLOCKSIZE)) == 0) {
mode_blk = NULL;
goto retry;
}
} else {
mode_blk = (struct scsi_mode_blk_desc *)&mode_hdr[1];
cpage = (sa_comp_t *)&mode_blk[1];
}
/*
* If we were setting the blocksize, and that failed, we
* want to set it to its original value. If we weren't
* setting the blocksize, we don't want to change it.
*/
scsi_ulto3b(current_blocksize, mode_blk->blklen);
/*
* Set density if requested, else preserve old density.
* SCSI_SAME_DENSITY only applies to SCSI-2 or better
* devices, else density we've latched up in our softc.
*/
if (params_to_set & SA_PARAM_DENSITY) {
mode_blk->density = current_density;
} else if (softc->scsi_rev > SCSI_REV_CCS) {
mode_blk->density = SCSI_SAME_DENSITY;
} else {
mode_blk->density = softc->media_density;
}
if (params_to_set & SA_PARAM_COMPRESSION)
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
bcopy(ccomp, cpage, sizeof (sa_comp_t));
/*
* The retry count is the only CCB field that might have been
* changed that we care about, so reset it back to 1.
*/
ccb->ccb_h.retry_count = 1;
cam_periph_runccb(ccb, saerror, 0, sense_flags,
softc->device_stats);
}
xpt_release_ccb(ccb);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (ccomp != NULL)
2007-05-14 21:48:53 +00:00
free(ccomp, M_SCSISA);
if (params_to_set & SA_PARAM_COMPRESSION) {
if (error) {
softc->flags &= ~SA_FLAG_COMP_ENABLED;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
/*
* Even if we get an error setting compression,
* do not say that we don't support it. We could
* have been wrong, or it may be media specific.
* softc->flags &= ~SA_FLAG_COMP_SUPP;
*/
softc->saved_comp_algorithm = softc->comp_algorithm;
softc->comp_algorithm = 0;
} else {
softc->flags |= SA_FLAG_COMP_ENABLED;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
softc->comp_algorithm = calg;
}
}
2007-05-14 21:48:53 +00:00
free(mode_buffer, M_SCSISA);
return (error);
}
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
static int
saextget(struct cdev *dev, struct cam_periph *periph, struct sbuf *sb,
struct mtextget *g)
{
int indent, error;
char tmpstr[80];
struct sa_softc *softc;
int tmpint;
uint32_t maxio_tmp;
struct ccb_getdev cgd;
softc = (struct sa_softc *)periph->softc;
error = 0;
error = sagetparams_common(dev, periph);
if (error)
goto extget_bailout;
if (!SA_IS_CTRL(dev) && !softc->open_pending_mount)
sagetpos(periph);
indent = 0;
SASBADDNODE(sb, indent, mtextget);
/*
* Basic CAM peripheral information.
*/
SASBADDVARSTR(sb, indent, periph->periph_name, %s, periph_name,
strlen(periph->periph_name) + 1);
SASBADDUINT(sb, indent, periph->unit_number, %u, unit_number);
xpt_setup_ccb(&cgd.ccb_h,
periph->path,
CAM_PRIORITY_NORMAL);
cgd.ccb_h.func_code = XPT_GDEV_TYPE;
xpt_action((union ccb *)&cgd);
if ((cgd.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
g->status = MT_EXT_GET_ERROR;
snprintf(g->error_str, sizeof(g->error_str),
"Error %#x returned for XPT_GDEV_TYPE CCB",
cgd.ccb_h.status);
goto extget_bailout;
}
cam_strvis(tmpstr, cgd.inq_data.vendor,
sizeof(cgd.inq_data.vendor), sizeof(tmpstr));
SASBADDVARSTRDESC(sb, indent, tmpstr, %s, vendor,
sizeof(cgd.inq_data.vendor) + 1, "SCSI Vendor ID");
cam_strvis(tmpstr, cgd.inq_data.product,
sizeof(cgd.inq_data.product), sizeof(tmpstr));
SASBADDVARSTRDESC(sb, indent, tmpstr, %s, product,
sizeof(cgd.inq_data.product) + 1, "SCSI Product ID");
cam_strvis(tmpstr, cgd.inq_data.revision,
sizeof(cgd.inq_data.revision), sizeof(tmpstr));
SASBADDVARSTRDESC(sb, indent, tmpstr, %s, revision,
sizeof(cgd.inq_data.revision) + 1, "SCSI Revision");
if (cgd.serial_num_len > 0) {
char *tmpstr2;
size_t ts2_len;
int ts2_malloc;
ts2_len = 0;
if (cgd.serial_num_len > sizeof(tmpstr)) {
ts2_len = cgd.serial_num_len + 1;
ts2_malloc = 1;
tmpstr2 = malloc(ts2_len, M_SCSISA, M_WAITOK | M_ZERO);
} else {
ts2_len = sizeof(tmpstr);
ts2_malloc = 0;
tmpstr2 = tmpstr;
}
cam_strvis(tmpstr2, cgd.serial_num, cgd.serial_num_len,
ts2_len);
SASBADDVARSTRDESC(sb, indent, tmpstr2, %s, serial_num,
(ssize_t)cgd.serial_num_len + 1, "Serial Number");
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
if (ts2_malloc != 0)
free(tmpstr2, M_SCSISA);
} else {
/*
* We return a serial_num element in any case, but it will
* be empty if the device has no serial number.
*/
tmpstr[0] = '\0';
SASBADDVARSTRDESC(sb, indent, tmpstr, %s, serial_num,
(ssize_t)0, "Serial Number");
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
}
SASBADDUINTDESC(sb, indent, softc->maxio, %u, maxio,
"Maximum I/O size allowed by driver and controller");
SASBADDUINTDESC(sb, indent, softc->cpi_maxio, %u, cpi_maxio,
"Maximum I/O size reported by controller");
SASBADDUINTDESC(sb, indent, softc->max_blk, %u, max_blk,
"Maximum block size supported by tape drive and media");
SASBADDUINTDESC(sb, indent, softc->min_blk, %u, min_blk,
"Minimum block size supported by tape drive and media");
SASBADDUINTDESC(sb, indent, softc->blk_gran, %u, blk_gran,
"Block granularity supported by tape drive and media");
maxio_tmp = min(softc->max_blk, softc->maxio);
SASBADDUINTDESC(sb, indent, maxio_tmp, %u, max_effective_iosize,
"Maximum possible I/O size");
SASBADDINTDESC(sb, indent, softc->flags & SA_FLAG_FIXED ? 1 : 0, %d,
fixed_mode, "Set to 1 for fixed block mode, 0 for variable block");
/*
* XXX KDM include SIM, bus, target, LUN?
*/
if (softc->flags & SA_FLAG_COMP_UNSUPP)
tmpint = 0;
else
tmpint = 1;
SASBADDINTDESC(sb, indent, tmpint, %d, compression_supported,
"Set to 1 if compression is supported, 0 if not");
if (softc->flags & SA_FLAG_COMP_ENABLED)
tmpint = 1;
else
tmpint = 0;
SASBADDINTDESC(sb, indent, tmpint, %d, compression_enabled,
"Set to 1 if compression is enabled, 0 if not");
SASBADDUINTDESC(sb, indent, softc->comp_algorithm, %u,
compression_algorithm, "Numeric compression algorithm");
safillprot(softc, &indent, sb);
SASBADDUINTDESC(sb, indent, softc->media_blksize, %u,
media_blocksize, "Block size reported by drive or set by user");
SASBADDINTDESC(sb, indent, (intmax_t)softc->fileno, %jd,
calculated_fileno, "Calculated file number, -1 if unknown");
SASBADDINTDESC(sb, indent, (intmax_t)softc->blkno, %jd,
calculated_rel_blkno, "Calculated block number relative to file, "
"set to -1 if unknown");
SASBADDINTDESC(sb, indent, (intmax_t)softc->rep_fileno, %jd,
reported_fileno, "File number reported by drive, -1 if unknown");
SASBADDINTDESC(sb, indent, (intmax_t)softc->rep_blkno, %jd,
reported_blkno, "Block number relative to BOP/BOT reported by "
"drive, -1 if unknown");
SASBADDINTDESC(sb, indent, (intmax_t)softc->partition, %jd,
partition, "Current partition number, 0 is the default");
SASBADDINTDESC(sb, indent, softc->bop, %d, bop,
"Set to 1 if drive is at the beginning of partition/tape, 0 if "
"not, -1 if unknown");
SASBADDINTDESC(sb, indent, softc->eop, %d, eop,
"Set to 1 if drive is past early warning, 0 if not, -1 if unknown");
SASBADDINTDESC(sb, indent, softc->bpew, %d, bpew,
"Set to 1 if drive is past programmable early warning, 0 if not, "
"-1 if unknown");
SASBADDINTDESC(sb, indent, (intmax_t)softc->last_io_resid, %jd,
residual, "Residual for the last I/O");
/*
* XXX KDM should we send a string with the current driver
* status already decoded instead of a numeric value?
*/
SASBADDINTDESC(sb, indent, softc->dsreg, %d, dsreg,
"Current state of the driver");
safilldensitysb(softc, &indent, sb);
SASBENDNODE(sb, indent, mtextget);
extget_bailout:
return (error);
}
static int
saparamget(struct sa_softc *softc, struct sbuf *sb)
{
int indent;
indent = 0;
SASBADDNODE(sb, indent, mtparamget);
SASBADDINTDESC(sb, indent, softc->sili, %d, sili,
"Suppress an error on underlength variable reads");
SASBADDINTDESC(sb, indent, softc->eot_warn, %d, eot_warn,
"Return an error to warn that end of tape is approaching");
safillprot(softc, &indent, sb);
SASBENDNODE(sb, indent, mtparamget);
return (0);
}
static void
saprevent(struct cam_periph *periph, int action)
{
struct sa_softc *softc;
union ccb *ccb;
int error, sf;
softc = (struct sa_softc *)periph->softc;
if ((action == PR_ALLOW) && (softc->flags & SA_FLAG_TAPE_LOCKED) == 0)
return;
if ((action == PR_PREVENT) && (softc->flags & SA_FLAG_TAPE_LOCKED) != 0)
return;
/*
* We can be quiet about illegal requests.
*/
if (CAM_DEBUGGED(periph->path, CAM_DEBUG_INFO)) {
sf = 0;
} else
sf = SF_QUIET_IR;
ccb = cam_periph_getccb(periph, 1);
/* It is safe to retry this operation */
scsi_prevent(&ccb->csio, 5, sadone, MSG_SIMPLE_Q_TAG, action,
SSD_FULL_SIZE, SCSIOP_TIMEOUT);
error = cam_periph_runccb(ccb, saerror, 0, sf, softc->device_stats);
if (error == 0) {
if (action == PR_ALLOW)
softc->flags &= ~SA_FLAG_TAPE_LOCKED;
else
softc->flags |= SA_FLAG_TAPE_LOCKED;
}
xpt_release_ccb(ccb);
}
static int
sarewind(struct cam_periph *periph)
{
union ccb *ccb;
struct sa_softc *softc;
int error;
softc = (struct sa_softc *)periph->softc;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
ccb = cam_periph_getccb(periph, 1);
/* It is safe to retry this operation */
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
scsi_rewind(&ccb->csio, 2, sadone, MSG_SIMPLE_Q_TAG, FALSE,
SSD_FULL_SIZE, REWIND_TIMEOUT);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_REW;
error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_REST;
xpt_release_ccb(ccb);
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
if (error == 0) {
softc->partition = softc->fileno = softc->blkno = (daddr_t) 0;
softc->rep_fileno = softc->rep_blkno = (daddr_t) 0;
} else {
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->fileno = softc->blkno = (daddr_t) -1;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->partition = (daddr_t) -1;
softc->rep_fileno = softc->rep_blkno = (daddr_t) -1;
}
return (error);
}
static int
saspace(struct cam_periph *periph, int count, scsi_space_code code)
{
union ccb *ccb;
struct sa_softc *softc;
int error;
softc = (struct sa_softc *)periph->softc;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
ccb = cam_periph_getccb(periph, 1);
/* This cannot be retried */
scsi_space(&ccb->csio, 0, sadone, MSG_SIMPLE_Q_TAG, code, count,
SSD_FULL_SIZE, SPACE_TIMEOUT);
/*
* Clear residual because we will be using it.
*/
softc->last_ctl_resid = 0;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = (count < 0)? MTIO_DSREG_REV : MTIO_DSREG_FWD;
error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_REST;
xpt_release_ccb(ccb);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
/*
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
* If a spacing operation has failed, we need to invalidate
* this mount.
*
* If the spacing operation was setmarks or to end of recorded data,
* we no longer know our relative position.
*
* If the spacing operations was spacing files in reverse, we
* take account of the residual, but still check against less
* than zero- if we've gone negative, we must have hit BOT.
*
* If the spacing operations was spacing records in reverse and
* we have a residual, we've either hit BOT or hit a filemark.
* In the former case, we know our new record number (0). In
* the latter case, we have absolutely no idea what the real
* record number is- we've stopped between the end of the last
* record in the previous file and the filemark that stopped
* our spacing backwards.
*/
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
if (error) {
softc->fileno = softc->blkno = (daddr_t) -1;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->rep_blkno = softc->partition = (daddr_t) -1;
softc->rep_fileno = (daddr_t) -1;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
} else if (code == SS_SETMARKS || code == SS_EOD) {
softc->fileno = softc->blkno = (daddr_t) -1;
} else if (code == SS_FILEMARKS && softc->fileno != (daddr_t) -1) {
softc->fileno += (count - softc->last_ctl_resid);
if (softc->fileno < 0) /* we must of hit BOT */
softc->fileno = 0;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->blkno = 0;
} else if (code == SS_BLOCKS && softc->blkno != (daddr_t) -1) {
softc->blkno += (count - softc->last_ctl_resid);
if (count < 0) {
if (softc->last_ctl_resid || softc->blkno < 0) {
if (softc->fileno == 0) {
softc->blkno = 0;
} else {
softc->blkno = (daddr_t) -1;
}
}
}
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
}
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
if (error == 0)
sagetpos(periph);
return (error);
}
static int
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
sawritefilemarks(struct cam_periph *periph, int nmarks, int setmarks, int immed)
{
union ccb *ccb;
struct sa_softc *softc;
int error, nwm = 0;
softc = (struct sa_softc *)periph->softc;
if (softc->open_rdonly)
return (EBADF);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
ccb = cam_periph_getccb(periph, 1);
/*
* Clear residual because we will be using it.
*/
softc->last_ctl_resid = 0;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_FMK;
/* this *must* not be retried */
scsi_write_filemarks(&ccb->csio, 0, sadone, MSG_SIMPLE_Q_TAG,
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
immed, setmarks, nmarks, SSD_FULL_SIZE, IO_TIMEOUT);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_REST;
error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats);
if (error == 0 && nmarks) {
struct sa_softc *softc = (struct sa_softc *)periph->softc;
nwm = nmarks - softc->last_ctl_resid;
softc->filemarks += nwm;
}
xpt_release_ccb(ccb);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
/*
* Update relative positions (if we're doing that).
*/
if (error) {
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
softc->fileno = softc->blkno = softc->partition = (daddr_t) -1;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
} else if (softc->fileno != (daddr_t) -1) {
softc->fileno += nwm;
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->blkno = 0;
}
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
/*
* Ask the tape drive for position information.
*/
sagetpos(periph);
/*
* If we got valid position information, since we just wrote a file
* mark, we know we're at the file mark and block 0 after that
* filemark.
*/
if (softc->rep_fileno != (daddr_t) -1) {
softc->fileno = softc->rep_fileno;
softc->blkno = 0;
}
return (error);
}
static int
sagetpos(struct cam_periph *periph)
{
union ccb *ccb;
struct scsi_tape_position_long_data long_pos;
struct sa_softc *softc = (struct sa_softc *)periph->softc;
int error;
if (softc->quirks & SA_QUIRK_NO_LONG_POS) {
softc->rep_fileno = (daddr_t) -1;
softc->rep_blkno = (daddr_t) -1;
softc->bop = softc->eop = softc->bpew = -1;
return (EOPNOTSUPP);
}
bzero(&long_pos, sizeof(long_pos));
ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
scsi_read_position_10(&ccb->csio,
/*retries*/ 1,
/*cbfcnp*/ sadone,
/*tag_action*/ MSG_SIMPLE_Q_TAG,
/*service_action*/ SA_RPOS_LONG_FORM,
/*data_ptr*/ (uint8_t *)&long_pos,
/*length*/ sizeof(long_pos),
/*sense_len*/ SSD_FULL_SIZE,
/*timeout*/ SCSIOP_TIMEOUT);
softc->dsreg = MTIO_DSREG_RBSY;
error = cam_periph_runccb(ccb, saerror, 0, SF_QUIET_IR,
softc->device_stats);
softc->dsreg = MTIO_DSREG_REST;
if (error == 0) {
if (long_pos.flags & SA_RPOS_LONG_MPU) {
/*
* If the drive doesn't know what file mark it is
* on, our calculated filemark isn't going to be
* accurate either.
*/
softc->fileno = (daddr_t) -1;
softc->rep_fileno = (daddr_t) -1;
} else {
softc->fileno = softc->rep_fileno =
scsi_8btou64(long_pos.logical_file_num);
}
if (long_pos.flags & SA_RPOS_LONG_LONU) {
softc->partition = (daddr_t) -1;
softc->rep_blkno = (daddr_t) -1;
/*
* If the tape drive doesn't know its block
* position, we can't claim to know it either.
*/
softc->blkno = (daddr_t) -1;
} else {
softc->partition = scsi_4btoul(long_pos.partition);
softc->rep_blkno =
scsi_8btou64(long_pos.logical_object_num);
}
if (long_pos.flags & SA_RPOS_LONG_BOP)
softc->bop = 1;
else
softc->bop = 0;
if (long_pos.flags & SA_RPOS_LONG_EOP)
softc->eop = 1;
else
softc->eop = 0;
if (long_pos.flags & SA_RPOS_LONG_BPEW)
softc->bpew = 1;
else
softc->bpew = 0;
} else if (error == EINVAL) {
/*
* If this drive returned an invalid-request type error,
* then it likely doesn't support the long form report.
*/
softc->quirks |= SA_QUIRK_NO_LONG_POS;
}
if (error != 0) {
softc->rep_fileno = softc->rep_blkno = (daddr_t) -1;
softc->partition = (daddr_t) -1;
softc->bop = softc->eop = softc->bpew = -1;
}
xpt_release_ccb(ccb);
return (error);
}
static int
sardpos(struct cam_periph *periph, int hard, u_int32_t *blkptr)
{
struct scsi_tape_position_data loc;
union ccb *ccb;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
struct sa_softc *softc = (struct sa_softc *)periph->softc;
int error;
/*
* We try and flush any buffered writes here if we were writing
* and we're trying to get hardware block position. It eats
* up performance substantially, but I'm wary of drive firmware.
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
*
* I think that *logical* block position is probably okay-
* but hardware block position might have to wait for data
* to hit media to be valid. Caveat Emptor.
*/
if (hard && (softc->flags & SA_FLAG_TAPE_WRITTEN)) {
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
error = sawritefilemarks(periph, 0, 0, 0);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
if (error && error != EACCES)
return (error);
}
ccb = cam_periph_getccb(periph, 1);
scsi_read_position(&ccb->csio, 1, sadone, MSG_SIMPLE_Q_TAG,
hard, &loc, SSD_FULL_SIZE, SCSIOP_TIMEOUT);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_RBSY;
error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_REST;
if (error == 0) {
if (loc.flags & SA_RPOS_UNCERTAIN) {
error = EINVAL; /* nothing is certain */
} else {
*blkptr = scsi_4btoul(loc.firstblk);
}
}
xpt_release_ccb(ccb);
return (error);
}
static int
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
sasetpos(struct cam_periph *periph, int hard, struct mtlocate *locate_info)
{
union ccb *ccb;
struct sa_softc *softc;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
int locate16;
int immed, cp;
int error;
/*
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
* We used to try and flush any buffered writes here.
* Now we push this onto user applications to either
* flush the pending writes themselves (via a zero count
* WRITE FILEMARKS command) or they can trust their tape
* drive to do this correctly for them.
*/
softc = (struct sa_softc *)periph->softc;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
ccb = cam_periph_getccb(periph, 1);
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
cp = locate_info->flags & MT_LOCATE_FLAG_CHANGE_PART ? 1 : 0;
immed = locate_info->flags & MT_LOCATE_FLAG_IMMED ? 1 : 0;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
/*
* Determine whether we have to use LOCATE or LOCATE16. The hard
* bit is only possible with LOCATE, but the new ioctls do not
* allow setting that bit. So we can't get into the situation of
* having the hard bit set with a block address that is larger than
* 32-bits.
*/
if (hard != 0)
locate16 = 0;
else if ((locate_info->dest_type != MT_LOCATE_DEST_OBJECT)
|| (locate_info->block_address_mode != MT_LOCATE_BAM_IMPLICIT)
|| (locate_info->logical_id > SA_SPOS_MAX_BLK))
locate16 = 1;
else
locate16 = 0;
if (locate16 != 0) {
scsi_locate_16(&ccb->csio,
/*retries*/ 1,
/*cbfcnp*/ sadone,
/*tag_action*/ MSG_SIMPLE_Q_TAG,
/*immed*/ immed,
/*cp*/ cp,
/*dest_type*/ locate_info->dest_type,
/*bam*/ locate_info->block_address_mode,
/*partition*/ locate_info->partition,
/*logical_id*/ locate_info->logical_id,
/*sense_len*/ SSD_FULL_SIZE,
/*timeout*/ SPACE_TIMEOUT);
} else {
scsi_locate_10(&ccb->csio,
/*retries*/ 1,
/*cbfcnp*/ sadone,
/*tag_action*/ MSG_SIMPLE_Q_TAG,
/*immed*/ immed,
/*cp*/ cp,
/*hard*/ hard,
/*partition*/ locate_info->partition,
/*block_address*/ locate_info->logical_id,
/*sense_len*/ SSD_FULL_SIZE,
/*timeout*/ SPACE_TIMEOUT);
}
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_POS;
error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_REST;
xpt_release_ccb(ccb);
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
/*
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
* We assume the calculated file and block numbers are unknown
* unless we have enough information to populate them.
*/
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->fileno = softc->blkno = (daddr_t) -1;
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
/*
* If the user requested changing the partition and the request
* succeeded, note the partition.
*/
if ((error == 0)
&& (cp != 0))
softc->partition = locate_info->partition;
else
softc->partition = (daddr_t) -1;
if (error == 0) {
switch (locate_info->dest_type) {
case MT_LOCATE_DEST_FILE:
/*
* This is the only case where we can reliably
* calculate the file and block numbers.
*/
softc->fileno = locate_info->logical_id;
softc->blkno = 0;
break;
case MT_LOCATE_DEST_OBJECT:
case MT_LOCATE_DEST_SET:
case MT_LOCATE_DEST_EOD:
default:
break;
}
}
/*
* Ask the drive for current position information.
*/
sagetpos(periph);
return (error);
}
static int
saretension(struct cam_periph *periph)
{
union ccb *ccb;
struct sa_softc *softc;
int error;
softc = (struct sa_softc *)periph->softc;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
ccb = cam_periph_getccb(periph, 1);
/* It is safe to retry this operation */
scsi_load_unload(&ccb->csio, 5, sadone, MSG_SIMPLE_Q_TAG, FALSE,
FALSE, TRUE, TRUE, SSD_FULL_SIZE, ERASE_TIMEOUT);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_TEN;
error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_REST;
xpt_release_ccb(ccb);
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
if (error == 0) {
softc->partition = softc->fileno = softc->blkno = (daddr_t) 0;
sagetpos(periph);
} else
softc->partition = softc->fileno = softc->blkno = (daddr_t) -1;
return (error);
}
static int
sareservereleaseunit(struct cam_periph *periph, int reserve)
{
union ccb *ccb;
struct sa_softc *softc;
int error;
softc = (struct sa_softc *)periph->softc;
ccb = cam_periph_getccb(periph, 1);
/* It is safe to retry this operation */
scsi_reserve_release_unit(&ccb->csio, 2, sadone, MSG_SIMPLE_Q_TAG,
FALSE, 0, SSD_FULL_SIZE, SCSIOP_TIMEOUT, reserve);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_RBSY;
error = cam_periph_runccb(ccb, saerror, 0,
SF_RETRY_UA | SF_NO_PRINT, softc->device_stats);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_REST;
xpt_release_ccb(ccb);
/*
* If the error was Illegal Request, then the device doesn't support
* RESERVE/RELEASE. This is not an error.
*/
if (error == EINVAL) {
error = 0;
}
return (error);
}
static int
saloadunload(struct cam_periph *periph, int load)
{
union ccb *ccb;
struct sa_softc *softc;
int error;
softc = (struct sa_softc *)periph->softc;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
ccb = cam_periph_getccb(periph, 1);
/* It is safe to retry this operation */
scsi_load_unload(&ccb->csio, 5, sadone, MSG_SIMPLE_Q_TAG, FALSE,
FALSE, FALSE, load, SSD_FULL_SIZE, REWIND_TIMEOUT);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = (load)? MTIO_DSREG_LD : MTIO_DSREG_UNL;
error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_REST;
xpt_release_ccb(ccb);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
if (error || load == 0) {
softc->partition = softc->fileno = softc->blkno = (daddr_t) -1;
softc->rep_fileno = softc->rep_blkno = (daddr_t) -1;
} else if (error == 0) {
softc->partition = softc->fileno = softc->blkno = (daddr_t) 0;
sagetpos(periph);
}
return (error);
}
static int
saerase(struct cam_periph *periph, int longerase)
{
union ccb *ccb;
struct sa_softc *softc;
int error;
softc = (struct sa_softc *)periph->softc;
if (softc->open_rdonly)
return (EBADF);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
ccb = cam_periph_getccb(periph, 1);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
scsi_erase(&ccb->csio, 1, sadone, MSG_SIMPLE_Q_TAG, FALSE, longerase,
SSD_FULL_SIZE, ERASE_TIMEOUT);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_ZER;
error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats);
Extend unit numbers to a full 10 bits (split into sections of the minor). Establish and use a control mode open. Control mode opens may open the device without locking, but are prohibited from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT works, but the clearing of latched error status is contingent upon whether another application has the device open, in which case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY and MTCOMP also require a periph aquire. Relative fileno and blkno are tracked. Note that just about any error will make these undefined, and if you space to EOD or use hardware block positioning, these are also lost until the next UNLOAD or REWIND. Driver state is also tracked and recorded in the unit softc to be passed back in mt_dsreg for a MTIOCGET call. Thanks to Dan Strick for suggesting this. Reintroduce 2 filemarks at EOD for all but QIC devices. I really think it's wrong, but there is a lot of 3rd party software that depends upon this (not the least of which is tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices can be marked as only being able to do 1 FM at EOD. At samount time force a load to BOT if we aren't mounted. If the LOAD command fails, use the REWIND command (e.g., for the IBM 3590 which for some gawdawful reason doesn't support the LOAD (to BOT) command). Also at samount time, if you don't know fixed or variable, try to *set* to one of the known fixed (or variable, for special case) density codes. We only have to do this once per boot, so it's not that painful. This is another way to try and figure out the wierd QIC devices without having to quirk everything in the universe. A substantial amount of cleanup as to what operations can and what operations cannot be retried. Don't retry space operations if they fail- it'll just lead to lossage. Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
softc->dsreg = MTIO_DSREG_REST;
xpt_release_ccb(ccb);
return (error);
}
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
/*
* Fill an sbuf with density data in XML format. This particular macro
* works for multi-byte integer fields.
*
* Note that 1 byte fields aren't supported here. The reason is that the
* compiler does not evaluate the sizeof(), and assumes that any of the
* sizes are possible for a given field. So passing in a multi-byte
* field will result in a warning that the assignment makes an integer
* from a pointer without a cast, if there is an assignment in the 1 byte
* case.
*/
#define SAFILLDENSSB(dens_data, sb, indent, field, desc_remain, \
len_to_go, cur_offset, desc){ \
size_t cur_field_len; \
\
cur_field_len = sizeof(dens_data->field); \
if (desc_remain < cur_field_len) { \
len_to_go -= desc_remain; \
cur_offset += desc_remain; \
continue; \
} \
len_to_go -= cur_field_len; \
cur_offset += cur_field_len; \
desc_remain -= cur_field_len; \
\
switch (sizeof(dens_data->field)) { \
case 1: \
KASSERT(1 == 0, ("Programmer error, invalid 1 byte " \
"field width for SAFILLDENSFIELD")); \
break; \
case 2: \
SASBADDUINTDESC(sb, indent, \
scsi_2btoul(dens_data->field), %u, field, desc); \
break; \
case 3: \
SASBADDUINTDESC(sb, indent, \
scsi_3btoul(dens_data->field), %u, field, desc); \
break; \
case 4: \
SASBADDUINTDESC(sb, indent, \
scsi_4btoul(dens_data->field), %u, field, desc); \
break; \
case 8: \
SASBADDUINTDESC(sb, indent, \
(uintmax_t)scsi_8btou64(dens_data->field), %ju, \
field, desc); \
break; \
default: \
break; \
} \
};
/*
* Fill an sbuf with density data in XML format. This particular macro
* works for strings.
*/
#define SAFILLDENSSBSTR(dens_data, sb, indent, field, desc_remain, \
len_to_go, cur_offset, desc){ \
size_t cur_field_len; \
char tmpstr[32]; \
\
cur_field_len = sizeof(dens_data->field); \
if (desc_remain < cur_field_len) { \
len_to_go -= desc_remain; \
cur_offset += desc_remain; \
continue; \
} \
len_to_go -= cur_field_len; \
cur_offset += cur_field_len; \
desc_remain -= cur_field_len; \
\
cam_strvis(tmpstr, dens_data->field, \
sizeof(dens_data->field), sizeof(tmpstr)); \
SASBADDVARSTRDESC(sb, indent, tmpstr, %s, field, \
strlen(tmpstr) + 1, desc); \
};
/*
* Fill an sbuf with density data descriptors.
*/
static void
safilldenstypesb(struct sbuf *sb, int *indent, uint8_t *buf, int buf_len,
int is_density)
{
struct scsi_density_hdr *hdr;
uint32_t hdr_len;
int len_to_go, cur_offset;
int length_offset;
int num_reports, need_close;
/*
* We need at least the header length. Note that this isn't an
* error, not all tape drives will have every data type.
*/
if (buf_len < sizeof(*hdr))
goto bailout;
hdr = (struct scsi_density_hdr *)buf;
hdr_len = scsi_2btoul(hdr->length);
len_to_go = min(buf_len - sizeof(*hdr), hdr_len);
if (is_density) {
length_offset = __offsetof(struct scsi_density_data,
bits_per_mm);
} else {
length_offset = __offsetof(struct scsi_medium_type_data,
num_density_codes);
}
cur_offset = sizeof(*hdr);
num_reports = 0;
need_close = 0;
while (len_to_go > length_offset) {
struct scsi_density_data *dens_data;
struct scsi_medium_type_data *type_data;
int desc_remain;
size_t cur_field_len;
dens_data = NULL;
type_data = NULL;
if (is_density) {
dens_data =(struct scsi_density_data *)&buf[cur_offset];
if (dens_data->byte2 & SDD_DLV)
desc_remain = scsi_2btoul(dens_data->length);
else
desc_remain = SDD_DEFAULT_LENGTH -
length_offset;
} else {
type_data = (struct scsi_medium_type_data *)
&buf[cur_offset];
desc_remain = scsi_2btoul(type_data->length);
}
len_to_go -= length_offset;
desc_remain = min(desc_remain, len_to_go);
cur_offset += length_offset;
if (need_close != 0) {
SASBENDNODE(sb, *indent, density_entry);
}
SASBADDNODENUM(sb, *indent, density_entry, num_reports);
num_reports++;
need_close = 1;
if (is_density) {
SASBADDUINTDESC(sb, *indent,
dens_data->primary_density_code, %u,
primary_density_code, "Primary Density Code");
SASBADDUINTDESC(sb, *indent,
dens_data->secondary_density_code, %u,
secondary_density_code, "Secondary Density Code");
SASBADDUINTDESC(sb, *indent,
dens_data->byte2 & ~SDD_DLV, %#x, density_flags,
"Density Flags");
SAFILLDENSSB(dens_data, sb, *indent, bits_per_mm,
desc_remain, len_to_go, cur_offset, "Bits per mm");
SAFILLDENSSB(dens_data, sb, *indent, media_width,
desc_remain, len_to_go, cur_offset, "Media width");
SAFILLDENSSB(dens_data, sb, *indent, tracks,
desc_remain, len_to_go, cur_offset,
"Number of Tracks");
SAFILLDENSSB(dens_data, sb, *indent, capacity,
desc_remain, len_to_go, cur_offset, "Capacity");
SAFILLDENSSBSTR(dens_data, sb, *indent, assigning_org,
desc_remain, len_to_go, cur_offset,
"Assigning Organization");
SAFILLDENSSBSTR(dens_data, sb, *indent, density_name,
desc_remain, len_to_go, cur_offset, "Density Name");
SAFILLDENSSBSTR(dens_data, sb, *indent, description,
desc_remain, len_to_go, cur_offset, "Description");
} else {
int i;
SASBADDUINTDESC(sb, *indent, type_data->medium_type,
%u, medium_type, "Medium Type");
cur_field_len =
__offsetof(struct scsi_medium_type_data,
media_width) -
__offsetof(struct scsi_medium_type_data,
num_density_codes);
if (desc_remain < cur_field_len) {
len_to_go -= desc_remain;
cur_offset += desc_remain;
continue;
}
len_to_go -= cur_field_len;
cur_offset += cur_field_len;
desc_remain -= cur_field_len;
SASBADDINTDESC(sb, *indent,
type_data->num_density_codes, %d,
num_density_codes, "Number of Density Codes");
SASBADDNODE(sb, *indent, density_code_list);
for (i = 0; i < type_data->num_density_codes;
i++) {
SASBADDUINTDESC(sb, *indent,
type_data->primary_density_codes[i], %u,
density_code, "Density Code");
}
SASBENDNODE(sb, *indent, density_code_list);
SAFILLDENSSB(type_data, sb, *indent, media_width,
desc_remain, len_to_go, cur_offset,
"Media width");
SAFILLDENSSB(type_data, sb, *indent, medium_length,
desc_remain, len_to_go, cur_offset,
"Medium length");
/*
* Account for the two reserved bytes.
*/
cur_field_len = sizeof(type_data->reserved2);
if (desc_remain < cur_field_len) {
len_to_go -= desc_remain;
cur_offset += desc_remain;
continue;
}
len_to_go -= cur_field_len;
cur_offset += cur_field_len;
desc_remain -= cur_field_len;
SAFILLDENSSBSTR(type_data, sb, *indent, assigning_org,
desc_remain, len_to_go, cur_offset,
"Assigning Organization");
SAFILLDENSSBSTR(type_data, sb, *indent,
medium_type_name, desc_remain, len_to_go,
cur_offset, "Medium type name");
SAFILLDENSSBSTR(type_data, sb, *indent, description,
desc_remain, len_to_go, cur_offset, "Description");
}
}
if (need_close != 0) {
SASBENDNODE(sb, *indent, density_entry);
}
bailout:
return;
}
/*
* Fill an sbuf with density data information
*/
static void
safilldensitysb(struct sa_softc *softc, int *indent, struct sbuf *sb)
{
int i, is_density;
SASBADDNODE(sb, *indent, mtdensity);
SASBADDUINTDESC(sb, *indent, softc->media_density, %u, media_density,
"Current Medium Density");
is_density = 0;
for (i = 0; i < SA_DENSITY_TYPES; i++) {
int tmpint;
if (softc->density_info_valid[i] == 0)
continue;
SASBADDNODE(sb, *indent, density_report);
if (softc->density_type_bits[i] & SRDS_MEDIUM_TYPE) {
tmpint = 1;
is_density = 0;
} else {
tmpint = 0;
is_density = 1;
}
SASBADDINTDESC(sb, *indent, tmpint, %d, medium_type_report,
"Medium type report");
if (softc->density_type_bits[i] & SRDS_MEDIA)
tmpint = 1;
else
tmpint = 0;
SASBADDINTDESC(sb, *indent, tmpint, %d, media_report,
"Media report");
safilldenstypesb(sb, indent, softc->density_info[i],
softc->density_info_valid[i], is_density);
SASBENDNODE(sb, *indent, density_report);
}
SASBENDNODE(sb, *indent, mtdensity);
}
#endif /* _KERNEL */
/*
* Read tape block limits command.
*/
void
scsi_read_block_limits(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action,
struct scsi_read_block_limits_data *rlimit_buf,
u_int8_t sense_len, u_int32_t timeout)
{
struct scsi_read_block_limits *scsi_cmd;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
cam_fill_csio(csio, retries, cbfcnp, CAM_DIR_IN, tag_action,
(u_int8_t *)rlimit_buf, sizeof(*rlimit_buf), sense_len,
sizeof(*scsi_cmd), timeout);
scsi_cmd = (struct scsi_read_block_limits *)&csio->cdb_io.cdb_bytes;
bzero(scsi_cmd, sizeof(*scsi_cmd));
scsi_cmd->opcode = READ_BLOCK_LIMITS;
}
void
scsi_sa_read_write(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, int readop, int sli,
int fixed, u_int32_t length, u_int8_t *data_ptr,
u_int32_t dxfer_len, u_int8_t sense_len, u_int32_t timeout)
{
struct scsi_sa_rw *scsi_cmd;
int read;
read = (readop & SCSI_RW_DIRMASK) == SCSI_RW_READ;
scsi_cmd = (struct scsi_sa_rw *)&csio->cdb_io.cdb_bytes;
scsi_cmd->opcode = read ? SA_READ : SA_WRITE;
scsi_cmd->sli_fixed = 0;
if (sli && read)
scsi_cmd->sli_fixed |= SAR_SLI;
if (fixed)
scsi_cmd->sli_fixed |= SARW_FIXED;
scsi_ulto3b(length, scsi_cmd->length);
scsi_cmd->control = 0;
cam_fill_csio(csio, retries, cbfcnp, (read ? CAM_DIR_IN : CAM_DIR_OUT) |
((readop & SCSI_RW_BIO) != 0 ? CAM_DATA_BIO : 0),
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
tag_action, data_ptr, dxfer_len, sense_len,
sizeof(*scsi_cmd), timeout);
}
void
scsi_load_unload(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, int immediate, int eot,
int reten, int load, u_int8_t sense_len,
u_int32_t timeout)
{
struct scsi_load_unload *scsi_cmd;
scsi_cmd = (struct scsi_load_unload *)&csio->cdb_io.cdb_bytes;
bzero(scsi_cmd, sizeof(*scsi_cmd));
scsi_cmd->opcode = LOAD_UNLOAD;
if (immediate)
scsi_cmd->immediate = SLU_IMMED;
if (eot)
scsi_cmd->eot_reten_load |= SLU_EOT;
if (reten)
scsi_cmd->eot_reten_load |= SLU_RETEN;
if (load)
scsi_cmd->eot_reten_load |= SLU_LOAD;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
cam_fill_csio(csio, retries, cbfcnp, CAM_DIR_NONE, tag_action,
NULL, 0, sense_len, sizeof(*scsi_cmd), timeout);
}
void
scsi_rewind(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, int immediate, u_int8_t sense_len,
u_int32_t timeout)
{
struct scsi_rewind *scsi_cmd;
scsi_cmd = (struct scsi_rewind *)&csio->cdb_io.cdb_bytes;
bzero(scsi_cmd, sizeof(*scsi_cmd));
scsi_cmd->opcode = REWIND;
if (immediate)
scsi_cmd->immediate = SREW_IMMED;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
cam_fill_csio(csio, retries, cbfcnp, CAM_DIR_NONE, tag_action, NULL,
0, sense_len, sizeof(*scsi_cmd), timeout);
}
void
scsi_space(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, scsi_space_code code,
u_int32_t count, u_int8_t sense_len, u_int32_t timeout)
{
struct scsi_space *scsi_cmd;
scsi_cmd = (struct scsi_space *)&csio->cdb_io.cdb_bytes;
scsi_cmd->opcode = SPACE;
scsi_cmd->code = code;
scsi_ulto3b(count, scsi_cmd->count);
scsi_cmd->control = 0;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
cam_fill_csio(csio, retries, cbfcnp, CAM_DIR_NONE, tag_action, NULL,
0, sense_len, sizeof(*scsi_cmd), timeout);
}
void
scsi_write_filemarks(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, int immediate, int setmark,
u_int32_t num_marks, u_int8_t sense_len,
u_int32_t timeout)
{
struct scsi_write_filemarks *scsi_cmd;
scsi_cmd = (struct scsi_write_filemarks *)&csio->cdb_io.cdb_bytes;
bzero(scsi_cmd, sizeof(*scsi_cmd));
scsi_cmd->opcode = WRITE_FILEMARKS;
if (immediate)
scsi_cmd->byte2 |= SWFMRK_IMMED;
if (setmark)
scsi_cmd->byte2 |= SWFMRK_WSMK;
scsi_ulto3b(num_marks, scsi_cmd->num_marks);
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
cam_fill_csio(csio, retries, cbfcnp, CAM_DIR_NONE, tag_action, NULL,
0, sense_len, sizeof(*scsi_cmd), timeout);
}
/*
* The reserve and release unit commands differ only by their opcodes.
*/
void
scsi_reserve_release_unit(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, int third_party,
int third_party_id, u_int8_t sense_len,
u_int32_t timeout, int reserve)
{
struct scsi_reserve_release_unit *scsi_cmd;
scsi_cmd = (struct scsi_reserve_release_unit *)&csio->cdb_io.cdb_bytes;
bzero(scsi_cmd, sizeof(*scsi_cmd));
if (reserve)
scsi_cmd->opcode = RESERVE_UNIT;
else
scsi_cmd->opcode = RELEASE_UNIT;
if (third_party) {
scsi_cmd->lun_thirdparty |= SRRU_3RD_PARTY;
scsi_cmd->lun_thirdparty |=
((third_party_id << SRRU_3RD_SHAMT) & SRRU_3RD_MASK);
}
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
cam_fill_csio(csio, retries, cbfcnp, CAM_DIR_NONE, tag_action, NULL,
0, sense_len, sizeof(*scsi_cmd), timeout);
}
void
scsi_erase(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, int immediate, int long_erase,
u_int8_t sense_len, u_int32_t timeout)
{
struct scsi_erase *scsi_cmd;
scsi_cmd = (struct scsi_erase *)&csio->cdb_io.cdb_bytes;
bzero(scsi_cmd, sizeof(*scsi_cmd));
scsi_cmd->opcode = ERASE;
if (immediate)
scsi_cmd->lun_imm_long |= SE_IMMED;
if (long_erase)
scsi_cmd->lun_imm_long |= SE_LONG;
Add a SA_FLAG_COMP_SUPP flag (to quirk compression as SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below). Add a queue_count field to softc. Add HP T20* Travan-5 like tape device as a FIXED/512 type device. Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device. Change VIPER 2525 to 1024 byte blocksize. It's possible other drives should change too, but see below.. Change argument to sagetparams to be pointer to a sa_comp_t union- this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION page. In general compression now tries to use the DATA COMPRESSION page and if that fails tries the DEVICE CONFIGURATION page. Change close routine to not rewind tape if there's a failure in either writing filemarks or in backing over one of two filemarks for a 2FM at EOT tape- instead mark the tape as 'frozen' and print a message saying that either an OFFLINE or REWIND or an MTEOM command is needed to clear this state (all bring certainty back to tape position). Fix sastrategy to not allow I/O to a frozen tape. Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT model for a tape drive (you can now dynamically change whether it's a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks something to handle the QIC drives we don't know about. Correctly propagate record of compression algorithm back. Clear FROZEN flag for EOM, REWIND and OFFLINE (and RETENSION and ERASE) cases. Fix an egregious bug in sadone that had left the device queue frozen for deferred (for fixed mode case) errors. Add comment in samount about how useless the test unit ready is for invalidating a mount (this has to be fixed later). Fix residual calculation (per Eivind) in saerror so that negative values for tape records being too large for the supplied buffer get caught. Do some other saerrro cleanup. Per Ken && Justin, add my name to copyright comment.
1999-05-11 04:01:35 +00:00
cam_fill_csio(csio, retries, cbfcnp, CAM_DIR_NONE, tag_action, NULL,
0, sense_len, sizeof(*scsi_cmd), timeout);
}
/*
* Read Tape Position command.
*/
void
scsi_read_position(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, int hardsoft,
struct scsi_tape_position_data *sbp,
u_int8_t sense_len, u_int32_t timeout)
{
struct scsi_tape_read_position *scmd;
cam_fill_csio(csio, retries, cbfcnp, CAM_DIR_IN, tag_action,
(u_int8_t *)sbp, sizeof (*sbp), sense_len, sizeof(*scmd), timeout);
scmd = (struct scsi_tape_read_position *)&csio->cdb_io.cdb_bytes;
bzero(scmd, sizeof(*scmd));
scmd->opcode = READ_POSITION;
scmd->byte1 = hardsoft;
}
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
/*
* Read Tape Position command.
*/
void
scsi_read_position_10(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, int service_action,
u_int8_t *data_ptr, u_int32_t length,
u_int32_t sense_len, u_int32_t timeout)
{
struct scsi_tape_read_position *scmd;
cam_fill_csio(csio,
retries,
cbfcnp,
/*flags*/CAM_DIR_IN,
tag_action,
/*data_ptr*/data_ptr,
/*dxfer_len*/length,
sense_len,
sizeof(*scmd),
timeout);
scmd = (struct scsi_tape_read_position *)&csio->cdb_io.cdb_bytes;
bzero(scmd, sizeof(*scmd));
scmd->opcode = READ_POSITION;
scmd->byte1 = service_action;
/*
* The length is only currently set (as of SSC4r03) if the extended
* form is specified. The other forms have fixed lengths.
*/
if (service_action == SA_RPOS_EXTENDED_FORM)
scsi_ulto2b(length, scmd->length);
}
/*
* Set Tape Position command.
*/
void
scsi_set_position(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, int hardsoft, u_int32_t blkno,
u_int8_t sense_len, u_int32_t timeout)
{
struct scsi_tape_locate *scmd;
cam_fill_csio(csio, retries, cbfcnp, CAM_DIR_NONE, tag_action,
(u_int8_t *)NULL, 0, sense_len, sizeof(*scmd), timeout);
scmd = (struct scsi_tape_locate *)&csio->cdb_io.cdb_bytes;
bzero(scmd, sizeof(*scmd));
scmd->opcode = LOCATE;
if (hardsoft)
scmd->byte1 |= SA_SPOS_BT;
scsi_ulto4b(blkno, scmd->blkaddr);
}
Significant upgrades to sa(4) and mt(1). The primary focus of these changes is to modernize FreeBSD's tape infrastructure so that we can take advantage of some of the features of modern tape drives and allow support for LTFS. Significant changes and new features include: o sa(4) driver status and parameter information is now exported via an XML structure. This will allow for changes and improvements later on that will not break userland applications. The old MTIOCGET status ioctl remains, so applications using the existing interface will not break. o 'mt status' now reports drive-reported tape position information as well as the previously available calculated tape position information. These numbers will be different at times, because the drive-reported block numbers are relative to BOP (Beginning of Partition), but the block numbers calculated previously via sa(4) (and still provided) are relative to the last filemark. Both numbers are now provided. 'mt status' now also shows the drive INQUIRY information, serial number and any position flags (BOP, EOT, etc.) provided with the tape position information. 'mt status -v' adds information on the maximum possible I/O size, and the underlying values used to calculate it. o The extra sa(4) /dev entries (/dev/saN.[0-3]) have been removed. The extra devices were originally added as place holders for density-specific device nodes. Some OSes (NetBSD, NetApp's OnTap and Solaris) have had device nodes that, when you write to them, will automatically select a given density for particular tape drives. This is a convenient way of switching densities, but it was never implemented in FreeBSD. Only the device nodes were there, and that sometimes confused users. For modern tape devices, the density is generally not selectable (e.g. with LTO) or defaults to the highest availble density when the tape is rewritten from BOT (e.g. TS11X0). So, for most users, density selection won't be necessary. If they do need to select the density, it is easy enough to use 'mt density' to change it. o Protection information is now supported. This is either a Reed-Solomon CRC or CRC32 that is included at the end of each block read and written. On write, the tape drive verifies the CRC, and on read, the tape drive provides a CRC for the userland application to verify. o New, extensible tape driver parameter get/set interface. o Density reporting information. For drives that support it, 'mt getdensity' will show detailed information on what formats the tape drive supports, and what formats the tape drive supports. o Some mt(1) functionality moved into a new mt(3) library so that external applications can reuse the code. o The new mt(3) library includes helper routines to aid in parsing the XML output of the sa(4) driver, and build a tree of driver metadata. o Support for the MTLOAD (load a tape in the drive) and MTWEOFI (write filemark immediate) ioctls needed by IBM's LTFS implementation. o Improve device departure behavior for the sa(4) driver. The previous implementation led to hangs when the device was open. o This has been tested on the following types of drives: IBM TS1150 IBM TS1140 IBM LTO-6 IBM LTO-5 HP LTO-2 Seagate DDS-4 Quantum DLT-4000 Exabyte 8505 Sony DDS-2 contrib/groff/tmac/doc-syms, share/mk/bsd.libnames.mk, lib/Makefile, Add libmt. lib/libmt/Makefile, lib/libmt/mt.3, lib/libmt/mtlib.c, lib/libmt/mtlib.h, New mt(3) library that contains functions moved from mt(1) and new functions needed to interact with the updated sa(4) driver. This includes XML parser helper functions that application writers can use when writing code to query tape parameters. rescue/rescue/Makefile: Add -lmt to CRUNCH_LIBS. src/share/man/man4/mtio.4 Clarify this man page a bit, and since it contains what is essentially the mtio.h header file, add new ioctls and structure definitions from mtio.h. src/share/man/man4/sa.4 Update BUGS and maintainer section. sys/cam/scsi/scsi_all.c, sys/cam/scsi/scsi_all.h: Add SCSI SECURITY PROTOCOL IN/OUT CDB definitions and CDB building functions. sys/cam/scsi/scsi_sa.c sys/cam/scsi/scsi_sa.h Many tape driver changes, largely outlined above. Increase the sa(4) driver read/write timeout from 4 to 32 minutes. This is based on the recommended values for IBM LTO 5/6 drives. This may also avoid timeouts for other tape hardware that can take a long time to do retries and error recovery. Longer term, a better way to handle this is to ask the drive for recommended timeout values using the REPORT SUPPORTED OPCODES command. Modern IBM and Oracle tape drives at least support that command, and it would allow for more accurate timeout values. Add XML status generation. This is done with a series of macros to eliminate as much duplicate code as possible. The new XML-based status values are reported through the new MTIOCEXTGET ioctl. Add XML driver parameter reporting, using the new MTIOCPARAMGET ioctl. Add a new driver parameter setting interface, using the new MTIOCPARAMSET and MTIOCSETLIST ioctls. Add a new MTIOCRBLIM ioctl to get block limits information. Add CCB/CDB building routines scsi_locate_16, scsi_locate_10, and scsi_read_position_10(). scsi_locate_10 implements the LOCATE command, as does the existing scsi_set_position() command. It just supports additional arguments and features. If/when we figure out a good way to provide backward compatibility for older applications using the old function API, we can just revamp scsi_set_position(). The same goes for scsi_read_position_10() and the existing scsi_read_position() function. Revamp sasetpos() to take the new mtlocate structure as an argument. It now will use either scsi_locate_10() or scsi_locate_16(), depending upon the arguments the user supplies. As before, once we change position we don't have a clear idea of what the current logical position of the tape drive is. For tape drives that support long form position data, we read the current position and store that for later reporting after changing the position. This should help applications like Bacula speed tape access under FreeBSD once they are modified to support the new ioctls. Add a new quirk, SA_QUIRK_NO_LONG_POS, that is set for all drives that report SCSI-2 or older, as well as drives that report an Illegal Request type error for READ POSITION with the long format. So we should automatically detect drives that don't support the long form and stop asking for it after an initial try. Add a partition number to the sa(4) softc. Improve device departure handling. The previous implementation led to hangs when the device was open. If an application had the sa(4) driver open, and attempted to close it after it went away, the cam_periph_release() call in saclose() would cause the periph to get destroyed because that was the last reference to it. Because destroy_dev() was called from the sa(4) driver's cleanup routine (sacleanup()), and would block waiting for the close to happen, a deadlock would result. So instead of calling destroy_dev() from the cleanup routine, call destroy_dev_sched_cb() from saoninvalidate() and wait for the callback. Acquire a reference for devfs in saregister(), and release it in the new sadevgonecb() routine when all devfs devices for the particular sa(4) driver instance are gone. Add a new function, sasetupdev(), to centralize setting per-instance devfs device parameters instead of repeating the code in saregister(). Add an open count to the softc, so we know how many peripheral driver references are a result of open sessions. Add the D_TRACKCLOSE flag to the cdevsw flags so that we get a 1:1 mapping of open to close calls instead of a N:1 mapping. This should be a no-op for everything except the control device, since we don't allow more than one open on non-control devices. However, since we do allow multiple opens on the control device, the combination of the open count and the D_TRACKCLOSE flag should result in an accurate peripheral driver reference count, and an accurate open count. The accurate open count allows us to release all peripheral driver references that are the result of open contexts once we get the callback from devfs. sys/sys/mtio.h: Add a number of new mt(4) ioctls and the requisite data structures. None of the existing interfaces been removed or changed. This includes definitions for the following new ioctls: MTIOCRBLIM /* get block limits */ MTIOCEXTLOCATE /* seek to position */ MTIOCEXTGET /* get tape status */ MTIOCPARAMGET /* get tape params */ MTIOCPARAMSET /* set tape params */ MTIOCSETLIST /* set N params */ usr.bin/mt/Makefile: mt(1) now depends on libmt, libsbuf and libbsdxml. usr.bin/mt/mt.1: Document new mt(1) features and subcommands. usr.bin/mt/mt.c: Implement support for mt(1) subcommands that need to use getopt(3) for their arguments. Implement a new 'mt status' command to replace the old 'mt status' command. The old status command has been renamed 'ostatus'. The new status function uses the MTIOCEXTGET ioctl, and therefore parses the XML data to determine drive status. The -x argument to 'mt status' allows the user to dump out the raw XML reported by the kernel. The new status display is mostly the same as the old status display, except that it doesn't print the redundant density mode information, and it does print the current partition number and position flags. Add a new command, 'mt locate', that will supersede the old 'mt setspos' and 'mt sethpos' commands. 'mt locate' implements all of the functionality of the MTIOCEXTLOCATE ioctl, and allows the user to change the logical position of the tape drive in a number of ways. (Partition, block number, file number, set mark number, end of data.) The immediate bit and the explicit address bits are implemented, but not documented in the man page. Add a new 'mt weofi' command to use the new MTWEOFI ioctl. This allows the user to ask the drive to write a filemark without waiting around for the operation to complete. Add a new 'mt getdensity' command that gets the XML-based tape drive density report from the sa(4) driver and displays it. This uses the SCSI REPORT DENSITY SUPPORT command to get comprehensive information from the tape drive about what formats it is able to read and write. Add a new 'mt protect' command that allows getting and setting tape drive protection information. The protection information is a CRC tacked on to the end of every read/write from and to the tape drive. Sponsored by: Spectra Logic MFC after: 1 month
2015-02-23 21:59:30 +00:00
/*
* XXX KDM figure out how to make a compatibility function.
*/
void
scsi_locate_10(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, int immed, int cp, int hard,
int64_t partition, u_int32_t block_address,
int sense_len, u_int32_t timeout)
{
struct scsi_tape_locate *scmd;
cam_fill_csio(csio,
retries,
cbfcnp,
CAM_DIR_NONE,
tag_action,
/*data_ptr*/ NULL,
/*dxfer_len*/ 0,
sense_len,
sizeof(*scmd),
timeout);
scmd = (struct scsi_tape_locate *)&csio->cdb_io.cdb_bytes;
bzero(scmd, sizeof(*scmd));
scmd->opcode = LOCATE;
if (immed)
scmd->byte1 |= SA_SPOS_IMMED;
if (cp)
scmd->byte1 |= SA_SPOS_CP;
if (hard)
scmd->byte1 |= SA_SPOS_BT;
scsi_ulto4b(block_address, scmd->blkaddr);
scmd->partition = partition;
}
void
scsi_locate_16(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, int immed, int cp, u_int8_t dest_type,
int bam, int64_t partition, u_int64_t logical_id,
int sense_len, u_int32_t timeout)
{
struct scsi_locate_16 *scsi_cmd;
cam_fill_csio(csio,
retries,
cbfcnp,
/*flags*/CAM_DIR_NONE,
tag_action,
/*data_ptr*/NULL,
/*dxfer_len*/0,
sense_len,
sizeof(*scsi_cmd),
timeout);
scsi_cmd = (struct scsi_locate_16 *)&csio->cdb_io.cdb_bytes;
bzero(scsi_cmd, sizeof(*scsi_cmd));
scsi_cmd->opcode = LOCATE_16;
if (immed)
scsi_cmd->byte1 |= SA_LC_IMMEDIATE;
if (cp)
scsi_cmd->byte1 |= SA_LC_CP;
scsi_cmd->byte1 |= (dest_type << SA_LC_DEST_TYPE_SHIFT);
scsi_cmd->byte2 |= bam;
scsi_cmd->partition = partition;
scsi_u64to8b(logical_id, scsi_cmd->logical_id);
}
void
scsi_report_density_support(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, int media, int medium_type,
u_int8_t *data_ptr, u_int32_t length,
u_int32_t sense_len, u_int32_t timeout)
{
struct scsi_report_density_support *scsi_cmd;
scsi_cmd =(struct scsi_report_density_support *)&csio->cdb_io.cdb_bytes;
bzero(scsi_cmd, sizeof(*scsi_cmd));
scsi_cmd->opcode = REPORT_DENSITY_SUPPORT;
if (media != 0)
scsi_cmd->byte1 |= SRDS_MEDIA;
if (medium_type != 0)
scsi_cmd->byte1 |= SRDS_MEDIUM_TYPE;
scsi_ulto2b(length, scsi_cmd->length);
cam_fill_csio(csio,
retries,
cbfcnp,
/*flags*/CAM_DIR_IN,
tag_action,
/*data_ptr*/data_ptr,
/*dxfer_len*/length,
sense_len,
sizeof(*scsi_cmd),
timeout);
}
void
scsi_set_capacity(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, int byte1, u_int32_t proportion,
u_int32_t sense_len, u_int32_t timeout)
{
struct scsi_set_capacity *scsi_cmd;
scsi_cmd = (struct scsi_set_capacity *)&csio->cdb_io.cdb_bytes;
bzero(scsi_cmd, sizeof(*scsi_cmd));
scsi_cmd->opcode = SET_CAPACITY;
scsi_cmd->byte1 = byte1;
scsi_ulto2b(proportion, scsi_cmd->cap_proportion);
cam_fill_csio(csio,
retries,
cbfcnp,
/*flags*/CAM_DIR_NONE,
tag_action,
/*data_ptr*/NULL,
/*dxfer_len*/0,
sense_len,
sizeof(*scsi_cmd),
timeout);
}
void
scsi_format_medium(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, int byte1, int byte2,
u_int8_t *data_ptr, u_int32_t dxfer_len,
u_int32_t sense_len, u_int32_t timeout)
{
struct scsi_format_medium *scsi_cmd;
scsi_cmd = (struct scsi_format_medium*)&csio->cdb_io.cdb_bytes;
bzero(scsi_cmd, sizeof(*scsi_cmd));
scsi_cmd->opcode = FORMAT_MEDIUM;
scsi_cmd->byte1 = byte1;
scsi_cmd->byte2 = byte2;
scsi_ulto2b(dxfer_len, scsi_cmd->length);
cam_fill_csio(csio,
retries,
cbfcnp,
/*flags*/(dxfer_len > 0) ? CAM_DIR_OUT : CAM_DIR_NONE,
tag_action,
/*data_ptr*/ data_ptr,
/*dxfer_len*/ dxfer_len,
sense_len,
sizeof(*scsi_cmd),
timeout);
}
void
scsi_allow_overwrite(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int8_t tag_action, int allow_overwrite, int partition,
u_int64_t logical_id, u_int32_t sense_len, u_int32_t timeout)
{
struct scsi_allow_overwrite *scsi_cmd;
scsi_cmd = (struct scsi_allow_overwrite *)&csio->cdb_io.cdb_bytes;
bzero(scsi_cmd, sizeof(*scsi_cmd));
scsi_cmd->opcode = ALLOW_OVERWRITE;
scsi_cmd->allow_overwrite = allow_overwrite;
scsi_cmd->partition = partition;
scsi_u64to8b(logical_id, scsi_cmd->logical_id);
cam_fill_csio(csio,
retries,
cbfcnp,
CAM_DIR_NONE,
tag_action,
/*data_ptr*/ NULL,
/*dxfer_len*/ 0,
sense_len,
sizeof(*scsi_cmd),
timeout);
}