From 1d8d8ef2c8e6bd951416941a42e3e6302238330a Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 7 Jul 2009 23:00:11 +0100 Subject: [scsi] Make SCSI command issuing partially asynchronous Move the icky call to step() from iscsi.c to scsi.c; this takes it at least one step further away from where it really doesn't belong. --- src/drivers/block/scsi.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/drivers/block') diff --git a/src/drivers/block/scsi.c b/src/drivers/block/scsi.c index 5431233f9..d6511c97b 100644 --- a/src/drivers/block/scsi.c +++ b/src/drivers/block/scsi.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include #include +#include #include /** @file @@ -57,11 +58,22 @@ static int scsi_command ( struct scsi_device *scsi, /* Clear sense response code before issuing command */ command->sense_response = 0; + /* Flag command as in-progress */ + command->rc = -EINPROGRESS; + /* Issue SCSI command */ if ( ( rc = scsi->command ( scsi, command ) ) != 0 ) { - /* Something went wrong with the issuing mechanism, - * (rather than with the command itself) - */ + /* Something went wrong with the issuing mechanism */ + DBG ( "SCSI %p " SCSI_CDB_FORMAT " err %s\n", + scsi, SCSI_CDB_DATA ( command->cdb ), strerror ( rc ) ); + return rc; + } + + /* Wait for command to complete */ + while ( command->rc == -EINPROGRESS ) + step(); + if ( ( rc = command->rc ) != 0 ) { + /* Something went wrong with the command execution */ DBG ( "SCSI %p " SCSI_CDB_FORMAT " err %s\n", scsi, SCSI_CDB_DATA ( command->cdb ), strerror ( rc ) ); return rc; -- cgit