diff options
author | Omar Sandoval <osandov@fb.com> | 2017-03-28 02:28:47 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2017-03-28 17:06:58 -0400 |
commit | 8b0c441e15a3e7877da4bb11fe15cf8359fd96b2 (patch) | |
tree | fcf12c43ef750b178b88305016433384080e8ee5 /drivers/sbus | |
parent | 103db8b2dfa5dad182d2e5a9cc96b13646634c17 (diff) |
jsflash: stop sharing request queue across multiple gendisks
Compile-tested only (by hacking it to compile on x86).
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/sbus')
-rw-r--r-- | drivers/sbus/char/jsflash.c | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c index 6ff61dad5e21..62fed9dc893e 100644 --- a/drivers/sbus/char/jsflash.c +++ b/drivers/sbus/char/jsflash.c | |||
@@ -183,11 +183,33 @@ static void jsfd_read(char *buf, unsigned long p, size_t togo) { | |||
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | static void jsfd_do_request(struct request_queue *q) | 186 | static int jsfd_queue; |
187 | |||
188 | static struct request *jsfd_next_request(void) | ||
189 | { | ||
190 | struct request_queue *q; | ||
191 | struct request *rq; | ||
192 | int old_pos = jsfd_queue; | ||
193 | |||
194 | do { | ||
195 | q = jsfd_disk[jsfd_queue]->queue; | ||
196 | if (++jsfd_queue == JSF_MAX) | ||
197 | jsfd_queue = 0; | ||
198 | if (q) { | ||
199 | rq = blk_fetch_request(q); | ||
200 | if (rq) | ||
201 | return rq; | ||
202 | } | ||
203 | } while (jsfd_queue != old_pos); | ||
204 | |||
205 | return NULL; | ||
206 | } | ||
207 | |||
208 | static void jsfd_request(void) | ||
187 | { | 209 | { |
188 | struct request *req; | 210 | struct request *req; |
189 | 211 | ||
190 | req = blk_fetch_request(q); | 212 | req = jsfd_next_request(); |
191 | while (req) { | 213 | while (req) { |
192 | struct jsfd_part *jdp = req->rq_disk->private_data; | 214 | struct jsfd_part *jdp = req->rq_disk->private_data; |
193 | unsigned long offset = blk_rq_pos(req) << 9; | 215 | unsigned long offset = blk_rq_pos(req) << 9; |
@@ -211,10 +233,15 @@ static void jsfd_do_request(struct request_queue *q) | |||
211 | err = 0; | 233 | err = 0; |
212 | end: | 234 | end: |
213 | if (!__blk_end_request_cur(req, err)) | 235 | if (!__blk_end_request_cur(req, err)) |
214 | req = blk_fetch_request(q); | 236 | req = jsfd_next_request(); |
215 | } | 237 | } |
216 | } | 238 | } |
217 | 239 | ||
240 | static void jsfd_do_request(struct request_queue *q) | ||
241 | { | ||
242 | jsfd_request(); | ||
243 | } | ||
244 | |||
218 | /* | 245 | /* |
219 | * The memory devices use the full 32/64 bits of the offset, and so we cannot | 246 | * The memory devices use the full 32/64 bits of the offset, and so we cannot |
220 | * check against negative addresses: they are ok. The return value is weird, | 247 | * check against negative addresses: they are ok. The return value is weird, |
@@ -544,8 +571,6 @@ static int jsflash_init(void) | |||
544 | return 0; | 571 | return 0; |
545 | } | 572 | } |
546 | 573 | ||
547 | static struct request_queue *jsf_queue; | ||
548 | |||
549 | static int jsfd_init(void) | 574 | static int jsfd_init(void) |
550 | { | 575 | { |
551 | static DEFINE_SPINLOCK(lock); | 576 | static DEFINE_SPINLOCK(lock); |
@@ -562,6 +587,11 @@ static int jsfd_init(void) | |||
562 | struct gendisk *disk = alloc_disk(1); | 587 | struct gendisk *disk = alloc_disk(1); |
563 | if (!disk) | 588 | if (!disk) |
564 | goto out; | 589 | goto out; |
590 | disk->queue = blk_init_queue(jsfd_do_request, &lock); | ||
591 | if (!disk->queue) { | ||
592 | put_disk(disk); | ||
593 | goto out; | ||
594 | } | ||
565 | jsfd_disk[i] = disk; | 595 | jsfd_disk[i] = disk; |
566 | } | 596 | } |
567 | 597 | ||
@@ -570,13 +600,6 @@ static int jsfd_init(void) | |||
570 | goto out; | 600 | goto out; |
571 | } | 601 | } |
572 | 602 | ||
573 | jsf_queue = blk_init_queue(jsfd_do_request, &lock); | ||
574 | if (!jsf_queue) { | ||
575 | err = -ENOMEM; | ||
576 | unregister_blkdev(JSFD_MAJOR, "jsfd"); | ||
577 | goto out; | ||
578 | } | ||
579 | |||
580 | for (i = 0; i < JSF_MAX; i++) { | 603 | for (i = 0; i < JSF_MAX; i++) { |
581 | struct gendisk *disk = jsfd_disk[i]; | 604 | struct gendisk *disk = jsfd_disk[i]; |
582 | if ((i & JSF_PART_MASK) >= JSF_NPART) continue; | 605 | if ((i & JSF_PART_MASK) >= JSF_NPART) continue; |
@@ -589,7 +612,6 @@ static int jsfd_init(void) | |||
589 | disk->fops = &jsfd_fops; | 612 | disk->fops = &jsfd_fops; |
590 | set_capacity(disk, jdp->dsize >> 9); | 613 | set_capacity(disk, jdp->dsize >> 9); |
591 | disk->private_data = jdp; | 614 | disk->private_data = jdp; |
592 | disk->queue = jsf_queue; | ||
593 | add_disk(disk); | 615 | add_disk(disk); |
594 | set_disk_ro(disk, 1); | 616 | set_disk_ro(disk, 1); |
595 | } | 617 | } |
@@ -619,6 +641,7 @@ static void __exit jsflash_cleanup_module(void) | |||
619 | for (i = 0; i < JSF_MAX; i++) { | 641 | for (i = 0; i < JSF_MAX; i++) { |
620 | if ((i & JSF_PART_MASK) >= JSF_NPART) continue; | 642 | if ((i & JSF_PART_MASK) >= JSF_NPART) continue; |
621 | del_gendisk(jsfd_disk[i]); | 643 | del_gendisk(jsfd_disk[i]); |
644 | blk_cleanup_queue(jsfd_disk[i]->queue); | ||
622 | put_disk(jsfd_disk[i]); | 645 | put_disk(jsfd_disk[i]); |
623 | } | 646 | } |
624 | if (jsf0.busy) | 647 | if (jsf0.busy) |
@@ -628,7 +651,6 @@ static void __exit jsflash_cleanup_module(void) | |||
628 | 651 | ||
629 | misc_deregister(&jsf_dev); | 652 | misc_deregister(&jsf_dev); |
630 | unregister_blkdev(JSFD_MAJOR, "jsfd"); | 653 | unregister_blkdev(JSFD_MAJOR, "jsfd"); |
631 | blk_cleanup_queue(jsf_queue); | ||
632 | } | 654 | } |
633 | 655 | ||
634 | module_init(jsflash_init_module); | 656 | module_init(jsflash_init_module); |