Commit 8309f3a8 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] Umem 2 of 2 - Make device plugging work for umem

We embed a request_queue_t in the card structure and so have a separate
one for each card.  This is used for plugging.

Given this embeded request_queue_t, mm_make_request no-longer needs to
make from device number to mddev, but can map from the queue to the card
instead.
parent af8b7bf8
......@@ -129,6 +129,8 @@ struct cardinfo {
*/
struct bio *bio, *currentbio, **biotail;
request_queue_t queue;
struct mm_page {
dma_addr_t page_dma;
struct mm_dma_desc *desc;
......@@ -142,8 +144,6 @@ struct cardinfo {
struct tasklet_struct tasklet;
unsigned int dma_status;
struct tq_struct plug_tq;
struct {
int good;
int warned;
......@@ -293,7 +293,7 @@ static void dump_dmastat(struct cardinfo *card, unsigned int dmastat)
* Whenever IO on the active page completes, the Ready page is activated
* and the ex-Active page is clean out and made Ready.
* Otherwise the Ready page is only activated when it becomes full, or
* when mm_unplug_device is called via run_task_queue(&tq_disk).
* when mm_unplug_device is called via blk_run_queues().
*
* If a request arrives while both pages a full, it is queued, and b_rdev is
* overloaded to record whether it was a read or a write.
......@@ -385,9 +385,11 @@ static inline void reset_page(struct mm_page *page)
static void mm_unplug_device(void *data)
{
struct cardinfo *card = data;
request_queue_t *q = data;
struct cardinfo *card = q->queuedata;
spin_lock_bh(&card->lock);
if (blk_remove_plug(q))
activate(card);
spin_unlock_bh(&card->lock);
}
......@@ -566,8 +568,7 @@ static void process_page(unsigned long data)
*/
static int mm_make_request(request_queue_t *q, struct bio *bio)
{
struct cardinfo *card = &cards[DEVICE_NR(
bio->bi_bdev->bd_dev)];
struct cardinfo *card = q->queuedata;
PRINTK("mm_make_request %ld %d\n", bh->b_rsector, bh->b_size);
/* set uptodate now, and clear it if there are any errors */
......@@ -577,9 +578,9 @@ static int mm_make_request(request_queue_t *q, struct bio *bio)
*card->biotail = bio;
bio->bi_next = NULL;
card->biotail = &bio->bi_next;
blk_plug_device(q);
spin_unlock_bh(&card->lock);
queue_task(&card->plug_tq, &tq_disk);
return 0;
}
......@@ -1066,11 +1067,12 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
card->bio = NULL;
card->biotail = &card->bio;
blk_queue_make_request(&card->queue, mm_make_request);
card->queue.queuedata = card;
card->queue.unplug_fn = mm_unplug_device;
tasklet_init(&card->tasklet, process_page, (unsigned long)card);
card->plug_tq.sync = 0;
card->plug_tq.routine = &mm_unplug_device;
card->plug_tq.data = card;
card->check_batteries = 0;
mem_present = readb(card->csr_remap + MEMCTRLSTATUS_MEMORY);
......@@ -1238,6 +1240,17 @@ static struct pci_driver mm_pci_driver = {
-- mm_init
-----------------------------------------------------------------------------------
*/
static request_queue_t * mm_queue_proc(kdev_t dev)
{
int c = DEVICE_NR(kdev_val(dev));
if (c < MM_MAXCARDS)
return &cards[c].queue;
else
return BLK_DEFAULT_QUEUE(MAJOR_NR);
}
int __init mm_init(void)
{
int retval, i;
......@@ -1277,11 +1290,9 @@ int __init mm_init(void)
mm_gendisk.part = mm_partitions;
mm_gendisk.nr_real = num_cards;
blk_dev[MAJOR_NR].queue = mm_queue_proc;
add_gendisk(&mm_gendisk);
blk_queue_make_request(BLK_DEFAULT_QUEUE(MAJOR_NR),
mm_make_request);
blk_size[MAJOR_NR] = mm_gendisk.sizes;
for (i = 0; i < num_cards; i++) {
register_disk(&mm_gendisk, mk_kdev(MAJOR_NR, i<<MM_SHIFT), MM_SHIFT,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment