linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ide: Bug fixes and improvements in the disk head parking code
@ 2008-10-11 17:37 Elias Oltmanns
  2008-10-13 19:04 ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 2+ messages in thread
From: Elias Oltmanns @ 2008-10-11 17:37 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-ide

Fix a memory leak due to a missing blk_put_request() in
issue_park_cmd(). Additionally, we should plug the queue when enqueueing
the unpark request because there is no guarantee that the park timeout
has not expired by then. Even though the chance for that to happen is
very slim, the request might end up hanging in the queue until the next
I/O operation is queued up. While at it, clean up the code a little:
- make issue_park_cmd() a function of type void since nobody cares for
  the return value anyway;
- use blk_start_queueing() instead of __blk_run_queue() since we don't
  have to worry about recursion;
- remove a superfluous pointer deference in task_no_data_intr().

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
---
Feel free to merge with original patch if Linus hasn't pulled your tree
yet.

 ide-park.c     |   11 ++++++-----
 ide-taskfile.c |    2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c
index 02d7e35..03b00e5 100644
--- a/drivers/ide/ide-park.c
+++ b/drivers/ide/ide-park.c
@@ -5,7 +5,7 @@
 
 DECLARE_WAIT_QUEUE_HEAD(ide_park_wq);
 
-static int issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
+static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
 {
 	struct request_queue *q = drive->queue;
 	struct request *rq;
@@ -24,10 +24,10 @@ static int issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
 		    del_timer(&hwgroup->timer)) {
 			hwgroup->sleeping = 0;
 			hwgroup->busy = 0;
-			__blk_run_queue(q);
+			blk_start_queueing(q);
 		}
 		spin_unlock_irq(&ide_lock);
-		return 0;
+		return;
 	}
 	spin_unlock_irq(&ide_lock);
 
@@ -37,6 +37,7 @@ static int issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
 	rq->cmd_type = REQ_TYPE_SPECIAL;
 	rq->special = &timeout;
 	rc = blk_execute_rq(q, NULL, rq, 1);
+	blk_put_request(rq);
 	if (rc)
 		goto out;
 
@@ -51,10 +52,10 @@ static int issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
 	rq->cmd[0] = REQ_UNPARK_HEADS;
 	rq->cmd_len = 1;
 	rq->cmd_type = REQ_TYPE_SPECIAL;
-	elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0);
+	elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 1);
 
 out:
-	return rc;
+	return;
 }
 
 ssize_t ide_park_show(struct device *dev, struct device_attribute *attr,
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 480c97f..bf4fb9d 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -153,7 +153,7 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *drive)
 	if (!custom)
 		ide_end_drive_cmd(drive, stat, ide_read_error(drive));
 	else if (tf->command == ATA_CMD_IDLEIMMEDIATE) {
-		drive->hwif->tp_ops->tf_read(drive, task);
+		hwif->tp_ops->tf_read(drive, task);
 		if (tf->lbal != 0xc4) {
 			printk(KERN_ERR "%s: head unload failed!\n",
 			       drive->name);

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

end of thread, other threads:[~2008-10-13 20:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-11 17:37 ide: Bug fixes and improvements in the disk head parking code Elias Oltmanns
2008-10-13 19:04 ` Bartlomiej Zolnierkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).