All of lore.kernel.org
 help / color / mirror / Atom feed
* RE: [Patch] Fix Suspend I/O block/unblock patch
@ 2004-10-16 21:59 James.Smart
  2004-10-16 23:13 ` James Bottomley
  0 siblings, 1 reply; 4+ messages in thread
From: James.Smart @ 2004-10-16 21:59 UTC (permalink / raw)
  To: James.Bottomley; +Cc: linux-scsi

> Could you give an example of this problem?  If there's a demonstrable
> issue with device_for_each_child(), we can probably persuade Greg to
> alter it.

Here's the stack trace that was giving us headaches...

Oct 11 10:04:37 daffy kernel: Debug: sleeping function called from invalid context at include/linux/rwsem.h:43
Oct 11 10:04:37 daffy kernel: in_atomic():1, irqs_disabled():0
Oct 11 10:04:37 daffy kernel:  [<c0122f15>] __might_sleep+0x95/0xb0
Oct 11 10:04:37 daffy kernel:  [<f8834600>] fc_timeout_blocked_tgt+0x0/0x40 [scsi_transport_fc]
Oct 11 10:04:37 daffy kernel:  [<c0230516>] device_for_each_child+0x26/0x80
Oct 11 10:04:37 daffy kernel:  [<f88345f0>] fc_device_unblock+0x0/0x10 [scsi_transport_fc]
Oct 11 10:04:37 daffy kernel:  [<f8834600>] fc_timeout_blocked_tgt+0x0/0x40 [scsi_transport_fc]
Oct 11 10:04:38 daffy kernel:  [<c012e2f9>] run_timer_softirq+0xd9/0x170
Oct 11 10:04:38 daffy kernel:  [<c012a262>] __do_softirq+0x62/0xe0
Oct 11 10:04:38 daffy kernel:  [<c012a30d>] do_softirq+0x2d/0x40
Oct 11 10:04:38 daffy kernel:  [<c011ac3a>] smp_apic_timer_interrupt+0xfa/0x110
Oct 11 10:04:38 daffy kernel:  [<c0107a6e>] apic_timer_interrupt+0x1a/0x20
Oct 11 10:04:38 daffy kernel:  [<c0105030>] default_idle+0x0/0x40
Oct 11 10:04:38 daffy kernel:  [<c0105059>] default_idle+0x29/0x40
Oct 11 10:04:38 daffy kernel:  [<c01050e4>] cpu_idle+0x34/0x50
Oct 11 10:04:38 daffy kernel:  target207:0:2: blocked target time out: target resuming


-- James S

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [Patch] Fix Suspend I/O block/unblock patch
@ 2004-10-14 14:31 James.Smart
  2004-10-16 16:39 ` James Bottomley
  0 siblings, 1 reply; 4+ messages in thread
From: James.Smart @ 2004-10-14 14:31 UTC (permalink / raw)
  To: linux-scsi

In further testing of the fc block/unblock patch, the recommendation to use device_for_each_child() instead of shost_for_each_device() in the target functions was not a good one. The calling sequences on the unblock path, which may eventually block, are not good for device_for_each_child(), which takes and holds a semaphore.

This patch reverts to using shost_for_each_device(), which takes the proper locks and performs ref counting. Although the block portion doesn't encounter the problem, it too was converted for the sake of consistency.  The patch also makes one other minor change - allowing an offline state change to occur if blocked.

-- James


This patch is specific to the scsi-target-2.6 bitkeeper tree.

diff -uNr scsi-target-2.6/drivers/scsi/scsi_lib.c scsi-target-2.6.patch/drivers/scsi/scsi_lib.c
--- scsi-target-2.6/drivers/scsi/scsi_lib.c	2004-10-14 08:26:13.776167096 -0400
+++ scsi-target-2.6.patch/drivers/scsi/scsi_lib.c	2004-10-14 08:26:13.778166792 -0400
@@ -1664,6 +1664,7 @@
 		case SDEV_CREATED:
 		case SDEV_RUNNING:
 		case SDEV_QUIESCE:
