Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 311590
b: refs/heads/master
c: 3258737
h: refs/heads/master
v: v3
  • Loading branch information
Tao Guo authored and Jens Axboe committed Jun 13, 2012
1 parent 68c09a2 commit 5095b8d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 047fe3605235888f3ebcda0c728cb31937eadfe6
refs/heads/master: 32587371ad3db2f9d335de10dbd8cffd4fff5669
40 changes: 40 additions & 0 deletions trunk/drivers/block/umem.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,44 @@ static void process_page(unsigned long data)
}
}

struct mm_plug_cb {
struct blk_plug_cb cb;
struct cardinfo *card;
};

static void mm_unplug(struct blk_plug_cb *cb)
{
struct mm_plug_cb *mmcb = container_of(cb, struct mm_plug_cb, cb);

spin_lock_irq(&mmcb->card->lock);
activate(mmcb->card);
spin_unlock_irq(&mmcb->card->lock);
kfree(mmcb);
}

static int mm_check_plugged(struct cardinfo *card)
{
struct blk_plug *plug = current->plug;
struct mm_plug_cb *mmcb;

if (!plug)
return 0;

list_for_each_entry(mmcb, &plug->cb_list, cb.list) {
if (mmcb->cb.callback == mm_unplug && mmcb->card == card)
return 1;
}
/* Not currently on the callback list */
mmcb = kmalloc(sizeof(*mmcb), GFP_ATOMIC);
if (!mmcb)
return 0;

mmcb->card = card;
mmcb->cb.callback = mm_unplug;
list_add(&mmcb->cb.list, &plug->cb_list);
return 1;
}

static void mm_make_request(struct request_queue *q, struct bio *bio)
{
struct cardinfo *card = q->queuedata;
Expand All @@ -523,6 +561,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;
Expand Down

0 comments on commit 5095b8d

Please sign in to comment.