Skip to content

Commit

Permalink
parport/pcd: stop sharing request queue across multiple gendisks
Browse files Browse the repository at this point in the history
Compile-tested only.

Cc: Tim Waugh <[email protected]>
Signed-off-by: Omar Sandoval <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
osandov authored and axboe committed Mar 28, 2017
1 parent eaf487c commit 547b50a
Showing 1 changed file with 38 additions and 19 deletions.
57 changes: 38 additions & 19 deletions drivers/block/paride/pcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
return;
}
if (!pcd_req && !set_next_request())
return;

if (rq_data_dir(pcd_req) == READ) {
struct pcd_unit *cd = pcd_req->rq_disk->private_data;
Expand All @@ -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;
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 547b50a

Please sign in to comment.