2005-01-05 22:34:37 +00:00
|
|
|
/*-
|
1998-09-15 06:36:34 +00:00
|
|
|
* Implementation of SCSI Sequential Access Peripheral driver for CAM.
|
|
|
|
*
|
2000-03-18 22:03:41 +00:00
|
|
|
* Copyright (c) 1999, 2000 Matthew Jacob
|
1998-09-15 06:36:34 +00:00
|
|
|
* 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$");
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/queue.h>
|
1999-12-29 04:46:21 +00:00
|
|
|
#ifdef _KERNEL
|
1998-09-15 06:36:34 +00:00
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#endif
|
|
|
|
#include <sys/types.h>
|
2003-02-07 21:09:51 +00:00
|
|
|
#include <sys/time.h>
|
2000-05-05 09:59:14 +00:00
|
|
|
#include <sys/bio.h>
|
2003-04-29 13:36:06 +00:00
|
|
|
#include <sys/limits.h>
|
1998-09-15 06:36:34 +00:00
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mtio.h>
|
2000-08-24 19:23:09 +00:00
|
|
|
#ifdef _KERNEL
|
1998-09-15 06:36:34 +00:00
|
|
|
#include <sys/conf.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>
|
2000-08-24 19:23:09 +00:00
|
|
|
#endif
|
2006-01-14 14:32:41 +00:00
|
|
|
#include <sys/fcntl.h>
|
1998-09-15 06:36:34 +00:00
|
|
|
#include <sys/devicestat.h>
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#ifndef _KERNEL
|
1998-09-15 06:36:34 +00:00
|
|
|
#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>
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#ifdef _KERNEL
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1998-10-02 05:15:51 +00:00
|
|
|
#include <opt_sa.h>
|
|
|
|
|
2001-07-02 17:48:59 +00:00
|
|
|
#ifndef SA_IO_TIMEOUT
|
|
|
|
#define SA_IO_TIMEOUT 4
|
|
|
|
#endif
|
1998-10-02 05:15:51 +00:00
|
|
|
#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
|
1999-11-17 06:05:09 +00:00
|
|
|
|
2001-07-02 17:48:59 +00:00
|
|
|
#define SCSIOP_TIMEOUT (60 * 1000) /* not an option */
|
|
|
|
|
|
|
|
#define IO_TIMEOUT (SA_IO_TIMEOUT * 60 * 1000)
|
1999-12-03 23:14:11 +00:00
|
|
|
#define REWIND_TIMEOUT (SA_REWIND_TIMEOUT * 60 * 1000)
|
|
|
|
#define ERASE_TIMEOUT (SA_ERASE_TIMEOUT * 60 * 1000)
|
|
|
|
#define SPACE_TIMEOUT (SA_SPACE_TIMEOUT * 60 * 1000)
|
1999-11-17 06:05:09 +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
|
|
|
/*
|
1999-10-02 20:17:16 +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
|
|
|
*/
|
1999-11-17 06:05:09 +00:00
|
|
|
|
1998-12-17 18:56:23 +00:00
|
|
|
#ifndef UNUSED_PARAMETER
|
|
|
|
#define UNUSED_PARAMETER(x) x = x
|
|
|
|
#endif
|
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
#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
|
|
|
|
*/
|
|
|
|
|
2011-11-07 06:44:47 +00:00
|
|
|
static MALLOC_DEFINE(M_SCSISA, "SCSI sa", "SCSI sequential access buffers");
|
1999-11-17 06:05:09 +00:00
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
typedef enum {
|
1999-05-11 04:01:35 +00:00
|
|
|
SA_STATE_NORMAL, SA_STATE_ABNORMAL
|
1998-09-15 06:36:34 +00:00
|
|
|
} sa_state;
|
|
|
|
|
2001-01-15 22:28:11 +00:00
|
|
|
#define ccb_pflags ppriv_field0
|
|
|
|
#define ccb_bp ppriv_ptr1
|
|
|
|
|
2014-07-31 22:09:50 +00:00
|
|
|
/* bits in ccb_pflags */
|
|
|
|
#define SA_POSITION_UPDATED 0x1
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
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,
|
1998-12-17 18:56:23 +00:00
|
|
|
SA_FLAG_EOM_PENDING = 0x0040,
|
|
|
|
SA_FLAG_EIO_PENDING = 0x0080,
|
|
|
|
SA_FLAG_EOF_PENDING = 0x0100,
|
1998-09-15 06:36:34 +00:00
|
|
|
SA_FLAG_ERR_PENDING = (SA_FLAG_EOM_PENDING|SA_FLAG_EIO_PENDING|
|
|
|
|
SA_FLAG_EOF_PENDING),
|
1998-12-17 18:56:23 +00:00
|
|
|
SA_FLAG_INVALID = 0x0200,
|
|
|
|
SA_FLAG_COMP_ENABLED = 0x0400,
|
1999-05-11 04:01:35 +00:00
|
|
|
SA_FLAG_COMP_SUPP = 0x0800,
|
|
|
|
SA_FLAG_COMP_UNSUPP = 0x1000,
|
|
|
|
SA_FLAG_TAPE_FROZEN = 0x2000
|
1998-09-15 06:36:34 +00:00
|
|
|
} sa_flags;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SA_MODE_REWIND = 0x00,
|
|
|
|
SA_MODE_NOREWIND = 0x01,
|
|
|
|
SA_MODE_OFFLINE = 0x02
|
|
|
|
} sa_mode;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SA_PARAM_NONE = 0x00,
|
|
|
|
SA_PARAM_BLOCKSIZE = 0x01,
|
|
|
|
SA_PARAM_DENSITY = 0x02,
|
|
|
|
SA_PARAM_COMPRESSION = 0x04,
|
|
|
|
SA_PARAM_BUFF_MODE = 0x08,
|
|
|
|
SA_PARAM_NUMBLOCKS = 0x10,
|
|
|
|
SA_PARAM_WP = 0x20,
|
|
|
|
SA_PARAM_SPEED = 0x40,
|
|
|
|
SA_PARAM_ALL = 0x7f
|
|
|
|
} sa_params;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SA_QUIRK_NONE = 0x00,
|
2000-05-09 04:54:10 +00:00
|
|
|
SA_QUIRK_NOCOMP = 0x01, /* Can't deal with compression at all */
|
|
|
|
SA_QUIRK_FIXED = 0x02, /* Force fixed mode */
|
|
|
|
SA_QUIRK_VARIABLE = 0x04, /* Force variable mode */
|
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
|
|
|
SA_QUIRK_2FM = 0x08, /* Needs Two File Marks at EOD */
|
2000-02-03 18:29:25 +00:00
|
|
|
SA_QUIRK_1FM = 0x10, /* No more than 1 File Mark at EOD */
|
2000-05-09 04:54:10 +00:00
|
|
|
SA_QUIRK_NODREAD = 0x20, /* Don't try and dummy read density */
|
2001-01-15 22:28:11 +00:00
|
|
|
SA_QUIRK_NO_MODESEL = 0x40, /* Don't do mode select at all */
|
|
|
|
SA_QUIRK_NO_CPAGE = 0x80 /* Don't use DEVICE COMPRESSION page */
|
1998-09-15 06:36:34 +00:00
|
|
|
} sa_quirks;
|
|
|
|
|
2013-05-18 23:36:21 +00:00
|
|
|
#define SA_QUIRK_BIT_STRING \
|
|
|
|
"\020" \
|
|
|
|
"\001NOCOMP" \
|
|
|
|
"\002FIXED" \
|
|
|
|
"\003VARIABLE" \
|
|
|
|
"\0042FM" \
|
|
|
|
"\0051FM" \
|
|
|
|
"\006NODREAD" \
|
|
|
|
"\007NO_MODESEL" \
|
|
|
|
"\010NO_CPAGE"
|
|
|
|
|
2009-04-20 10:40:42 +00:00
|
|
|
#define SAMODE(z) (dev2unit(z) & 0x3)
|
|
|
|
#define SADENSITY(z) ((dev2unit(z) >> 2) & 0x3)
|
|
|
|
#define SA_IS_CTRL(z) (dev2unit(z) & (1 << 4))
|
1999-11-17 17:11:21 +00:00
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
#define SA_NOT_CTLDEV 0
|
|
|
|
#define SA_CTLDEV 1
|
|
|
|
|
|
|
|
#define SA_ATYPE_R 0
|
|
|
|
#define SA_ATYPE_NR 1
|
|
|
|
#define SA_ATYPE_ER 2
|
|
|
|
|
2009-04-20 10:40:42 +00:00
|
|
|
#define SAMINOR(ctl, mode, access) \
|
|
|
|
((ctl << 4) | (mode << 2) | (access & 0x3))
|
1999-11-17 06:05:09 +00:00
|
|
|
|
|
|
|
#define SA_NUM_MODES 4
|
|
|
|
struct sa_devs {
|
2004-06-16 09:47:26 +00:00
|
|
|
struct cdev *ctl_dev;
|
1999-11-17 06:05:09 +00:00
|
|
|
struct sa_mode_devs {
|
2004-06-16 09:47:26 +00:00
|
|
|
struct cdev *r_dev;
|
|
|
|
struct cdev *nr_dev;
|
|
|
|
struct cdev *er_dev;
|
1999-11-17 06:05:09 +00:00
|
|
|
} mode_devs[SA_NUM_MODES];
|
|
|
|
};
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
struct sa_softc {
|
|
|
|
sa_state state;
|
|
|
|
sa_flags flags;
|
|
|
|
sa_quirks quirks;
|
2013-08-16 16:14:32 +00:00
|
|
|
u_int si_flags;
|
2000-04-15 05:54:02 +00:00
|
|
|
struct bio_queue_head bio_queue;
|
1999-05-11 04:01:35 +00:00
|
|
|
int queue_count;
|
2003-03-08 21:44:46 +00:00
|
|
|
struct devstat *device_stats;
|
1999-11-17 06:05:09 +00:00
|
|
|
struct sa_devs devs;
|
1998-09-15 06:36:34 +00:00
|
|
|
int blk_gran;
|
|
|
|
int blk_mask;
|
|
|
|
int blk_shift;
|
|
|
|
u_int32_t max_blk;
|
|
|
|
u_int32_t min_blk;
|
2013-08-16 16:14:32 +00:00
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
u_int32_t comp_algorithm;
|
|
|
|
u_int32_t saved_comp_algorithm;
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
u_int32_t media_blksize;
|
1998-12-17 18:56:23 +00:00
|
|
|
u_int32_t last_media_blksize;
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
u_int32_t media_numblks;
|
|
|
|
u_int8_t media_density;
|
1998-09-15 06:36:34 +00:00
|
|
|
u_int8_t speed;
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
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 */
|
1998-09-15 06:36:34 +00:00
|
|
|
int buffer_mode;
|
|
|
|
int filemarks;
|
|
|
|
union ccb saved_ccb;
|
2001-01-19 21:08:15 +00:00
|
|
|
int last_resid_was_io;
|
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
|
|
|
/*
|
|
|
|
* Relative to BOT Location.
|
|
|
|
*/
|
|
|
|
daddr_t fileno;
|
|
|
|
daddr_t blkno;
|
|
|
|
|
1998-12-19 23:33:21 +00:00
|
|
|
/*
|
|
|
|
* Latched Error Info
|
|
|
|
*/
|
1998-12-22 17:26:13 +00:00
|
|
|
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;
|
1998-12-22 17:26:13 +00:00
|
|
|
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;
|
1998-12-22 17:26:13 +00:00
|
|
|
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
|
2006-01-14 14:32:41 +00:00
|
|
|
: 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;
|
1998-09-15 06:36:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct sa_quirk_entry {
|
1999-01-12 08:15:47 +00:00
|
|
|
struct scsi_inquiry_pattern inq_pat; /* matching pattern */
|
|
|
|
sa_quirks quirks; /* specific quirk type */
|
|
|
|
u_int32_t prefblk; /* preferred blocksize when in fixed mode */
|
1998-09-15 06:36:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct sa_quirk_entry sa_quirk_table[] =
|
|
|
|
{
|
2000-05-09 04:54:10 +00:00
|
|
|
{
|
|
|
|
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "OnStream",
|
|
|
|
"ADR*", "*"}, SA_QUIRK_FIXED|SA_QUIRK_NODREAD |
|
|
|
|
SA_QUIRK_1FM|SA_QUIRK_NO_MODESEL, 32768
|
|
|
|
},
|
2001-06-01 12:36:24 +00:00
|
|
|
{
|
|
|
|
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "ARCHIVE",
|
2001-06-06 13:01:44 +00:00
|
|
|
"Python 06408*", "*"}, SA_QUIRK_NODREAD, 0
|
2001-06-01 12:36:24 +00:00
|
|
|
},
|
1998-09-15 06:36:34 +00:00
|
|
|
{
|
|
|
|
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "ARCHIVE",
|
2000-02-03 18:29:25 +00:00
|
|
|
"Python 25601*", "*"}, SA_QUIRK_NOCOMP|SA_QUIRK_NODREAD, 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "ARCHIVE",
|
|
|
|
"Python*", "*"}, SA_QUIRK_NODREAD, 0
|
1998-11-26 10:47:52 +00:00
|
|
|
},
|
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
|
1999-01-12 08:15:47 +00:00
|
|
|
},
|
2000-11-08 18:37:12 +00:00
|
|
|
{
|
|
|
|
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "ARCHIVE",
|
|
|
|
"VIPER 2525 25462", "-011"},
|
|
|
|
SA_QUIRK_NOCOMP|SA_QUIRK_1FM|SA_QUIRK_NODREAD, 0
|
|
|
|
},
|
1999-01-12 08:15:47 +00:00
|
|
|
{
|
|
|
|
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "ARCHIVE",
|
1999-05-11 04:01:35 +00:00
|
|
|
"VIPER 2525*", "*"}, SA_QUIRK_FIXED|SA_QUIRK_1FM, 1024
|
|
|
|
},
|
2001-01-15 22:28:11 +00:00
|
|
|
#if 0
|
|
|
|
{
|
|
|
|
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "HP",
|
|
|
|
"C15*", "*"}, SA_QUIRK_VARIABLE|SA_QUIRK_NO_CPAGE, 0,
|
|
|
|
},
|
|
|
|
#endif
|
2002-12-16 17:40:17 +00:00
|
|
|
{
|
|
|
|
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "HP",
|
|
|
|
"C56*", "*"}, SA_QUIRK_VARIABLE|SA_QUIRK_2FM, 0
|
|
|
|
},
|
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",
|
1999-03-01 01:07:47 +00:00
|
|
|
"T4000*", "*"}, SA_QUIRK_FIXED|SA_QUIRK_1FM, 512
|
1999-01-12 08:15:47 +00:00
|
|
|
},
|
1999-01-16 04:02:31 +00:00
|
|
|
{
|
|
|
|
{ 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
|
|
|
|
},
|
1999-09-28 05:14:52 +00:00
|
|
|
{ /* jreynold@primenet.com */
|
|
|
|
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "Seagate",
|
|
|
|
"STT8000N*", "*"}, SA_QUIRK_1FM, 0
|
|
|
|
},
|
1999-10-02 20:17:16 +00:00
|
|
|
{ /* mike@sentex.net */
|
|
|
|
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "Seagate",
|
|
|
|
"STT20000*", "*"}, SA_QUIRK_1FM, 0
|
|
|
|
},
|
2011-12-08 03:20:48 +00:00
|
|
|
{
|
|
|
|
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "SEAGATE",
|
|
|
|
"DAT 06241-XXX", "*"}, SA_QUIRK_VARIABLE|SA_QUIRK_2FM, 0
|
|
|
|
},
|
1999-01-12 08:15:47 +00:00
|
|
|
{
|
|
|
|
{ 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
|
|
|
},
|
1999-05-25 23:10:54 +00:00
|
|
|
{
|
|
|
|
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "TANDBERG",
|
|
|
|
" TDC 3800", "*"}, SA_QUIRK_NOCOMP|SA_QUIRK_1FM, 512
|
|
|
|
},
|
1999-06-24 15:21:10 +00:00
|
|
|
{
|
|
|
|
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "TANDBERG",
|
|
|
|
" TDC 4100", "*"}, SA_QUIRK_NOCOMP|SA_QUIRK_1FM, 512
|
|
|
|
},
|
1998-11-26 10:47:52 +00:00
|
|
|
{
|
|
|
|
{ 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
|
1999-01-12 08:15:47 +00:00
|
|
|
},
|
1999-05-11 04:01:35 +00:00
|
|
|
{
|
|
|
|
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "TANDBERG",
|
|
|
|
" SLR*", "*"}, SA_QUIRK_1FM, 0
|
|
|
|
},
|
1999-01-12 08:15:47 +00:00
|
|
|
{
|
|
|
|
{ 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
|
1999-04-18 01:05:03 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "WANGTEK",
|
|
|
|
"51000*", "*"}, SA_QUIRK_FIXED|SA_QUIRK_1FM, 1024
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
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 *);
|
1998-09-15 06:36:34 +00:00
|
|
|
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,
|
1999-05-11 04:01:35 +00:00
|
|
|
sa_comp_t *comp_page);
|
1998-09-15 06:36:34 +00:00
|
|
|
static int sasetparams(struct cam_periph *periph,
|
|
|
|
sa_params params_to_set,
|
|
|
|
u_int32_t blocksize, u_int8_t density,
|
1999-01-12 08:15:47 +00:00
|
|
|
u_int32_t comp_algorithm,
|
|
|
|
u_int32_t sense_flags);
|
1998-09-15 06:36:34 +00:00
|
|
|
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);
|
2004-06-16 09:47:26 +00:00
|
|
|
static int samount(struct cam_periph *, int, struct cdev *);
|
1998-09-15 06:36:34 +00:00
|
|
|
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,
|
|
|
|
int nmarks, int setmarks);
|
1998-12-18 04:31:43 +00:00
|
|
|
static int sardpos(struct cam_periph *periph, int, u_int32_t *);
|
|
|
|
static int sasetpos(struct cam_periph *periph, int, u_int32_t *);
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
|
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");
|
2014-06-28 03:56:17 +00:00
|
|
|
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
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
static struct periph_driver sadriver =
|
|
|
|
{
|
|
|
|
sainit, "sa",
|
|
|
|
TAILQ_HEAD_INITIALIZER(sadriver.units), /* generation */ 0
|
|
|
|
};
|
|
|
|
|
2001-02-07 07:05:59 +00:00
|
|
|
PERIPHDRIVER_DECLARE(sa, sadriver);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
/* For 2.2-stable support */
|
|
|
|
#ifndef D_TAPE
|
|
|
|
#define D_TAPE 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1999-05-30 16:53:49 +00:00
|
|
|
static struct cdevsw sa_cdevsw = {
|
2004-02-21 21:10:55 +00:00
|
|
|
.d_version = D_VERSION,
|
2003-03-03 12:15:54 +00:00
|
|
|
.d_open = saopen,
|
|
|
|
.d_close = saclose,
|
|
|
|
.d_read = physread,
|
|
|
|
.d_write = physwrite,
|
|
|
|
.d_ioctl = saioctl,
|
|
|
|
.d_strategy = sastrategy,
|
|
|
|
.d_name = "sa",
|
2013-08-16 16:14:32 +00:00
|
|
|
.d_flags = D_TAPE,
|
1998-09-15 06:36:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2004-06-16 09:47:26 +00:00
|
|
|
saopen(struct cdev *dev, int flags, int fmt, struct thread *td)
|
1998-09-15 06:36:34 +00:00
|
|
|
{
|
|
|
|
struct cam_periph *periph;
|
|
|
|
struct sa_softc *softc;
|
|
|
|
int error;
|
|
|
|
|
2002-08-15 20:54:03 +00:00
|
|
|
periph = (struct cam_periph *)dev->si_drv1;
|
2007-04-15 08:49:19 +00:00
|
|
|
if (cam_periph_acquire(periph) != CAM_REQ_CMP) {
|
|
|
|
return (ENXIO);
|
1999-11-17 06:05:09 +00:00
|
|
|
}
|
2007-04-15 08:49:19 +00:00
|
|
|
|
|
|
|
cam_periph_lock(periph);
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
softc = (struct sa_softc *)periph->softc;
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO,
|
2009-04-20 10:40:42 +00:00
|
|
|
("saopen(%s): softc=0x%x\n", devtoname(dev), softc->flags));
|
1998-09-15 06:36:34 +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 (SA_IS_CTRL(dev)) {
|
|
|
|
softc->ctrl_mode = 1;
|
1999-11-17 06:05:09 +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 (0);
|
|
|
|
}
|
|
|
|
|
2007-04-15 08:49:19 +00:00
|
|
|
if ((error = cam_periph_hold(periph, PRIBIO|PCATCH)) != 0) {
|
|
|
|
cam_periph_unlock(periph);
|
|
|
|
cam_periph_release(periph);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
if (softc->flags & SA_FLAG_OPEN) {
|
|
|
|
error = EBUSY;
|
|
|
|
} else if (softc->flags & SA_FLAG_INVALID) {
|
|
|
|
error = ENXIO;
|
|
|
|
} else {
|
2006-01-14 14:32:41 +00:00
|
|
|
/*
|
|
|
|
* Preserve whether this is a read_only open.
|
|
|
|
*/
|
|
|
|
softc->open_rdonly = (flags & O_RDWR) == O_RDONLY;
|
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
/*
|
|
|
|
* The function samount ensures media is loaded and ready.
|
|
|
|
* It also does a device RESERVE if the tape isn't yet mounted.
|
2006-01-14 14:32:41 +00:00
|
|
|
*
|
|
|
|
* If the mount fails and this was a non-blocking open,
|
|
|
|
* make this a 'open_pending_mount' action.
|
1999-11-17 06:05:09 +00:00
|
|
|
*/
|
|
|
|
error = samount(periph, flags, dev);
|
2006-01-14 14:32:41 +00:00
|
|
|
if (error && (flags & O_NONBLOCK)) {
|
|
|
|
softc->flags |= SA_FLAG_OPEN;
|
|
|
|
softc->open_pending_mount = 1;
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_unhold(periph);
|
2006-01-14 14:32:41 +00:00
|
|
|
cam_periph_unlock(periph);
|
|
|
|
return (0);
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
if (error) {
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_unhold(periph);
|
|
|
|
cam_periph_unlock(periph);
|
1999-11-17 06:05:09 +00:00
|
|
|
cam_periph_release(periph);
|
2007-04-15 08:49:19 +00:00
|
|
|
return (error);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
2007-04-15 08:49:19 +00:00
|
|
|
|
|
|
|
saprevent(periph, PR_PREVENT);
|
|
|
|
softc->flags |= SA_FLAG_OPEN;
|
|
|
|
|
|
|
|
cam_periph_unhold(periph);
|
1998-09-15 06:36:34 +00:00
|
|
|
cam_periph_unlock(periph);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-06-16 09:47:26 +00:00
|
|
|
saclose(struct cdev *dev, int flag, int fmt, struct thread *td)
|
1998-09-15 06:36:34 +00:00
|
|
|
{
|
|
|
|
struct cam_periph *periph;
|
|
|
|
struct sa_softc *softc;
|
2009-04-20 10:40:42 +00:00
|
|
|
int mode, error, writing, tmp;
|
1998-12-22 17:26:13 +00:00
|
|
|
int closedbits = SA_FLAG_OPEN;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
mode = SAMODE(dev);
|
2002-08-15 20:54:03 +00:00
|
|
|
periph = (struct cam_periph *)dev->si_drv1;
|
1998-09-15 06:36:34 +00:00
|
|
|
if (periph == NULL)
|
|
|
|
return (ENXIO);
|
|
|
|
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_lock(periph);
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
softc = (struct sa_softc *)periph->softc;
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO,
|
2009-04-20 10:40:42 +00:00
|
|
|
("saclose(%s): softc=0x%x\n", devtoname(dev), softc->flags));
|
1999-05-11 04:01:35 +00:00
|
|
|
|
|
|
|
|
2006-01-14 14:32:41 +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;
|
1999-11-17 06:05:09 +00:00
|
|
|
cam_periph_unlock(periph);
|
2007-04-15 08:49:19 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2006-01-14 14:32:41 +00:00
|
|
|
if (softc->open_pending_mount) {
|
|
|
|
softc->flags &= ~SA_FLAG_OPEN;
|
|
|
|
softc->open_pending_mount = 0;
|
|
|
|
cam_periph_unlock(periph);
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_release(periph);
|
2006-01-14 14:32:41 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2007-04-15 08:49:19 +00:00
|
|
|
if ((error = cam_periph_hold(periph, PRIBIO)) != 0) {
|
|
|
|
cam_periph_unlock(periph);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1998-12-17 18:56:23 +00:00
|
|
|
/*
|
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.
|
1998-12-17 18:56:23 +00:00
|
|
|
*/
|
|
|
|
error = sacheckeod(periph);
|
|
|
|
if (error) {
|
2006-12-05 07:45:28 +00:00
|
|
|
xpt_print(periph->path,
|
|
|
|
"failed to write terminating filemark(s)\n");
|
1999-05-11 04:01:35 +00:00
|
|
|
softc->flags |= SA_FLAG_TAPE_FROZEN;
|
1998-12-17 18:56:23 +00:00
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1998-12-17 18:56:23 +00:00
|
|
|
/*
|
|
|
|
* Whatever we end up doing, allow users to eject tapes from here on.
|
|
|
|
*/
|
1998-09-15 06:36:34 +00:00
|
|
|
saprevent(periph, PR_ALLOW);
|
|
|
|
|
1998-12-17 18:56:23 +00:00
|
|
|
/*
|
|
|
|
* Decide how to end...
|
|
|
|
*/
|
1999-11-21 20:23:58 +00:00
|
|
|
if ((softc->flags & SA_FLAG_TAPE_MOUNTED) == 0) {
|
|
|
|
closedbits |= SA_FLAG_TAPE_FROZEN;
|
|
|
|
} else switch (mode) {
|
1998-09-15 06:36:34 +00:00
|
|
|
case SA_MODE_OFFLINE:
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
break;
|
1998-12-17 18:56:23 +00:00
|
|
|
case SA_MODE_REWIND:
|
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;
|
|
|
|
}
|
1998-12-17 18:56:23 +00:00
|
|
|
break;
|
1998-09-15 06:36:34 +00:00
|
|
|
case SA_MODE_NOREWIND:
|
1998-12-17 18:56:23 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
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) {
|
2006-12-05 07:45:28 +00:00
|
|
|
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");
|
1999-05-11 04:01:35 +00:00
|
|
|
softc->flags |= SA_FLAG_TAPE_FROZEN;
|
1998-12-17 18:56:23 +00:00
|
|
|
}
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
break;
|
1999-05-11 04:01:35 +00:00
|
|
|
default:
|
2006-12-05 07:45:28 +00:00
|
|
|
xpt_print(periph->path, "unknown mode 0x%x in saclose\n", mode);
|
1999-05-11 04:01:35 +00:00
|
|
|
/* NOTREACHED */
|
|
|
|
break;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
1998-12-17 18:56:23 +00:00
|
|
|
/*
|
1998-12-19 23:33:21 +00:00
|
|
|
* We wish to note here that there are no more filemarks to be written.
|
1998-12-17 18:56:23 +00:00
|
|
|
*/
|
|
|
|
softc->filemarks = 0;
|
1998-12-19 23:33:21 +00:00
|
|
|
softc->flags &= ~SA_FLAG_TAPE_WRITTEN;
|
1998-12-17 18:56:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* And we are no longer open for business.
|
|
|
|
*/
|
1998-12-22 17:26:13 +00:00
|
|
|
softc->flags &= ~closedbits;
|
1999-05-11 04:01:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Inform users if tape state if frozen....
|
|
|
|
*/
|
|
|
|
if (softc->flags & SA_FLAG_TAPE_FROZEN) {
|
2006-12-05 07:45:28 +00:00
|
|
|
xpt_print(periph->path, "tape is now frozen- use an OFFLINE, "
|
|
|
|
"REWIND or MTEOM command to clear this state.\n");
|
1999-05-11 04:01:35 +00:00
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
/* release the device if it is no longer mounted */
|
|
|
|
if ((softc->flags & SA_FLAG_TAPE_MOUNTED) == 0)
|
|
|
|
sareservereleaseunit(periph, FALSE);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_unhold(periph);
|
1998-09-15 06:36:34 +00:00
|
|
|
cam_periph_unlock(periph);
|
|
|
|
cam_periph_release(periph);
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
return (error);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
2000-04-15 05:54:02 +00:00
|
|
|
sastrategy(struct bio *bp)
|
1998-09-15 06:36:34 +00:00
|
|
|
{
|
|
|
|
struct cam_periph *periph;
|
|
|
|
struct sa_softc *softc;
|
|
|
|
|
2001-05-08 08:30:48 +00:00
|
|
|
bp->bio_resid = bp->bio_bcount;
|
2000-04-15 05:54:02 +00:00
|
|
|
if (SA_IS_CTRL(bp->bio_dev)) {
|
2001-05-08 08:30:48 +00:00
|
|
|
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
|
|
|
}
|
2002-08-15 20:54:03 +00:00
|
|
|
periph = (struct cam_periph *)bp->bio_dev->si_drv1;
|
1998-09-15 06:36:34 +00:00
|
|
|
if (periph == NULL) {
|
2001-05-08 08:30:48 +00:00
|
|
|
biofinish(bp, NULL, ENXIO);
|
|
|
|
return;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_lock(periph);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
2007-04-15 08:49:19 +00:00
|
|
|
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) {
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_unlock(periph);
|
2001-05-08 08:30:48 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
if (softc->flags & SA_FLAG_TAPE_FROZEN) {
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_unlock(periph);
|
2001-05-08 08:30:48 +00:00
|
|
|
biofinish(bp, NULL, EPERM);
|
|
|
|
return;
|
1999-05-11 04:01:35 +00:00
|
|
|
}
|
|
|
|
|
2006-01-14 14:32:41 +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) {
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_unlock(periph);
|
2006-01-14 14:32:41 +00:00
|
|
|
biofinish(bp, NULL, EBADF);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (softc->open_pending_mount) {
|
|
|
|
int error = samount(periph, 0, bp->bio_dev);
|
|
|
|
if (error) {
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_unlock(periph);
|
2006-01-14 14:32:41 +00:00
|
|
|
biofinish(bp, NULL, ENXIO);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
saprevent(periph, PR_PREVENT);
|
|
|
|
softc->open_pending_mount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
/*
|
2006-01-14 14:32:41 +00:00
|
|
|
* If it's a null transfer, return immediately
|
1998-09-15 06:36:34 +00:00
|
|
|
*/
|
2001-05-08 08:30:48 +00:00
|
|
|
if (bp->bio_bcount == 0) {
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_unlock(periph);
|
2001-05-08 08:30:48 +00:00
|
|
|
biodone(bp);
|
|
|
|
return;
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
/* valid request? */
|
|
|
|
if (softc->flags & SA_FLAG_FIXED) {
|
|
|
|
/*
|
|
|
|
* Fixed block device. The byte count must
|
|
|
|
* be a multiple of our block size.
|
|
|
|
*/
|
1999-01-16 04:02:31 +00:00
|
|
|
if (((softc->blk_mask != ~0) &&
|
2000-04-15 05:54:02 +00:00
|
|
|
((bp->bio_bcount & softc->blk_mask) != 0)) ||
|
1999-01-16 04:02:31 +00:00
|
|
|
((softc->blk_mask == ~0) &&
|
2000-04-15 05:54:02 +00:00
|
|
|
((bp->bio_bcount % softc->min_blk) != 0))) {
|
2006-12-05 07:45:28 +00:00
|
|
|
xpt_print(periph->path, "Invalid request. Fixed block "
|
|
|
|
"device requests must be a multiple of %d bytes\n",
|
|
|
|
softc->min_blk);
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_unlock(periph);
|
2001-05-08 08:30:48 +00:00
|
|
|
biofinish(bp, NULL, EINVAL);
|
|
|
|
return;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
2000-04-15 05:54:02 +00:00
|
|
|
} else if ((bp->bio_bcount > softc->max_blk) ||
|
|
|
|
(bp->bio_bcount < softc->min_blk) ||
|
|
|
|
(bp->bio_bcount & softc->blk_mask) != 0) {
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
xpt_print_path(periph->path);
|
2006-12-05 07:45:28 +00:00
|
|
|
printf("Invalid request. Variable block "
|
|
|
|
"device requests must be ");
|
1998-09-15 06:36:34 +00:00
|
|
|
if (softc->blk_mask != 0) {
|
1999-01-16 04:02:31 +00:00
|
|
|
printf("a multiple of %d ", (0x1 << softc->blk_gran));
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
1999-01-16 04:02:31 +00:00
|
|
|
printf("between %d and %d bytes\n", softc->min_blk,
|
|
|
|
softc->max_blk);
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_unlock(periph);
|
2001-05-08 08:30:48 +00:00
|
|
|
biofinish(bp, NULL, EINVAL);
|
|
|
|
return;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-01-16 04:02:31 +00:00
|
|
|
* Place it at the end of the queue.
|
1998-09-15 06:36:34 +00:00
|
|
|
*/
|
2000-04-15 05:54:02 +00:00
|
|
|
bioq_insert_tail(&softc->bio_queue, bp);
|
1999-05-11 04:01:35 +00:00
|
|
|
softc->queue_count++;
|
2003-06-02 00:37:42 +00:00
|
|
|
#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));
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Schedule ourselves for performing the work.
|
|
|
|
*/
|
2009-10-23 08:27:55 +00:00
|
|
|
xpt_schedule(periph, CAM_PRIORITY_NORMAL);
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_unlock(periph);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-01-14 14:32:41 +00:00
|
|
|
|
|
|
|
#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; \
|
|
|
|
}
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
static int
|
2004-06-16 09:47:26 +00:00
|
|
|
saioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
|
1998-09-15 06:36:34 +00:00
|
|
|
{
|
|
|
|
struct cam_periph *periph;
|
|
|
|
struct sa_softc *softc;
|
1999-07-03 16:29:32 +00:00
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
int mode;
|
1999-11-17 06:05:09 +00:00
|
|
|
int error = 0;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
mode = SAMODE(dev);
|
1999-07-03 16:29:32 +00:00
|
|
|
error = 0; /* shut up gcc */
|
|
|
|
spaceop = 0; /* shut up gcc */
|
1998-09-15 06:36:34 +00:00
|
|
|
|
2002-08-15 20:54:03 +00:00
|
|
|
periph = (struct cam_periph *)dev->si_drv1;
|
1998-09-15 06:36:34 +00:00
|
|
|
if (periph == NULL)
|
|
|
|
return (ENXIO);
|
|
|
|
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_lock(periph);
|
1998-09-15 06:36:34 +00:00
|
|
|
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) {
|
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:
|
|
|
|
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) {
|
2007-04-15 08:49:19 +00:00
|
|
|
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;
|
|
|
|
|
2005-04-14 04:51:18 +00:00
|
|
|
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 */
|
|
|
|
}
|
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.
|
|
|
|
*/
|
2007-04-15 08:49:19 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
/*
|
|
|
|
* Find the device that the user is talking about
|
|
|
|
*/
|
|
|
|
switch (cmd) {
|
|
|
|
case MTIOCGET:
|
|
|
|
{
|
|
|
|
struct mtget *g = (struct mtget *)arg;
|
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
/*
|
|
|
|
* If this isn't the control mode device, actually go out
|
|
|
|
* and ask the drive again what it's set to.
|
|
|
|
*/
|
2006-01-14 14:32:41 +00:00
|
|
|
if (!SA_IS_CTRL(dev) && !softc->open_pending_mount) {
|
1999-11-17 06:05:09 +00:00
|
|
|
u_int8_t write_protect;
|
|
|
|
int comp_enabled, comp_supported;
|
|
|
|
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);
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
if (write_protect)
|
|
|
|
softc->flags |= SA_FLAG_TAPE_WP;
|
|
|
|
else
|
|
|
|
softc->flags &= ~SA_FLAG_TAPE_WP;
|
|
|
|
softc->flags &= ~(SA_FLAG_COMP_SUPP|
|
|
|
|
SA_FLAG_COMP_ENABLED|SA_FLAG_COMP_UNSUPP);
|
|
|
|
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;
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
bzero(g, sizeof(struct mtget));
|
1998-12-19 23:33:21 +00:00
|
|
|
g->mt_type = MT_ISAR;
|
1998-09-15 06:36:34 +00:00
|
|
|
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 {
|
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;
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
g->mt_comp0 = softc->comp_algorithm;
|
|
|
|
g->mt_comp1 = softc->comp_algorithm;
|
|
|
|
g->mt_comp2 = softc->comp_algorithm;
|
|
|
|
g->mt_comp3 = softc->comp_algorithm;
|
|
|
|
}
|
1999-05-11 04:01:35 +00:00
|
|
|
g->mt_density = softc->media_density;
|
1998-09-15 06:36:34 +00:00
|
|
|
g->mt_density0 = softc->media_density;
|
|
|
|
g->mt_density1 = softc->media_density;
|
|
|
|
g->mt_density2 = softc->media_density;
|
|
|
|
g->mt_density3 = softc->media_density;
|
1999-05-11 04:01:35 +00:00
|
|
|
g->mt_blksiz = softc->media_blksize;
|
1998-09-15 06:36:34 +00:00
|
|
|
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;
|
2001-01-19 21:08:15 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
error = 0;
|
|
|
|
break;
|
|
|
|
}
|
1998-12-19 23:33:21 +00:00
|
|
|
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));
|
1998-12-22 17:26:13 +00:00
|
|
|
bcopy((caddr_t) &softc->last_io_cdb, sep->io_cdb,
|
|
|
|
sizeof (sep->io_cdb));
|
|
|
|
sep->ctl_resid = softc->last_ctl_resid;
|
1998-12-19 23:33:21 +00:00
|
|
|
bcopy((caddr_t) &softc->last_ctl_sense, sep->ctl_sense,
|
|
|
|
sizeof (sep->ctl_sense));
|
1998-12-22 17:26:13 +00:00
|
|
|
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
|
|
|
|
2006-01-14 14:32:41 +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));
|
1998-12-19 23:33:21 +00:00
|
|
|
error = 0;
|
|
|
|
break;
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
case MTIOCTOP:
|
|
|
|
{
|
|
|
|
struct mtop *mt;
|
|
|
|
int count;
|
|
|
|
|
2006-01-14 14:32:41 +00:00
|
|
|
PENDING_MOUNT_CHECK(softc, periph, dev);
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
mt = (struct mtop *)arg;
|
|
|
|
|
2006-01-14 14:32:41 +00:00
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
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) {
|
1998-12-17 18:56:23 +00:00
|
|
|
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
|
|
|
|
* we have last written we know ehether or not
|
|
|
|
* we need to write more when we close the device.
|
|
|
|
*/
|
1998-12-17 18:56:23 +00:00
|
|
|
error = sawritefilemarks(periph, count, FALSE);
|
1998-09-15 06:36:34 +00:00
|
|
|
break;
|
1998-12-22 17:26:13 +00:00
|
|
|
case MTWSS: /* write a setmark */
|
|
|
|
error = sawritefilemarks(periph, count, TRUE);
|
|
|
|
break;
|
1998-09-15 06:36:34 +00:00
|
|
|
case MTBSR: /* backward space record */
|
|
|
|
case MTFSR: /* forward space record */
|
|
|
|
case MTBSF: /* backward space file */
|
|
|
|
case MTFSF: /* forward space file */
|
1998-12-22 17:26:13 +00:00
|
|
|
case MTBSS: /* backward space setmark */
|
|
|
|
case MTFSS: /* forward space setmark */
|
1998-09-15 06:36:34 +00:00
|
|
|
case MTEOD: /* space to end of recorded medium */
|
|
|
|
{
|
|
|
|
int nmarks;
|
|
|
|
|
1999-07-03 16:29:32 +00:00
|
|
|
spaceop = SS_FILEMARKS;
|
1998-09-15 06:36:34 +00:00
|
|
|
nmarks = softc->filemarks;
|
|
|
|
error = sacheckeod(periph);
|
1998-12-17 18:56:23 +00:00
|
|
|
if (error) {
|
2006-12-05 07:45:28 +00:00
|
|
|
xpt_print(periph->path,
|
|
|
|
"EOD check prior to spacing failed\n");
|
1998-12-17 18:56:23 +00:00
|
|
|
softc->flags |= SA_FLAG_EIO_PENDING;
|
|
|
|
break;
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
nmarks -= softc->filemarks;
|
1998-12-22 17:26:13 +00:00
|
|
|
switch(mt->mt_op) {
|
|
|
|
case MTBSR:
|
1998-09-15 06:36:34 +00:00
|
|
|
count = -count;
|
1998-12-22 17:26:13 +00:00
|
|
|
/* FALLTHROUGH */
|
|
|
|
case MTFSR:
|
1998-09-15 06:36:34 +00:00
|
|
|
spaceop = SS_BLOCKS;
|
1998-12-22 17:26:13 +00:00
|
|
|
break;
|
|
|
|
case MTBSF:
|
|
|
|
count = -count;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case MTFSF:
|
|
|
|
break;
|
|
|
|
case MTBSS:
|
|
|
|
count = -count;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case MTFSS:
|
|
|
|
spaceop = SS_SETMARKS;
|
|
|
|
break;
|
|
|
|
case MTEOD:
|
1998-09-15 06:36:34 +00:00
|
|
|
spaceop = SS_EOD;
|
|
|
|
count = 0;
|
|
|
|
nmarks = 0;
|
1998-12-22 17:26:13 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
1998-12-22 17:26:13 +00:00
|
|
|
if (error)
|
|
|
|
break;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
nmarks = softc->filemarks;
|
1998-12-22 17:26:13 +00:00
|
|
|
/*
|
|
|
|
* XXX: Why are we checking again?
|
|
|
|
*/
|
1998-09-15 06:36:34 +00:00
|
|
|
error = sacheckeod(periph);
|
1998-12-22 17:26:13 +00:00
|
|
|
if (error)
|
|
|
|
break;
|
1998-09-15 06:36:34 +00:00
|
|
|
nmarks -= softc->filemarks;
|
1998-12-22 17:26:13 +00:00
|
|
|
error = saspace(periph, count - nmarks, spaceop);
|
1998-12-17 18:56:23 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
1999-05-11 04:01:35 +00:00
|
|
|
softc->flags &=
|
|
|
|
~(SA_FLAG_TAPE_WRITTEN|SA_FLAG_TAPE_FROZEN);
|
1998-12-17 18:56:23 +00:00
|
|
|
softc->filemarks = 0;
|
1998-09-15 06:36:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MTREW: /* rewind */
|
2006-01-14 14:32:41 +00:00
|
|
|
PENDING_MOUNT_CHECK(softc, periph, dev);
|
1998-12-17 18:56:23 +00:00
|
|
|
(void) sacheckeod(periph);
|
1998-09-15 06:36:34 +00:00
|
|
|
error = sarewind(periph);
|
1998-12-17 18:56:23 +00:00
|
|
|
/* see above */
|
1998-12-22 17:26:13 +00:00
|
|
|
softc->flags &=
|
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;
|
1998-12-17 18:56:23 +00:00
|
|
|
softc->filemarks = 0;
|
1998-09-15 06:36:34 +00:00
|
|
|
break;
|
|
|
|
case MTERASE: /* erase */
|
2006-01-14 14:32:41 +00:00
|
|
|
PENDING_MOUNT_CHECK(softc, periph, dev);
|
1998-09-15 06:36:34 +00:00
|
|
|
error = saerase(periph, count);
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
break;
|
|
|
|
case MTRETENS: /* re-tension tape */
|
2006-01-14 14:32:41 +00:00
|
|
|
PENDING_MOUNT_CHECK(softc, periph, dev);
|
1998-09-15 06:36:34 +00:00
|
|
|
error = saretension(periph);
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
break;
|
|
|
|
case MTOFFL: /* rewind and put the drive offline */
|
1998-12-17 18:56:23 +00:00
|
|
|
|
2006-01-14 14:32:41 +00:00
|
|
|
PENDING_MOUNT_CHECK(softc, periph, dev);
|
|
|
|
|
1998-12-17 18:56:23 +00:00
|
|
|
(void) sacheckeod(periph);
|
|
|
|
/* see above */
|
|
|
|
softc->flags &= ~SA_FLAG_TAPE_WRITTEN;
|
|
|
|
softc->filemarks = 0;
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
error = sarewind(periph);
|
1999-11-21 20:23:58 +00:00
|
|
|
/* clear the frozen flag anyway */
|
|
|
|
softc->flags &= ~SA_FLAG_TAPE_FROZEN;
|
1999-05-11 04:01:35 +00:00
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
/*
|
1999-11-21 20:23:58 +00:00
|
|
|
* Be sure to allow media removal before ejecting.
|
1998-09-15 06:36:34 +00:00
|
|
|
*/
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
saprevent(periph, PR_ALLOW);
|
1999-11-21 20:23:58 +00:00
|
|
|
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);
|
1999-11-21 20:23:58 +00:00
|
|
|
if (error == 0) {
|
|
|
|
softc->flags &= ~SA_FLAG_TAPE_MOUNTED;
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
break;
|
1999-05-11 04:01:35 +00:00
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
case MTNOP: /* no operation, sets status only */
|
|
|
|
case MTCACHE: /* enable controller cache */
|
|
|
|
case MTNOCACHE: /* disable controller cache */
|
|
|
|
error = 0;
|
|
|
|
break;
|
1999-05-11 04:01:35 +00:00
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
case MTSETBSIZ: /* Set block size for device */
|
|
|
|
|
2006-01-14 14:32:41 +00:00
|
|
|
PENDING_MOUNT_CHECK(softc, periph, dev);
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
error = sasetparams(periph, SA_PARAM_BLOCKSIZE, count,
|
1999-01-12 08:15:47 +00:00
|
|
|
0, 0, 0);
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
if (error == 0) {
|
1998-12-17 18:56:23 +00:00
|
|
|
softc->last_media_blksize =
|
|
|
|
softc->media_blksize;
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
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;
|
|
|
|
}
|
1998-12-17 18:56:23 +00:00
|
|
|
/*
|
|
|
|
* Make the user's desire 'persistent'.
|
|
|
|
*/
|
|
|
|
softc->quirks &= ~SA_QUIRK_VARIABLE;
|
|
|
|
softc->quirks |= SA_QUIRK_FIXED;
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
} 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;
|
|
|
|
}
|
1998-12-17 18:56:23 +00:00
|
|
|
/*
|
|
|
|
* Make the user's desire 'persistent'.
|
|
|
|
*/
|
|
|
|
softc->quirks |= SA_QUIRK_VARIABLE;
|
|
|
|
softc->quirks &= ~SA_QUIRK_FIXED;
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
}
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
break;
|
|
|
|
case MTSETDNSTY: /* Set density for device and mode */
|
2006-01-14 14:32:41 +00:00
|
|
|
PENDING_MOUNT_CHECK(softc, periph, dev);
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
if (count > UCHAR_MAX) {
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
error = sasetparams(periph, SA_PARAM_DENSITY,
|
1999-01-12 08:15:47 +00:00
|
|
|
0, count, 0, 0);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MTCOMP: /* enable compression */
|
2006-01-14 14:32:41 +00:00
|
|
|
PENDING_MOUNT_CHECK(softc, periph, dev);
|
1998-09-15 06:36:34 +00:00
|
|
|
/*
|
|
|
|
* 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)) {
|
1998-09-15 06:36:34 +00:00
|
|
|
error = ENODEV;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
error = sasetparams(periph, SA_PARAM_COMPRESSION,
|
1999-12-03 23:14:11 +00:00
|
|
|
0, 0, count, SF_NO_PRINT);
|
1998-09-15 06:36:34 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MTIOCIEOT:
|
|
|
|
case MTIOCEEOT:
|
|
|
|
error = 0;
|
|
|
|
break;
|
1998-12-18 04:31:43 +00:00
|
|
|
case MTIOCRDSPOS:
|
2006-01-14 14:32:41 +00:00
|
|
|
PENDING_MOUNT_CHECK(softc, periph, dev);
|
1998-12-18 04:31:43 +00:00
|
|
|
error = sardpos(periph, 0, (u_int32_t *) arg);
|
|
|
|
break;
|
|
|
|
case MTIOCRDHPOS:
|
2006-01-14 14:32:41 +00:00
|
|
|
PENDING_MOUNT_CHECK(softc, periph, dev);
|
1998-12-18 04:31:43 +00:00
|
|
|
error = sardpos(periph, 1, (u_int32_t *) arg);
|
|
|
|
break;
|
|
|
|
case MTIOCSLOCATE:
|
2006-01-14 14:32:41 +00:00
|
|
|
PENDING_MOUNT_CHECK(softc, periph, dev);
|
1998-12-18 04:31:43 +00:00
|
|
|
error = sasetpos(periph, 0, (u_int32_t *) arg);
|
|
|
|
break;
|
|
|
|
case MTIOCHLOCATE:
|
2006-01-14 14:32:41 +00:00
|
|
|
PENDING_MOUNT_CHECK(softc, periph, dev);
|
1998-12-18 04:31:43 +00:00
|
|
|
error = sasetpos(periph, 1, (u_int32_t *) arg);
|
|
|
|
break;
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
default:
|
|
|
|
error = cam_periph_ioctl(periph, cmd, arg, saerror);
|
|
|
|
break;
|
|
|
|
}
|
2001-01-19 21:08:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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:
|
|
|
|
softc->fileno = (daddr_t) -1;
|
|
|
|
softc->blkno = (daddr_t) -1;
|
|
|
|
softc->flags &= ~SA_FLAG_TAPE_FROZEN;
|
2006-12-05 07:45:28 +00:00
|
|
|
xpt_print(periph->path,
|
|
|
|
"tape state now unfrozen.\n");
|
2001-01-19 21:08:15 +00:00
|
|
|
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) {
|
2007-04-15 08:49:19 +00:00
|
|
|
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
|
|
|
}
|
2007-04-15 08:49:19 +00:00
|
|
|
cam_periph_unlock(periph);
|
1998-09-15 06:36:34 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sainit(void)
|
|
|
|
{
|
|
|
|
cam_status status;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Install a global async callback.
|
|
|
|
*/
|
2007-05-16 16:54:23 +00:00
|
|
|
status = xpt_register_async(AC_FOUND_DEVICE, saasync, NULL, NULL);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
if (status != CAM_REQ_CMP) {
|
|
|
|
printf("sa: Failed to attach master async callback "
|
|
|
|
"due to status 0x%x!\n", status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
*/
|
2007-05-16 16:54:23 +00:00
|
|
|
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.
|
|
|
|
*/
|
2003-04-01 15:06:26 +00:00
|
|
|
bioq_flush(&softc->bio_queue, NULL, ENXIO);
|
1999-05-11 04:01:35 +00:00
|
|
|
softc->queue_count = 0;
|
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
|
|
|
}
|
|
|
|
|
1998-09-15 06:36:34 +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;
|
1999-11-17 06:05:09 +00:00
|
|
|
int i;
|
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 = (struct sa_softc *)periph->softc;
|
|
|
|
|
2003-03-08 21:44:46 +00:00
|
|
|
devstat_remove_entry(softc->device_stats);
|
2009-01-10 17:22:49 +00:00
|
|
|
cam_periph_unlock(periph);
|
1999-11-17 06:05:09 +00:00
|
|
|
destroy_dev(softc->devs.ctl_dev);
|
|
|
|
for (i = 0; i < SA_NUM_MODES; i++) {
|
|
|
|
destroy_dev(softc->devs.mode_devs[i].r_dev);
|
|
|
|
destroy_dev(softc->devs.mode_devs[i].nr_dev);
|
|
|
|
destroy_dev(softc->devs.mode_devs[i].er_dev);
|
|
|
|
}
|
2009-01-10 17:22:49 +00:00
|
|
|
cam_periph_lock(periph);
|
2005-07-01 15:21:30 +00:00
|
|
|
free(softc, M_SCSISA);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2001-07-04 05:22:42 +00:00
|
|
|
if (cgd == NULL)
|
|
|
|
break;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
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;
|
|
|
|
|
2000-01-17 06:27:37 +00:00
|
|
|
if (SID_TYPE(&cgd->inq_data) != T_SEQUENTIAL)
|
1998-09-15 06:36:34 +00:00
|
|
|
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,
|
1998-09-15 06:36:34 +00:00
|
|
|
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:
|
1999-05-22 22:00:24 +00:00
|
|
|
cam_periph_async(periph, code, path, arg);
|
1998-09-15 06:36:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
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),
|
2014-06-28 03:56:17 +00:00
|
|
|
OID_AUTO, "allow_io_split", CTLTYPE_INT | 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", CTLTYPE_INT | CTLFLAG_RD,
|
|
|
|
&softc->maxio, 0, "Maximum I/O size");
|
|
|
|
SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
|
|
|
|
OID_AUTO, "cpi_maxio", CTLTYPE_INT | CTLFLAG_RD,
|
|
|
|
&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);
|
|
|
|
}
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
static cam_status
|
|
|
|
saregister(struct cam_periph *periph, void *arg)
|
|
|
|
{
|
|
|
|
struct sa_softc *softc;
|
|
|
|
struct ccb_getdev *cgd;
|
2011-04-14 21:25:32 +00:00
|
|
|
struct ccb_pathinq cpi;
|
1998-09-15 06:36:34 +00:00
|
|
|
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];
|
1999-11-17 06:05:09 +00:00
|
|
|
int i;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
cgd = (struct ccb_getdev *)arg;
|
|
|
|
if (cgd == NULL) {
|
|
|
|
printf("saregister: no getdev CCB, can't register device\n");
|
1999-12-03 23:14:11 +00:00
|
|
|
return (CAM_REQ_CMP_ERR);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
2000-10-27 16:40:57 +00:00
|
|
|
softc = (struct sa_softc *)
|
2005-07-01 15:21:30 +00:00
|
|
|
malloc(sizeof (*softc), M_SCSISA, M_NOWAIT | M_ZERO);
|
1998-09-15 06:36:34 +00:00
|
|
|
if (softc == NULL) {
|
|
|
|
printf("saregister: Unable to probe new device. "
|
|
|
|
"Unable to allocate softc\n");
|
1999-12-03 23:14:11 +00:00
|
|
|
return (CAM_REQ_CMP_ERR);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
softc->scsi_rev = SID_ANSI_REV(&cgd->inq_data);
|
1998-09-15 06:36:34 +00:00
|
|
|
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;
|
|
|
|
|
2000-04-15 05:54:02 +00:00
|
|
|
bioq_init(&softc->bio_queue);
|
1998-09-15 06:36:34 +00:00
|
|
|
periph->softc = softc;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See if this device has any quirks.
|
|
|
|
*/
|
|
|
|
match = cam_quirkmatch((caddr_t)&cgd->inq_data,
|
|
|
|
(caddr_t)sa_quirk_table,
|
|
|
|
sizeof(sa_quirk_table)/sizeof(*sa_quirk_table),
|
|
|
|
sizeof(*sa_quirk_table), scsi_inquiry_match);
|
|
|
|
|
1999-01-12 08:15:47 +00:00
|
|
|
if (match != NULL) {
|
1998-09-15 06:36:34 +00:00
|
|
|
softc->quirks = ((struct sa_quirk_entry *)match)->quirks;
|
1999-01-12 08:15:47 +00:00
|
|
|
softc->last_media_blksize =
|
|
|
|
((struct sa_quirk_entry *)match)->prefblk;
|
|
|
|
} else
|
1998-09-15 06:36:34 +00:00
|
|
|
softc->quirks = SA_QUIRK_NONE;
|
|
|
|
|
2011-04-14 21:25:32 +00:00
|
|
|
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);
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
/*
|
2011-04-14 21:25:32 +00:00
|
|
|
* The SA driver supports a blocksize, but we don't know the
|
1999-05-11 04:01:35 +00:00
|
|
|
* blocksize until we media is inserted. So, set a flag to
|
1998-09-15 06:36:34 +00:00
|
|
|
* indicate that the blocksize is unavailable right now.
|
|
|
|
*/
|
2007-05-16 16:54:23 +00:00
|
|
|
cam_periph_unlock(periph);
|
2003-03-08 21:44:46 +00:00
|
|
|
softc->device_stats = devstat_new_entry("sa", periph->unit_number, 0,
|
2000-01-17 06:27:37 +00:00
|
|
|
DEVSTAT_BS_UNAVAILABLE, SID_TYPE(&cgd->inq_data) |
|
2011-04-14 21:25:32 +00:00
|
|
|
XPORT_DEVSTAT_TYPE(cpi.transport), DEVSTAT_PRIORITY_TAPE);
|
1999-11-17 06:05:09 +00:00
|
|
|
|
2013-08-16 16:14:32 +00:00
|
|
|
/*
|
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.
|
2013-08-16 16:14:32 +00:00
|
|
|
*/
|
|
|
|
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;
|
2013-08-16 16:14:32 +00:00
|
|
|
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);
|
|
|
|
|
2013-08-16 16:14:32 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
2013-08-16 16:14:32 +00:00
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
softc->devs.ctl_dev = make_dev(&sa_cdevsw, SAMINOR(SA_CTLDEV,
|
2009-04-20 10:40:42 +00:00
|
|
|
0, SA_ATYPE_R), UID_ROOT, GID_OPERATOR,
|
2001-02-21 17:29:01 +00:00
|
|
|
0660, "%s%d.ctl", periph->periph_name, periph->unit_number);
|
2002-08-15 20:54:03 +00:00
|
|
|
softc->devs.ctl_dev->si_drv1 = periph;
|
2013-08-16 16:14:32 +00:00
|
|
|
softc->devs.ctl_dev->si_iosize_max = softc->maxio;
|
|
|
|
softc->devs.ctl_dev->si_flags |= softc->si_flags;
|
1999-11-17 06:05:09 +00:00
|
|
|
|
|
|
|
for (i = 0; i < SA_NUM_MODES; i++) {
|
1999-11-17 17:11:21 +00:00
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
softc->devs.mode_devs[i].r_dev = make_dev(&sa_cdevsw,
|
2009-04-20 10:40:42 +00:00
|
|
|
SAMINOR(SA_NOT_CTLDEV, i, SA_ATYPE_R),
|
2001-02-21 17:29:01 +00:00
|
|
|
UID_ROOT, GID_OPERATOR, 0660, "%s%d.%d",
|
1999-11-17 06:05:09 +00:00
|
|
|
periph->periph_name, periph->unit_number, i);
|
2002-08-15 20:54:03 +00:00
|
|
|
softc->devs.mode_devs[i].r_dev->si_drv1 = periph;
|
2013-08-16 16:14:32 +00:00
|
|
|
softc->devs.mode_devs[i].r_dev->si_iosize_max = softc->maxio;
|
|
|
|
softc->devs.mode_devs[i].r_dev->si_flags |= softc->si_flags;
|
1999-11-17 17:11:21 +00:00
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
softc->devs.mode_devs[i].nr_dev = make_dev(&sa_cdevsw,
|
2009-04-20 10:40:42 +00:00
|
|
|
SAMINOR(SA_NOT_CTLDEV, i, SA_ATYPE_NR),
|
2001-02-21 17:29:01 +00:00
|
|
|
UID_ROOT, GID_OPERATOR, 0660, "n%s%d.%d",
|
1999-11-17 06:05:09 +00:00
|
|
|
periph->periph_name, periph->unit_number, i);
|
2002-08-15 20:54:03 +00:00
|
|
|
softc->devs.mode_devs[i].nr_dev->si_drv1 = periph;
|
2013-08-16 16:14:32 +00:00
|
|
|
softc->devs.mode_devs[i].nr_dev->si_iosize_max = softc->maxio;
|
|
|
|
softc->devs.mode_devs[i].nr_dev->si_flags |= softc->si_flags;
|
1999-11-17 17:11:21 +00:00
|
|
|
|
|
|
|
softc->devs.mode_devs[i].er_dev = make_dev(&sa_cdevsw,
|
2009-04-20 10:40:42 +00:00
|
|
|
SAMINOR(SA_NOT_CTLDEV, i, SA_ATYPE_ER),
|
2001-02-21 17:29:01 +00:00
|
|
|
UID_ROOT, GID_OPERATOR, 0660, "e%s%d.%d",
|
1999-11-17 06:05:09 +00:00
|
|
|
periph->periph_name, periph->unit_number, i);
|
2002-08-15 20:54:03 +00:00
|
|
|
softc->devs.mode_devs[i].er_dev->si_drv1 = periph;
|
2013-08-16 16:14:32 +00:00
|
|
|
softc->devs.mode_devs[i].er_dev->si_iosize_max = softc->maxio;
|
|
|
|
softc->devs.mode_devs[i].er_dev->si_flags |= softc->si_flags;
|
2000-09-14 14:53:57 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make the (well known) aliases for the first mode.
|
|
|
|
*/
|
|
|
|
if (i == 0) {
|
2004-06-16 09:47:26 +00:00
|
|
|
struct cdev *alias;
|
2002-08-15 20:54:03 +00:00
|
|
|
|
|
|
|
alias = make_dev_alias(softc->devs.mode_devs[i].r_dev,
|
2001-02-21 17:29:01 +00:00
|
|
|
"%s%d", periph->periph_name, periph->unit_number);
|
2002-08-15 20:54:03 +00:00
|
|
|
alias->si_drv1 = periph;
|
2013-08-16 16:14:32 +00:00
|
|
|
alias->si_iosize_max = softc->maxio;
|
|
|
|
alias->si_flags |= softc->si_flags;
|
|
|
|
|
2002-08-15 20:54:03 +00:00
|
|
|
alias = make_dev_alias(softc->devs.mode_devs[i].nr_dev,
|
2001-02-21 17:29:01 +00:00
|
|
|
"n%s%d", periph->periph_name, periph->unit_number);
|
2002-08-15 20:54:03 +00:00
|
|
|
alias->si_drv1 = periph;
|
2013-08-16 16:14:32 +00:00
|
|
|
alias->si_iosize_max = softc->maxio;
|
|
|
|
alias->si_flags |= softc->si_flags;
|
|
|
|
|
2002-08-15 20:54:03 +00:00
|
|
|
alias = make_dev_alias(softc->devs.mode_devs[i].er_dev,
|
2001-02-21 17:29:01 +00:00
|
|
|
"e%s%d", periph->periph_name, periph->unit_number);
|
2002-08-15 20:54:03 +00:00
|
|
|
alias->si_drv1 = periph;
|
2013-08-16 16:14:32 +00:00
|
|
|
alias->si_iosize_max = softc->maxio;
|
|
|
|
alias->si_flags |= softc->si_flags;
|
2000-09-14 14:53:57 +00:00
|
|
|
}
|
1999-11-17 06:05:09 +00:00
|
|
|
}
|
2007-04-19 18:14:33 +00:00
|
|
|
cam_periph_lock(periph);
|
1999-11-17 06:05:09 +00:00
|
|
|
|
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);
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
/*
|
|
|
|
* Add an async callback so that we get
|
|
|
|
* notified if this device goes away.
|
|
|
|
*/
|
2007-05-16 16:54:23 +00:00
|
|
|
xpt_register_async(AC_LOST_DEVICE, saasync, periph, periph->path);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
xpt_announce_periph(periph, NULL);
|
2013-05-18 23:36:21 +00:00
|
|
|
xpt_announce_quirks(periph, softc->quirks, SA_QUIRK_BIT_STRING);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-12-03 23:14:11 +00:00
|
|
|
return (CAM_REQ_CMP);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sastart(struct cam_periph *periph, union ccb *start_ccb)
|
|
|
|
{
|
|
|
|
struct sa_softc *softc;
|
|
|
|
|
|
|
|
softc = (struct sa_softc *)periph->softc;
|
|
|
|
|
2003-06-02 00:37:42 +00:00
|
|
|
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sastart\n"));
|
2001-01-15 22:28:11 +00:00
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
switch (softc->state) {
|
|
|
|
case SA_STATE_NORMAL:
|
|
|
|
{
|
|
|
|
/* Pull a buffer from the queue and get going on it */
|
2000-04-15 05:54:02 +00:00
|
|
|
struct bio *bp;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* See if there is a buf with work for us to do..
|
|
|
|
*/
|
2000-04-15 05:54:02 +00:00
|
|
|
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) {
|
1998-09-15 06:36:34 +00:00
|
|
|
xpt_release_ccb(start_ccb);
|
|
|
|
} else if ((softc->flags & SA_FLAG_ERR_PENDING) != 0) {
|
2000-04-15 05:54:02 +00:00
|
|
|
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:
|
1999-05-11 04:01:35 +00:00
|
|
|
softc->queue_count--;
|
2000-04-15 05:54:02 +00:00
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
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
|
|
|
/*
|
|
|
|
* We now just clear errors in this case
|
|
|
|
* and let the residual be the notifier.
|
|
|
|
*/
|
|
|
|
bp->bio_error = 0;
|
|
|
|
} 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) {
|
2000-04-15 05:54:02 +00:00
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
2000-04-15 05:54:02 +00:00
|
|
|
bp = bioq_first(&softc->bio_queue);
|
1999-03-01 01:07:47 +00:00
|
|
|
/*
|
|
|
|
* 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,
|
1999-05-11 04:01:35 +00:00
|
|
|
("sastart- ERR_PENDING now 0x%x, bp is %sNULL, "
|
|
|
|
"%d more buffers queued up\n",
|
1999-03-01 01:07:47 +00:00
|
|
|
(softc->flags & SA_FLAG_ERR_PENDING),
|
1999-05-11 04:01:35 +00:00
|
|
|
(bp != NULL)? "not " : " ", softc->queue_count));
|
1999-03-01 01:07:47 +00:00
|
|
|
xpt_release_ccb(start_ccb);
|
1998-12-19 23:33:21 +00:00
|
|
|
biodone(done_bp);
|
1998-09-15 06:36:34 +00:00
|
|
|
} else {
|
|
|
|
u_int32_t length;
|
|
|
|
|
2000-04-15 05:54:02 +00:00
|
|
|
bioq_remove(&softc->bio_queue, bp);
|
1999-05-11 04:01:35 +00:00
|
|
|
softc->queue_count--;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
if ((softc->flags & SA_FLAG_FIXED) != 0) {
|
|
|
|
if (softc->blk_shift != 0) {
|
|
|
|
length =
|
2000-04-15 05:54:02 +00:00
|
|
|
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 if (softc->media_blksize != 0) {
|
2001-01-15 22:28:11 +00:00
|
|
|
length = 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
|
|
|
} else {
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_error = EIO;
|
2006-12-05 07:45:28 +00:00
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
2003-06-02 00:37:42 +00:00
|
|
|
#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
|
1998-09-15 06:36:34 +00:00
|
|
|
} else {
|
2000-04-15 05:54:02 +00:00
|
|
|
length = bp->bio_bcount;
|
2003-06-02 00:37:42 +00:00
|
|
|
#if 0
|
1998-12-17 18:56:23 +00:00
|
|
|
CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_INFO,
|
2003-06-02 00:37:42 +00:00
|
|
|
("issuing a %d variable byte %s\n",
|
|
|
|
length, (bp->bio_cmd == BIO_READ)? "read" :
|
|
|
|
"write"));
|
|
|
|
#endif
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
2003-03-15 10:50:44 +00:00
|
|
|
devstat_start_transaction_bio(softc->device_stats, bp);
|
1998-09-15 06:36:34 +00:00
|
|
|
/*
|
1998-12-17 18:56:23 +00:00
|
|
|
* Some people have theorized that we should
|
1998-09-15 06:36:34 +00:00
|
|
|
* 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.
|
1998-12-17 18:56:23 +00:00
|
|
|
*
|
|
|
|
* 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.
|
1998-09-15 06:36:34 +00:00
|
|
|
*/
|
2000-04-15 05:54:02 +00:00
|
|
|
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;
|
1999-05-11 04:01:35 +00:00
|
|
|
scsi_sa_read_write(&start_ccb->csio, 0, sadone,
|
2013-08-16 16:14:32 +00:00
|
|
|
MSG_SIMPLE_Q_TAG, (bp->bio_cmd == BIO_READ ?
|
|
|
|
SCSI_RW_READ : SCSI_RW_WRITE) |
|
|
|
|
((bp->bio_flags & BIO_UNMAPPED) != 0 ?
|
|
|
|
SCSI_RW_BIO : 0), FALSE,
|
|
|
|
(softc->flags & SA_FLAG_FIXED) != 0, length,
|
|
|
|
(bp->bio_flags & BIO_UNMAPPED) != 0 ? (void *)bp :
|
|
|
|
bp->bio_data, bp->bio_bcount, SSD_FULL_SIZE,
|
2001-07-02 17:48:59 +00:00
|
|
|
IO_TIMEOUT);
|
2001-01-15 22:28:11 +00:00
|
|
|
start_ccb->ccb_h.ccb_pflags &= ~SA_POSITION_UPDATED;
|
1998-09-15 06:36:34 +00:00
|
|
|
start_ccb->ccb_h.ccb_bp = bp;
|
2000-04-15 05:54:02 +00:00
|
|
|
bp = bioq_first(&softc->bio_queue);
|
1998-09-15 06:36:34 +00:00
|
|
|
xpt_action(start_ccb);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bp != NULL) {
|
|
|
|
/* Have more work to do, so ensure we stay scheduled */
|
2009-10-23 08:27:55 +00:00
|
|
|
xpt_schedule(periph, CAM_PRIORITY_NORMAL);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1999-05-11 04:01:35 +00:00
|
|
|
case SA_STATE_ABNORMAL:
|
|
|
|
default:
|
|
|
|
panic("state 0x%x in sastart", softc->state);
|
|
|
|
break;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
sadone(struct cam_periph *periph, union ccb *done_ccb)
|
|
|
|
{
|
|
|
|
struct sa_softc *softc;
|
|
|
|
struct ccb_scsiio *csio;
|
2014-07-31 22:09:50 +00:00
|
|
|
struct bio *bp;
|
|
|
|
int error;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
softc = (struct sa_softc *)periph->softc;
|
|
|
|
csio = &done_ccb->csio;
|
|
|
|
|
2014-07-31 22:09:50 +00:00
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
2014-07-31 22:09:50 +00:00
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
2014-07-31 22:09:50 +00:00
|
|
|
if (error == EIO) {
|
1998-09-15 06:36:34 +00:00
|
|
|
|
2014-07-31 22:09:50 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
1998-09-15 06:36:34 +00:00
|
|
|
|
2014-07-31 22:09:50 +00:00
|
|
|
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) {
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_flags |= BIO_ERROR;
|
2014-07-31 22:09:50 +00:00
|
|
|
}
|
|
|
|
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 {
|
2014-07-31 22:09:50 +00:00
|
|
|
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
|
|
|
}
|
2014-07-31 22:09:50 +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
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
}
|
2014-07-31 22:09:50 +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));
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
2014-07-31 22:09:50 +00:00
|
|
|
biofinish(bp, softc->device_stats, 0);
|
1998-09-15 06:36:34 +00:00
|
|
|
xpt_release_ccb(done_ccb);
|
|
|
|
}
|
|
|
|
|
1998-12-17 18:56:23 +00:00
|
|
|
/*
|
|
|
|
* Mount the tape (make sure it's ready for I/O).
|
|
|
|
*/
|
1998-09-15 06:36:34 +00:00
|
|
|
static int
|
2004-06-16 09:47:26 +00:00
|
|
|
samount(struct cam_periph *periph, int oflags, struct cdev *dev)
|
1998-09-15 06:36:34 +00:00
|
|
|
{
|
|
|
|
struct sa_softc *softc;
|
|
|
|
union ccb *ccb;
|
|
|
|
int error;
|
|
|
|
|
1998-12-17 18:56:23 +00:00
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
softc = (struct sa_softc *)periph->softc;
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
/*
|
1999-11-17 06:05:09 +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.
|
1999-05-11 04:01:35 +00:00
|
|
|
*/
|
1999-11-17 06:05:09 +00:00
|
|
|
|
|
|
|
if (softc->flags & SA_FLAG_TAPE_MOUNTED) {
|
|
|
|
ccb = cam_periph_getccb(periph, 1);
|
|
|
|
scsi_test_unit_ready(&ccb->csio, 0, sadone,
|
2001-07-02 17:48:59 +00:00
|
|
|
MSG_SIMPLE_Q_TAG, SSD_FULL_SIZE, IO_TIMEOUT);
|
1999-12-03 23:14:11 +00:00
|
|
|
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
|
2003-03-08 21:44:46 +00:00
|
|
|
softc->device_stats);
|
1999-11-17 06:05:09 +00:00
|
|
|
if (error == ENXIO) {
|
|
|
|
softc->flags &= ~SA_FLAG_TAPE_MOUNTED;
|
|
|
|
scsi_test_unit_ready(&ccb->csio, 0, sadone,
|
2001-07-02 17:48:59 +00:00
|
|
|
MSG_SIMPLE_Q_TAG, SSD_FULL_SIZE, IO_TIMEOUT);
|
1999-12-03 23:14:11 +00:00
|
|
|
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
|
2003-03-08 21:44:46 +00:00
|
|
|
softc->device_stats);
|
1999-11-17 06:05:09 +00:00
|
|
|
} else if (error) {
|
1999-12-03 23:14:11 +00:00
|
|
|
/*
|
|
|
|
* We don't need to freeze the tape because we
|
|
|
|
* will now attempt to rewind/load it.
|
|
|
|
*/
|
1999-11-17 06:05:09 +00:00
|
|
|
softc->flags &= ~SA_FLAG_TAPE_MOUNTED;
|
2005-03-31 21:43:19 +00:00
|
|
|
if (CAM_DEBUGGED(periph->path, CAM_DEBUG_INFO)) {
|
2006-12-05 07:45:28 +00:00
|
|
|
xpt_print(periph->path,
|
|
|
|
"error %d on TUR in samount\n", error);
|
1999-12-03 23:14:11 +00:00
|
|
|
}
|
1999-11-17 06:05:09 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
error = sareservereleaseunit(periph, TRUE);
|
|
|
|
if (error) {
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
ccb = cam_periph_getccb(periph, 1);
|
1999-12-04 01:13:59 +00:00
|
|
|
scsi_test_unit_ready(&ccb->csio, 0, sadone,
|
2001-07-02 17:48:59 +00:00
|
|
|
MSG_SIMPLE_Q_TAG, SSD_FULL_SIZE, IO_TIMEOUT);
|
1999-12-04 01:13:59 +00:00
|
|
|
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
|
2003-03-08 21:44:46 +00:00
|
|
|
softc->device_stats);
|
1999-11-17 06:05:09 +00:00
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
if ((softc->flags & SA_FLAG_TAPE_MOUNTED) == 0) {
|
1999-11-17 06:05:09 +00:00
|
|
|
struct scsi_read_block_limits_data *rblim = NULL;
|
|
|
|
int comp_enabled, comp_supported;
|
1998-12-17 18:56:23 +00:00
|
|
|
u_int8_t write_protect, guessing = 0;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear out old state.
|
|
|
|
*/
|
|
|
|
softc->flags &= ~(SA_FLAG_TAPE_WP|SA_FLAG_TAPE_WRITTEN|
|
|
|
|
SA_FLAG_ERR_PENDING|SA_FLAG_COMP_ENABLED|
|
1999-05-11 04:01:35 +00:00
|
|
|
SA_FLAG_COMP_SUPP|SA_FLAG_COMP_UNSUPP);
|
1998-09-15 06:36:34 +00:00
|
|
|
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,
|
1999-12-03 23:14:11 +00:00
|
|
|
FALSE, FALSE, 1, SSD_FULL_SIZE, REWIND_TIMEOUT);
|
|
|
|
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
|
2003-03-08 21:44:46 +00:00
|
|
|
softc->device_stats);
|
1999-11-17 06:05:09 +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
|
|
|
/*
|
1999-03-01 01:07:47 +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
|
|
|
*/
|
1999-03-01 01:07:47 +00:00
|
|
|
if (error) {
|
1999-11-17 06:05:09 +00:00
|
|
|
scsi_rewind(&ccb->csio, 2, sadone, MSG_SIMPLE_Q_TAG,
|
|
|
|
FALSE, SSD_FULL_SIZE, REWIND_TIMEOUT);
|
1999-12-03 23:14:11 +00:00
|
|
|
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
|
2003-03-08 21:44:46 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-11-17 06:05:09 +00:00
|
|
|
* Do a dummy test read to force access to the
|
|
|
|
* media so that the drive will really know what's
|
1999-12-03 23:14:11 +00:00
|
|
|
* there. We actually don't really care what the
|
|
|
|
* blocksize on tape is and don't expect to really
|
|
|
|
* read a full record.
|
1998-09-15 06:36:34 +00:00
|
|
|
*/
|
|
|
|
rblim = (struct scsi_read_block_limits_data *)
|
2007-06-16 18:20:29 +00:00
|
|
|
malloc(8192, M_SCSISA, M_NOWAIT);
|
1999-11-17 06:05:09 +00:00
|
|
|
if (rblim == NULL) {
|
2006-12-05 07:45:28 +00:00
|
|
|
xpt_print(periph->path, "no memory for test read\n");
|
1999-11-17 06:05:09 +00:00
|
|
|
xpt_release_ccb(ccb);
|
|
|
|
error = ENOMEM;
|
|
|
|
goto exit;
|
|
|
|
}
|
2000-02-03 18:29:25 +00:00
|
|
|
|
|
|
|
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,
|
2001-07-02 17:48:59 +00:00
|
|
|
IO_TIMEOUT);
|
2000-02-03 18:29:25 +00:00
|
|
|
(void) cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
|
2003-03-08 21:44:46 +00:00
|
|
|
softc->device_stats);
|
2000-02-03 18:29:25 +00:00
|
|
|
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,
|
2003-03-08 21:44:46 +00:00
|
|
|
softc->device_stats);
|
2000-02-03 18:29:25 +00:00
|
|
|
if (error) {
|
2006-12-05 07:45:28 +00:00
|
|
|
xpt_print(periph->path,
|
|
|
|
"unable to rewind after test read\n");
|
2000-02-03 18:29:25 +00:00
|
|
|
xpt_release_ccb(ccb);
|
|
|
|
goto exit;
|
|
|
|
}
|
1999-11-17 06:05:09 +00:00
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
/*
|
|
|
|
* Next off, determine block limits.
|
|
|
|
*/
|
|
|
|
scsi_read_block_limits(&ccb->csio, 5, sadone, MSG_SIMPLE_Q_TAG,
|
2001-07-02 17:48:59 +00:00
|
|
|
rblim, SSD_FULL_SIZE, SCSIOP_TIMEOUT);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
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,
|
2003-03-08 21:44:46 +00:00
|
|
|
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
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
xpt_release_ccb(ccb);
|
|
|
|
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
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) {
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
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,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
1998-09-15 06:36:34 +00:00
|
|
|
goto exit;
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1998-12-17 18:56:23 +00:00
|
|
|
/*
|
|
|
|
* 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,
|
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,
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-12-17 18:56:23 +00:00
|
|
|
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:
|
2000-09-14 21:38:44 +00:00
|
|
|
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:
|
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;
|
1998-12-17 18:56:23 +00:00
|
|
|
softc->last_media_blksize = 512;
|
|
|
|
break;
|
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;
|
1998-12-17 18:56:23 +00:00
|
|
|
default:
|
|
|
|
softc->last_media_blksize =
|
|
|
|
softc->media_blksize;
|
|
|
|
softc->quirks |= SA_QUIRK_VARIABLE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-01-12 08:15:47 +00:00
|
|
|
|
1998-12-17 18:56:23 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
1999-01-12 08:15:47 +00:00
|
|
|
|
1999-01-16 19:20:30 +00:00
|
|
|
if ((softc->quirks & SA_QUIRK_2FM) == 0) {
|
1998-12-17 18:56:23 +00:00
|
|
|
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:
|
1999-05-11 04:01:35 +00:00
|
|
|
softc->quirks &= ~SA_QUIRK_1FM;
|
1998-12-17 18:56:23 +00:00
|
|
|
softc->quirks |= SA_QUIRK_2FM;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now validate that some info we got makes sense.
|
|
|
|
*/
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
if ((softc->max_blk < softc->media_blksize) ||
|
|
|
|
(softc->min_blk > softc->media_blksize &&
|
|
|
|
softc->media_blksize)) {
|
2006-12-05 07:45:28 +00:00
|
|
|
xpt_print(periph->path,
|
|
|
|
"BLOCK LIMITS (%d..%d) could not match current "
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
"block settings (%d)- adjusting\n", softc->min_blk,
|
|
|
|
softc->max_blk, softc->media_blksize);
|
|
|
|
softc->max_blk = softc->min_blk =
|
|
|
|
softc->media_blksize;
|
|
|
|
}
|
1998-12-17 18:56:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now put ourselves into the right frame of mind based
|
|
|
|
* upon quirks...
|
|
|
|
*/
|
|
|
|
tryagain:
|
1999-01-12 08:15:47 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
1998-12-17 18:56:23 +00:00
|
|
|
if ((softc->quirks & SA_QUIRK_FIXED) &&
|
2000-05-09 04:54:10 +00:00
|
|
|
(softc->quirks & SA_QUIRK_NO_MODESEL) == 0 &&
|
1999-01-12 08:15:47 +00:00
|
|
|
(softc->media_blksize != softc->last_media_blksize)) {
|
1998-12-17 18:56:23 +00:00
|
|
|
softc->media_blksize = softc->last_media_blksize;
|
|
|
|
if (softc->media_blksize == 0) {
|
1999-01-12 08:15:47 +00:00
|
|
|
softc->media_blksize = 512;
|
1998-12-17 18:56:23 +00:00
|
|
|
if (softc->media_blksize < softc->min_blk) {
|
|
|
|
softc->media_blksize = softc->min_blk;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
error = sasetparams(periph, SA_PARAM_BLOCKSIZE,
|
1999-01-12 08:15:47 +00:00
|
|
|
softc->media_blksize, 0, 0, SF_NO_PRINT);
|
1998-12-17 18:56:23 +00:00
|
|
|
if (error) {
|
2006-12-05 07:45:28 +00:00
|
|
|
xpt_print(periph->path,
|
|
|
|
"unable to set fixed blocksize to %d\n",
|
|
|
|
softc->media_blksize);
|
1998-12-17 18:56:23 +00:00
|
|
|
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,
|
1999-01-12 08:15:47 +00:00
|
|
|
0, 0, 0, SF_NO_PRINT);
|
1998-12-17 18:56:23 +00:00
|
|
|
if (error) {
|
|
|
|
/*
|
|
|
|
* If this fails and we were guessing, just
|
|
|
|
* assume that we got it wrong and go try
|
1999-01-12 08:15:47 +00:00
|
|
|
* fixed block mode. Don't even check against
|
|
|
|
* density code at this point.
|
1998-12-17 18:56:23 +00:00
|
|
|
*/
|
1999-01-12 08:15:47 +00:00
|
|
|
if (guessing) {
|
1998-12-17 18:56:23 +00:00
|
|
|
softc->quirks &= ~SA_QUIRK_VARIABLE;
|
|
|
|
softc->quirks |= SA_QUIRK_FIXED;
|
|
|
|
if (softc->last_media_blksize == 0)
|
|
|
|
softc->last_media_blksize = 512;
|
|
|
|
goto tryagain;
|
|
|
|
}
|
2006-12-05 07:45:28 +00:00
|
|
|
xpt_print(periph->path,
|
|
|
|
"unable to set variable blocksize\n");
|
1998-12-17 18:56:23 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
/*
|
|
|
|
* Now that we have the current block size,
|
|
|
|
* set up some parameters for sastart's usage.
|
|
|
|
*/
|
|
|
|
if (softc->media_blksize) {
|
1998-09-15 06:36:34 +00:00
|
|
|
softc->flags |= SA_FLAG_FIXED;
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
if (powerof2(softc->media_blksize)) {
|
|
|
|
softc->blk_shift =
|
|
|
|
ffs(softc->media_blksize) - 1;
|
|
|
|
softc->blk_mask = softc->media_blksize - 1;
|
1998-09-15 06:36:34 +00:00
|
|
|
} else {
|
|
|
|
softc->blk_mask = ~0;
|
|
|
|
softc->blk_shift = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
* The SCSI-3 spec allows 0 to mean "unspecified".
|
|
|
|
* The SCSI-1 spec allows 0 to mean 'infinite'.
|
|
|
|
*
|
|
|
|
* Either works here.
|
1998-09-15 06:36:34 +00:00
|
|
|
*/
|
|
|
|
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;
|
1999-05-11 04:01:35 +00:00
|
|
|
softc->flags |= SA_FLAG_COMP_SUPP;
|
|
|
|
if (comp_enabled)
|
|
|
|
softc->flags |= SA_FLAG_COMP_ENABLED;
|
1998-09-15 06:36:34 +00:00
|
|
|
} else
|
|
|
|
softc->flags |= SA_FLAG_COMP_UNSUPP;
|
|
|
|
|
2000-05-09 04:54:10 +00:00
|
|
|
if ((softc->buffer_mode == SMH_SA_BUF_MODE_NOBUF) &&
|
|
|
|
(softc->quirks & SA_QUIRK_NO_MODESEL) == 0) {
|
1998-12-17 18:56:23 +00:00
|
|
|
error = sasetparams(periph, SA_PARAM_BUFF_MODE, 0,
|
1999-01-12 08:15:47 +00:00
|
|
|
0, 0, SF_NO_PRINT);
|
2001-09-14 19:00:51 +00:00
|
|
|
if (error == 0) {
|
1998-12-17 18:56:23 +00:00
|
|
|
softc->buffer_mode = SMH_SA_BUF_MODE_SIBUF;
|
2001-09-14 19:00:51 +00:00
|
|
|
} else {
|
2006-12-05 07:45:28 +00:00
|
|
|
xpt_print(periph->path,
|
|
|
|
"unable to set buffered mode\n");
|
2001-09-14 19:00:51 +00:00
|
|
|
}
|
2000-05-09 04:54:10 +00:00
|
|
|
error = 0; /* not an error */
|
1998-12-17 18:56:23 +00:00
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
|
1999-03-01 01:07:47 +00:00
|
|
|
if (error == 0) {
|
1998-12-17 18:56:23 +00:00
|
|
|
softc->flags |= SA_FLAG_TAPE_MOUNTED;
|
1999-03-01 01:07:47 +00:00
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
exit:
|
|
|
|
if (rblim != NULL)
|
2007-05-14 21:48:53 +00:00
|
|
|
free(rblim, M_SCSISA);
|
1998-09-15 06:36:34 +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 (error != 0) {
|
|
|
|
softc->dsreg = MTIO_DSREG_NIL;
|
1999-03-01 01:07:47 +00:00
|
|
|
} else {
|
|
|
|
softc->fileno = softc->blkno = 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;
|
1999-03-01 01:07:47 +00:00
|
|
|
}
|
1999-10-02 20:17:16 +00:00
|
|
|
#ifdef SA_1FM_AT_EOD
|
1999-05-11 04:01:35 +00:00
|
|
|
if ((softc->quirks & SA_QUIRK_2FM) == 0)
|
|
|
|
softc->quirks |= SA_QUIRK_1FM;
|
1999-10-02 20:17:16 +00:00
|
|
|
#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
|
1998-09-15 06:36:34 +00:00
|
|
|
} else
|
|
|
|
xpt_release_ccb(ccb);
|
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
1999-11-17 06:05:09 +00:00
|
|
|
}
|
1999-12-03 23:14:11 +00:00
|
|
|
return (error);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
static int
|
2000-10-31 22:34:51 +00:00
|
|
|
samarkswanted(struct cam_periph *periph)
|
1998-09-15 06:36:34 +00:00
|
|
|
{
|
|
|
|
int markswanted;
|
|
|
|
struct sa_softc *softc;
|
|
|
|
|
|
|
|
softc = (struct sa_softc *)periph->softc;
|
|
|
|
markswanted = 0;
|
|
|
|
if ((softc->flags & SA_FLAG_TAPE_WRITTEN) != 0) {
|
|
|
|
markswanted++;
|
1999-05-11 04:01:35 +00:00
|
|
|
if (softc->quirks & SA_QUIRK_2FM)
|
1998-09-15 06:36:34 +00:00
|
|
|
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);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
2000-10-31 22:34:51 +00:00
|
|
|
if (markswanted > 0) {
|
1998-12-17 18:56:23 +00:00
|
|
|
error = sawritefilemarks(periph, markswanted, FALSE);
|
1998-09-15 06:36:34 +00:00
|
|
|
} else {
|
|
|
|
error = 0;
|
|
|
|
}
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1999-05-11 04:01:35 +00:00
|
|
|
saerror(union ccb *ccb, u_int32_t cflgs, u_int32_t sflgs)
|
1998-09-15 06:36:34 +00:00
|
|
|
{
|
1999-05-11 04:01:35 +00:00
|
|
|
static const char *toobig =
|
2002-06-19 20:44:48 +00:00
|
|
|
"%d-byte tape record bigger than supplied buffer\n";
|
1998-09-15 06:36:34 +00:00
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
error = 0;
|
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;
|
|
|
|
|
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.
|
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) {
|
1998-09-15 06:36:34 +00:00
|
|
|
if ((softc->flags & SA_FLAG_FIXED) != 0)
|
|
|
|
resid *= softc->media_blksize;
|
|
|
|
} else {
|
|
|
|
resid = csio->dxfer_len;
|
|
|
|
info = resid;
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
if ((softc->flags & SA_FLAG_FIXED) != 0) {
|
|
|
|
if (softc->media_blksize)
|
|
|
|
info /= softc->media_blksize;
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
2014-07-31 22:09:50 +00:00
|
|
|
if (csio->cdb_io.cdb_bytes[0] == SA_READ ||
|
|
|
|
csio->cdb_io.cdb_bytes[0] == SA_WRITE) {
|
1998-12-19 23:33:21 +00:00
|
|
|
bcopy((caddr_t) sense, (caddr_t) &softc->last_io_sense,
|
|
|
|
sizeof (struct scsi_sense_data));
|
1998-12-22 17:26:13 +00:00
|
|
|
bcopy(csio->cdb_io.cdb_bytes, softc->last_io_cdb,
|
|
|
|
(int) csio->cdb_len);
|
1998-12-19 23:33:21 +00:00
|
|
|
softc->last_io_resid = resid;
|
2001-01-19 21:08:15 +00:00
|
|
|
softc->last_resid_was_io = 1;
|
1998-12-19 23:33:21 +00:00
|
|
|
} else {
|
|
|
|
bcopy((caddr_t) sense, (caddr_t) &softc->last_ctl_sense,
|
|
|
|
sizeof (struct scsi_sense_data));
|
1998-12-22 17:26:13 +00:00
|
|
|
bcopy(csio->cdb_io.cdb_bytes, softc->last_ctl_cdb,
|
|
|
|
(int) csio->cdb_len);
|
1998-12-19 23:33:21 +00:00
|
|
|
softc->last_ctl_resid = resid;
|
2001-01-19 21:08:15 +00:00
|
|
|
softc->last_resid_was_io = 0;
|
1998-12-19 23:33:21 +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
|
|
|
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));
|
1999-11-17 06:05:09 +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
|
|
|
CAM_DEBUG(periph->path, CAM_DEBUG_INFO,
|
|
|
|
("Cam Status 0x%x\n", status));
|
1998-12-19 23:33:21 +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
|
|
|
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.
|
|
|
|
*/
|
1999-05-11 04:01:35 +00:00
|
|
|
return (cam_periph_error(ccb, cflgs, sflgs, &softc->saved_ccb));
|
1998-09-15 06:36:34 +00:00
|
|
|
|
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.
|
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));
|
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
|
|
|
|
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) {
|
1998-09-15 06:36:34 +00:00
|
|
|
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
|
2004-01-18 00:17:14 +00:00
|
|
|
* 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;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
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;
|
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;
|
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) {
|
1999-05-11 04:01:35 +00:00
|
|
|
error = -1;
|
1998-09-15 06:36:34 +00:00
|
|
|
softc->flags |= SA_FLAG_EOF_PENDING;
|
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;
|
2001-01-15 22:28:11 +00:00
|
|
|
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
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
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
|
|
|
|
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)) {
|
1999-05-11 04:01:35 +00:00
|
|
|
if (info < 0) {
|
2006-12-05 07:45:28 +00:00
|
|
|
xpt_print(csio->ccb_h.path, toobig,
|
|
|
|
csio->dxfer_len - info);
|
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;
|
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) {
|
1999-05-11 04:01:35 +00:00
|
|
|
if (softc->blkno != (daddr_t) -1) {
|
|
|
|
softc->blkno++;
|
2001-01-15 22:28:11 +00:00
|
|
|
csio->ccb_h.ccb_pflags |=
|
|
|
|
SA_POSITION_UPDATED;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
1999-05-11 04:01:35 +00:00
|
|
|
sa_comp_t *tcs)
|
1998-09-15 06:36:34 +00:00
|
|
|
{
|
|
|
|
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;
|
1999-05-11 04:01:35 +00:00
|
|
|
u_int8_t cpage;
|
1998-09-15 06:36:34 +00:00
|
|
|
int error;
|
|
|
|
cam_status status;
|
|
|
|
|
|
|
|
softc = (struct sa_softc *)periph->softc;
|
1999-05-11 04:01:35 +00:00
|
|
|
ccb = cam_periph_getccb(periph, 1);
|
2001-01-15 22:28:11 +00:00
|
|
|
if (softc->quirks & SA_QUIRK_NO_CPAGE)
|
|
|
|
cpage = SA_DEVICE_CONFIGURATION_PAGE;
|
|
|
|
else
|
|
|
|
cpage = SA_DATA_COMPRESSION_PAGE;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
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
|
1999-05-11 04:01:35 +00:00
|
|
|
mode_buffer_len += sizeof (sa_comp_t);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
mode_hdr = (struct scsi_mode_header_6 *)mode_buffer;
|
|
|
|
mode_blk = (struct scsi_mode_blk_desc *)&mode_hdr[1];
|
|
|
|
|
1999-01-16 04:02:31 +00:00
|
|
|
/* 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) ?
|
1999-05-11 04:01:35 +00:00
|
|
|
cpage : SMS_VENDOR_SPECIFIC_PAGE, mode_buffer, mode_buffer_len,
|
2001-07-02 17:48:59 +00:00
|
|
|
SSD_FULL_SIZE, SCSIOP_TIMEOUT);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-12-03 23:14:11 +00:00
|
|
|
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
|
2003-03-08 21:44:46 +00:00
|
|
|
softc->device_stats);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
status = ccb->ccb_h.status & CAM_STATUS_MASK;
|
|
|
|
|
1999-01-16 04:02:31 +00:00
|
|
|
if (error == EINVAL && (params_to_get & SA_PARAM_COMPRESSION) != 0) {
|
1998-09-15 06:36:34 +00:00
|
|
|
/*
|
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.
|
1998-09-15 06:36:34 +00:00
|
|
|
*/
|
1999-05-11 04:01:35 +00:00
|
|
|
if (cpage == SA_DATA_COMPRESSION_PAGE) {
|
|
|
|
cpage = SA_DEVICE_CONFIGURATION_PAGE;
|
|
|
|
goto retry;
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
softc->quirks |= SA_QUIRK_NOCOMP;
|
2007-05-14 21:48:53 +00:00
|
|
|
free(mode_buffer, M_SCSISA);
|
1998-09-15 06:36:34 +00:00
|
|
|
goto retry;
|
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;
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
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))) {
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
/*
|
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.
|
1998-09-15 06:36:34 +00:00
|
|
|
*/
|
1999-05-11 04:01:35 +00:00
|
|
|
mode_buffer_len -= sizeof (sa_comp_t);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
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.
|
|
|
|
*/
|
1999-12-03 23:14:11 +00:00
|
|
|
bcopy(&mode_hdr[0], &mode_hdr[1], sizeof (sa_comp_t));
|
|
|
|
bzero(&mode_hdr[0], sizeof (mode_hdr[0]));
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
/*
|
|
|
|
* Now, we issue another mode sense and just ask
|
|
|
|
* for the block descriptor, etc.
|
|
|
|
*/
|
1998-09-15 06:36:34 +00:00
|
|
|
|
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,
|
2001-07-02 17:48:59 +00:00
|
|
|
mode_buffer, mode_buffer_len, SSD_FULL_SIZE,
|
|
|
|
SCSIOP_TIMEOUT);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-12-03 23:14:11 +00:00
|
|
|
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
|
2003-03-08 21:44:46 +00:00
|
|
|
softc->device_stats);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
if (error != 0)
|
|
|
|
goto sagetparamsexit;
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
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) {
|
1999-12-03 23:14:11 +00:00
|
|
|
sa_comp_t *ntcs = (sa_comp_t *) &mode_blk[1];
|
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
|
2011-02-21 09:01:34 +00:00
|
|
|
* Data Compression if the algorithm field is
|
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;
|
1998-12-17 18:56:23 +00:00
|
|
|
}
|
1999-05-11 04:01:35 +00:00
|
|
|
if (tcs != NULL)
|
1999-12-03 23:14:11 +00:00
|
|
|
bcopy(ntcs, tcs, sizeof (sa_comp_t));
|
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");
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sagetparamsexit:
|
|
|
|
|
|
|
|
xpt_release_ccb(ccb);
|
2007-05-14 21:48:53 +00:00
|
|
|
free(mode_buffer, M_SCSISA);
|
1999-12-03 23:14:11 +00:00
|
|
|
return (error);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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,
|
1999-05-11 04:01:35 +00:00
|
|
|
u_int32_t blocksize, u_int8_t density, u_int32_t calg,
|
1999-01-12 08:15:47 +00:00
|
|
|
u_int32_t sense_flags)
|
1998-09-15 06:36:34 +00:00
|
|
|
{
|
|
|
|
struct sa_softc *softc;
|
|
|
|
u_int32_t current_blocksize;
|
1999-05-11 04:01:35 +00:00
|
|
|
u_int32_t current_calg;
|
1998-09-15 06:36:34 +00:00
|
|
|
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;
|
1999-05-11 04:01:35 +00:00
|
|
|
sa_comp_t *ccomp, *cpage;
|
1998-09-15 06:36:34 +00:00
|
|
|
int buff_mode;
|
1999-05-11 04:01:35 +00:00
|
|
|
union ccb *ccb = NULL;
|
1998-09-15 06:36:34 +00:00
|
|
|
int error;
|
|
|
|
|
|
|
|
softc = (struct sa_softc *)periph->softc;
|
|
|
|
|
2007-06-16 18:20:29 +00:00
|
|
|
ccomp = malloc(sizeof (sa_comp_t), M_SCSISA, M_NOWAIT);
|
|
|
|
if (ccomp == NULL)
|
|
|
|
return (ENOMEM);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
1999-05-11 04:01:35 +00:00
|
|
|
error = sagetparams(periph,
|
|
|
|
params_to_set | SA_PARAM_BLOCKSIZE | SA_PARAM_SPEED,
|
|
|
|
¤t_blocksize, ¤t_density, NULL, &buff_mode, NULL,
|
|
|
|
¤t_speed, &comp_supported, &comp_enabled,
|
|
|
|
¤t_calg, ccomp);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
if (error != 0) {
|
2007-05-14 21:48:53 +00:00
|
|
|
free(ccomp, M_SCSISA);
|
1999-12-03 23:14:11 +00:00
|
|
|
return (error);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mode_buffer_len = sizeof(*mode_hdr) + sizeof(*mode_blk);
|
|
|
|
if (params_to_set & SA_PARAM_COMPRESSION)
|
1999-05-11 04:01:35 +00:00
|
|
|
mode_buffer_len += sizeof (sa_comp_t);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
2007-06-16 18:20:29 +00:00
|
|
|
mode_buffer = malloc(mode_buffer_len, M_SCSISA, M_NOWAIT | M_ZERO);
|
|
|
|
if (mode_buffer == NULL) {
|
|
|
|
free(ccomp, M_SCSISA);
|
|
|
|
return (ENOMEM);
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
mode_hdr = (struct scsi_mode_header_6 *)mode_buffer;
|
|
|
|
mode_blk = (struct scsi_mode_blk_desc *)&mode_hdr[1];
|
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
ccb = cam_periph_getccb(periph, 1);
|
|
|
|
|
|
|
|
retry:
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
if (params_to_set & SA_PARAM_COMPRESSION) {
|
1999-11-17 06:05:09 +00:00
|
|
|
if (mode_blk) {
|
|
|
|
cpage = (sa_comp_t *)&mode_blk[1];
|
|
|
|
} else {
|
|
|
|
cpage = (sa_comp_t *)&mode_hdr[1];
|
|
|
|
}
|
1999-05-11 04:01:35 +00:00
|
|
|
bcopy(ccomp, cpage, sizeof (sa_comp_t));
|
1999-12-03 23:14:11 +00:00
|
|
|
cpage->hdr.pagecode &= ~0x80;
|
1998-09-15 06:36:34 +00:00
|
|
|
} else
|
1999-05-11 04:01:35 +00:00
|
|
|
cpage = NULL;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
1999-11-17 06:05:09 +00:00
|
|
|
if (mode_blk) {
|
|
|
|
if (params_to_set & SA_PARAM_BLOCKSIZE)
|
|
|
|
scsi_ulto3b(blocksize, mode_blk->blklen);
|
|
|
|
else
|
|
|
|
scsi_ulto3b(current_blocksize, mode_blk->blklen);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
2003-09-13 02:01:56 +00:00
|
|
|
/* 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;
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
if (mode_blk)
|
|
|
|
mode_hdr->blk_desc_len = sizeof(struct scsi_mode_blk_desc);
|
|
|
|
else
|
|
|
|
mode_hdr->blk_desc_len = 0;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
1999-05-11 04:01:35 +00:00
|
|
|
if (params_to_set & SA_PARAM_COMPRESSION) {
|
1998-09-15 06:36:34 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
1999-12-03 23:14:11 +00:00
|
|
|
switch (ccomp->hdr.pagecode & ~0x80) {
|
2003-06-02 00:37:42 +00:00
|
|
|
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;
|
|
|
|
}
|
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) {
|
1999-12-03 23:14:11 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
1999-05-11 04:01:35 +00:00
|
|
|
break;
|
|
|
|
}
|
1999-11-17 06:05:09 +00:00
|
|
|
/* enable compression && decompression */
|
1999-12-03 23:14:11 +00:00
|
|
|
dcp->dce_and_dcc = SA_DCP_DCE | SA_DCP_DCC;
|
|
|
|
dcp->dde_and_red |= SA_DCP_DDE;
|
1999-11-17 06:05:09 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
1999-05-11 04:01:35 +00:00
|
|
|
if (calg != MT_COMP_ENABLE) {
|
|
|
|
scsi_ulto4b(calg, dcp->comp_algorithm);
|
1999-11-17 06:05:09 +00:00
|
|
|
scsi_ulto4b(calg, dcp->decomp_algorithm);
|
1999-05-11 04:01:35 +00:00
|
|
|
} else if (scsi_4btoul(dcp->comp_algorithm) == 0 &&
|
|
|
|
softc->saved_comp_algorithm != 0) {
|
1998-09-15 06:36:34 +00:00
|
|
|
scsi_ulto4b(softc->saved_comp_algorithm,
|
1999-05-11 04:01:35 +00:00
|
|
|
dcp->comp_algorithm);
|
1999-11-17 06:05:09 +00:00
|
|
|
scsi_ulto4b(softc->saved_comp_algorithm,
|
|
|
|
dcp->decomp_algorithm);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
1999-05-11 04:01:35 +00:00
|
|
|
break;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
2003-06-02 00:37:42 +00:00
|
|
|
/*
|
|
|
|
* 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 */
|
1999-05-11 04:01:35 +00:00
|
|
|
default:
|
|
|
|
/*
|
1999-12-03 23:14:11 +00:00
|
|
|
* The drive doesn't seem to support compression,
|
1999-05-11 04:01:35 +00:00
|
|
|
* so turn off the set compression bit.
|
|
|
|
*/
|
|
|
|
params_to_set &= ~SA_PARAM_COMPRESSION;
|
2006-12-05 07:45:28 +00:00
|
|
|
xpt_print(periph->path,
|
|
|
|
"device does not seem to support compression\n");
|
1999-12-03 23:14:11 +00:00
|
|
|
|
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);
|
1999-12-03 23:14:11 +00:00
|
|
|
xpt_release_ccb(ccb);
|
|
|
|
return (ENODEV);
|
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);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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,
|
2001-07-02 17:48:59 +00:00
|
|
|
FALSE, mode_buffer, mode_buffer_len, SSD_FULL_SIZE, SCSIOP_TIMEOUT);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
error = cam_periph_runccb(ccb, saerror, 0,
|
2003-03-08 21:44:46 +00:00
|
|
|
sense_flags, softc->device_stats);
|
1998-12-22 17:26:13 +00:00
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
if (CAM_DEBUGGED(periph->path, CAM_DEBUG_INFO)) {
|
1998-12-17 18:56:23 +00:00
|
|
|
int idx;
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
char *xyz = mode_buffer;
|
|
|
|
xpt_print_path(periph->path);
|
1998-12-22 17:26:13 +00:00
|
|
|
printf("Err%d, Mode Select Data=", error);
|
1998-12-17 18:56:23 +00:00
|
|
|
for (idx = 0; idx < mode_buffer_len; idx++)
|
1998-12-22 17:26:13 +00:00
|
|
|
printf(" 0x%02x", xyz[idx] & 0xff);
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
|
|
|
|
/*
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
* 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.
|
1998-09-15 06:36:34 +00:00
|
|
|
*/
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
if (params_to_set & SA_PARAM_DENSITY) {
|
1998-09-15 06:36:34 +00:00
|
|
|
mode_blk->density = current_density;
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
} else if (softc->scsi_rev > SCSI_REV_CCS) {
|
|
|
|
mode_blk->density = SCSI_SAME_DENSITY;
|
|
|
|
} else {
|
|
|
|
mode_blk->density = softc->media_density;
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
if (params_to_set & SA_PARAM_COMPRESSION)
|
1999-05-11 04:01:35 +00:00
|
|
|
bcopy(ccomp, cpage, sizeof (sa_comp_t));
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
1999-12-03 23:14:11 +00:00
|
|
|
cam_periph_runccb(ccb, saerror, 0, sense_flags,
|
2003-03-08 21:44:46 +00:00
|
|
|
softc->device_stats);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
xpt_release_ccb(ccb);
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
if (ccomp != NULL)
|
2007-05-14 21:48:53 +00:00
|
|
|
free(ccomp, M_SCSISA);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1998-12-19 23:33:21 +00:00
|
|
|
if (params_to_set & SA_PARAM_COMPRESSION) {
|
|
|
|
if (error) {
|
|
|
|
softc->flags &= ~SA_FLAG_COMP_ENABLED;
|
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;
|
|
|
|
*/
|
1998-12-19 23:33:21 +00:00
|
|
|
softc->saved_comp_algorithm = softc->comp_algorithm;
|
|
|
|
softc->comp_algorithm = 0;
|
|
|
|
} else {
|
|
|
|
softc->flags |= SA_FLAG_COMP_ENABLED;
|
1999-05-11 04:01:35 +00:00
|
|
|
softc->comp_algorithm = calg;
|
1998-12-19 23:33:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-14 21:48:53 +00:00
|
|
|
free(mode_buffer, M_SCSISA);
|
1999-12-03 23:14:11 +00:00
|
|
|
return (error);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
saprevent(struct cam_periph *periph, int action)
|
|
|
|
{
|
|
|
|
struct sa_softc *softc;
|
|
|
|
union ccb *ccb;
|
1999-01-16 19:20:30 +00:00
|
|
|
int error, sf;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
softc = (struct sa_softc *)periph->softc;
|
|
|
|
|
1999-01-16 19:20:30 +00:00
|
|
|
if ((action == PR_ALLOW) && (softc->flags & SA_FLAG_TAPE_LOCKED) == 0)
|
1998-09-15 06:36:34 +00:00
|
|
|
return;
|
1999-01-16 19:20:30 +00:00
|
|
|
if ((action == PR_PREVENT) && (softc->flags & SA_FLAG_TAPE_LOCKED) != 0)
|
|
|
|
return;
|
|
|
|
|
2000-02-03 18:29:25 +00:00
|
|
|
/*
|
|
|
|
* We can be quiet about illegal requests.
|
|
|
|
*/
|
|
|
|
if (CAM_DEBUGGED(periph->path, CAM_DEBUG_INFO)) {
|
1999-01-16 19:20:30 +00:00
|
|
|
sf = 0;
|
2000-02-03 18:29:25 +00:00
|
|
|
} else
|
1999-01-16 19:20:30 +00:00
|
|
|
sf = SF_QUIET_IR;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-01-16 04:02:31 +00:00
|
|
|
ccb = cam_periph_getccb(periph, 1);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-01-16 04:02:31 +00:00
|
|
|
/* It is safe to retry this operation */
|
|
|
|
scsi_prevent(&ccb->csio, 5, sadone, MSG_SIMPLE_Q_TAG, action,
|
2001-07-02 17:48:59 +00:00
|
|
|
SSD_FULL_SIZE, SCSIOP_TIMEOUT);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
2003-03-08 21:44:46 +00:00
|
|
|
error = cam_periph_runccb(ccb, saerror, 0, sf, softc->device_stats);
|
1998-09-15 06:36:34 +00:00
|
|
|
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;
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
ccb = cam_periph_getccb(periph, 1);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-01-16 04:02:31 +00:00
|
|
|
/* It is safe to retry this operation */
|
1999-05-11 04:01:35 +00:00
|
|
|
scsi_rewind(&ccb->csio, 2, sadone, MSG_SIMPLE_Q_TAG, FALSE,
|
1999-11-17 06:05:09 +00:00
|
|
|
SSD_FULL_SIZE, REWIND_TIMEOUT);
|
1998-09-15 06:36:34 +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
|
|
|
softc->dsreg = MTIO_DSREG_REW;
|
2003-03-08 21:44:46 +00:00
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
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
|
|
|
if (error == 0)
|
|
|
|
softc->fileno = softc->blkno = (daddr_t) 0;
|
|
|
|
else
|
|
|
|
softc->fileno = softc->blkno = (daddr_t) -1;
|
1998-09-15 06:36:34 +00:00
|
|
|
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;
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
ccb = cam_periph_getccb(periph, 1);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-01-16 04:02:31 +00:00
|
|
|
/* This cannot be retried */
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-01-16 04:02:31 +00:00
|
|
|
scsi_space(&ccb->csio, 0, sadone, MSG_SIMPLE_Q_TAG, code, count,
|
1999-11-17 06:05:09 +00:00
|
|
|
SSD_FULL_SIZE, SPACE_TIMEOUT);
|
1999-01-16 04:02:31 +00:00
|
|
|
|
2001-01-16 00:53:45 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
2003-03-08 21:44:46 +00:00
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
1999-01-16 04:02:31 +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.
|
|
|
|
*
|
2001-01-16 00:53:45 +00:00
|
|
|
* 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.
|
1999-01-16 04:02:31 +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 (error) {
|
|
|
|
softc->fileno = softc->blkno = (daddr_t) -1;
|
|
|
|
} 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) {
|
2001-01-16 00:53:45 +00:00
|
|
|
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) {
|
2001-01-16 00:53:45 +00:00
|
|
|
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
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
sawritefilemarks(struct cam_periph *periph, int nmarks, int setmarks)
|
|
|
|
{
|
|
|
|
union ccb *ccb;
|
|
|
|
struct sa_softc *softc;
|
2001-01-16 00:53:45 +00:00
|
|
|
int error, nwm = 0;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
softc = (struct sa_softc *)periph->softc;
|
2006-01-14 14:32:41 +00:00
|
|
|
if (softc->open_rdonly)
|
|
|
|
return (EBADF);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
ccb = cam_periph_getccb(periph, 1);
|
2001-01-16 00:53:45 +00:00
|
|
|
/*
|
|
|
|
* Clear residual because we will be using it.
|
|
|
|
*/
|
|
|
|
softc->last_ctl_resid = 0;
|
1998-09-15 06:36:34 +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
|
|
|
softc->dsreg = MTIO_DSREG_FMK;
|
1999-01-16 04:02:31 +00:00
|
|
|
/* this *must* not be retried */
|
|
|
|
scsi_write_filemarks(&ccb->csio, 0, sadone, MSG_SIMPLE_Q_TAG,
|
2001-07-02 17:48:59 +00:00
|
|
|
FALSE, 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;
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
|
2003-03-08 21:44:46 +00:00
|
|
|
error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1998-12-18 04:31:43 +00:00
|
|
|
if (error == 0 && nmarks) {
|
|
|
|
struct sa_softc *softc = (struct sa_softc *)periph->softc;
|
2001-01-16 00:53:45 +00:00
|
|
|
nwm = nmarks - softc->last_ctl_resid;
|
|
|
|
softc->filemarks += nwm;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
2001-01-16 00:53:45 +00:00
|
|
|
|
1998-12-18 04:31:43 +00:00
|
|
|
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) {
|
|
|
|
softc->fileno = softc->blkno = (daddr_t) -1;
|
|
|
|
} else if (softc->fileno != (daddr_t) -1) {
|
2001-01-16 00:53:45 +00:00
|
|
|
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;
|
|
|
|
}
|
1998-12-18 04:31:43 +00:00
|
|
|
return (error);
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1998-12-18 04:31:43 +00:00
|
|
|
static int
|
|
|
|
sardpos(struct cam_periph *periph, int hard, u_int32_t *blkptr)
|
|
|
|
{
|
|
|
|
struct scsi_tape_position_data loc;
|
|
|
|
union ccb *ccb;
|
1999-05-11 04:01:35 +00:00
|
|
|
struct sa_softc *softc = (struct sa_softc *)periph->softc;
|
1998-12-18 04:31:43 +00:00
|
|
|
int error;
|
|
|
|
|
|
|
|
/*
|
2001-01-15 22:28:11 +00:00
|
|
|
* 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.
|
1999-05-11 04:01:35 +00:00
|
|
|
*
|
2001-01-15 22:28:11 +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.
|
1998-12-18 04:31:43 +00:00
|
|
|
*/
|
|
|
|
|
2001-01-15 22:28:11 +00:00
|
|
|
if (hard && (softc->flags & SA_FLAG_TAPE_WRITTEN)) {
|
1999-05-11 04:01:35 +00:00
|
|
|
error = sawritefilemarks(periph, 0, 0);
|
|
|
|
if (error && error != EACCES)
|
|
|
|
return (error);
|
|
|
|
}
|
1998-12-18 04:31:43 +00:00
|
|
|
|
2000-10-05 17:02:20 +00:00
|
|
|
ccb = cam_periph_getccb(periph, 1);
|
1998-12-18 04:31:43 +00:00
|
|
|
scsi_read_position(&ccb->csio, 1, sadone, MSG_SIMPLE_Q_TAG,
|
2001-07-02 17:48:59 +00:00
|
|
|
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;
|
2003-03-08 21:44:46 +00:00
|
|
|
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;
|
1998-12-18 04:31:43 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
sasetpos(struct cam_periph *periph, int hard, u_int32_t *blkptr)
|
|
|
|
{
|
|
|
|
union ccb *ccb;
|
|
|
|
struct sa_softc *softc;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/*
|
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.
|
|
|
|
*/
|
1998-12-18 04:31:43 +00:00
|
|
|
|
|
|
|
softc = (struct sa_softc *)periph->softc;
|
1999-05-11 04:01:35 +00:00
|
|
|
ccb = cam_periph_getccb(periph, 1);
|
1998-12-18 04:31:43 +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
|
|
|
|
1998-12-18 04:31:43 +00:00
|
|
|
scsi_set_position(&ccb->csio, 1, sadone, MSG_SIMPLE_Q_TAG,
|
2001-07-02 17:48:59 +00:00
|
|
|
hard, *blkptr, SSD_FULL_SIZE, 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;
|
2003-03-08 21:44:46 +00:00
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
xpt_release_ccb(ccb);
|
1998-12-18 04:31:43 +00:00
|
|
|
/*
|
1999-05-11 04:01:35 +00:00
|
|
|
* Note relative file && block number position as now unknown.
|
1998-12-18 04:31:43 +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
|
|
|
softc->fileno = softc->blkno = (daddr_t) -1;
|
1998-09-15 06:36:34 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
saretension(struct cam_periph *periph)
|
|
|
|
{
|
|
|
|
union ccb *ccb;
|
|
|
|
struct sa_softc *softc;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
softc = (struct sa_softc *)periph->softc;
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
ccb = cam_periph_getccb(periph, 1);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-01-16 04:02:31 +00:00
|
|
|
/* It is safe to retry this operation */
|
|
|
|
scsi_load_unload(&ccb->csio, 5, sadone, MSG_SIMPLE_Q_TAG, FALSE,
|
1999-11-17 06:05:09 +00:00
|
|
|
FALSE, TRUE, TRUE, SSD_FULL_SIZE, ERASE_TIMEOUT);
|
1998-09-15 06:36:34 +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
|
|
|
softc->dsreg = MTIO_DSREG_TEN;
|
2003-03-08 21:44:46 +00:00
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
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
|
|
|
if (error == 0)
|
|
|
|
softc->fileno = softc->blkno = (daddr_t) 0;
|
|
|
|
else
|
|
|
|
softc->fileno = softc->blkno = (daddr_t) -1;
|
1999-12-03 23:14:11 +00:00
|
|
|
return (error);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
sareservereleaseunit(struct cam_periph *periph, int reserve)
|
|
|
|
{
|
|
|
|
union ccb *ccb;
|
|
|
|
struct sa_softc *softc;
|
1999-12-03 23:14:11 +00:00
|
|
|
int error;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1998-12-22 17:26:13 +00:00
|
|
|
softc = (struct sa_softc *)periph->softc;
|
1999-01-16 04:02:31 +00:00
|
|
|
ccb = cam_periph_getccb(periph, 1);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-01-16 04:02:31 +00:00
|
|
|
/* It is safe to retry this operation */
|
1999-12-03 23:14:11 +00:00
|
|
|
scsi_reserve_release_unit(&ccb->csio, 2, sadone, MSG_SIMPLE_Q_TAG,
|
2001-07-02 17:48:59 +00:00
|
|
|
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;
|
1999-12-03 23:14:11 +00:00
|
|
|
error = cam_periph_runccb(ccb, saerror, 0,
|
2003-03-08 21:44:46 +00:00
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
xpt_release_ccb(ccb);
|
|
|
|
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
/*
|
|
|
|
* If the error was Illegal Request, then the device doesn't support
|
|
|
|
* RESERVE/RELEASE. This is not an error.
|
|
|
|
*/
|
1998-12-22 17:26:13 +00:00
|
|
|
if (error == EINVAL) {
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
error = 0;
|
1998-12-22 17:26:13 +00:00
|
|
|
}
|
Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.
At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).
When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).
Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).
Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.
Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).
1998-12-11 07:19:36 +00:00
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
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;
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
ccb = cam_periph_getccb(periph, 1);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-01-16 04:02:31 +00:00
|
|
|
/* It is safe to retry this operation */
|
|
|
|
scsi_load_unload(&ccb->csio, 5, sadone, MSG_SIMPLE_Q_TAG, FALSE,
|
1999-12-03 23:14:11 +00:00
|
|
|
FALSE, FALSE, load, SSD_FULL_SIZE, REWIND_TIMEOUT);
|
1998-09-15 06:36:34 +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
|
|
|
softc->dsreg = (load)? MTIO_DSREG_LD : MTIO_DSREG_UNL;
|
2003-03-08 21:44:46 +00:00
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
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
|
|
|
|
|
|
|
if (error || load == 0)
|
|
|
|
softc->fileno = softc->blkno = (daddr_t) -1;
|
|
|
|
else if (error == 0)
|
|
|
|
softc->fileno = softc->blkno = (daddr_t) 0;
|
1998-09-15 06:36:34 +00:00
|
|
|
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;
|
2006-01-14 14:32:41 +00:00
|
|
|
if (softc->open_rdonly)
|
|
|
|
return (EBADF);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
ccb = cam_periph_getccb(periph, 1);
|
1998-09-15 06:36:34 +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
|
|
|
scsi_erase(&ccb->csio, 1, sadone, MSG_SIMPLE_Q_TAG, FALSE, longerase,
|
1999-11-17 06:05:09 +00:00
|
|
|
SSD_FULL_SIZE, ERASE_TIMEOUT);
|
1998-09-15 06:36:34 +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
|
|
|
softc->dsreg = MTIO_DSREG_ZER;
|
2003-03-08 21:44:46 +00:00
|
|
|
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;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
xpt_release_ccb(ccb);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#endif /* _KERNEL */
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
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);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
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;
|
2013-08-16 16:14:32 +00:00
|
|
|
int read;
|
|
|
|
|
|
|
|
read = (readop & SCSI_RW_DIRMASK) == SCSI_RW_READ;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
scsi_cmd = (struct scsi_sa_rw *)&csio->cdb_io.cdb_bytes;
|
2013-08-16 16:14:32 +00:00
|
|
|
scsi_cmd->opcode = read ? SA_READ : SA_WRITE;
|
1998-09-15 06:36:34 +00:00
|
|
|
scsi_cmd->sli_fixed = 0;
|
2013-08-16 16:14:32 +00:00
|
|
|
if (sli && read)
|
1998-09-15 06:36:34 +00:00
|
|
|
scsi_cmd->sli_fixed |= SAR_SLI;
|
|
|
|
if (fixed)
|
|
|
|
scsi_cmd->sli_fixed |= SARW_FIXED;
|
|
|
|
scsi_ulto3b(length, scsi_cmd->length);
|
|
|
|
scsi_cmd->control = 0;
|
|
|
|
|
2013-08-16 16:14:32 +00:00
|
|
|
cam_fill_csio(csio, retries, cbfcnp, (read ? CAM_DIR_IN : CAM_DIR_OUT) |
|
|
|
|
((readop & SCSI_RW_BIO) != 0 ? CAM_DATA_BIO : 0),
|
1999-05-11 04:01:35 +00:00
|
|
|
tag_action, data_ptr, dxfer_len, sense_len,
|
|
|
|
sizeof(*scsi_cmd), timeout);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
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);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
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);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
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);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
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);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
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);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
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);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
1998-12-18 04:31:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
}
|