From 031bacf85956364ca3c752a44e198380aeae908c Mon Sep 17 00:00:00 2001 From: Nate Lawson Date: Thu, 16 Jan 2003 00:24:29 +0000 Subject: [PATCH] kernel: * Fix a bug where devices weren't cleaned up on close(): CAM_REQ_CMP != 0 user: * Increase timeout in usermode to CAM_TIME_INFINITY. The initiator is in charge of timeouts and the value was in ms, not seconds. * Bring two debugging printfs under the debug flag * Clean up man page to show increased testing on isp(4) Submitted by: gibbs (bugfixes) --- share/examples/scsi_target/scsi_cmds.c | 6 ++++-- share/examples/scsi_target/scsi_target.c | 7 +++++-- share/man/man4/targ.4 | 11 +++++------ sys/cam/scsi/scsi_target.c | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/share/examples/scsi_target/scsi_cmds.c b/share/examples/scsi_target/scsi_cmds.c index d624cfb6b1c..1cbe6d8f0c0 100644 --- a/share/examples/scsi_target/scsi_cmds.c +++ b/share/examples/scsi_target/scsi_cmds.c @@ -125,8 +125,10 @@ tcmd_handle(struct ccb_accept_tio *atio, struct ccb_scsiio *ctio, io_ops event) struct atio_descr *a_descr; int ret; - warnx("tcmd_handle atio %p ctio %p atioflags %#x", atio, ctio, - atio->ccb_h.flags); + if (debug) { + warnx("tcmd_handle atio %p ctio %p atioflags %#x", atio, ctio, + atio->ccb_h.flags); + } ret = 0; a_descr = (struct atio_descr *)atio->ccb_h.targ_descr; diff --git a/share/examples/scsi_target/scsi_target.c b/share/examples/scsi_target/scsi_target.c index 0f0d6b8ae28..09f6610b6fd 100644 --- a/share/examples/scsi_target/scsi_target.c +++ b/share/examples/scsi_target/scsi_target.c @@ -453,7 +453,10 @@ request_loop() /* Assume work function handled the exception */ if ((ccb_h->status & CAM_DEV_QFRZN) != 0) { - warnx("Queue frozen receiving CCB, releasing"); + if (debug) { + warnx("Queue frozen receiving CCB, " + "releasing"); + } rel_simq(); } @@ -819,7 +822,7 @@ get_ctio() /* Initialize CTIO, CTIO descr, and AIO */ ctio->ccb_h.func_code = XPT_CONT_TARGET_IO; ctio->ccb_h.retry_count = 2; - ctio->ccb_h.timeout = 5; + ctio->ccb_h.timeout = CAM_TIME_INFINITY; ctio->data_ptr = c_descr->buf; ctio->ccb_h.targ_descr = c_descr; c_descr->aiocb.aio_buf = c_descr->buf; diff --git a/share/man/man4/targ.4 b/share/man/man4/targ.4 index d2bd3aa50c5..d623c12720f 100644 --- a/share/man/man4/targ.4 +++ b/share/man/man4/targ.4 @@ -48,7 +48,7 @@ driver supplies control devices, .Pa /dev/targ0 , .Pa /dev/targ1 , etc. -If a device is already in use, the open will fail and +If a device is already in use, open(2) will fail and .Va errno will be set to .Er EBUSY . @@ -121,6 +121,8 @@ are the control devices. .El .Sh SEE ALSO .Pa /usr/share/examples/scsi_target , +.Xr ahc 4 , +.Xr isp 4 , .Xr scsi 4 .Rs .%T "FreeBSD Target Information" @@ -129,12 +131,9 @@ are the control devices. .Sh BUGS Currently, only the .Xr ahc 4 -driver fully supports target mode. -The -.Xr isp 4 and -.Xr sym 4 -drivers have some target mode support but are untested. +.Xr isp 4 +drivers fully support target mode. .Pp The .Xr ahc 4 diff --git a/sys/cam/scsi/scsi_target.c b/sys/cam/scsi/scsi_target.c index 31633dc88a3..9db2604dce3 100644 --- a/sys/cam/scsi/scsi_target.c +++ b/sys/cam/scsi/scsi_target.c @@ -214,7 +214,7 @@ targclose(dev_t dev, int flag, int fmt, struct thread *td) softc = (struct targ_softc *)dev->si_drv1; TARG_LOCK(softc); error = targdisable(softc); - if (error == 0) { + if (error == CAM_REQ_CMP) { dev->si_drv1 = 0; mtx_lock(&targ_mtx); if (softc->periph != NULL) {