Mon Apr 25 14:14:22 2011 UTC ()
Don't kill outstanding requests when detaching a scsibus on shutdown.
Both the controller and tyhe targets are still running.


(hannken)
diff -r1.260 -r1.261 src/sys/dev/scsipi/scsiconf.c

cvs diff -r1.260 -r1.261 src/sys/dev/scsipi/scsiconf.c (expand / switch to unified diff)

--- src/sys/dev/scsipi/scsiconf.c 2011/04/18 01:47:28 1.260
+++ src/sys/dev/scsipi/scsiconf.c 2011/04/25 14:14:22 1.261
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: scsiconf.c,v 1.260 2011/04/18 01:47:28 rmind Exp $ */ 1/* $NetBSD: scsiconf.c,v 1.261 2011/04/25 14:14:22 hannken Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum; Jason R. Thorpe of the Numerical Aerospace 8 * by Charles M. Hannum; Jason R. Thorpe of the Numerical Aerospace
9 * Simulation Facility, NASA Ames Research Center. 9 * Simulation Facility, NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -38,27 +38,27 @@ @@ -38,27 +38,27 @@
38 * Mellon University, makes this software available to CMU to distribute 38 * Mellon University, makes this software available to CMU to distribute
39 * or use in any manner that they see fit as long as this message is kept with 39 * or use in any manner that they see fit as long as this message is kept with
40 * the software. For this reason TFS also grants any other persons or 40 * the software. For this reason TFS also grants any other persons or
41 * organisations permission to use or modify this software. 41 * organisations permission to use or modify this software.
42 * 42 *
43 * TFS supplies this software to be publicly redistributed 43 * TFS supplies this software to be publicly redistributed
44 * on the understanding that TFS is not responsible for the correct 44 * on the understanding that TFS is not responsible for the correct
45 * functioning of this software in any circumstances. 45 * functioning of this software in any circumstances.
46 * 46 *
47 * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 47 * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
48 */ 48 */
49 49
50#include <sys/cdefs.h> 50#include <sys/cdefs.h>
51__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.260 2011/04/18 01:47:28 rmind Exp $"); 51__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.261 2011/04/25 14:14:22 hannken Exp $");
52 52
53#include <sys/param.h> 53#include <sys/param.h>
54#include <sys/systm.h> 54#include <sys/systm.h>
55#include <sys/kernel.h> 55#include <sys/kernel.h>
56#include <sys/proc.h> 56#include <sys/proc.h>
57#include <sys/kthread.h> 57#include <sys/kthread.h>
58#include <sys/malloc.h> 58#include <sys/malloc.h>
59#include <sys/mutex.h> 59#include <sys/mutex.h>
60#include <sys/once.h> 60#include <sys/once.h>
61#include <sys/device.h> 61#include <sys/device.h>
62#include <sys/conf.h> 62#include <sys/conf.h>
63#include <sys/fcntl.h> 63#include <sys/fcntl.h>
64#include <sys/scsiio.h> 64#include <sys/scsiio.h>
@@ -259,26 +259,28 @@ scsibusdetach(device_t self, int flags) @@ -259,26 +259,28 @@ scsibusdetach(device_t self, int flags)
259 pmf_device_deregister(self); 259 pmf_device_deregister(self);
260 260
261 /* 261 /*
262 * Process outstanding commands (which will never complete as the 262 * Process outstanding commands (which will never complete as the
263 * controller is gone). 263 * controller is gone).
264 */ 264 */
265 for (ctarget = 0; ctarget < chan->chan_ntargets; ctarget++) { 265 for (ctarget = 0; ctarget < chan->chan_ntargets; ctarget++) {
266 if (ctarget == chan->chan_id) 266 if (ctarget == chan->chan_id)
267 continue; 267 continue;
268 for (clun = 0; clun < chan->chan_nluns; clun++) { 268 for (clun = 0; clun < chan->chan_nluns; clun++) {
269 periph = scsipi_lookup_periph(chan, ctarget, clun); 269 periph = scsipi_lookup_periph(chan, ctarget, clun);
270 if (periph == NULL) 270 if (periph == NULL)
271 continue; 271 continue;
 272 if ((flags & DETACH_SHUTDOWN) != 0)
 273 return EBUSY;
272 TAILQ_FOREACH(xs, &periph->periph_xferq, device_q) { 274 TAILQ_FOREACH(xs, &periph->periph_xferq, device_q) {
273 callout_stop(&xs->xs_callout); 275 callout_stop(&xs->xs_callout);
274 xs->error = XS_DRIVER_STUFFUP; 276 xs->error = XS_DRIVER_STUFFUP;
275 scsipi_done(xs); 277 scsipi_done(xs);
276 } 278 }
277 } 279 }
278 } 280 }
279 281
280 /* 282 /*
281 * Detach all of the periphs. 283 * Detach all of the periphs.
282 */ 284 */
283 error = scsipi_target_detach(chan, -1, -1, flags); 285 error = scsipi_target_detach(chan, -1, -1, flags);
284 286