public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] make the SCSI mid-layer obey the device online flag
@ 2003-06-04 16:01 James Bottomley
  2003-06-04 16:51 ` Mike Anderson
  0 siblings, 1 reply; 23+ messages in thread
From: James Bottomley @ 2003-06-04 16:01 UTC (permalink / raw)
  To: SCSI Mailing List; +Cc: Alan Stern

[-- Attachment #1: Type: text/plain, Size: 893 bytes --]

It has been pointed out by the USB people that the mid-layer doesn't
obey its own online flag.

The attached patch should fix this.  However, there are a few caveats to
offlining (read that as devices should still be prepared to process
commands).

1. Any special command will still be accepted (that's a command either
via the SCSI_IOCTL_SEND_COMMAND, or an internally generated command).
2. Outstanding already processed commands in the queue (i.e. commands
which have already been through the upper layer drivers but needed
requeuing for some reason like QUEUE_FULL or device busy).

I'm willing to consider changing 2., it just requires more speciallised
logic to distinguish between a command that has been prepared by the
upper level drivers and a command sent via 1.

However, not that LLDs may not assume they will receive no commands just
because scsi_device->online is zero.

James


[-- Attachment #2: tmp.diff --]
[-- Type: text/plain, Size: 825 bytes --]

===== drivers/scsi/scsi_lib.c 1.92 vs edited =====
--- 1.92/drivers/scsi/scsi_lib.c	Mon May 26 05:50:43 2003
+++ edited/drivers/scsi/scsi_lib.c	Wed Jun  4 11:43:01 2003
@@ -945,6 +945,18 @@
 			cmd = req->special;
 	} else if (req->flags & (REQ_CMD | REQ_BLOCK_PC)) {
 		/*
+		 * Just check to see if the device is online.  If
+		 * it isn't, we refuse to process ordinary commands
+		 * (we will allow specials just in case someone needs
+		 * to send a command to an offline device without bringing
+		 * it back online)
+		 */
+		if(!sdev->online) {
+			printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to offline device\n",
+			       sdev->host->host_no, sdev->id, sdev->lun);
+			return BLKPREP_KILL;
+		}
+		/*
 		 * Now try and find a command block that we can use.
 		 */
 		if (!req->special) {

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2003-06-09 23:45 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-04 16:01 [PATCH] make the SCSI mid-layer obey the device online flag James Bottomley
2003-06-04 16:51 ` Mike Anderson
2003-06-04 19:14   ` James Bottomley
2003-06-05  0:34     ` Patrick Mansfield
2003-06-05 12:59       ` James Bottomley
2003-06-05 13:41       ` Alan Stern
2003-06-06  6:36     ` Christoph Hellwig
2003-06-06 15:19       ` James Bottomley
2003-06-06 15:51         ` Oliver Neukum
2003-06-06 16:02         ` Luben Tuikov
2003-06-06 15:28       ` Luben Tuikov
2003-06-06 15:39         ` James Bottomley
2003-06-06 15:52           ` Luben Tuikov
2003-06-06 16:04             ` James Bottomley
2003-06-06 20:51             ` Christoph Hellwig
2003-06-06 23:27               ` Luben Tuikov
2003-06-06 23:43                 ` James Bottomley
2003-06-07  5:20                   ` Luben Tuikov
2003-06-06 20:23         ` Mike Anderson
2003-06-06 20:52           ` Christoph Hellwig
2003-06-10  0:00           ` Mike Anderson
2003-06-06 20:49         ` Christoph Hellwig
2003-06-06 23:21           ` Luben Tuikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox