1998-09-15 06:36:34 +00:00
|
|
|
/*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1999-05-11 04:01:35 +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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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>
|
2000-05-05 09:59:14 +00:00
|
|
|
#include <sys/bio.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>
|
2000-08-24 19:23:09 +00:00
|
|
|
#endif
|
1998-09-15 06:36:34 +00:00
|
|
|
#include <sys/devicestat.h>
|
|
|
|
#include <machine/limits.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_extend.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>
|
|
|
|
|
|
|
|
#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
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
#define SA_CCB_BUFFER_IO 0x0
|
|
|
|
#define SA_CCB_WAITING 0x1
|
|
|
|
#define SA_CCB_TYPEMASK 0x1
|
|
|
|
#define SA_POSITION_UPDATED 0x2
|
|
|
|
|
|
|
|
#define Set_CCB_Type(x, type) \
|
|
|
|
x->ccb_h.ccb_pflags &= ~SA_CCB_TYPEMASK; \
|
|
|
|
x->ccb_h.ccb_pflags |= type
|
|
|
|
|
|
|
|
#define CCB_Type(x) (x->ccb_h.ccb_pflags & SA_CCB_TYPEMASK)
|
|
|
|
|
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;
|
|
|
|
|
1999-11-17 17:11:21 +00:00
|
|
|
/* units are bits 4-7, 16-21 (1024 units) */
|
|
|
|
#define SAUNIT(DEV) \
|
|
|
|
(((minor(DEV) & 0xF0) >> 4) | ((minor(DEV) & 0x3f0000) >> 16))
|
|
|
|
|
|
|
|
#define SAMODE(z) ((minor(z) & 0x3))
|
|
|
|
#define SADENSITY(z) (((minor(z) >> 2) & 0x3))
|
|
|
|
#define SA_IS_CTRL(z) (minor(z) & (1 << 29))
|
|
|
|
|
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
|
|
|
|
|
|
|
|
#define SAMINOR(ctl, unit, mode, access) \
|
1999-11-17 17:11:21 +00:00
|
|
|
((ctl << 29) | ((unit & 0x3f0) << 16) | ((unit & 0xf) << 4) | \
|
|
|
|
(mode << 0x2) | (access & 0x3))
|
1999-11-17 06:05:09 +00:00
|
|
|
|
|
|
|
#define SA_NUM_MODES 4
|
|
|
|
struct sa_devs {
|
|
|
|
dev_t ctl_dev;
|
|
|
|
struct sa_mode_devs {
|
|
|
|
dev_t r_dev;
|
|
|
|
dev_t nr_dev;
|
|
|
|
dev_t er_dev;
|
|
|
|
} 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;
|
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;
|
1998-09-15 06:36:34 +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;
|
|
|
|
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;
|
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;
|
|
|
|
u_int32_t _last_io_resid;
|
|
|
|
u_int8_t _last_io_cdb[CAM_MAX_CDBLEN];
|
|
|
|
struct scsi_sense_data _last_ctl_sense;
|
|
|
|
u_int32_t _last_ctl_resid;
|
|
|
|
u_int8_t _last_ctl_cdb[CAM_MAX_CDBLEN];
|
|
|
|
#define last_io_sense errinfo._last_io_sense
|
|
|
|
#define last_io_resid errinfo._last_io_resid
|
|
|
|
#define last_io_cdb errinfo._last_io_cdb
|
|
|
|
#define last_ctl_sense errinfo._last_ctl_sense
|
|
|
|
#define last_ctl_resid errinfo._last_ctl_resid
|
|
|
|
#define last_ctl_cdb errinfo._last_ctl_cdb
|
|
|
|
} errinfo;
|
Extend unit numbers to a full 10 bits (split into sections
of the minor). Establish and use a control mode open. Control
mode opens may open the device without locking, but are prohibited
from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT
works, but the clearing of latched error status is contingent
upon whether another application has the device open, in which
case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY
and MTCOMP also require a periph aquire.
Relative fileno and blkno are tracked. Note that just about any
error will make these undefined, and if you space to EOD or use
hardware block positioning, these are also lost until the next
UNLOAD or REWIND.
Driver state is also tracked and recorded in the unit softc
to be passed back in mt_dsreg for a MTIOCGET call.
Thanks to Dan Strick for suggesting this.
Reintroduce 2 filemarks at EOD for all but QIC devices. I
really think it's wrong, but there is a lot of 3rd party
software that depends upon this (not the least of which is
tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices
can be marked as only being able to do 1 FM at EOD.
At samount time force a load to BOT if we aren't mounted. If the
LOAD command fails, use the REWIND command (e.g., for the IBM 3590
which for some gawdawful reason doesn't support the LOAD (to BOT)
command).
Also at samount time, if you don't know fixed or variable, try to
*set* to one of the known fixed (or variable, for special case)
density codes. We only have to do this once per boot, so it's not
that painful. This is another way to try and figure out the wierd
QIC devices without having to quirk everything in the universe.
A substantial amount of cleanup as to what operations can and what
operations cannot be retried. Don't retry space operations if they
fail- it'll just lead to lossage.
Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
|
|
|
/*
|
|
|
|
* Misc other flags/state
|
|
|
|
*/
|
|
|
|
u_int32_t
|
|
|
|
: 31,
|
|
|
|
ctrl_mode : 1; /* control device open */
|
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
|
|
|
|
},
|
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
|
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
|
|
|
|
},
|
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);
|
1998-12-17 18:56:23 +00:00
|
|
|
static int samount(struct cam_periph *, int, dev_t);
|
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
|
|
|
|
|
|
|
static struct periph_driver sadriver =
|
|
|
|
{
|
|
|
|
sainit, "sa",
|
|
|
|
TAILQ_HEAD_INITIALIZER(sadriver.units), /* generation */ 0
|
|
|
|
};
|
|
|
|
|
|
|
|
DATA_SET(periphdriver_set, sadriver);
|
|
|
|
|
|
|
|
/* For 2.2-stable support */
|
|
|
|
#ifndef D_TAPE
|
|
|
|
#define D_TAPE 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SA_CDEV_MAJOR 14
|
|
|
|
|
1999-05-30 16:53:49 +00:00
|
|
|
static struct cdevsw sa_cdevsw = {
|
|
|
|
/* open */ saopen,
|
|
|
|
/* close */ saclose,
|
|
|
|
/* read */ physread,
|
|
|
|
/* write */ physwrite,
|
|
|
|
/* ioctl */ saioctl,
|
|
|
|
/* poll */ nopoll,
|
|
|
|
/* mmap */ nommap,
|
|
|
|
/* strategy */ sastrategy,
|
|
|
|
/* name */ "sa",
|
|
|
|
/* maj */ SA_CDEV_MAJOR,
|
|
|
|
/* dump */ nodump,
|
|
|
|
/* psize */ nopsize,
|
|
|
|
/* flags */ D_TAPE,
|
1999-09-08 17:01:41 +00:00
|
|
|
/* bmaj */ -1
|
1998-09-15 06:36:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct extend_array *saperiphs;
|
|
|
|
|
|
|
|
static int
|
|
|
|
saopen(dev_t dev, int flags, int fmt, struct proc *p)
|
|
|
|
{
|
|
|
|
struct cam_periph *periph;
|
|
|
|
struct sa_softc *softc;
|
|
|
|
int unit;
|
|
|
|
int mode;
|
|
|
|
int density;
|
|
|
|
int error;
|
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
|
|
|
int s;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
unit = SAUNIT(dev);
|
|
|
|
mode = SAMODE(dev);
|
|
|
|
density = SADENSITY(dev);
|
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
s = splsoftcam();
|
1998-09-15 06:36:34 +00:00
|
|
|
periph = cam_extend_get(saperiphs, unit);
|
1999-11-17 06:05:09 +00:00
|
|
|
if (periph == NULL) {
|
|
|
|
(void) splx(s);
|
1998-09-15 06:36:34 +00:00
|
|
|
return (ENXIO);
|
1999-11-17 06:05:09 +00:00
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
softc = (struct sa_softc *)periph->softc;
|
1999-11-17 06:05:09 +00:00
|
|
|
if ((error = cam_periph_lock(periph, PRIBIO|PCATCH)) != 0) {
|
|
|
|
splx(s);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
splx(s);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO,
|
|
|
|
("saopen(%d): dev=0x%x softc=0x%x\n", unit, unit, softc->flags));
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
if (cam_periph_acquire(periph) != CAM_REQ_CMP) {
|
|
|
|
cam_periph_unlock(periph);
|
1999-12-03 23:14:11 +00:00
|
|
|
return (ENXIO);
|
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
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
|
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 {
|
|
|
|
/*
|
|
|
|
* The function samount ensures media is loaded and ready.
|
|
|
|
* It also does a device RESERVE if the tape isn't yet mounted.
|
|
|
|
*/
|
|
|
|
error = samount(periph, flags, dev);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
if (error) {
|
|
|
|
cam_periph_release(periph);
|
|
|
|
} else {
|
1998-09-15 06:36:34 +00:00
|
|
|
saprevent(periph, PR_PREVENT);
|
|
|
|
softc->flags |= SA_FLAG_OPEN;
|
|
|
|
}
|
|
|
|
cam_periph_unlock(periph);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
saclose(dev_t dev, int flag, int fmt, struct proc *p)
|
|
|
|
{
|
|
|
|
struct cam_periph *periph;
|
|
|
|
struct sa_softc *softc;
|
1999-05-11 04:01:35 +00:00
|
|
|
int unit, 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
|
|
|
|
|
|
|
unit = SAUNIT(dev);
|
|
|
|
mode = SAMODE(dev);
|
|
|
|
periph = cam_extend_get(saperiphs, unit);
|
|
|
|
if (periph == NULL)
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
softc = (struct sa_softc *)periph->softc;
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO,
|
|
|
|
("saclose(%d): dev=0x%x softc=0x%x\n", unit, unit, softc->flags));
|
|
|
|
|
|
|
|
|
1999-11-17 06:05:09 +00:00
|
|
|
if ((error = cam_periph_lock(periph, PRIBIO)) != 0) {
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
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_release(periph);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
xpt_print_path(periph->path);
|
1999-05-11 04:01:35 +00:00
|
|
|
printf("failed to write terminating filemark(s)\n");
|
|
|
|
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) {
|
1998-12-17 18:56:23 +00:00
|
|
|
xpt_print_path(periph->path);
|
|
|
|
printf("unable to backspace over one of double"
|
1999-05-11 04:01:35 +00:00
|
|
|
" filemarks at end of tape\n");
|
|
|
|
xpt_print_path(periph->path);
|
1999-09-28 05:14:52 +00:00
|
|
|
printf("it is possible that this device"
|
1999-05-11 04:01:35 +00:00
|
|
|
" needs a SA_QUIRK_1FM quirk set for it\n");
|
|
|
|
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:
|
|
|
|
xpt_print_path(periph->path);
|
|
|
|
panic("unknown mode 0x%x in saclose\n", mode);
|
|
|
|
/* 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) {
|
|
|
|
xpt_print_path(periph->path);
|
|
|
|
printf("tape is now frozen- use an OFFLINE, REWIND or MTEOM "
|
|
|
|
"command to clear this state.\n");
|
|
|
|
}
|
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
|
|
|
|
|
|
|
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;
|
|
|
|
u_int unit;
|
|
|
|
int s;
|
|
|
|
|
2000-04-15 05:54:02 +00:00
|
|
|
if (SA_IS_CTRL(bp->bio_dev)) {
|
|
|
|
bp->bio_error = EINVAL;
|
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
|
|
|
goto bad;
|
|
|
|
}
|
2000-04-15 05:54:02 +00:00
|
|
|
unit = SAUNIT(bp->bio_dev);
|
1998-09-15 06:36:34 +00:00
|
|
|
periph = cam_extend_get(saperiphs, unit);
|
|
|
|
if (periph == NULL) {
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_error = ENXIO;
|
1998-09-15 06:36:34 +00:00
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
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
|
|
|
s = splsoftcam();
|
|
|
|
|
|
|
|
if (softc->flags & SA_FLAG_INVALID) {
|
|
|
|
splx(s);
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_error = ENXIO;
|
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
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
if (softc->flags & SA_FLAG_TAPE_FROZEN) {
|
|
|
|
splx(s);
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_error = EPERM;
|
1999-05-11 04:01:35 +00:00
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
splx(s);
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
/*
|
|
|
|
* If it's a null transfer, return immediatly
|
|
|
|
*/
|
2000-04-15 05:54:02 +00:00
|
|
|
if (bp->bio_bcount == 0)
|
1998-09-15 06:36:34 +00:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* 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))) {
|
1998-09-15 06:36:34 +00:00
|
|
|
xpt_print_path(periph->path);
|
|
|
|
printf("Invalid request. Fixed block device "
|
|
|
|
"requests must be a multiple "
|
|
|
|
"of %d bytes\n", softc->min_blk);
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_error = EINVAL;
|
1998-09-15 06:36:34 +00:00
|
|
|
goto bad;
|
|
|
|
}
|
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);
|
|
|
|
printf("Invalid request. Variable block device "
|
1999-01-16 04:02:31 +00:00
|
|
|
"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);
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_error = EINVAL;
|
1998-09-15 06:36:34 +00:00
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-01-16 04:02:31 +00:00
|
|
|
* Mask interrupts so that the device cannot be invalidated until
|
1998-09-15 06:36:34 +00:00
|
|
|
* after we are in the queue. Otherwise, we might not properly
|
|
|
|
* clean up one of the buffers.
|
|
|
|
*/
|
|
|
|
s = splbio();
|
|
|
|
|
|
|
|
/*
|
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);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
softc->queue_count++;
|
|
|
|
CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("sastrategy: enqueuing a %d "
|
2000-04-15 05:54:02 +00:00
|
|
|
"%s byte %s queue count now %d\n", (int) bp->bio_bcount,
|
1999-05-11 04:01:35 +00:00
|
|
|
(softc->flags & SA_FLAG_FIXED)? "fixed" : "variable",
|
2000-04-15 05:54:02 +00:00
|
|
|
(bp->bio_cmd == BIO_READ)? "read" : "write", softc->queue_count));
|
1999-05-11 04:01:35 +00:00
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
splx(s);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Schedule ourselves for performing the work.
|
|
|
|
*/
|
1999-01-16 04:02:31 +00:00
|
|
|
xpt_schedule(periph, 1);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
bad:
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_flags |= BIO_ERROR;
|
1998-09-15 06:36:34 +00:00
|
|
|
done:
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Correctly set the buf to indicate a completed xfer
|
|
|
|
*/
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_resid = bp->bio_bcount;
|
1998-09-15 06:36:34 +00:00
|
|
|
biodone(bp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
saioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
int s;
|
1998-09-15 06:36:34 +00:00
|
|
|
int unit;
|
|
|
|
int mode;
|
|
|
|
int density;
|
1999-11-17 06:05:09 +00:00
|
|
|
int error = 0;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
unit = SAUNIT(dev);
|
|
|
|
mode = SAMODE(dev);
|
|
|
|
density = SADENSITY(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
|
|
|
|
|
|
|
periph = cam_extend_get(saperiphs, unit);
|
|
|
|
if (periph == NULL)
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
s = splsoftcam();
|
|
|
|
if ((periph->flags & CAM_PERIPH_LOCKED) == 0) {
|
|
|
|
error = cam_periph_lock(periph, PRIBIO|PCATCH);
|
|
|
|
if (error != 0) {
|
|
|
|
splx(s);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
didlockperiph = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
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
|
|
|
case MTSETBSIZ:
|
|
|
|
case MTSETDNSTY:
|
|
|
|
case MTCOMP:
|
|
|
|
/*
|
|
|
|
* We need to acquire the peripheral here rather
|
|
|
|
* than at open time because we are sharing writable
|
|
|
|
* access to data structures.
|
|
|
|
*/
|
|
|
|
s = splsoftcam();
|
|
|
|
error = cam_periph_lock(periph, PRIBIO|PCATCH);
|
|
|
|
if (error != 0) {
|
|
|
|
splx(s);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
didlockperiph = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
if (!SA_IS_CTRL(dev)) {
|
|
|
|
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;
|
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
|
|
|
|
|
|
|
if (SA_IS_CTRL(dev) == 0 || didlockperiph)
|
|
|
|
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;
|
|
|
|
|
|
|
|
mt = (struct mtop *)arg;
|
|
|
|
|
|
|
|
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE,
|
|
|
|
("saioctl: op=0x%x count=0x%x\n",
|
|
|
|
mt->mt_op, mt->mt_count));
|
|
|
|
|
|
|
|
count = mt->mt_count;
|
|
|
|
switch (mt->mt_op) {
|
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) {
|
|
|
|
xpt_print_path(periph->path);
|
|
|
|
printf("EOD check prior to spacing failed\n");
|
|
|
|
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 */
|
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);
|
1998-12-17 18:56:23 +00:00
|
|
|
softc->filemarks = 0;
|
1998-09-15 06:36:34 +00:00
|
|
|
break;
|
|
|
|
case MTERASE: /* erase */
|
|
|
|
error = saerase(periph, count);
|
1999-05-11 04:01:35 +00:00
|
|
|
softc->flags &=
|
|
|
|
~(SA_FLAG_TAPE_WRITTEN|SA_FLAG_TAPE_FROZEN);
|
1998-09-15 06:36:34 +00:00
|
|
|
break;
|
|
|
|
case MTRETENS: /* re-tension tape */
|
|
|
|
error = saretension(periph);
|
1999-05-11 04:01:35 +00:00
|
|
|
softc->flags &=
|
|
|
|
~(SA_FLAG_TAPE_WRITTEN|SA_FLAG_TAPE_FROZEN);
|
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
|
|
|
|
|
|
|
(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 */
|
|
|
|
|
|
|
|
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 */
|
|
|
|
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 */
|
|
|
|
/*
|
|
|
|
* 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:
|
|
|
|
error = sardpos(periph, 0, (u_int32_t *) arg);
|
|
|
|
break;
|
|
|
|
case MTIOCRDHPOS:
|
|
|
|
error = sardpos(periph, 1, (u_int32_t *) arg);
|
|
|
|
break;
|
|
|
|
case MTIOCSLOCATE:
|
|
|
|
error = sasetpos(periph, 0, (u_int32_t *) arg);
|
|
|
|
break;
|
|
|
|
case MTIOCHLOCATE:
|
|
|
|
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;
|
|
|
|
}
|
Extend unit numbers to a full 10 bits (split into sections
of the minor). Establish and use a control mode open. Control
mode opens may open the device without locking, but are prohibited
from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT
works, but the clearing of latched error status is contingent
upon whether another application has the device open, in which
case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY
and MTCOMP also require a periph aquire.
Relative fileno and blkno are tracked. Note that just about any
error will make these undefined, and if you space to EOD or use
hardware block positioning, these are also lost until the next
UNLOAD or REWIND.
Driver state is also tracked and recorded in the unit softc
to be passed back in mt_dsreg for a MTIOCGET call.
Thanks to Dan Strick for suggesting this.
Reintroduce 2 filemarks at EOD for all but QIC devices. I
really think it's wrong, but there is a lot of 3rd party
software that depends upon this (not the least of which is
tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices
can be marked as only being able to do 1 FM at EOD.
At samount time force a load to BOT if we aren't mounted. If the
LOAD command fails, use the REWIND command (e.g., for the IBM 3590
which for some gawdawful reason doesn't support the LOAD (to BOT)
command).
Also at samount time, if you don't know fixed or variable, try to
*set* to one of the known fixed (or variable, for special case)
density codes. We only have to do this once per boot, so it's not
that painful. This is another way to try and figure out the wierd
QIC devices without having to quirk everything in the universe.
A substantial amount of cleanup as to what operations can and what
operations cannot be retried. Don't retry space operations if they
fail- it'll just lead to lossage.
Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
|
|
|
if (didlockperiph) {
|
|
|
|
cam_periph_unlock(periph);
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sainit(void)
|
|
|
|
{
|
|
|
|
cam_status status;
|
|
|
|
struct cam_path *path;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create our extend array for storing the devices we attach to.
|
|
|
|
*/
|
|
|
|
saperiphs = cam_extend_new();
|
|
|
|
if (saperiphs == NULL) {
|
|
|
|
printf("sa: Failed to alloc extend array!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Install a global async callback.
|
|
|
|
*/
|
|
|
|
status = xpt_create_path(&path, NULL, CAM_XPT_PATH_ID,
|
|
|
|
CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD);
|
|
|
|
|
|
|
|
if (status == CAM_REQ_CMP) {
|
|
|
|
/* Register the async callbacks of interrest */
|
|
|
|
struct ccb_setasync csa; /*
|
|
|
|
* This is an immediate CCB,
|
|
|
|
* so using the stack is OK
|
|
|
|
*/
|
1999-05-11 04:01:35 +00:00
|
|
|
xpt_setup_ccb(&csa.ccb_h, path, 5);
|
1998-09-15 06:36:34 +00:00
|
|
|
csa.ccb_h.func_code = XPT_SASYNC_CB;
|
|
|
|
csa.event_enable = AC_FOUND_DEVICE;
|
|
|
|
csa.callback = saasync;
|
|
|
|
csa.callback_arg = NULL;
|
|
|
|
xpt_action((union ccb *)&csa);
|
|
|
|
status = csa.ccb_h.status;
|
|
|
|
xpt_free_path(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2000-04-15 05:54:02 +00:00
|
|
|
struct bio *q_bp;
|
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 ccb_setasync csa;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
softc = (struct sa_softc *)periph->softc;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* De-register any async callbacks.
|
|
|
|
*/
|
|
|
|
xpt_setup_ccb(&csa.ccb_h, periph->path,
|
|
|
|
/* priority */ 5);
|
|
|
|
csa.ccb_h.func_code = XPT_SASYNC_CB;
|
|
|
|
csa.event_enable = 0;
|
|
|
|
csa.callback = saasync;
|
|
|
|
csa.callback_arg = periph;
|
|
|
|
xpt_action((union ccb *)&csa);
|
|
|
|
|
|
|
|
softc->flags |= SA_FLAG_INVALID;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Although the oninvalidate() routines are always called at
|
|
|
|
* splsoftcam, we need to be at splbio() here to keep the buffer
|
|
|
|
* queue from being modified while we traverse it.
|
|
|
|
*/
|
|
|
|
s = splbio();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return all queued I/O with ENXIO.
|
|
|
|
* XXX Handle any transactions queued to the card
|
|
|
|
* with XPT_ABORT_CCB.
|
|
|
|
*/
|
2000-04-15 05:54:02 +00:00
|
|
|
while ((q_bp = bioq_first(&softc->bio_queue)) != NULL){
|
|
|
|
bioq_remove(&softc->bio_queue, q_bp);
|
|
|
|
q_bp->bio_resid = q_bp->bio_bcount;
|
|
|
|
q_bp->bio_error = ENXIO;
|
|
|
|
q_bp->bio_flags |= BIO_ERROR;
|
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
|
|
|
biodone(q_bp);
|
|
|
|
}
|
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
|
|
|
splx(s);
|
|
|
|
|
|
|
|
xpt_print_path(periph->path);
|
|
|
|
printf("lost device\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
devstat_remove_entry(&softc->device_stats);
|
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);
|
|
|
|
}
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
cam_extend_release(saperiphs, periph->unit_number);
|
|
|
|
xpt_print_path(periph->path);
|
|
|
|
printf("removing device entry\n");
|
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
|
|
|
free(softc, M_DEVBUF);
|
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;
|
|
|
|
|
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,
|
1998-09-15 06:36:34 +00:00
|
|
|
"sa", CAM_PERIPH_BIO, cgd->ccb_h.path,
|
|
|
|
saasync, AC_FOUND_DEVICE, cgd);
|
|
|
|
|
|
|
|
if (status != CAM_REQ_CMP
|
|
|
|
&& status != CAM_REQ_INPROG)
|
|
|
|
printf("saasync: Unable to probe new device "
|
|
|
|
"due to status 0x%x\n", status);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
1999-05-22 22:00:24 +00:00
|
|
|
cam_periph_async(periph, code, path, arg);
|
1998-09-15 06:36:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static cam_status
|
|
|
|
saregister(struct cam_periph *periph, void *arg)
|
|
|
|
{
|
|
|
|
struct sa_softc *softc;
|
|
|
|
struct ccb_setasync csa;
|
|
|
|
struct ccb_getdev *cgd;
|
|
|
|
caddr_t match;
|
1999-11-17 06:05:09 +00:00
|
|
|
int i;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
cgd = (struct ccb_getdev *)arg;
|
|
|
|
if (periph == NULL) {
|
|
|
|
printf("saregister: periph was NULL!!\n");
|
1999-12-03 23:14:11 +00:00
|
|
|
return (CAM_REQ_CMP_ERR);
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 *)
|
|
|
|
malloc(sizeof (*softc), M_DEVBUF, 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;
|
|
|
|
cam_extend_set(saperiphs, periph->unit_number, periph);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
#ifdef CAMDEBUG
|
|
|
|
xpt_print_path(periph->path);
|
1999-02-05 08:49:34 +00:00
|
|
|
printf("found quirk entry %d\n", (int)
|
|
|
|
(((struct sa_quirk_entry *) match) - sa_quirk_table));
|
1999-01-12 08:15:47 +00:00
|
|
|
#endif
|
|
|
|
} else
|
1998-09-15 06:36:34 +00:00
|
|
|
softc->quirks = SA_QUIRK_NONE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
1999-11-17 06:05:09 +00:00
|
|
|
devstat_add_entry(&softc->device_stats, "sa", periph->unit_number, 0,
|
2000-01-17 06:27:37 +00:00
|
|
|
DEVSTAT_BS_UNAVAILABLE, SID_TYPE(&cgd->inq_data) |
|
|
|
|
DEVSTAT_TYPE_IF_SCSI, DEVSTAT_PRIORITY_TAPE);
|
1999-11-17 06:05:09 +00:00
|
|
|
|
|
|
|
softc->devs.ctl_dev = make_dev(&sa_cdevsw, SAMINOR(SA_CTLDEV,
|
|
|
|
periph->unit_number, 0, SA_ATYPE_R), UID_ROOT, GID_OPERATOR,
|
|
|
|
0660, "r%s%d.ctl", periph->periph_name, periph->unit_number);
|
|
|
|
|
|
|
|
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,
|
|
|
|
SAMINOR(SA_NOT_CTLDEV, periph->unit_number, i, SA_ATYPE_R),
|
|
|
|
UID_ROOT, GID_OPERATOR, 0660, "r%s%d.%d",
|
|
|
|
periph->periph_name, periph->unit_number, i);
|
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,
|
|
|
|
SAMINOR(SA_NOT_CTLDEV, periph->unit_number, i, SA_ATYPE_NR),
|
|
|
|
UID_ROOT, GID_OPERATOR, 0660, "nr%s%d.%d",
|
|
|
|
periph->periph_name, periph->unit_number, i);
|
|
|
|
|
1999-11-17 17:11:21 +00:00
|
|
|
|
|
|
|
softc->devs.mode_devs[i].er_dev = make_dev(&sa_cdevsw,
|
1999-11-17 06:05:09 +00:00
|
|
|
SAMINOR(SA_NOT_CTLDEV, periph->unit_number, i, SA_ATYPE_ER),
|
|
|
|
UID_ROOT, GID_OPERATOR, 0660, "er%s%d.%d",
|
|
|
|
periph->periph_name, periph->unit_number, i);
|
2000-09-14 14:53:57 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make the (well known) aliases for the first mode.
|
|
|
|
*/
|
|
|
|
if (i == 0) {
|
|
|
|
make_dev_alias(softc->devs.mode_devs[i].r_dev,
|
|
|
|
"r%s%d", periph->periph_name, periph->unit_number);
|
|
|
|
make_dev_alias(softc->devs.mode_devs[i].nr_dev,
|
|
|
|
"nr%s%d", periph->periph_name, periph->unit_number);
|
|
|
|
make_dev_alias(softc->devs.mode_devs[i].er_dev,
|
|
|
|
"er%s%d", periph->periph_name, periph->unit_number);
|
|
|
|
}
|
1999-11-17 06:05:09 +00:00
|
|
|
}
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
/*
|
|
|
|
* Add an async callback so that we get
|
|
|
|
* notified if this device goes away.
|
|
|
|
*/
|
|
|
|
xpt_setup_ccb(&csa.ccb_h, periph->path, /* priority */ 5);
|
|
|
|
csa.ccb_h.func_code = XPT_SASYNC_CB;
|
|
|
|
csa.event_enable = AC_LOST_DEVICE;
|
|
|
|
csa.callback = saasync;
|
|
|
|
csa.callback_arg = periph;
|
|
|
|
xpt_action((union ccb *)&csa);
|
|
|
|
|
|
|
|
xpt_announce_periph(periph, NULL);
|
|
|
|
|
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;
|
|
|
|
|
1998-12-19 23:33:21 +00:00
|
|
|
CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("sastart"));
|
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
|
|
|
int s;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See if there is a buf with work for us to do..
|
|
|
|
*/
|
|
|
|
s = splbio();
|
2000-04-15 05:54:02 +00:00
|
|
|
bp = bioq_first(&softc->bio_queue);
|
1998-09-15 06:36:34 +00:00
|
|
|
if (periph->immediate_priority <= periph->pinfo.priority) {
|
|
|
|
CAM_DEBUG_PRINT(CAM_DEBUG_SUBTRACE,
|
|
|
|
("queuing for immediate ccb\n"));
|
2001-01-15 22:28:11 +00:00
|
|
|
Set_CCB_Type(start_ccb, SA_CCB_WAITING);
|
1998-09-15 06:36:34 +00:00
|
|
|
SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h,
|
|
|
|
periph_links.sle);
|
|
|
|
periph->immediate_priority = CAM_PRIORITY_NONE;
|
|
|
|
splx(s);
|
|
|
|
wakeup(&periph->ccb_list);
|
|
|
|
} else if (bp == NULL) {
|
|
|
|
splx(s);
|
|
|
|
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;
|
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;
|
|
|
|
bp->bio_flags |= BIO_ERROR;
|
1998-09-15 06:36:34 +00:00
|
|
|
if ((softc->flags & SA_FLAG_EOM_PENDING) != 0) {
|
2000-04-15 05:54:02 +00:00
|
|
|
if (bp->bio_cmd == BIO_WRITE)
|
|
|
|
bp->bio_error = ENOSPC;
|
1999-03-01 01:07:47 +00:00
|
|
|
else
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_error = EIO;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
1998-12-19 23:33:21 +00:00
|
|
|
if ((softc->flags & SA_FLAG_EOF_PENDING) != 0) {
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_error = EIO;
|
1998-12-19 23:33:21 +00:00
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
if ((softc->flags & SA_FLAG_EIO_PENDING) != 0) {
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_error = EIO;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
1998-12-19 23:33:21 +00:00
|
|
|
done_bp = bp;
|
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));
|
1998-09-15 06:36:34 +00:00
|
|
|
splx(s);
|
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;
|
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
|
|
|
xpt_print_path(periph->path);
|
|
|
|
printf("zero blocksize for "
|
|
|
|
"FIXED length writes?\n");
|
|
|
|
splx(s);
|
|
|
|
biodone(bp);
|
|
|
|
break;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
1998-12-17 18:56:23 +00:00
|
|
|
CAM_DEBUG(periph->path, CAM_DEBUG_INFO,
|
|
|
|
("Fixed Record Count is %d\n", length));
|
1998-09-15 06:36:34 +00:00
|
|
|
} else {
|
2000-04-15 05:54:02 +00:00
|
|
|
length = bp->bio_bcount;
|
1998-12-17 18:56:23 +00:00
|
|
|
CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_INFO,
|
|
|
|
("Variable Record Count is %d\n", length));
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
devstat_start_transaction(&softc->device_stats);
|
|
|
|
/*
|
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,
|
2000-04-15 05:54:02 +00:00
|
|
|
MSG_SIMPLE_Q_TAG, (bp->bio_cmd == BIO_READ),
|
1999-05-11 04:01:35 +00:00
|
|
|
FALSE, (softc->flags & SA_FLAG_FIXED) != 0,
|
2000-04-15 05:54:02 +00:00
|
|
|
length, bp->bio_data, bp->bio_bcount, SSD_FULL_SIZE,
|
1999-05-11 04:01:35 +00:00
|
|
|
120 * 60 * 1000);
|
2001-01-15 22:28:11 +00:00
|
|
|
start_ccb->ccb_h.ccb_pflags &= ~SA_POSITION_UPDATED;
|
|
|
|
Set_CCB_Type(start_ccb, SA_CCB_BUFFER_IO);
|
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
|
|
|
splx(s);
|
|
|
|
xpt_action(start_ccb);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bp != NULL) {
|
|
|
|
/* Have more work to do, so ensure we stay scheduled */
|
1999-05-11 04:01:35 +00:00
|
|
|
xpt_schedule(periph, 1);
|
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;
|
|
|
|
|
|
|
|
softc = (struct sa_softc *)periph->softc;
|
|
|
|
csio = &done_ccb->csio;
|
2001-01-15 22:28:11 +00:00
|
|
|
switch (CCB_Type(csio)) {
|
1998-09-15 06:36:34 +00:00
|
|
|
case SA_CCB_BUFFER_IO:
|
|
|
|
{
|
2000-04-15 05:54:02 +00:00
|
|
|
struct bio *bp;
|
1998-09-15 06:36:34 +00:00
|
|
|
int error;
|
|
|
|
|
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;
|
2000-04-15 05:54:02 +00:00
|
|
|
bp = (struct bio *)done_ccb->ccb_h.ccb_bp;
|
1998-09-15 06:36:34 +00:00
|
|
|
error = 0;
|
|
|
|
if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
|
|
|
|
if ((error = saerror(done_ccb, 0, 0)) == ERESTART) {
|
|
|
|
/*
|
1998-12-19 23:33:21 +00:00
|
|
|
* A retry was scheduled, so just return.
|
1998-09-15 06:36:34 +00:00
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error == EIO) {
|
|
|
|
int s;
|
2000-04-15 05:54:02 +00:00
|
|
|
struct bio *q_bp;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
/*
|
1999-11-21 20:23:58 +00:00
|
|
|
* Catastrophic error. Mark the tape as frozen
|
|
|
|
* (we no longer know tape position).
|
|
|
|
*
|
1999-03-01 01:07:47 +00:00
|
|
|
* Return all queued I/O with EIO, and unfreeze
|
1998-09-15 06:36:34 +00:00
|
|
|
* our queue so that future transactions that
|
|
|
|
* attempt to fix this problem can get to the
|
|
|
|
* device.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
s = splbio();
|
1999-11-21 20:23:58 +00:00
|
|
|
softc->flags |= SA_FLAG_TAPE_FROZEN;
|
2000-04-15 05:54:02 +00:00
|
|
|
while ((q_bp = bioq_first(&softc->bio_queue)) != NULL) {
|
|
|
|
bioq_remove(&softc->bio_queue, q_bp);
|
|
|
|
q_bp->bio_resid = q_bp->bio_bcount;
|
|
|
|
q_bp->bio_error = EIO;
|
|
|
|
q_bp->bio_flags |= BIO_ERROR;
|
1998-09-15 06:36:34 +00:00
|
|
|
biodone(q_bp);
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
if (error != 0) {
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_resid = bp->bio_bcount;
|
|
|
|
bp->bio_error = error;
|
|
|
|
bp->bio_flags |= BIO_ERROR;
|
Extend unit numbers to a full 10 bits (split into sections
of the minor). Establish and use a control mode open. Control
mode opens may open the device without locking, but are prohibited
from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT
works, but the clearing of latched error status is contingent
upon whether another application has the device open, in which
case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY
and MTCOMP also require a periph aquire.
Relative fileno and blkno are tracked. Note that just about any
error will make these undefined, and if you space to EOD or use
hardware block positioning, these are also lost until the next
UNLOAD or REWIND.
Driver state is also tracked and recorded in the unit softc
to be passed back in mt_dsreg for a MTIOCGET call.
Thanks to Dan Strick for suggesting this.
Reintroduce 2 filemarks at EOD for all but QIC devices. I
really think it's wrong, but there is a lot of 3rd party
software that depends upon this (not the least of which is
tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices
can be marked as only being able to do 1 FM at EOD.
At samount time force a load to BOT if we aren't mounted. If the
LOAD command fails, use the REWIND command (e.g., for the IBM 3590
which for some gawdawful reason doesn't support the LOAD (to BOT)
command).
Also at samount time, if you don't know fixed or variable, try to
*set* to one of the known fixed (or variable, for special case)
density codes. We only have to do this once per boot, so it's not
that painful. This is another way to try and figure out the wierd
QIC devices without having to quirk everything in the universe.
A substantial amount of cleanup as to what operations can and what
operations cannot be retried. Don't retry space operations if they
fail- it'll just lead to lossage.
Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
|
|
|
/*
|
|
|
|
* In the error case, position is updated in saerror.
|
|
|
|
*/
|
1998-09-15 06:36:34 +00:00
|
|
|
} else {
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_resid = csio->resid;
|
|
|
|
bp->bio_error = 0;
|
1998-09-15 06:36:34 +00:00
|
|
|
if (csio->resid != 0) {
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_flags |= BIO_ERROR;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
2000-04-15 05:54:02 +00:00
|
|
|
if (bp->bio_cmd == BIO_WRITE) {
|
1998-09-15 06:36:34 +00:00
|
|
|
softc->flags |= SA_FLAG_TAPE_WRITTEN;
|
|
|
|
softc->filemarks = 0;
|
|
|
|
}
|
2001-01-15 22:28:11 +00:00
|
|
|
if (!(csio->ccb_h.ccb_pflags & SA_POSITION_UPDATED) &&
|
|
|
|
(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
|
|
|
if ((softc->flags & SA_FLAG_FIXED) != 0) {
|
|
|
|
u_int32_t l;
|
|
|
|
if (softc->blk_shift != 0) {
|
2000-04-15 05:54:02 +00:00
|
|
|
l = bp->bio_bcount >>
|
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->blk_shift;
|
|
|
|
} else {
|
2000-04-15 05:54:02 +00:00
|
|
|
l = bp->bio_bcount /
|
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->media_blksize;
|
|
|
|
}
|
|
|
|
softc->blkno += (daddr_t) l;
|
|
|
|
} else {
|
|
|
|
softc->blkno++;
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
1999-05-11 04:01:35 +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);
|
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
|
|
|
#ifdef CAMDEBUG
|
2000-04-15 05:54:02 +00:00
|
|
|
if (error || bp->bio_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
|
|
|
CAM_DEBUG(periph->path, CAM_DEBUG_INFO,
|
|
|
|
("error %d resid %ld count %ld\n", error,
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_resid, bp->bio_bcount));
|
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
|
|
|
}
|
|
|
|
#endif
|
2000-04-15 05:54:02 +00:00
|
|
|
devstat_end_transaction_bio(&softc->device_stats, bp);
|
1998-09-15 06:36:34 +00:00
|
|
|
biodone(bp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SA_CCB_WAITING:
|
|
|
|
{
|
|
|
|
/* Caller will release the CCB */
|
|
|
|
wakeup(&done_ccb->ccb_h.cbfcnp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
1998-12-17 18:56:23 +00:00
|
|
|
samount(struct cam_periph *periph, int oflags, dev_t 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,
|
|
|
|
MSG_SIMPLE_Q_TAG, SSD_FULL_SIZE, 5 * 60 * 1000);
|
1999-12-03 23:14:11 +00:00
|
|
|
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
|
1999-11-17 06:05:09 +00:00
|
|
|
&softc->device_stats);
|
|
|
|
QFRLS(ccb);
|
|
|
|
if (error == ENXIO) {
|
|
|
|
softc->flags &= ~SA_FLAG_TAPE_MOUNTED;
|
|
|
|
scsi_test_unit_ready(&ccb->csio, 0, sadone,
|
|
|
|
MSG_SIMPLE_Q_TAG, SSD_FULL_SIZE, 5 * 60 * 1000);
|
1999-12-03 23:14:11 +00:00
|
|
|
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
|
1999-11-17 06:05:09 +00:00
|
|
|
&softc->device_stats);
|
|
|
|
QFRLS(ccb);
|
|
|
|
} 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;
|
1999-12-03 23:14:11 +00:00
|
|
|
if (CAM_DEBUGGED(ccb->ccb_h.path, CAM_DEBUG_INFO)) {
|
|
|
|
xpt_print_path(ccb->ccb_h.path);
|
|
|
|
printf("error %d on TUR in samount\n", error);
|
|
|
|
}
|
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,
|
|
|
|
MSG_SIMPLE_Q_TAG, SSD_FULL_SIZE, 5 * 60 * 1000);
|
|
|
|
error = cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
|
|
|
|
&softc->device_stats);
|
|
|
|
QFRLS(ccb);
|
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,
|
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->device_stats);
|
1999-11-17 06:05:09 +00:00
|
|
|
QFRLS(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-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,
|
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->device_stats);
|
1999-11-17 06:05:09 +00:00
|
|
|
QFRLS(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) {
|
|
|
|
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 *)
|
1999-12-03 23:14:11 +00:00
|
|
|
malloc(8192, M_TEMP, M_WAITOK);
|
1999-11-17 06:05:09 +00:00
|
|
|
if (rblim == NULL) {
|
|
|
|
xpt_print_path(ccb->ccb_h.path);
|
|
|
|
printf("no memory for test read\n");
|
|
|
|
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,
|
|
|
|
120 * 60 * 1000);
|
|
|
|
(void) cam_periph_runccb(ccb, saerror, 0, SF_NO_PRINT,
|
|
|
|
&softc->device_stats);
|
|
|
|
QFRLS(ccb);
|
|
|
|
scsi_rewind(&ccb->csio, 1, sadone, MSG_SIMPLE_Q_TAG,
|
|
|
|
FALSE, SSD_FULL_SIZE, REWIND_TIMEOUT);
|
|
|
|
error = cam_periph_runccb(ccb, saerror, 0,
|
|
|
|
SF_NO_PRINT | SF_RETRY_SELTO | SF_RETRY_UA,
|
|
|
|
&softc->device_stats);
|
|
|
|
QFRLS(ccb);
|
|
|
|
if (error) {
|
|
|
|
xpt_print_path(ccb->ccb_h.path);
|
|
|
|
printf("unable to rewind after test read\n");
|
|
|
|
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,
|
1999-01-12 08:15:47 +00:00
|
|
|
rblim, SSD_FULL_SIZE, 5000);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-01-12 08:15:47 +00:00
|
|
|
error = cam_periph_runccb(ccb, saerror, 0,
|
1999-12-03 23:14:11 +00:00
|
|
|
SF_NO_PRINT | SF_RETRY_UA | SF_RETRY_SELTO,
|
|
|
|
&softc->device_stats);
|
1999-11-17 06:05:09 +00:00
|
|
|
QFRLS(ccb);
|
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 {
|
|
|
|
if (softc->scsi_rev >= SCSI_REV_3) {
|
|
|
|
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)) {
|
|
|
|
xpt_print_path(ccb->ccb_h.path);
|
|
|
|
printf("BLOCK LIMITS (%d..%d) could not match current "
|
|
|
|
"block settings (%d)- adjusting\n", softc->min_blk,
|
|
|
|
softc->max_blk, softc->media_blksize);
|
|
|
|
softc->max_blk = softc->min_blk =
|
|
|
|
softc->media_blksize;
|
|
|
|
}
|
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) {
|
|
|
|
xpt_print_path(ccb->ccb_h.path);
|
|
|
|
printf("unable to set fixed blocksize to %d\n",
|
|
|
|
softc->media_blksize);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((softc->quirks & SA_QUIRK_VARIABLE) &&
|
|
|
|
(softc->media_blksize != 0)) {
|
|
|
|
softc->last_media_blksize = softc->media_blksize;
|
|
|
|
softc->media_blksize = 0;
|
|
|
|
error = sasetparams(periph, SA_PARAM_BLOCKSIZE,
|
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;
|
|
|
|
}
|
1999-01-12 08:15:47 +00:00
|
|
|
xpt_print_path(ccb->ccb_h.path);
|
1998-12-17 18:56:23 +00:00
|
|
|
printf("unable to set variable blocksize\n");
|
|
|
|
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);
|
1998-12-17 18:56:23 +00:00
|
|
|
if (error == 0)
|
|
|
|
softc->buffer_mode = SMH_SA_BUF_MODE_SIBUF;
|
2000-05-09 04:54:10 +00:00
|
|
|
xpt_print_path(ccb->ccb_h.path);
|
|
|
|
printf("unable to set buffered mode\n");
|
|
|
|
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)
|
|
|
|
free(rblim, M_TEMP);
|
|
|
|
|
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);
|
|
|
|
}
|
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;
|
|
|
|
struct sa_softc *softc;
|
|
|
|
|
|
|
|
softc = (struct sa_softc *)periph->softc;
|
|
|
|
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 =
|
|
|
|
"%d-byte tape record bigger than suplied 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;
|
1999-11-17 06:05:09 +00:00
|
|
|
u_int32_t resid = 0;
|
|
|
|
int32_t info = 0;
|
1998-09-15 06:36:34 +00:00
|
|
|
int error_code, sense_key, asc, ascq;
|
1999-05-11 04:01:35 +00:00
|
|
|
int error, defer_action;
|
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;
|
|
|
|
scsi_extract_sense(sense, &error_code, &sense_key, &asc, &ascq);
|
|
|
|
error = 0;
|
1999-05-11 04:01:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate/latch up, any residuals...
|
|
|
|
*/
|
1998-12-19 23:33:21 +00:00
|
|
|
if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR) {
|
1998-09-15 06:36:34 +00:00
|
|
|
if ((sense->error_code & SSD_ERRCODE_VALID) != 0) {
|
1999-05-11 04:01:35 +00:00
|
|
|
info = (int32_t) scsi_4btoul(sense->info);
|
1998-09-15 06:36:34 +00:00
|
|
|
resid = info;
|
|
|
|
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
|
|
|
}
|
2001-01-15 22:28:11 +00:00
|
|
|
if (CCB_Type(csio) == SA_CCB_BUFFER_IO) {
|
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;
|
|
|
|
} 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-15 22:28:11 +00:00
|
|
|
CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Key 0x%x ASC/ASCQ "
|
|
|
|
"0x%x 0x%x flags 0x%x resid %d dxfer_len %d\n", sense_key,
|
1999-11-17 06:05:09 +00:00
|
|
|
asc, ascq, sense->flags & ~SSD_KEY_RESERVED, resid,
|
|
|
|
csio->dxfer_len));
|
|
|
|
} else {
|
|
|
|
CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Cam Status 0x%x\n",
|
|
|
|
csio->ccb_h.status & CAM_STATUS_MASK));
|
1998-12-19 23:33:21 +00:00
|
|
|
}
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
/*
|
|
|
|
* If it's neither a SCSI Check Condition Error nor a non-read/write
|
|
|
|
* command, let the common code deal with it the error setting.
|
|
|
|
*/
|
|
|
|
if ((csio->ccb_h.status & CAM_STATUS_MASK) != CAM_SCSI_STATUS_ERROR ||
|
2001-01-15 22:28:11 +00:00
|
|
|
(CCB_Type(csio) == SA_CCB_WAITING)) {
|
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
|
|
|
/*
|
|
|
|
* Calculate whether we'll defer action.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (resid > 0 && resid < csio->dxfer_len &&
|
|
|
|
(softc->flags & SA_FLAG_FIXED) != 0) {
|
|
|
|
defer_action = TRUE;
|
|
|
|
} else {
|
|
|
|
defer_action = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle filemark, end of tape, mismatched record sizes....
|
|
|
|
* From this point out, we're only handling read/write cases.
|
|
|
|
* Handle writes && reads differently.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (csio->cdb_io.cdb_bytes[0] == SA_WRITE) {
|
|
|
|
if (sense->flags & SSD_FILEMARK) {
|
|
|
|
xpt_print_path(csio->ccb_h.path);
|
|
|
|
printf("filemark detected on write?\n");
|
|
|
|
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;
|
1999-05-11 04:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sense->flags & SSD_EOM) {
|
1998-09-15 06:36:34 +00:00
|
|
|
csio->resid = resid;
|
|
|
|
if (defer_action) {
|
1999-05-11 04:01:35 +00:00
|
|
|
error = -1;
|
1998-09-15 06:36:34 +00:00
|
|
|
softc->flags |= SA_FLAG_EOM_PENDING;
|
|
|
|
} else {
|
1999-05-11 04:01:35 +00:00
|
|
|
error = ENOSPC;
|
1998-09-15 06:36:34 +00:00
|
|
|
}
|
|
|
|
}
|
1999-05-11 04:01:35 +00:00
|
|
|
} else {
|
|
|
|
if (sense_key == SSD_KEY_BLANK_CHECK) {
|
1998-09-15 06:36:34 +00:00
|
|
|
csio->resid = resid;
|
1999-05-11 04:01:35 +00:00
|
|
|
if (defer_action) {
|
|
|
|
error = -1;
|
|
|
|
softc->flags |= SA_FLAG_EOM_PENDING;
|
|
|
|
} else {
|
|
|
|
error = EIO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sense->flags & SSD_FILEMARK) {
|
|
|
|
csio->resid = resid;
|
|
|
|
if (defer_action) {
|
|
|
|
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
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Incorrect Length usually applies to read, but can apply to writes.
|
|
|
|
*/
|
|
|
|
if (error == 0 && (sense->flags & SSD_ILI)) {
|
|
|
|
if (info < 0) {
|
|
|
|
xpt_print_path(csio->ccb_h.path);
|
|
|
|
printf(toobig, csio->dxfer_len - info);
|
|
|
|
csio->resid = csio->dxfer_len;
|
|
|
|
error = EIO;
|
|
|
|
} else {
|
|
|
|
csio->resid = resid;
|
|
|
|
if ((softc->flags & SA_FLAG_FIXED) != 0) {
|
|
|
|
if (defer_action)
|
|
|
|
softc->flags |= SA_FLAG_EIO_PENDING;
|
|
|
|
else
|
|
|
|
error = EIO;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Bump the block number if we hadn't seen a filemark.
|
|
|
|
* Do this independent of errors (we've moved anyway).
|
|
|
|
*/
|
|
|
|
if ((sense->flags & SSD_FILEMARK) == 0) {
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (error == 0)
|
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
|
|
|
if (error == -1)
|
|
|
|
return (0);
|
|
|
|
else
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2000-10-27 16:40:57 +00:00
|
|
|
mode_buffer = malloc(mode_buffer_len, M_TEMP, M_WAITOK | M_ZERO);
|
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,
|
|
|
|
SSD_FULL_SIZE, 5000);
|
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,
|
|
|
|
&softc->device_stats);
|
|
|
|
QFRLS(ccb);
|
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;
|
|
|
|
free(mode_buffer, M_TEMP);
|
|
|
|
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,
|
|
|
|
mode_buffer, mode_buffer_len, SSD_FULL_SIZE, 5000);
|
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,
|
1999-05-11 04:01:35 +00:00
|
|
|
&softc->device_stats);
|
1999-12-03 23:14:11 +00:00
|
|
|
QFRLS(ccb);
|
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
|
|
|
|
* Data Compression if the the algorithm field is
|
|
|
|
* 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);
|
|
|
|
free(mode_buffer, M_TEMP);
|
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;
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
ccomp = malloc(sizeof (sa_comp_t), M_TEMP, M_WAITOK);
|
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) {
|
1999-05-11 04:01:35 +00:00
|
|
|
free(ccomp, M_TEMP);
|
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
|
|
|
|
2000-10-27 16:40:57 +00:00
|
|
|
mode_buffer = malloc(mode_buffer_len, M_TEMP, M_WAITOK | M_ZERO);
|
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;
|
|
|
|
|
|
|
|
/* set single-initiator buffering mode */
|
|
|
|
mode_hdr->dev_spec |= SMH_SA_BUF_MODE_SIBUF;
|
|
|
|
|
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) {
|
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
|
|
|
}
|
1999-11-17 06:05:09 +00:00
|
|
|
case SA_DEVICE_CONFIGURATION_PAGE:
|
1999-05-11 04:01:35 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
xpt_print_path(periph->path);
|
1999-12-03 23:14:11 +00:00
|
|
|
printf("device does not seem to support compression\n");
|
|
|
|
|
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) {
|
|
|
|
free(mode_buffer, M_TEMP);
|
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,
|
|
|
|
FALSE, mode_buffer, mode_buffer_len, SSD_FULL_SIZE, 5000);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
error = cam_periph_runccb(ccb, saerror, 0,
|
|
|
|
sense_flags, &softc->device_stats);
|
1999-12-03 23:14:11 +00:00
|
|
|
QFRLS(ccb);
|
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,
|
|
|
|
&softc->device_stats);
|
|
|
|
QFRLS(ccb);
|
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)
|
|
|
|
free(ccomp, M_TEMP);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-15 06:36:34 +00:00
|
|
|
free(mode_buffer, M_TEMP);
|
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,
|
1999-11-17 06:05:09 +00:00
|
|
|
SSD_FULL_SIZE, 100000);
|
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
|
|
|
error = cam_periph_runccb(ccb, saerror, 0, sf, &softc->device_stats);
|
1999-11-21 20:23:58 +00:00
|
|
|
QFRLS(ccb);
|
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;
|
1999-01-16 04:02:31 +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
|
|
|
|
|
|
|
if ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
|
1999-01-16 04:02:31 +00:00
|
|
|
cam_release_devq(ccb->ccb_h.path, 0, 0, 0, FALSE);
|
|
|
|
|
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;
|
1999-01-16 04:02:31 +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
|
|
|
|
|
|
|
if ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
|
1999-01-16 04:02:31 +00:00
|
|
|
cam_release_devq(ccb->ccb_h.path, 0, 0, 0, FALSE);
|
|
|
|
|
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;
|
|
|
|
|
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,
|
1998-12-18 04:31:43 +00:00
|
|
|
FALSE, setmarks, nmarks, SSD_FULL_SIZE, 60000);
|
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
|
|
|
|
1998-12-18 04:31:43 +00:00
|
|
|
error = cam_periph_runccb(ccb, saerror, 0, 0, &softc->device_stats);
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
if ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
|
1999-01-16 04:02:31 +00:00
|
|
|
cam_release_devq(ccb->ccb_h.path, 0, 0, 0, FALSE);
|
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,
|
|
|
|
hard, &loc, SSD_FULL_SIZE, 5000);
|
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;
|
1998-12-18 04:31:43 +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 ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
|
|
|
|
cam_release_devq(ccb->ccb_h.path, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
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,
|
|
|
|
hard, *blkptr, SSD_FULL_SIZE, 60 * 60 * 1000);
|
Extend unit numbers to a full 10 bits (split into sections
of the minor). Establish and use a control mode open. Control
mode opens may open the device without locking, but are prohibited
from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT
works, but the clearing of latched error status is contingent
upon whether another application has the device open, in which
case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY
and MTCOMP also require a periph aquire.
Relative fileno and blkno are tracked. Note that just about any
error will make these undefined, and if you space to EOD or use
hardware block positioning, these are also lost until the next
UNLOAD or REWIND.
Driver state is also tracked and recorded in the unit softc
to be passed back in mt_dsreg for a MTIOCGET call.
Thanks to Dan Strick for suggesting this.
Reintroduce 2 filemarks at EOD for all but QIC devices. I
really think it's wrong, but there is a lot of 3rd party
software that depends upon this (not the least of which is
tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices
can be marked as only being able to do 1 FM at EOD.
At samount time force a load to BOT if we aren't mounted. If the
LOAD command fails, use the REWIND command (e.g., for the IBM 3590
which for some gawdawful reason doesn't support the LOAD (to BOT)
command).
Also at samount time, if you don't know fixed or variable, try to
*set* to one of the known fixed (or variable, for special case)
density codes. We only have to do this once per boot, so it's not
that painful. This is another way to try and figure out the wierd
QIC devices without having to quirk everything in the universe.
A substantial amount of cleanup as to what operations can and what
operations cannot be retried. Don't retry space operations if they
fail- it'll just lead to lossage.
Not yet done is invalidating mounts correctly after errors. ENOTIME.
1999-02-05 07:32:52 +00:00
|
|
|
|
|
|
|
softc->dsreg = MTIO_DSREG_POS;
|
1998-12-18 04:31:43 +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 ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
|
|
|
|
cam_release_devq(ccb->ccb_h.path, 0, 0, 0, 0);
|
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;
|
1999-01-16 04:02:31 +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
|
|
|
|
|
|
|
if ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
|
1999-01-16 04:02:31 +00:00
|
|
|
cam_release_devq(ccb->ccb_h.path, 0, 0, 0, FALSE);
|
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,
|
1999-01-16 04:02:31 +00:00
|
|
|
FALSE, 0, SSD_FULL_SIZE, 5000, 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,
|
|
|
|
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;
|
1999-12-03 23:14:11 +00:00
|
|
|
QFRLS(ccb);
|
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;
|
1999-01-16 04:02:31 +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;
|
1999-12-03 23:14:11 +00:00
|
|
|
QFRLS(ccb);
|
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;
|
|
|
|
|
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;
|
|
|
|
error = cam_periph_runccb(ccb, saerror, 0, 0, &softc->device_stats);
|
|
|
|
softc->dsreg = MTIO_DSREG_REST;
|
1998-09-15 06:36:34 +00:00
|
|
|
|
|
|
|
if ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 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
|
|
|
cam_release_devq(ccb->ccb_h.path, 0, 0, 0, FALSE);
|
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;
|
|
|
|
|
|
|
|
scsi_cmd = (struct scsi_sa_rw *)&csio->cdb_io.cdb_bytes;
|
|
|
|
scsi_cmd->opcode = readop ? SA_READ : SA_WRITE;
|
|
|
|
scsi_cmd->sli_fixed = 0;
|
|
|
|
if (sli && readop)
|
|
|
|
scsi_cmd->sli_fixed |= SAR_SLI;
|
|
|
|
if (fixed)
|
|
|
|
scsi_cmd->sli_fixed |= SARW_FIXED;
|
|
|
|
scsi_ulto3b(length, scsi_cmd->length);
|
|
|
|
scsi_cmd->control = 0;
|
|
|
|
|
1999-05-11 04:01:35 +00:00
|
|
|
cam_fill_csio(csio, retries, cbfcnp, readop ? CAM_DIR_IN : CAM_DIR_OUT,
|
|
|
|
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);
|
|
|
|
}
|