Commit 547b50a1 authored by Omar Sandoval's avatar Omar Sandoval Committed by Jens Axboe

parport/pcd: stop sharing request queue across multiple gendisks

Compile-tested only.

Cc: Tim Waugh <tim@cyberelk.net>
Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent eaf487ca
......@@ -300,6 +300,11 @@ static void pcd_init_units(void)
struct gendisk *disk = alloc_disk(1);
if (!disk)
continue;
disk->queue = blk_init_queue(do_pcd_request, &pcd_lock);
if (!disk->queue) {
put_disk(disk);
continue;
}
cd->disk = disk;
cd->pi = &cd->pia;
cd->present = 0;
......@@ -735,18 +740,36 @@ static int pcd_detect(void)
}
/* I/O request processing */
static struct request_queue *pcd_queue;
static int pcd_queue;
static int set_next_request(void)
{
struct pcd_unit *cd;
struct request_queue *q;
int old_pos = pcd_queue;
do {
cd = &pcd[pcd_queue];
q = cd->present ? cd->disk->queue : NULL;
if (++pcd_queue == PCD_UNITS)
pcd_queue = 0;
if (q) {
pcd_req = blk_fetch_request(q);
if (pcd_req)
break;
}
} while (pcd_queue != old_pos);
return pcd_req != NULL;
}
static void do_pcd_request(struct request_queue * q)
static void pcd_request(void)
{
if (pcd_busy)
return;
while (1) {
if (!pcd_req) {
pcd_req = blk_fetch_request(q);
if (!pcd_req)
if (!pcd_req && !set_next_request())
return;
}
if (rq_data_dir(pcd_req) == READ) {
struct pcd_unit *cd = pcd_req->rq_disk->private_data;
......@@ -766,6 +789,11 @@ static void do_pcd_request(struct request_queue * q)
}
}
static void do_pcd_request(struct request_queue *q)
{
pcd_request();
}
static inline void next_request(int err)
{
unsigned long saved_flags;
......@@ -774,7 +802,7 @@ static inline void next_request(int err)
if (!__blk_end_request_cur(pcd_req, err))
pcd_req = NULL;
pcd_busy = 0;
do_pcd_request(pcd_queue);
pcd_request();
spin_unlock_irqrestore(&pcd_lock, saved_flags);
}
......@@ -849,7 +877,7 @@ static void do_pcd_read_drq(void)
do_pcd_read();
spin_lock_irqsave(&pcd_lock, saved_flags);
do_pcd_request(pcd_queue);
pcd_request();
spin_unlock_irqrestore(&pcd_lock, saved_flags);
}
......@@ -957,19 +985,10 @@ static int __init pcd_init(void)
return -EBUSY;
}
pcd_queue = blk_init_queue(do_pcd_request, &pcd_lock);
if (!pcd_queue) {
unregister_blkdev(major, name);
for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++)
put_disk(cd->disk);
return -ENOMEM;
}
for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) {
if (cd->present) {
register_cdrom(&cd->info);
cd->disk->private_data = cd;
cd->disk->queue = pcd_queue;
add_disk(cd->disk);
}
}
......@@ -988,9 +1007,9 @@ static void __exit pcd_exit(void)
pi_release(cd->pi);
unregister_cdrom(&cd->info);
}
blk_cleanup_queue(cd->disk->queue);
put_disk(cd->disk);
}
blk_cleanup_queue(pcd_queue);
unregister_blkdev(major, name);
pi_unregister_driver(par_drv);
}
......
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