rationalize scsi_queue_next & friends
PATCH 1/1 rationalize scsi_queue_next & friends
(1) second arg to scsi_queue_next_request() is only ever non-NULL inside scsi_lib.c and only used in the first conditional inside that function - ripped out of scsi_queue_next_request() and put into a new helper scsi_requeue_command().
(2) Most remaining callers of are in the form
scsi_put_command(cmd);
scsi_queue_next_request(q, NULL);
add a new helper, scsi_next_command() for them.(2b) many callers of that still contain a repeated codepath, namely
everything from scsi_release_request except the final kfree. New helper __scsi_release_request() for those.
(3) All remaining callers loop over the devices of a host and call scsi_queue_next_request() on them - new helper scsi_run_host_queues().
(4) scsi_queue_next_request() renamed to scsi_run_queue(), second arg is gone and it's static to scsi_lib.c now.
drivers/scsi/scsi.c +11 -8
@@ -176,6 +176,16 @@return sreq; } +void __scsi_release_request (struct scsi_request *sreq) +{ +if (likely (sreq->sr_command !=NULL )) { +struct scsi_cmnd *cmd = sreq->sr_command; + + sreq->sr_command =NULL ; +scsi_next_command (cmd); + } +} +/* * Function: scsi_release_request *
@@ -187,14 +197,7 @@*/ void scsi_release_request (struct scsi_request *sreq) { -if (likely (sreq->sr_command !=NULL )) { -struct request_queue *q = sreq->sr_device->request_queue; - -scsi_put_command (sreq->sr_command); - sreq->sr_command =NULL ; -scsi_queue_next_request (q,NULL ); - } - +__scsi_release_request (sreq);kfree (sreq); }
drivers/scsi/scsi_error.c +2 -6
@@ -1412,8 +1412,7 @@* now that error recovery is done, we will need to ensure that these * requests are started. */ -list_for_each_entry (sdev, &shost->my_devices, siblings) -blk_run_queue (sdev->request_queue); +scsi_run_host_queues (shost); }/**
@@ -1649,7 +1648,6 @@struct scsi_cmnd *scmd =scsi_get_command (dev,GFP_KERNEL );struct request req;int rtn; -struct request_queue *q; scmd->request = &req;memset (&scmd->eh_timeout,0 ,sizeof (scmd->eh_timeout));
@@ -1701,8 +1699,6 @@ }scsi_delete_timer (scmd); - q = scmd->device->request_queue; -scsi_put_command (scmd); -scsi_queue_next_request (q,NULL ); +scsi_next_command (scmd);return rtn; }
drivers/scsi/scsi_lib.c +84 -102
288 lines not on this page · raw message
drivers/scsi/scsi_priv.h +3 -2
@@ -73,6 +73,7 @@extern int scsi_insert_special_req (struct scsi_request *sreq,int );extern void scsi_init_cmd_from_req (struct scsi_cmnd *cmd,struct scsi_request *sreq); +extern void __scsi_release_request (struct scsi_request *sreq);/* scsi_error.c */ extern void scsi_times_out (struct scsi_cmnd *cmd);
@@ -84,8 +85,8 @@extern int scsi_maybe_unblock_host (struct scsi_device *sdev);extern void scsi_setup_cmd_retry (struct scsi_cmnd *cmd);extern int scsi_queue_insert (struct scsi_cmnd *cmd,int reason); -extern void scsi_queue_next_request (struct request_queue *q, -struct scsi_cmnd *cmd); +extern void scsi_next_command (struct scsi_cmnd *cmd); +extern void scsi_run_host_queues (struct Scsi_Host *shost);extern struct request_queue *scsi_alloc_queue (struct scsi_device *sdev);extern void scsi_free_queue (struct request_queue *q);extern int scsi_init_queue (void );