Skip to content

Commit 3258737

Browse files
tao-guoaxboe
authored andcommitted
umem: fix up unplugging
Fix a regression introduced by 7eaceac ("block: remove per-queue plugging"). In that patch, Jens removed the whole mm_unplug_device() function, which used to be the trigger to make umem start to work. We need to implement unplugging to make umem start to work, or I/O will never be triggered. Signed-off-by: Tao Guo <Tao.Guo@emc.com> Cc: Neil Brown <neilb@suse.de> Cc: Jens Axboe <axboe@kernel.dk> Cc: Shaohua Li <shli@kernel.org> Cc: <stable@vger.kernel.org> Acked-by: NeilBrown <neilb@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 047fe36 commit 3258737

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎drivers/block/umem.c‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,44 @@ static void process_page(unsigned long data)
513513
}
514514
}
515515

516+
struct mm_plug_cb {
517+
struct blk_plug_cb cb;
518+
struct cardinfo *card;
519+
};
520+
521+
static void mm_unplug(struct blk_plug_cb *cb)
522+
{
523+
struct mm_plug_cb *mmcb = container_of(cb, struct mm_plug_cb, cb);
524+
525+
spin_lock_irq(&mmcb->card->lock);
526+
activate(mmcb->card);
527+
spin_unlock_irq(&mmcb->card->lock);
528+
kfree(mmcb);
529+
}
530+
531+
static int mm_check_plugged(struct cardinfo *card)
532+
{
533+
struct blk_plug *plug = current->plug;
534+
struct mm_plug_cb *mmcb;
535+
536+
if (!plug)
537+
return 0;
538+
539+
list_for_each_entry(mmcb, &plug->cb_list, cb.list) {
540+
if (mmcb->cb.callback == mm_unplug && mmcb->card == card)
541+
return 1;
542+
}
543+
/* Not currently on the callback list */
544+
mmcb = kmalloc(sizeof(*mmcb), GFP_ATOMIC);
545+
if (!mmcb)
546+
return 0;
547+
548+
mmcb->card = card;
549+
mmcb->cb.callback = mm_unplug;
550+
list_add(&mmcb->cb.list, &plug->cb_list);
551+
return 1;
552+
}
553+
516554
static void mm_make_request(struct request_queue *q, struct bio *bio)
517555
{
518556
struct cardinfo *card = q->queuedata;
@@ -523,6 +561,8 @@ static void mm_make_request(struct request_queue *q, struct bio *bio)
523561
*card->biotail = bio;
524562
bio->bi_next = NULL;
525563
card->biotail = &bio->bi_next;
564+
if (bio->bi_rw & REQ_SYNC || !mm_check_plugged(card))
565+
activate(card);
526566
spin_unlock_irq(&card->lock);
527567

528568
return;

0 commit comments

Comments
 (0)