Skip to content

Commit

Permalink
scsi: set ->scsi_done before calling scsi_dispatch_cmd
Browse files Browse the repository at this point in the history
The blk-mq code path will set this to a different function, so make the
code simpler by setting it up in a legacy-request specific place.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Webb Scales <webbnh@hp.com>
Acked-by: Jens Axboe <axboe@kernel.dk>
Tested-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Robert Elliott <elliott@hp.com>
  • Loading branch information
Christoph Hellwig committed Jul 25, 2014
1 parent d0d3bbf commit 3b5382c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
23 changes: 1 addition & 22 deletions drivers/scsi/scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
#define CREATE_TRACE_POINTS
#include <trace/events/scsi.h>

static void scsi_done(struct scsi_cmnd *cmd);

/*
* Definitions and constants.
*/
Expand Down Expand Up @@ -693,8 +691,6 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
}

trace_scsi_dispatch_cmd_start(cmd);

cmd->scsi_done = scsi_done;
rtn = host->hostt->queuecommand(host, cmd);
if (rtn) {
trace_scsi_dispatch_cmd_error(cmd, rtn);
Expand All @@ -708,27 +704,10 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)

return rtn;
done:
scsi_done(cmd);
cmd->scsi_done(cmd);
return 0;
}

/**
* scsi_done - Invoke completion on finished SCSI command.
* @cmd: The SCSI Command for which a low-level device driver (LLDD) gives
* ownership back to SCSI Core -- i.e. the LLDD has finished with it.
*
* Description: This function is the mid-level's (SCSI Core) interrupt routine,
* which regains ownership of the SCSI command (de facto) from a LLDD, and
* calls blk_complete_request() for further processing.
*
* This function is interrupt context safe.
*/
static void scsi_done(struct scsi_cmnd *cmd)
{
trace_scsi_dispatch_cmd_done(cmd);
blk_complete_request(cmd->request);
}

/**
* scsi_finish_command - cleanup and pass command back to upper layer
* @cmd: the command
Expand Down
20 changes: 20 additions & 0 deletions drivers/scsi/scsi_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <scsi/scsi_eh.h>
#include <scsi/scsi_host.h>

#include <trace/events/scsi.h>

#include "scsi_priv.h"
#include "scsi_logging.h"

Expand Down Expand Up @@ -1454,6 +1456,23 @@ static void scsi_softirq_done(struct request *rq)
}
}

/**
* scsi_done - Invoke completion on finished SCSI command.
* @cmd: The SCSI Command for which a low-level device driver (LLDD) gives
* ownership back to SCSI Core -- i.e. the LLDD has finished with it.
*
* Description: This function is the mid-level's (SCSI Core) interrupt routine,
* which regains ownership of the SCSI command (de facto) from a LLDD, and
* calls blk_complete_request() for further processing.
*
* This function is interrupt context safe.
*/
static void scsi_done(struct scsi_cmnd *cmd)
{
trace_scsi_dispatch_cmd_done(cmd);
blk_complete_request(cmd->request);
}

/*
* Function: scsi_request_fn()
*
Expand Down Expand Up @@ -1556,6 +1575,7 @@ static void scsi_request_fn(struct request_queue *q)
/*
* Dispatch the command to the low-level driver.
*/
cmd->scsi_done = scsi_done;
rtn = scsi_dispatch_cmd(cmd);
if (rtn) {
scsi_queue_insert(cmd, rtn);
Expand Down

0 comments on commit 3b5382c

Please sign in to comment.