Re: [PATCH 2/2] block: Avoid deadlocks with bio allocation bystacking drivers
From: Muthu Kumar
Date: Tue Sep 11 2012 - 14:36:22 EST
Kent,
On Mon, Sep 10, 2012 at 2:56 PM, Kent Overstreet <koverstreet@xxxxxxxxxx> wrote:
..
<snip>
..
>
> +static void bio_alloc_rescue(struct work_struct *work)
> +{
> + struct bio_set *bs = container_of(work, struct bio_set, rescue_work);
> + struct bio *bio;
> +
> + while (1) {
> + spin_lock(&bs->rescue_lock);
> + bio = bio_list_pop(&bs->rescue_list);
> + spin_unlock(&bs->rescue_lock);
> +
> + if (!bio)
> + break;
> +
> + generic_make_request(bio);
> + }
> +}
> +
> +static void punt_bios_to_rescuer(struct bio_set *bs)
> +{
> + struct bio_list punt, nopunt;
> + struct bio *bio;
> +
> + /*
> + * In order to guarantee forward progress we must punt only bios that
> + * were allocated from this bio_set; otherwise, if there was a bio on
> + * there for a stacking driver higher up in the stack, processing it
> + * could require allocating bios from this bio_set, and doing that from
> + * our own rescuer would be bad.
> + *
> + * Since bio lists are singly linked, pop them all instead of trying to
> + * remove from the middle of the list:
> + */
> +
> + bio_list_init(&punt);
> + bio_list_init(&nopunt);
> +
> + while ((bio = bio_list_pop(current->bio_list)))
> + bio_list_add(bio->bi_pool == bs ? &punt : &nopunt, bio);
> +
> + *current->bio_list = nopunt;
> +
> + spin_lock(&bs->rescue_lock);
> + bio_list_merge(&bs->rescue_list, &punt);
> + spin_unlock(&bs->rescue_lock);
> +
> + queue_work(bs->rescue_workqueue, &bs->rescue_work);
> +}
Does this preserve the CPU from which the bio was submitted
originally. Not familiar with cmwq, may be Tejun can clarify.
Tejun - the question is, do we honor the rq_affinity with the above
rescue worker implementation?
Regards,
Muthu
--
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/