From: Shaohua Li <shaohua.li@intel.com>
To: lkml <linux-kernel@vger.kernel.org>, linux-scsi@vger.kernel.org
Cc: JBottomley@Parallels.com, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@infradead.org>, Ted Ts'o <tytso@mit.edu>,
"Wu, Fengguang" <fengguang.wu@intel.com>,
"Darrick J. Wong" <djwong@us.ibm.com>
Subject: [patch 2/2]scsi: changed sdev order in starved list only when it dispatches requests
Date: Thu, 22 Dec 2011 11:10:15 +0800 [thread overview]
Message-ID: <1324523415.22361.472.camel@sli10-conroe> (raw)
The sdev is deleted from starved list and then try to dispatch from this
device. It's quite possible the sdev can't eventually dispatch a request,
then the sdev will be in starved list tail. This isn't fair.
With below patch, we move the sdev to starved list tail only after it
dispatched a request. If the sdev doesn't have request queued, it will
be deleted from starved list. In this way, if the sdev doesn't dispatch
request, its order in starved list will not be changed.
Signed-off-by: Shaohua Li <shaohua.li@intel.com>
---
drivers/scsi/scsi_lib.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
Index: linux/drivers/scsi/scsi_lib.c
===================================================================
--- linux.orig/drivers/scsi/scsi_lib.c 2011-12-22 09:36:54.000000000 +0800
+++ linux/drivers/scsi/scsi_lib.c 2011-12-22 09:42:06.000000000 +0800
@@ -436,7 +436,6 @@ static void scsi_run_queue(struct reques
if (!head_sdev)
head_sdev = sdev;
- list_del_init(&sdev->starved_entry);
if (scsi_target_is_busy(scsi_target(sdev))) {
list_move_tail(&sdev->starved_entry,
&shost->starved_list);
@@ -1329,9 +1328,6 @@ static inline int scsi_target_queue_read
return 0;
}
- /* We're OK to process the command, so we can't be starved */
- if (!list_empty(&sdev->starved_entry))
- list_del_init(&sdev->starved_entry);
return 1;
}
@@ -1366,10 +1362,6 @@ static inline int scsi_host_queue_ready(
return 0;
}
- /* We're OK to process the command, so we can't be starved */
- if (!list_empty(&sdev->starved_entry))
- list_del_init(&sdev->starved_entry);
-
return 1;
}
@@ -1497,6 +1489,7 @@ static void scsi_request_fn(struct reque
struct Scsi_Host *shost;
struct scsi_cmnd *cmd;
struct request *req;
+ bool empty_queue = false;
if (!sdev) {
while ((req = blk_peek_request(q)) != NULL)
@@ -1575,6 +1568,11 @@ static void scsi_request_fn(struct reque
scsi_target(sdev)->target_busy++;
shost->host_busy++;
+ /* dispatched one requests, move it to tail */
+ if (!list_empty(&sdev->starved_entry))
+ list_move_tail(&sdev->starved_entry,
+ &shost->starved_list);
+
/*
* XXX(hch): This is rather suboptimal, scsi_dispatch_cmd will
* take the lock again.
@@ -1596,6 +1594,7 @@ static void scsi_request_fn(struct reque
goto out_delay;
}
+ empty_queue = true;
goto out;
not_ready:
@@ -1618,7 +1617,15 @@ out_delay:
out:
/* must be careful here...if we trigger the ->remove() function
* we cannot be holding the q lock */
- spin_unlock_irq(q->queue_lock);
+ spin_unlock(q->queue_lock);
+
+ if (empty_queue) {
+ spin_lock(shost->host_lock);
+ list_del_init(&sdev->starved_entry);
+ spin_unlock_irq(shost->host_lock);
+ } else
+ local_irq_disable();
+
put_device(&sdev->sdev_gendev);
spin_lock_irq(q->queue_lock);
}
reply other threads:[~2011-12-22 2:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1324523415.22361.472.camel@sli10-conroe \
--to=shaohua.li@intel.com \
--cc=JBottomley@Parallels.com \
--cc=axboe@kernel.dk \
--cc=djwong@us.ibm.com \
--cc=fengguang.wu@intel.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox