Re: [PATCH] umem: fix up unplugging.

From: Tao Guo
Date: Wed Apr 04 2012 - 18:20:33 EST


Hi Andrew,

Thanks for your reply.

Yes, without this patch the umem driver just doesn't work.
It is a bug introduced by commit 7eaceaccab5f40bbfda044629a6298616aeaed50.
In that patch, Jens removed the whole mm_unplug_device() function,
which used to be
the trigger to make umem start to work.

Thanks,
-Tao


On Wed, Apr 4, 2012 at 2:46 PM, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Fri, 30 Dec 2011 09:17:31 -0500
>
> (Long delay...)
>
> Tao Guo <glorioustao@xxxxxxxxx> wrote:
>
>> We need to implement unplugging to make umem start to work, or I/O
>> will never be triggered.
>>
>
> I take it from this that umem simply doesn't work at all?
>
> If so, for how long has this been the case and should we just delete the
> thing?
>
>>
>> --- a/drivers/block/umem.c
>> +++ b/drivers/block/umem.c
>> @@ -111,7 +111,8 @@ struct cardinfo {
>>    int       current_idx;
>>    sector_t    Âcurrent_sector;
>>
>> - Â Â struct request_queue *queue;
>> +   struct request_queue  Â*queue;
>> +   struct blk_plug_cb   Âplug_cb;
>>
>> Â Â Â struct mm_page {
>>        dma_addr_t       Âpage_dma;
>> @@ -513,6 +514,33 @@ static void process_page(unsigned long data)
>> Â Â Â }
>> Â}
>>
>> +static void mm_unplug(struct blk_plug_cb *cb)
>> +{
>> + Â Â struct cardinfo *card = container_of(cb, struct cardinfo, plug_cb);
>> +
>> + Â Â spin_lock_irq(&card->lock);
>> + Â Â activate(card);
>> + Â Â spin_unlock_irq(&card->lock);
>> +}
>> +
>> +int mm_check_plugged(struct cardinfo *card)
>> +{
>> + Â Â struct blk_plug *plug = current->plug;
>> + Â Â struct cardinfo *c;
>> +
>> + Â Â if (!plug)
>> + Â Â Â Â Â Â return 0;
>> +
>> + Â Â list_for_each_entry(c, &plug->cb_list, plug_cb.list) {
>> + Â Â Â Â Â Â if (c == card)
>> + Â Â Â Â Â Â Â Â Â Â return 1;
>> + Â Â }
>> +
>> + Â Â /* set up unplug callback */
>> + Â Â list_add(&card->plug_cb.list, &plug->cb_list);
>> + Â Â return 1;
>> +}
>> +
>> Âstatic void mm_make_request(struct request_queue *q, struct bio *bio)
>> Â{
>> Â Â Â struct cardinfo *card = q->queuedata;
>> @@ -523,6 +551,8 @@ static void mm_make_request(struct request_queue *q, struct bio *bio)
>> Â Â Â *card->biotail = bio;
>> Â Â Â bio->bi_next = NULL;
>> Â Â Â card->biotail = &bio->bi_next;
>> + Â Â if (bio->bi_rw & REQ_SYNC || !mm_check_plugged(card))
>> + Â Â Â Â Â Â activate(card);
>> Â Â Â spin_unlock_irq(&card->lock);
>>
>> Â Â Â return;
>> @@ -884,6 +914,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev,
>> Â Â Â blk_queue_make_request(card->queue, mm_make_request);
>> Â Â Â card->queue->queue_lock = &card->lock;
>> Â Â Â card->queue->queuedata = card;
>> + Â Â card->plug_cb.callback = mm_unplug;
>>
>> Â Â Â tasklet_init(&card->tasklet, process_page, (unsigned long)card);
>
--
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/