Skip to contentSkip to conversation

ide-disk: Fix request requeuing

PATCH Applied Borislav Petkov 2 participants 2 messages Sep 30, 2011 – Oct 3, 2011 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ide-disk: Fix request requeuing

Simon Kirby reported that on his RAID setup with idedisk underneath the box OOMs after a couple of days of runtime. Running with CONFIG_DEBUG_KMEMLEAK pointed to idedisk_prep_fn() which unconditionally allocates an ide_cmd struct. However, ide_requeue_and_plug() can be called more than once per request, either from the request issue or the IRQ handler path and do blk_peek_request() ends up in idedisk_prep_fn() repeatedly, allocating a struct ide_cmd everytime and "forgetting" the previous pointer.

Make sure the code reuses the old allocated chunk.

---
 drivers/ide/ide-disk.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/ide/ide-disk.c +6 -1
index 274798068a54..16f69be820c7 100644
@@ -435,7 +435,12 @@ static int idedisk_prep_fn(struct request_queue *q, struct request *rq)
 	if (!(rq->cmd_flags & REQ_FLUSH))
 		return BLKPREP_OK;
 
-	cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC);
+	if (rq->special) {
+		cmd = rq->special;
+		memset(cmd, 0, sizeof(*cmd));
+	} else {
+		cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC);
+	}
 
 	/* FIXME: map struct ide_taskfile on rq->cmd[] */
 	BUG_ON(cmd == NULL);
Signature · 1 line
1.7.5.3.401.gfb674
Applied
#1 lore raw

From: Borislav Petkov <[email protected]>
Date: Fri, 30 Sep 2011 08:45:32 +0200

Quoted 9 lines

Simon Kirby reported that on his RAID setup with idedisk underneath the box OOMs after a couple of days of runtime. Running with CONFIG_DEBUG_KMEMLEAK pointed to idedisk_prep_fn() which unconditionally allocates an ide_cmd struct. However, ide_requeue_and_plug() can be called more than once per request, either from the request issue or the IRQ handler path and do blk_peek_request() ends up in idedisk_prep_fn() repeatedly, allocating a struct ide_cmd everytime and "forgetting" the previous pointer.

Quoted 7 lines

Make sure the code reuses the old allocated chunk.

Applied, thanks a lot.