mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Fix short timeout problems with the pt(4) driver:
- increase the default timeout from 10 seconds to 60 seconds - add a new kernel option, SCSI_PT_DEFAULT_TIMEOUT, that lets users specify the default timeout for the pt driver to use - add two new ioctls, one to get the timeout for a given pt device, the other to set the timeout for a given pt device. The idea is that userland applications using the device can set the timeout to suit their purposes. The ioctls are defined in a new header file, sys/ptio.h PR: 10266 Reviewed by: gibbs, joerg
This commit is contained in:
parent
8cb6a40a33
commit
3ece1bd296
7 changed files with 146 additions and 39 deletions
|
|
@ -23,7 +23,7 @@
|
|||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id$
|
||||
.\" $Id: pt.4,v 1.5 1997/03/07 02:49:30 jmg Exp $
|
||||
.\"
|
||||
.Dd March 2, 1995
|
||||
.Dt PT 4
|
||||
|
|
@ -32,7 +32,8 @@
|
|||
.Nm pt
|
||||
.Nd SCSI processor type driver
|
||||
.Sh SYNOPSIS
|
||||
.Cd device pt0 at scbus?
|
||||
.Cd device pt0
|
||||
.Cd device pt1 at scbus0 target 3 unit 0
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
|
|
@ -49,42 +50,31 @@ A
|
|||
adapter must be separately configured into the system
|
||||
before this driver can be used.
|
||||
.Pp
|
||||
This device only supports
|
||||
This device supports
|
||||
.Xr read 2
|
||||
and
|
||||
.Xr write 2 ,
|
||||
and the generic
|
||||
.Tn SCSI
|
||||
and the
|
||||
.Xr ioctl 2
|
||||
calls.
|
||||
The
|
||||
.Sq Li at scbus?
|
||||
is required in the config file for the configuration
|
||||
system to know this is a SCSI device and generate the appropriate
|
||||
tables.
|
||||
.Pp
|
||||
The
|
||||
.Sq Li 0
|
||||
in
|
||||
.Sq Li pt0
|
||||
in the configuration is required.
|
||||
This is a deficiency in
|
||||
.Xr config 8 .
|
||||
calls described below.
|
||||
.Sh IOCTLS
|
||||
The
|
||||
.Bl -tag -width 012345678901234
|
||||
The following
|
||||
.Xr ioctl 2
|
||||
calls are supported by the
|
||||
.Nm
|
||||
driver has no
|
||||
.Fn ioctl
|
||||
commands of its own but rather acts as a medium for the
|
||||
generic
|
||||
.Xr scsi 4
|
||||
commands. These are described in
|
||||
.Aq Pa sys/scsiio.h .
|
||||
All
|
||||
.Xr scsi 4
|
||||
debug ioctls work on
|
||||
driver. They are defined in the header file
|
||||
.Aq Pa sys/ptio.h .
|
||||
.Pp
|
||||
.It PTIOCGETTIMEOUT
|
||||
This ioctl allows userland applications to fetch the current
|
||||
.Nm
|
||||
devices.
|
||||
driver read and write timeout. The value returned is in seconds.
|
||||
.It PTIOCSETTIMEOUT
|
||||
This ioctl allows userland applications to set the current
|
||||
.Nm
|
||||
driver read and write timeouts. The value should be in seconds.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width /dev/ptQQQ -compact
|
||||
.It Pa /dev/pt Ns Ar N
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: scsi_pt.c,v 1.10 1999/05/31 11:24:07 phk Exp $
|
||||
* $Id: scsi_pt.c,v 1.11 1999/08/17 20:25:47 billf Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
|
|
@ -37,6 +37,7 @@
|
|||
#include <sys/devicestat.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/ptio.h>
|
||||
|
||||
#include <cam/cam.h>
|
||||
#include <cam/cam_ccb.h>
|
||||
|
|
@ -49,6 +50,8 @@
|
|||
#include <cam/scsi/scsi_message.h>
|
||||
#include <cam/scsi/scsi_pt.h>
|
||||
|
||||
#include "opt_pt.h"
|
||||
|
||||
typedef enum {
|
||||
PT_STATE_PROBE,
|
||||
PT_STATE_NORMAL
|
||||
|
|
@ -79,6 +82,7 @@ struct pt_softc {
|
|||
pt_state state;
|
||||
pt_flags flags;
|
||||
union ccb saved_ccb;
|
||||
int io_timeout;
|
||||
};
|
||||
|
||||
static d_open_t ptopen;
|
||||
|
|
@ -93,6 +97,7 @@ static periph_dtor_t ptdtor;
|
|||
static periph_start_t ptstart;
|
||||
static void ptdone(struct cam_periph *periph,
|
||||
union ccb *done_ccb);
|
||||
static d_ioctl_t ptioctl;
|
||||
static int pterror(union ccb *ccb, u_int32_t cam_flags,
|
||||
u_int32_t sense_flags);
|
||||
|
||||
|
|
@ -117,7 +122,7 @@ static struct cdevsw pt_cdevsw = {
|
|||
/* close */ ptclose,
|
||||
/* read */ physread,
|
||||
/* write */ physwrite,
|
||||
/* ioctl */ noioctl,
|
||||
/* ioctl */ ptioctl,
|
||||
/* stop */ nostop,
|
||||
/* reset */ noreset,
|
||||
/* devtotty */ nodevtotty,
|
||||
|
|
@ -136,6 +141,10 @@ static struct cdevsw pt_cdevsw = {
|
|||
|
||||
static struct extend_array *ptperiphs;
|
||||
|
||||
#ifndef SCSI_PT_DEFAULT_TIMEOUT
|
||||
#define SCSI_PT_DEFAULT_TIMEOUT 60
|
||||
#endif
|
||||
|
||||
static int
|
||||
ptopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
{
|
||||
|
|
@ -339,6 +348,8 @@ ptctor(struct cam_periph *periph, void *arg)
|
|||
softc->state = PT_STATE_NORMAL;
|
||||
bufq_init(&softc->buf_queue);
|
||||
|
||||
softc->io_timeout = SCSI_PT_DEFAULT_TIMEOUT * 1000;
|
||||
|
||||
periph->softc = softc;
|
||||
|
||||
cam_extend_set(ptperiphs, periph->unit_number, periph);
|
||||
|
|
@ -543,7 +554,7 @@ ptstart(struct cam_periph *periph, union ccb *start_ccb)
|
|||
bp->b_bcount,
|
||||
bp->b_data,
|
||||
/*sense_len*/SSD_FULL_SIZE,
|
||||
/*timeout*/10000);
|
||||
/*timeout*/softc->io_timeout);
|
||||
|
||||
start_ccb->ccb_h.ccb_state = PT_CCB_BUFFER_IO;
|
||||
|
||||
|
|
@ -694,6 +705,58 @@ pterror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
|
|||
&softc->saved_ccb));
|
||||
}
|
||||
|
||||
static int
|
||||
ptioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct pt_softc *softc;
|
||||
int unit;
|
||||
int error;
|
||||
|
||||
unit = minor(dev);
|
||||
periph = cam_extend_get(ptperiphs, unit);
|
||||
|
||||
if (periph == NULL)
|
||||
return(ENXIO);
|
||||
|
||||
softc = (struct pt_softc *)periph->softc;
|
||||
|
||||
if ((error = cam_periph_lock(periph, PRIBIO|PCATCH)) != 0) {
|
||||
return (error); /* error code from tsleep */
|
||||
}
|
||||
|
||||
switch(cmd) {
|
||||
case PTIOCGETTIMEOUT:
|
||||
if (softc->io_timeout >= 1000)
|
||||
*(int *)addr = softc->io_timeout / 1000;
|
||||
else
|
||||
*(int *)addr = 0;
|
||||
break;
|
||||
case PTIOCSETTIMEOUT:
|
||||
{
|
||||
int s;
|
||||
|
||||
if (*(int *)addr < 1) {
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
s = splsoftcam();
|
||||
softc->io_timeout = *(int *)addr * 1000;
|
||||
splx(s);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
error = cam_periph_ioctl(periph, cmd, addr, pterror);
|
||||
break;
|
||||
}
|
||||
|
||||
cam_periph_unlock(periph);
|
||||
|
||||
return(error);
|
||||
}
|
||||
|
||||
void
|
||||
scsi_send_receive(struct ccb_scsiio *csio, u_int32_t retries,
|
||||
void (*cbfcnp)(struct cam_periph *, union ccb *),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# LINT -- config file for checking all the sources, tries to pull in
|
||||
# as much of the source tree as it can.
|
||||
#
|
||||
# $Id: LINT,v 1.626 1999/08/15 09:38:20 phk Exp $
|
||||
# $Id: LINT,v 1.627 1999/08/15 09:54:56 phk Exp $
|
||||
#
|
||||
# NB: You probably don't want to try running a kernel built from this
|
||||
# file. Instead, you should start from GENERIC, and add options from
|
||||
|
|
@ -759,6 +759,10 @@ options SA_SPACE_TIMEOUT="(60)"
|
|||
options SA_REWIND_TIMEOUT="(2*60)"
|
||||
options SA_ERASE_TIMEOUT="(4*60)"
|
||||
|
||||
# Optional timeout for the CAM processor target (pt) device
|
||||
# This is specified in seconds. The default is 60 seconds.
|
||||
options SCSI_PT_DEFAULT_TIMEOUT="60"
|
||||
|
||||
|
||||
#####################################################################
|
||||
# MISCELLANEOUS DEVICES AND OPTIONS
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: options,v 1.145 1999/08/10 09:42:32 des Exp $
|
||||
# $Id: options,v 1.146 1999/08/16 22:39:53 gibbs Exp $
|
||||
#
|
||||
# On the handling of kernel options
|
||||
#
|
||||
|
|
@ -169,11 +169,14 @@ SCSI_NO_OP_STRINGS opt_scsi.h
|
|||
CHANGER_MIN_BUSY_SECONDS opt_cd.h
|
||||
CHANGER_MAX_BUSY_SECONDS opt_cd.h
|
||||
|
||||
# Options used only in cam/scsi/sa.c.
|
||||
# Options used only in cam/scsi/scsi_sa.c.
|
||||
SA_SPACE_TIMEOUT opt_sa.h
|
||||
SA_REWIND_TIMEOUT opt_sa.h
|
||||
SA_ERASE_TIMEOUT opt_sa.h
|
||||
|
||||
# Options used only in cam/scsi/scsi_pt.c
|
||||
SCSI_PT_DEFAULT_TIMEOUT opt_pt.h
|
||||
|
||||
# Options used only in pci/ncr.c
|
||||
SCSI_NCR_DEBUG opt_ncr.h
|
||||
SCSI_NCR_DFLT_TAGS opt_ncr.h
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# LINT -- config file for checking all the sources, tries to pull in
|
||||
# as much of the source tree as it can.
|
||||
#
|
||||
# $Id: LINT,v 1.626 1999/08/15 09:38:20 phk Exp $
|
||||
# $Id: LINT,v 1.627 1999/08/15 09:54:56 phk Exp $
|
||||
#
|
||||
# NB: You probably don't want to try running a kernel built from this
|
||||
# file. Instead, you should start from GENERIC, and add options from
|
||||
|
|
@ -759,6 +759,10 @@ options SA_SPACE_TIMEOUT="(60)"
|
|||
options SA_REWIND_TIMEOUT="(2*60)"
|
||||
options SA_ERASE_TIMEOUT="(4*60)"
|
||||
|
||||
# Optional timeout for the CAM processor target (pt) device
|
||||
# This is specified in seconds. The default is 60 seconds.
|
||||
options SCSI_PT_DEFAULT_TIMEOUT="60"
|
||||
|
||||
|
||||
#####################################################################
|
||||
# MISCELLANEOUS DEVICES AND OPTIONS
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# LINT -- config file for checking all the sources, tries to pull in
|
||||
# as much of the source tree as it can.
|
||||
#
|
||||
# $Id: LINT,v 1.626 1999/08/15 09:38:20 phk Exp $
|
||||
# $Id: LINT,v 1.627 1999/08/15 09:54:56 phk Exp $
|
||||
#
|
||||
# NB: You probably don't want to try running a kernel built from this
|
||||
# file. Instead, you should start from GENERIC, and add options from
|
||||
|
|
@ -759,6 +759,10 @@ options SA_SPACE_TIMEOUT="(60)"
|
|||
options SA_REWIND_TIMEOUT="(2*60)"
|
||||
options SA_ERASE_TIMEOUT="(4*60)"
|
||||
|
||||
# Optional timeout for the CAM processor target (pt) device
|
||||
# This is specified in seconds. The default is 60 seconds.
|
||||
options SCSI_PT_DEFAULT_TIMEOUT="60"
|
||||
|
||||
|
||||
#####################################################################
|
||||
# MISCELLANEOUS DEVICES AND OPTIONS
|
||||
|
|
|
|||
39
sys/sys/ptio.h
Normal file
39
sys/sys/ptio.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 1999 Kenneth D. Merry.
|
||||
* 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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
#ifndef _SYS_PTIO_H
|
||||
#define _SYS_PTIO_H 1
|
||||
|
||||
#ifndef KERNEL
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <sys/ioccom.h>
|
||||
|
||||
#define PTIOCGETTIMEOUT _IOR('T', 1, int)
|
||||
#define PTIOCSETTIMEOUT _IOW('T', 2, int)
|
||||
|
||||
#endif /* !_SYS_PTIO_H */
|
||||
Loading…
Reference in a new issue