+		case SDEV_BLOCK:
 			break;
 		default:
 			goto illegal;
diff -uNr scsi-target-2.6/drivers/scsi/scsi_transport_fc.c scsi-target-2.6.patch/drivers/scsi/scsi_transport_fc.c
--- scsi-target-2.6/drivers/scsi/scsi_transport_fc.c	2004-10-14 08:26:13.783166032 -0400
+++ scsi-target-2.6.patch/drivers/scsi/scsi_transport_fc.c	2004-10-14 08:26:13.785165728 -0400
@@ -325,29 +325,6 @@
 EXPORT_SYMBOL(fc_release_transport);
 
 
-
-/**
- * fc_device_block - called by target functions to block a scsi device
- * @dev:	scsi device
- * @data:	unused
- **/
-static int fc_device_block(struct device *dev, void *data)
-{
-	scsi_internal_device_block(to_scsi_device(dev));
-	return 0;
-}
-
-/**
- * fc_device_unblock - called by target functions to unblock a scsi device
- * @dev:	scsi device
- * @data:	unused
- **/
-static int fc_device_unblock(struct device *dev, void *data)
-{
-	scsi_internal_device_unblock(to_scsi_device(dev));
-	return 0;
-}
-
 /**
  * fc_timeout_blocked_tgt - Timeout handler for blocked scsi targets
  *			 that fail to recover in the alloted time.
@@ -356,6 +333,8 @@
 static void fc_timeout_blocked_tgt(unsigned long data)
 {
 	struct scsi_target *starget = (struct scsi_target *)data;
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct scsi_device *sdev;
 
 	dev_printk(KERN_ERR, &starget->dev, 
 		"blocked target time out: target resuming\n");
@@ -365,7 +344,10 @@
 	 * unblock this device, then IO errors will probably
 	 * result if the host still isn't ready.
 	 */
-	device_for_each_child(&starget->dev, NULL, fc_device_unblock);
+	shost_for_each_device(sdev, shost) {
+		if (sdev->id == starget->id)
+			scsi_internal_device_unblock(sdev);
+	}
 }
 
 /**
@@ -387,13 +369,18 @@
 int
 fc_target_block(struct scsi_target *starget)
 {
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct scsi_device *sdev;
 	int timeout = fc_starget_dev_loss_tmo(starget);
 	struct timer_list *timer = &fc_starget_dev_loss_timer(starget);
 
 	if (timeout < 0 || timeout > SCSI_DEVICE_BLOCK_MAX_TIMEOUT)
 		return -EINVAL;
 
-	device_for_each_child(&starget->dev, NULL, fc_device_block);
+	shost_for_each_device(sdev, shost) {
+		if (sdev->id == starget->id)
+			scsi_internal_device_block(sdev);
+	}
 
 	/* The scsi lld blocks this target for the timeout period only. */
 	timer->data = (unsigned long)starget;
@@ -419,6 +406,9 @@
 void
 fc_target_unblock(struct scsi_target *starget)
 {
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct scsi_device *sdev;
+
 	/* 
 	 * Stop the target timer first. Take no action on the del_timer
 	 * failure as the state machine state change will validate the
@@ -426,7 +416,10 @@
 	 */
 	del_timer_sync(&fc_starget_dev_loss_timer(starget));
 
-	device_for_each_child(&starget->dev, NULL, fc_device_unblock);
+	shost_for_each_device(sdev, shost) {
+		if (sdev->id == starget->id)
+			scsi_internal_device_unblock(sdev);
+	}
 }
 EXPORT_SYMBOL(fc_target_unblock);
 

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

end of thread, other threads:[~2004-10-16 23:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-16 21:59 [Patch] Fix Suspend I/O block/unblock patch James.Smart
2004-10-16 23:13 ` James Bottomley
  -- strict thread matches above, loose matches on Subject: below --
2004-10-14 14:31 James.Smart
2004-10-16 16:39 ` James Bottomley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.