On 5/19/09, Matthew Wilcox <matthew@xxxxxx> wrote: > On Tue, May 19, 2009 at 03:04:07PM +0300, saeed bishara wrote: >> I have a system with 4 disks that configured to enter standby >> mode, the power supplier of this system can't drive concurrent >> spin-ups of more than one disk, and it needs the spin-ups to be few >> seconds far from each other. >> I've implemented this feature by adding a semaphore, and in the >> scsi_dispatch_command, the process will wait for that semaphore if the >> disk in standby mode and other disk in a middle of doing spinup. but >> the problem is that sometimes that function is called while in atomic >> context, and waiting to the semaphore is prohibeted. >> how do you guys suggest to block a request which comes in atomic mode? > > Call scsi_queue_insert(cmd, SCSI_MLQUEUE_HOST_BUSY); and return > SCSI_MLQUEUE_HOST_BUSY. The midlayer won't retry the command until > another command finishes. This has the downside that it won't try a > command to the spun-up device until a command has finished either ... > > This is kind of the wrong way to do it though. Are you sending down > commands to standby the device, or are the drives moving to standby > state on their own recognisance? It would be better to block the other > devices. See this code? I'm actually supporting both cases, timer standby and immediate standby. right now, the decision to block a requests is taken when a new command is to be dispatched, the code checks if the disk in standby and another disk is spinning up then the current command is blocked. this makes your first suggestion to use the SCSI_MLQUEUE_HOST_BUSY more easy to implement. but, in that case, as there are no queued commands for that device, how can I trigger the midlayer to resume sending commands for that device? can that be done using scsi_run_queue? > > /* Check to see if the scsi lld made this device blocked. */ > if (unlikely(scsi_device_blocked(cmd->device))) { > /* > * in blocked state, the command is just put back on > * the device queue. The suspend state has already > * blocked the queue so future requests should not > * occur until the device transitions out of the > * suspend state. > */ > > scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY); > > SCSI_LOG_MLQUEUE(3, printk("queuecommand : device blocked > \n")); > > /* > * NOTE: rtn is still zero here because we don't need the > * queue to be plugged on return (it's already stopped) > */ > goto out; > } > > You need to make the drives go into this state (by calling > scsi_internal_device_block()) when they suspend, if you can tell when > they suspend. > > -- > Matthew Wilcox Intel Open Source Technology Centre > "Bill, look, we understand that you're interested in selling us this > operating system, but compare it to ours. We can't possibly take such > a retrograde step." > -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html