From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757266AbYILOnb (ORCPT ); Fri, 12 Sep 2008 10:43:31 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753532AbYILOm6 (ORCPT ); Fri, 12 Sep 2008 10:42:58 -0400 Received: from mx1.redhat.com ([66.187.233.31]:44802 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757133AbYILOm5 (ORCPT ); Fri, 12 Sep 2008 10:42:57 -0400 Date: Fri, 12 Sep 2008 10:43:06 -0400 (EDT) Message-Id: <20080912.104306.11596001.k-ueda@ct.jp.nec.com> To: jens.axboe@oracle.com, agk@redhat.com, James.Bottomley@HansenPartnership.com Cc: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, dm-devel@redhat.com, j-nomura@ce.jp.nec.com, k-ueda@ct.jp.nec.com Subject: [PATCH 04/13] scsi: exports busy status From: Kiyoshi Ueda In-Reply-To: <20080912.103814.74754581.k-ueda@ct.jp.nec.com> References: <20080912.103814.74754581.k-ueda@ct.jp.nec.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch change scsi mid-layer to export its busy status. Not set the busy flag, when scsi can't dispatch I/Os anymore and needs to kill I/Os. Otherwise, request stacking drivers may hold requests forever. Signed-off-by: Kiyoshi Ueda Signed-off-by: Jun'ichi Nomura Cc: James Bottomley --- drivers/scsi/scsi.c | 4 ++-- drivers/scsi/scsi_lib.c | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) Index: 2.6.27-rc6/drivers/scsi/scsi_lib.c =================================================================== --- 2.6.27-rc6.orig/drivers/scsi/scsi_lib.c +++ 2.6.27-rc6/drivers/scsi/scsi_lib.c @@ -459,17 +459,30 @@ static void scsi_init_cmd_errh(struct sc void scsi_device_unbusy(struct scsi_device *sdev) { + int host_congested; struct Scsi_Host *shost = sdev->host; unsigned long flags; spin_lock_irqsave(shost->host_lock, flags); shost->host_busy--; + if ((shost->can_queue > 0 && shost->host_busy >= shost->can_queue) || + shost->host_blocked || shost->host_self_blocked || + scsi_host_in_recovery(shost)) + host_congested = 1; + else + host_congested = 0; + if (unlikely(scsi_host_in_recovery(shost) && (shost->host_failed || shost->host_eh_scheduled))) scsi_eh_wakeup(shost); spin_unlock(shost->host_lock); + spin_lock(sdev->request_queue->queue_lock); sdev->device_busy--; + if (bdi_lld_congested(&sdev->request_queue->backing_dev_info) && + !host_congested && !(sdev->device_busy >= sdev->queue_depth) && + !sdev->device_blocked) + clear_bdi_lld_congested(&sdev->request_queue->backing_dev_info); spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); } @@ -1495,9 +1508,14 @@ static void scsi_request_fn(struct reque * accept it. */ req = elv_next_request(q); - if (!req || !scsi_dev_queue_ready(q, sdev)) + if (!req) break; + if (!scsi_dev_queue_ready(q, sdev)) { + set_bdi_lld_congested(&q->backing_dev_info); + break; + } + if (unlikely(!scsi_device_online(sdev))) { sdev_printk(KERN_ERR, sdev, "rejecting I/O to offline device\n"); @@ -1568,6 +1586,8 @@ static void scsi_request_fn(struct reque rtn = scsi_dispatch_cmd(cmd); spin_lock_irq(q->queue_lock); if(rtn) { + set_bdi_lld_congested(&q->backing_dev_info); + /* we're refusing the command; because of * the way locks get dropped, we need to * check here if plugging is required */ @@ -1592,6 +1612,7 @@ static void scsi_request_fn(struct reque * later time. */ spin_lock_irq(q->queue_lock); + set_bdi_lld_congested(&q->backing_dev_info); blk_requeue_request(q, req); sdev->device_busy--; if(sdev->device_busy == 0) Index: 2.6.27-rc6/drivers/scsi/scsi.c =================================================================== --- 2.6.27-rc6.orig/drivers/scsi/scsi.c +++ 2.6.27-rc6/drivers/scsi/scsi.c @@ -861,8 +861,6 @@ void scsi_finish_command(struct scsi_cmn struct scsi_driver *drv; unsigned int good_bytes; - scsi_device_unbusy(sdev); - /* * Clear the flags which say that the device/host is no longer * capable of accepting new commands. These are set in scsi_queue.c @@ -874,6 +872,8 @@ void scsi_finish_command(struct scsi_cmn shost->host_blocked = 0; sdev->device_blocked = 0; + scsi_device_unbusy(sdev); + /* * If we have valid sense information, then some kind of recovery * must have taken place. Make a note of this.