Skip to content

Commit

Permalink
[PATCH] block: CFQ refcounting fix
Browse files Browse the repository at this point in the history
I ran across a memory leak related to the cfq scheduler. The cfq
init function increments the refcnt of the associated request_queue.

This refcount gets decremented in cfq's exit function. Since blk_cleanup_queue
only calls the elevator exit function when its refcnt goes to zero, the
request_q never gets cleaned up. It didn't look like other io schedulers were
incrementing this refcnt, so I removed the refcnt increment and it fixed the
memory leak for me.

To reproduce the problem, simply use cfq and use the scsi_host scan sysfs
attribute to scan "- - -" repeatedly on a scsi host and watch the memory
vanish.

Signed-off-by: Brian King <brking@us.ibm.com>
Acked-by: Jens Axboe <axboe@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Brian King authored and Linus Torvalds committed Sep 7, 2005
1 parent 49e31cb commit 38f1852
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions drivers/block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -2260,8 +2260,6 @@ static void cfq_put_cfqd(struct cfq_data *cfqd)
if (!atomic_dec_and_test(&cfqd->ref))
return;

blk_put_queue(q);

cfq_shutdown_timer_wq(cfqd);
q->elevator->elevator_data = NULL;

Expand Down Expand Up @@ -2318,7 +2316,6 @@ static int cfq_init_queue(request_queue_t *q, elevator_t *e)
e->elevator_data = cfqd;

cfqd->queue = q;
atomic_inc(&q->refcnt);

cfqd->max_queued = q->nr_requests / 4;
q->nr_batching = cfq_queued;
Expand Down

0 comments on commit 38f1852

Please sign in to comment.