* [PATCH] ide-disk: Fix request requeuing
@ 2011-09-30 6:45 Borislav Petkov
2011-10-03 18:28 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Borislav Petkov @ 2011-09-30 6:45 UTC (permalink / raw)
To: linux-ide; +Cc: Simon Kirby, David Miller, Borislav Petkov
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.
Reported-and-tested-by: Simon Kirby <sim@hostway.ca>
Cc: <stable@kernel.org> [ 39.x, 3.0.x ]
Link: http://marc.info/?l=linux-kernel&m=131667641517919
Link: http://lkml.kernel.org/r/20110922072643.GA27232@hostway.ca
Signed-off-by: Borislav Petkov <bp@alien8.de>
---
drivers/ide/ide-disk.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 274798068a54..16f69be820c7 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -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);
--
1.7.5.3.401.gfb674
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ide-disk: Fix request requeuing
2011-09-30 6:45 [PATCH] ide-disk: Fix request requeuing Borislav Petkov
@ 2011-10-03 18:28 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-10-03 18:28 UTC (permalink / raw)
To: bp; +Cc: linux-ide, sim
From: Borislav Petkov <bp@alien8.de>
Date: Fri, 30 Sep 2011 08:45:32 +0200
> 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.
>
> Reported-and-tested-by: Simon Kirby <sim@hostway.ca>
> Cc: <stable@kernel.org> [ 39.x, 3.0.x ]
> Link: http://marc.info/?l=linux-kernel&m=131667641517919
> Link: http://lkml.kernel.org/r/20110922072643.GA27232@hostway.ca
> Signed-off-by: Borislav Petkov <bp@alien8.de>
Applied, thanks a lot.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-10-03 18:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-30 6:45 [PATCH] ide-disk: Fix request requeuing Borislav Petkov
2011-10-03 18:28 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.