[SCSI] do not manipulate device reference counts in scsi_get/put_command
Many callers won't need this and we can optimize them away. In addition the handling in the __-prefixed variants was inconsistant to start with. Based on an earlier patch from Bart Van Assche. [jejb: fix kerneldoc probelm picked up by Fengguang Wu] Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
This commit is contained in:
committed by
James Bottomley
parent
21a05df547
commit
0479633686
@@ -95,6 +95,7 @@ static void scsi_unprep_request(struct request *req)
|
||||
req->special = NULL;
|
||||
|
||||
scsi_put_command(cmd);
|
||||
put_device(&cmd->device->sdev_gendev);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -529,6 +530,7 @@ void scsi_next_command(struct scsi_cmnd *cmd)
|
||||
get_device(&sdev->sdev_gendev);
|
||||
|
||||
scsi_put_command(cmd);
|
||||
put_device(&sdev->sdev_gendev);
|
||||
scsi_run_queue(q);
|
||||
|
||||
/* ok to remove device now */
|
||||
@@ -1123,6 +1125,7 @@ err_exit:
|
||||
scsi_release_buffers(cmd);
|
||||
cmd->request->special = NULL;
|
||||
scsi_put_command(cmd);
|
||||
put_device(&cmd->device->sdev_gendev);
|
||||
return error;
|
||||
}
|
||||
EXPORT_SYMBOL(scsi_init_io);
|
||||
@@ -1133,9 +1136,15 @@ static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev,
|
||||
struct scsi_cmnd *cmd;
|
||||
|
||||
if (!req->special) {
|
||||
cmd = scsi_get_command(sdev, GFP_ATOMIC);
|
||||
if (unlikely(!cmd))
|
||||
/* Bail if we can't get a reference to the device */
|
||||
if (!get_device(&sdev->sdev_gendev))
|
||||
return NULL;
|
||||
|
||||
cmd = scsi_get_command(sdev, GFP_ATOMIC);
|
||||
if (unlikely(!cmd)) {
|
||||
put_device(&sdev->sdev_gendev);
|
||||
return NULL;
|
||||
}
|
||||
req->special = cmd;
|
||||
} else {
|
||||
cmd = req->special;
|
||||
@@ -1298,6 +1307,7 @@ int scsi_prep_return(struct request_queue *q, struct request *req, int ret)
|
||||
struct scsi_cmnd *cmd = req->special;
|
||||
scsi_release_buffers(cmd);
|
||||
scsi_put_command(cmd);
|
||||
put_device(&cmd->device->sdev_gendev);
|
||||
req->special = NULL;
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user