diff options
author | Vivek Goyal <vgoyal@redhat.com> | 2010-09-24 14:35:45 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-09-24 14:35:45 -0400 |
commit | 639e2f2aa76eefaf22078dccbbf2f3483f587aa7 (patch) | |
tree | 7df6fac9e0b45584f79ae75bf7f7d55019ff1fbc /drivers | |
parent | 786029ff810ff4a2fd52c0462713985a415417ab (diff) |
atari floppy: Stop sharing request queue across multiple gendisks
o Use one request queue per gendisk instead of sharing the queue.
o Don't have hardware. No compile testing or run time testing done. Completely
untested.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/ataflop.c | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index aceb96476524..0f4eec442e5d 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c | |||
@@ -79,8 +79,8 @@ | |||
79 | 79 | ||
80 | #undef DEBUG | 80 | #undef DEBUG |
81 | 81 | ||
82 | static struct request_queue *floppy_queue; | ||
83 | static struct request *fd_request; | 82 | static struct request *fd_request; |
83 | static int fdc_queue; | ||
84 | 84 | ||
85 | /* Disk types: DD, HD, ED */ | 85 | /* Disk types: DD, HD, ED */ |
86 | static struct atari_disk_type { | 86 | static struct atari_disk_type { |
@@ -1391,6 +1391,29 @@ static void setup_req_params( int drive ) | |||
1391 | ReqTrack, ReqSector, (unsigned long)ReqData )); | 1391 | ReqTrack, ReqSector, (unsigned long)ReqData )); |
1392 | } | 1392 | } |
1393 | 1393 | ||
1394 | /* | ||
1395 | * Round-robin between our available drives, doing one request from each | ||
1396 | */ | ||
1397 | static struct request *set_next_request(void) | ||
1398 | { | ||
1399 | struct request_queue *q; | ||
1400 | int old_pos = fdc_queue; | ||
1401 | struct request *rq; | ||
1402 | |||
1403 | do { | ||
1404 | q = unit[fdc_queue].disk->queue; | ||
1405 | if (++fdc_queue == FD_MAX_UNITS) | ||
1406 | fdc_queue = 0; | ||
1407 | if (q) { | ||
1408 | rq = blk_fetch_request(q); | ||
1409 | if (rq) | ||
1410 | break; | ||
1411 | } | ||
1412 | } while (fdc_queue != old_pos); | ||
1413 | |||
1414 | return rq; | ||
1415 | } | ||
1416 | |||
1394 | 1417 | ||
1395 | static void redo_fd_request(void) | 1418 | static void redo_fd_request(void) |
1396 | { | 1419 | { |
@@ -1405,7 +1428,7 @@ static void redo_fd_request(void) | |||
1405 | 1428 | ||
1406 | repeat: | 1429 | repeat: |
1407 | if (!fd_request) { | 1430 | if (!fd_request) { |
1408 | fd_request = blk_fetch_request(floppy_queue); | 1431 | fd_request = set_next_request(); |
1409 | if (!fd_request) | 1432 | if (!fd_request) |
1410 | goto the_end; | 1433 | goto the_end; |
1411 | } | 1434 | } |
@@ -1932,10 +1955,6 @@ static int __init atari_floppy_init (void) | |||
1932 | PhysTrackBuffer = virt_to_phys(TrackBuffer); | 1955 | PhysTrackBuffer = virt_to_phys(TrackBuffer); |
1933 | BufferDrive = BufferSide = BufferTrack = -1; | 1956 | BufferDrive = BufferSide = BufferTrack = -1; |
1934 | 1957 | ||
1935 | floppy_queue = blk_init_queue(do_fd_request, &ataflop_lock); | ||
1936 | if (!floppy_queue) | ||
1937 | goto Enomem; | ||
1938 | |||
1939 | for (i = 0; i < FD_MAX_UNITS; i++) { | 1958 | for (i = 0; i < FD_MAX_UNITS; i++) { |
1940 | unit[i].track = -1; | 1959 | unit[i].track = -1; |
1941 | unit[i].flags = 0; | 1960 | unit[i].flags = 0; |
@@ -1944,7 +1963,10 @@ static int __init atari_floppy_init (void) | |||
1944 | sprintf(unit[i].disk->disk_name, "fd%d", i); | 1963 | sprintf(unit[i].disk->disk_name, "fd%d", i); |
1945 | unit[i].disk->fops = &floppy_fops; | 1964 | unit[i].disk->fops = &floppy_fops; |
1946 | unit[i].disk->private_data = &unit[i]; | 1965 | unit[i].disk->private_data = &unit[i]; |
1947 | unit[i].disk->queue = floppy_queue; | 1966 | unit[i].disk->queue = blk_init_queue(do_fd_request, |
1967 | &ataflop_lock); | ||
1968 | if (!unit[i].disk->queue) | ||
1969 | goto Enomem; | ||
1948 | set_capacity(unit[i].disk, MAX_DISK_SIZE * 2); | 1970 | set_capacity(unit[i].disk, MAX_DISK_SIZE * 2); |
1949 | add_disk(unit[i].disk); | 1971 | add_disk(unit[i].disk); |
1950 | } | 1972 | } |
@@ -1959,10 +1981,14 @@ static int __init atari_floppy_init (void) | |||
1959 | 1981 | ||
1960 | return 0; | 1982 | return 0; |
1961 | Enomem: | 1983 | Enomem: |
1962 | while (i--) | 1984 | while (i--) { |
1985 | struct request_queue *q = unit[i].disk->queue; | ||
1986 | |||
1963 | put_disk(unit[i].disk); | 1987 | put_disk(unit[i].disk); |
1964 | if (floppy_queue) | 1988 | if (q) |
1965 | blk_cleanup_queue(floppy_queue); | 1989 | blk_cleanup_queue(q); |
1990 | } | ||
1991 | |||
1966 | unregister_blkdev(FLOPPY_MAJOR, "fd"); | 1992 | unregister_blkdev(FLOPPY_MAJOR, "fd"); |
1967 | return -ENOMEM; | 1993 | return -ENOMEM; |
1968 | } | 1994 | } |
@@ -2011,12 +2037,14 @@ static void __exit atari_floppy_exit(void) | |||
2011 | int i; | 2037 | int i; |
2012 | blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); | 2038 | blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); |
2013 | for (i = 0; i < FD_MAX_UNITS; i++) { | 2039 | for (i = 0; i < FD_MAX_UNITS; i++) { |
2040 | struct request_queue *q = unit[i].disk->queue; | ||
2041 | |||
2014 | del_gendisk(unit[i].disk); | 2042 | del_gendisk(unit[i].disk); |
2015 | put_disk(unit[i].disk); | 2043 | put_disk(unit[i].disk); |
2044 | blk_cleanup_queue(q); | ||
2016 | } | 2045 | } |
2017 | unregister_blkdev(FLOPPY_MAJOR, "fd"); | 2046 | unregister_blkdev(FLOPPY_MAJOR, "fd"); |
2018 | 2047 | ||
2019 | blk_cleanup_queue(floppy_queue); | ||
2020 | del_timer_sync(&fd_timer); | 2048 | del_timer_sync(&fd_timer); |
2021 | atari_stram_free( DMABuffer ); | 2049 | atari_stram_free( DMABuffer ); |
2022 | } | 2050 | } |