Commit a336ca6f authored by Tejun Heo's avatar Tejun Heo Committed by Jens Axboe

ataflop: dequeue and track in-flight request

ataflop has single request in flight.  Till now, whenever it needs to
access the in-flight request it called elv_next_request().  This patch
makes ataflop track the in-flight request directly and dequeue it when
processing starts.  The added complexity is minimal and this will help
future block layer changes.

[ Impact: dequeue in-flight request, one elv_next_request() per request ]
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent 8a12c4a4
...@@ -79,9 +79,7 @@ ...@@ -79,9 +79,7 @@
#undef DEBUG #undef DEBUG
static struct request_queue *floppy_queue; static struct request_queue *floppy_queue;
static struct request *fd_request;
#define QUEUE (floppy_queue)
#define CURRENT elv_next_request(floppy_queue)
/* Disk types: DD, HD, ED */ /* Disk types: DD, HD, ED */
static struct atari_disk_type { static struct atari_disk_type {
...@@ -376,6 +374,12 @@ static DEFINE_TIMER(readtrack_timer, fd_readtrack_check, 0, 0); ...@@ -376,6 +374,12 @@ static DEFINE_TIMER(readtrack_timer, fd_readtrack_check, 0, 0);
static DEFINE_TIMER(timeout_timer, fd_times_out, 0, 0); static DEFINE_TIMER(timeout_timer, fd_times_out, 0, 0);
static DEFINE_TIMER(fd_timer, check_change, 0, 0); static DEFINE_TIMER(fd_timer, check_change, 0, 0);
static void fd_end_request_cur(int err)
{
if (!__blk_end_request_cur(fd_request, err))
fd_request = NULL;
}
static inline void start_motor_off_timer(void) static inline void start_motor_off_timer(void)
{ {
mod_timer(&motor_off_timer, jiffies + FD_MOTOR_OFF_DELAY); mod_timer(&motor_off_timer, jiffies + FD_MOTOR_OFF_DELAY);
...@@ -606,15 +610,15 @@ static void fd_error( void ) ...@@ -606,15 +610,15 @@ static void fd_error( void )
return; return;
} }
if (!CURRENT) if (!fd_request)
return; return;
CURRENT->errors++; fd_request->errors++;
if (CURRENT->errors >= MAX_ERRORS) { if (fd_request->errors >= MAX_ERRORS) {
printk(KERN_ERR "fd%d: too many errors.\n", SelectedDrive ); printk(KERN_ERR "fd%d: too many errors.\n", SelectedDrive );
__blk_end_request_cur(CURRENT, -EIO); fd_end_request_cur(-EIO);
} }
else if (CURRENT->errors == RECALIBRATE_ERRORS) { else if (fd_request->errors == RECALIBRATE_ERRORS) {
printk(KERN_WARNING "fd%d: recalibrating\n", SelectedDrive ); printk(KERN_WARNING "fd%d: recalibrating\n", SelectedDrive );
if (SelectedDrive != -1) if (SelectedDrive != -1)
SUD.track = -1; SUD.track = -1;
...@@ -725,14 +729,14 @@ static void do_fd_action( int drive ) ...@@ -725,14 +729,14 @@ static void do_fd_action( int drive )
if (IS_BUFFERED( drive, ReqSide, ReqTrack )) { if (IS_BUFFERED( drive, ReqSide, ReqTrack )) {
if (ReqCmd == READ) { if (ReqCmd == READ) {
copy_buffer( SECTOR_BUFFER(ReqSector), ReqData ); copy_buffer( SECTOR_BUFFER(ReqSector), ReqData );
if (++ReqCnt < blk_rq_cur_sectors(CURRENT)) { if (++ReqCnt < blk_rq_cur_sectors(fd_request)) {
/* read next sector */ /* read next sector */
setup_req_params( drive ); setup_req_params( drive );
goto repeat; goto repeat;
} }
else { else {
/* all sectors finished */ /* all sectors finished */
__blk_end_request_cur(CURRENT, 0); fd_end_request_cur(0);
redo_fd_request(); redo_fd_request();
return; return;
} }
...@@ -1130,14 +1134,14 @@ static void fd_rwsec_done1(int status) ...@@ -1130,14 +1134,14 @@ static void fd_rwsec_done1(int status)
} }
} }
if (++ReqCnt < blk_rq_cur_sectors(CURRENT)) { if (++ReqCnt < blk_rq_cur_sectors(fd_request)) {
/* read next sector */ /* read next sector */
setup_req_params( SelectedDrive ); setup_req_params( SelectedDrive );
do_fd_action( SelectedDrive ); do_fd_action( SelectedDrive );
} }
else { else {
/* all sectors finished */ /* all sectors finished */
__blk_end_request_cur(CURRENT, 0); fd_end_request_cur(0);
redo_fd_request(); redo_fd_request();
} }
return; return;
...@@ -1378,7 +1382,7 @@ static void setup_req_params( int drive ) ...@@ -1378,7 +1382,7 @@ static void setup_req_params( int drive )
ReqData = ReqBuffer + 512 * ReqCnt; ReqData = ReqBuffer + 512 * ReqCnt;
if (UseTrackbuffer) if (UseTrackbuffer)
read_track = (ReqCmd == READ && CURRENT->errors == 0); read_track = (ReqCmd == READ && fd_request->errors == 0);
else else
read_track = 0; read_track = 0;
...@@ -1392,25 +1396,28 @@ static void redo_fd_request(void) ...@@ -1392,25 +1396,28 @@ static void redo_fd_request(void)
int drive, type; int drive, type;
struct atari_floppy_struct *floppy; struct atari_floppy_struct *floppy;
DPRINT(("redo_fd_request: CURRENT=%p dev=%s CURRENT->sector=%ld\n", DPRINT(("redo_fd_request: fd_request=%p dev=%s fd_request->sector=%ld\n",
CURRENT, CURRENT ? CURRENT->rq_disk->disk_name : "", fd_request, fd_request ? fd_request->rq_disk->disk_name : "",
CURRENT ? blk_rq_pos(CURRENT) : 0 )); fd_request ? blk_rq_pos(fd_request) : 0 ));
IsFormatting = 0; IsFormatting = 0;
repeat: repeat:
if (!fd_request) {
if (!CURRENT) fd_request = elv_next_request(floppy_queue);
if (!fd_request)
goto the_end; goto the_end;
blkdev_dequeue_request(fd_request);
}
floppy = CURRENT->rq_disk->private_data; floppy = fd_request->rq_disk->private_data;
drive = floppy - unit; drive = floppy - unit;
type = floppy->type; type = floppy->type;
if (!UD.connected) { if (!UD.connected) {
/* drive not connected */ /* drive not connected */
printk(KERN_ERR "Unknown Device: fd%d\n", drive ); printk(KERN_ERR "Unknown Device: fd%d\n", drive );
__blk_end_request_cur(CURRENT, -EIO); fd_end_request_cur(-EIO);
goto repeat; goto repeat;
} }
...@@ -1426,12 +1433,12 @@ static void redo_fd_request(void) ...@@ -1426,12 +1433,12 @@ static void redo_fd_request(void)
/* user supplied disk type */ /* user supplied disk type */
if (--type >= NUM_DISK_MINORS) { if (--type >= NUM_DISK_MINORS) {
printk(KERN_WARNING "fd%d: invalid disk format", drive ); printk(KERN_WARNING "fd%d: invalid disk format", drive );
__blk_end_request_cur(CURRENT, -EIO); fd_end_request_cur(-EIO);
goto repeat; goto repeat;
} }
if (minor2disktype[type].drive_types > DriveType) { if (minor2disktype[type].drive_types > DriveType) {
printk(KERN_WARNING "fd%d: unsupported disk format", drive ); printk(KERN_WARNING "fd%d: unsupported disk format", drive );
__blk_end_request_cur(CURRENT, -EIO); fd_end_request_cur(-EIO);
goto repeat; goto repeat;
} }
type = minor2disktype[type].index; type = minor2disktype[type].index;
...@@ -1440,8 +1447,8 @@ static void redo_fd_request(void) ...@@ -1440,8 +1447,8 @@ static void redo_fd_request(void)
UD.autoprobe = 0; UD.autoprobe = 0;
} }
if (blk_rq_pos(CURRENT) + 1 > UDT->blocks) { if (blk_rq_pos(fd_request) + 1 > UDT->blocks) {
__blk_end_request_cur(CURRENT, -EIO); fd_end_request_cur(-EIO);
goto repeat; goto repeat;
} }
...@@ -1449,9 +1456,9 @@ static void redo_fd_request(void) ...@@ -1449,9 +1456,9 @@ static void redo_fd_request(void)
del_timer( &motor_off_timer ); del_timer( &motor_off_timer );
ReqCnt = 0; ReqCnt = 0;
ReqCmd = rq_data_dir(CURRENT); ReqCmd = rq_data_dir(fd_request);
ReqBlock = blk_rq_pos(CURRENT); ReqBlock = blk_rq_pos(fd_request);
ReqBuffer = CURRENT->buffer; ReqBuffer = fd_request->buffer;
setup_req_params( drive ); setup_req_params( drive );
do_fd_action( drive ); do_fd_action( drive );
......
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