Re: [PATCH]cfq-iosched: fix an oops caused by slab leak

From: Jeff Moyer
Date: Wed May 26 2010 - 15:43:12 EST


Shaohua Li <shaohua.li@xxxxxxxxx> writes:

> I got below oops when unloading cfq-iosched. Considering scenario:
> queue A merge to B, C merge to D and B will be merged to D. Before B is merged
> to D, we do split B. We should put B's reference for D.
[...]
> Signed-off-by: Shaohua Li <shaohua.li@xxxxxxxxx>
>
> diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
> index ed897b5..855fd5f 100644
> --- a/block/cfq-iosched.c
> +++ b/block/cfq-iosched.c
> @@ -2537,15 +2537,10 @@ static void cfq_free_io_context(struct io_context *ioc)
> __call_for_each_cic(ioc, cic_free_func);
> }
>
> -static void cfq_exit_cfqq(struct cfq_data *cfqd, struct cfq_queue *cfqq)
> +static void cfq_put_cooperator(struct cfq_queue *cfqq)
> {
> struct cfq_queue *__cfqq, *next;
>
> - if (unlikely(cfqq == cfqd->active_queue)) {
> - __cfq_slice_expired(cfqd, cfqq, 0);
> - cfq_schedule_dispatch(cfqd);
> - }
> -
> /*
> * If this queue was scheduled to merge with another queue, be
> * sure to drop the reference taken on that queue (and others in
> @@ -2561,6 +2556,16 @@ static void cfq_exit_cfqq(struct cfq_data *cfqd, struct cfq_queue *cfqq)
> cfq_put_queue(__cfqq);
> __cfqq = next;
> }
> +}
> +
> +static void cfq_exit_cfqq(struct cfq_data *cfqd, struct cfq_queue *cfqq)
> +{
> + if (unlikely(cfqq == cfqd->active_queue)) {
> + __cfq_slice_expired(cfqd, cfqq, 0);
> + cfq_schedule_dispatch(cfqd);
> + }
> +
> + cfq_put_cooperator(cfqq);
>
> cfq_put_queue(cfqq);
> }
> @@ -3516,6 +3521,9 @@ split_cfqq(struct cfq_io_context *cic, struct cfq_queue *cfqq)
> }
>
> cic_set_cfqq(cic, NULL, 1);
> +
> + cfq_put_cooperator(cfqq);
> +
> cfq_put_queue(cfqq);
> return NULL;
> }

Reviewed-by: Jeff Moyer <jmoyer@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/