scsi_dh: switch to scsi_execute_req_flags()
cover scsi_dh: switch to scsi_execute_req_flags()
Hi all,
here's a patchset to switch to scsi_execute_req_flags() for all SCSI device handlers. Originally we would be using blk_execute_rq_nowait to allow the 'activate' function to run asynchronously.
However, as we're now calling the 'activate' function synchronously there's no point in using the blk_execute_rq() interface and we should be using scsi_execute_req_flags() instead.
As usual, comments and reviews are welcome.
Hannes Reinecke (3):
scsi_dh_rdac: switch to scsi_execute_req_flags()
scsi_dh_emc: switch to scsi_execute_req_flags()
scsi_dh_hp_sw: switch to scsi_execute_req_flags()
drivers/scsi/device_handler/scsi_dh_emc.c | 245 ++++++---------------------- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 218 +++++++------------------ drivers/scsi/device_handler/scsi_dh_rdac.c | 160 +++++------------- 3 files changed, 160 insertions(+), 463 deletions(-)
Signature · 1 line
2.6.6
PATCH 2/3 scsi_dh_emc: switch to scsi_execute_req_flags()
Switch to using scsi_execute_req_flags() instead of using the block primitives.
--- drivers/scsi/device_handler/scsi_dh_emc.c | 245 +++++++----------------------- 1 file changed, 54 insertions(+), 191 deletions(-)
drivers/scsi/device_handler/scsi_dh_emc.c +54 -191
@@ -88,12 +88,6 @@ struct clariion_dh_data {*/ unsigned char buffer[CLARIION_BUFFER_SIZE ];/* -* SCSI sense buffer for commands -- assumes serial issuance -* and completion sequence of all commands for same multipath. -*/ -unsigned char sense[SCSI_SENSE_BUFFERSIZE ]; -unsigned int senselen; -/* * LUN state */ int lun_state;
@@ -116,44 +110,38 @@ struct clariion_dh_data {/* * Parse MODE_SELECT cmd reply. */ -static int trespass_endio (struct scsi_device *sdev,char *sense) +static int trespass_endio (struct scsi_device *sdev, +struct scsi_sense_hdr *sshdr) {int err =SCSI_DH_IO ; -struct scsi_sense_hdr sshdr; - -if (!scsi_normalize_sense (sense,SCSI_SENSE_BUFFERSIZE , &sshdr)) { -sdev_printk (KERN_ERR , sdev,"%s: Found valid sense data 0x%2x, " -"0x%2x, 0x%2x while sending CLARiiON trespass " -"command.\n" ,CLARIION_NAME , sshdr.sense_key, - sshdr.asc, sshdr.ascq); -if ((sshdr.sense_key ==0x05 ) && (sshdr.asc ==0x04 ) && - (sshdr.ascq ==0x00 )) { -/* -* Array based copy in progress -- do not send -* mode_select or copy will be aborted mid-stream. -*/ -sdev_printk (KERN_INFO , sdev,"%s: Array Based Copy in " -"progress while sending CLARiiON trespass " -"command.\n" ,CLARIION_NAME ); - err =SCSI_DH_DEV_TEMP_BUSY ; - }else if ((sshdr.sense_key ==0x02 ) && (sshdr.asc ==0x04 ) && - (sshdr.ascq ==0x03 )) { -/* -* LUN Not Ready - Manual Intervention Required -* indicates in-progress ucode upgrade (NDU). -*/ -sdev_printk (KERN_INFO , sdev,"%s: Detected in-progress " -"ucode upgrade NDU operation while sending " -"CLARiiON trespass command.\n" ,CLARIION_NAME ); - err =SCSI_DH_DEV_TEMP_BUSY ; - }else - err =SCSI_DH_DEV_FAILED ; - }else { -sdev_printk (KERN_INFO , sdev, -"%s: failed to send MODE SELECT, no sense available\n" , -CLARIION_NAME ); - } +sdev_printk (KERN_ERR , sdev,"%s: Found valid sense data 0x%2x, " +"0x%2x, 0x%2x while sending CLARiiON trespass " +"command.\n" ,CLARIION_NAME , sshdr->sense_key, + sshdr->asc, sshdr->ascq); + +if ((sshdr->sense_key ==0x05 ) && (sshdr->asc ==0x04 ) && + (sshdr->ascq ==0x00 )) { +/* +* Array based copy in progress -- do not send +* mode_select or copy will be aborted mid-stream. +*/ +sdev_printk (KERN_INFO , sdev,"%s: Array Based Copy in " +"progress while sending CLARiiON trespass " +"command.\n" ,CLARIION_NAME ); + err =SCSI_DH_DEV_TEMP_BUSY ; + }else if ((sshdr->sense_key ==0x02 ) && (sshdr->asc ==0x04 ) && + (sshdr->ascq ==0x03 )) { +/* +* LUN Not Ready - Manual Intervention Required +* indicates in-progress ucode upgrade (NDU). +*/ +sdev_printk (KERN_INFO , sdev,"%s: Detected in-progress " +"ucode upgrade NDU operation while sending " +"CLARiiON trespass command.\n" ,CLARIION_NAME ); + err =SCSI_DH_DEV_TEMP_BUSY ; + }else + err =SCSI_DH_DEV_FAILED ;return err; }
@@ -257,103 +245,13 @@ static char * parse_sp_model(struct scsi_device *sdev, unsigned char *buffer)return sp_model; } -/* -* Get block request for REQ_BLOCK_PC command issued to path. Currently -* limited to MODE_SELECT (trespass) and INQUIRY (VPD page 0xC0) commands. -* -* Uses data and sense buffers in hardware handler context structure and -* assumes serial servicing of commands, both issuance and completion. -*/ -static struct request *get_req (struct scsi_device *sdev,int cmd, -unsigned char *buffer) -{ -struct request *rq; -int len =0 ; - - rq =blk_get_request (sdev->request_queue, - (cmd !=INQUIRY ) ?WRITE :READ ,GFP_NOIO ); -if (IS_ERR (rq)) { -sdev_printk (KERN_INFO , sdev,"get_req: blk_get_request failed" ); -return NULL ; - } - -blk_rq_set_block_pc (rq); - rq->cmd_len =COMMAND_SIZE (cmd); - rq->cmd[0 ] = cmd; - -switch (cmd) { -case MODE_SELECT : - len =sizeof (short_trespass); - rq->cmd[1 ] =0x10 ; - rq->cmd[4 ] = len; -break ; -case MODE_SELECT_10 : - len =sizeof (long_trespass); - rq->cmd[1 ] =0x10 ; - rq->cmd[8 ] = len; -break ; -case INQUIRY : - len =CLARIION_BUFFER_SIZE ; - rq->cmd[4 ] = len; -memset (buffer,0 , len); -break ; -default : -BUG_ON (1 ); -break ; - } - - rq->cmd_flags |=REQ_FAILFAST_DEV |REQ_FAILFAST_TRANSPORT | -REQ_FAILFAST_DRIVER ; - rq->timeout =CLARIION_TIMEOUT ; - rq->retries =CLARIION_RETRIES ; - -if (blk_rq_map_kern (rq->q, rq, buffer, len,GFP_NOIO )) { -blk_put_request (rq); -return NULL ; - } - -return rq; -} - -static int send_inquiry_cmd (struct scsi_device *sdev,int page, -struct clariion_dh_data *csdev) -{ -struct request *rq =get_req (sdev,INQUIRY , csdev->buffer); -int err; - -if (!rq) -return SCSI_DH_RES_TEMP_UNAVAIL ; - - rq->sense = csdev->sense; -memset (rq->sense,0 ,SCSI_SENSE_BUFFERSIZE ); - rq->sense_len = csdev->senselen =0 ; - - rq->cmd[0 ] =INQUIRY ; -if (page !=0 ) { - rq->cmd[1 ] =1 ; - rq->cmd[2 ] = page; - } - err =blk_execute_rq (sdev->request_queue,NULL , rq,1 ); -if (err == -EIO ) { -sdev_printk (KERN_INFO , sdev, -"%s: failed to send %s INQUIRY: %x\n" , -CLARIION_NAME , page?"EVPD" :"standard" , - rq->errors); - csdev->senselen = rq->sense_len; - err =SCSI_DH_IO ; - } - -blk_put_request (rq); - -return err; -} -static int send_trespass_cmd (struct scsi_device *sdev,struct clariion_dh_data *csdev) { -struct request *rq;unsigned char *page22; -int err, len, cmd; +unsigned char cdb[COMMAND_SIZE (MODE_SELECT )]; +int err, res =SCSI_DH_OK , len; +struct scsi_sense_hdr sshdr;if (csdev->flags &CLARIION_SHORT_TRESPASS ) { page22 = short_trespass;
@@ -361,40 +259,37 @@ static int send_trespass_cmd(struct scsi_device *sdev,/* Set Honor Reservations bit */ page22[6 ] |=0x80 ; len =sizeof (short_trespass); - cmd =MODE_SELECT ; + cdb[0 ] =MODE_SELECT ; + cdb[1 ] =0x10 ; + cdb[4 ] = len; }else { page22 = long_trespass;if (!(csdev->flags &CLARIION_HONOR_RESERVATIONS ))/* Set Honor Reservations bit */ page22[10 ] |=0x80 ; len =sizeof (long_trespass); - cmd =MODE_SELECT_10 ; + cdb[0 ] =MODE_SELECT_10 ; + cdb[8 ] = len; }BUG_ON ((len >CLARIION_BUFFER_SIZE ));memcpy (csdev->buffer, page22, len); - rq =get_req (sdev, cmd, csdev->buffer); -if (!rq) -return SCSI_DH_RES_TEMP_UNAVAIL ; - - rq->sense = csdev->sense; -memset (rq->sense,0 ,SCSI_SENSE_BUFFERSIZE ); - rq->sense_len = csdev->senselen =0 ; - - err =blk_execute_rq (sdev->request_queue,NULL , rq,1 ); -if (err == -EIO ) { -if (rq->sense_len) { - err =trespass_endio (sdev, csdev->sense); - }else { + err =scsi_execute_req_flags (sdev, cdb,DMA_TO_DEVICE , + csdev->buffer, len, &sshdr, +CLARIION_TIMEOUT *HZ ,CLARIION_RETRIES , +NULL ,REQ_FAILFAST_MASK ); +if (err) { +if (scsi_sense_valid (&sshdr)) + res =trespass_endio (sdev, &sshdr); +else {sdev_printk (KERN_INFO , sdev,"%s: failed to send MODE SELECT: %x\n" , -CLARIION_NAME , rq->errors); +CLARIION_NAME , err); + res =SCSI_DH_IO ; } } -blk_put_request (rq); - -return err; +return res; } static int clariion_check_sense(struct scsi_device *sdev,
@@ -464,21 +359,7 @@ static int clariion_std_inquiry(struct scsi_device *sdev,int err;char *sp_model; - err =send_inquiry_cmd (sdev,0 , csdev); -if (err !=SCSI_DH_OK && csdev->senselen) { -struct scsi_sense_hdr sshdr; - -if (scsi_normalize_sense (csdev->sense,SCSI_SENSE_BUFFERSIZE , - &sshdr)) { -sdev_printk (KERN_ERR , sdev,"%s: INQUIRY sense code " -"%02x/%02x/%02x\n" ,CLARIION_NAME , - sshdr.sense_key, sshdr.asc, sshdr.ascq); - } - err =SCSI_DH_IO ; - goto out; - } - - sp_model =parse_sp_model (sdev, csdev->buffer); + sp_model =parse_sp_model (sdev, sdev->inquiry);if (!sp_model) { err =SCSI_DH_DEV_UNSUPP ; goto out;
@@ -500,30 +381,12 @@ static int clariion_std_inquiry(struct scsi_device *sdev,static int clariion_send_inquiry (struct scsi_device *sdev,struct clariion_dh_data *csdev) { -int err, retry =CLARIION_RETRIES ; - -retry: - err =send_inquiry_cmd (sdev,0xC0 , csdev); -if (err !=SCSI_DH_OK && csdev->senselen) { -struct scsi_sense_hdr sshdr; - - err =scsi_normalize_sense (csdev->sense,SCSI_SENSE_BUFFERSIZE , - &sshdr); -if (!err) -return SCSI_DH_IO ; - - err =clariion_check_sense (sdev, &sshdr); -if (retry >0 && err ==ADD_TO_MLQUEUE ) { - retry--; - goto retry; - } -sdev_printk (KERN_ERR , sdev,"%s: INQUIRY sense code " -"%02x/%02x/%02x\n" ,CLARIION_NAME , - sshdr.sense_key, sshdr.asc, sshdr.ascq); - err =SCSI_DH_IO ; - }else { +int err =SCSI_DH_IO ; + +if (!scsi_get_vpd_page (sdev,0xC0 , csdev->buffer, +CLARIION_BUFFER_SIZE )) err =parse_sp_info_reply (sdev, csdev); - } +return err; }
Signature · 1 line
2.6.6
PATCH 3/3 scsi_dh_hp_sw: switch to scsi_execute_req_flags()
In reply to Hannes ReineckeSwitch to using scsi_execute_req_flags() instead of using the block primitives.
--- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 218 ++++++++-------------------- 1 file changed, 61 insertions(+), 157 deletions(-)
drivers/scsi/device_handler/scsi_dh_hp_sw.c +61 -157
@@ -38,13 +38,10 @@#define HP_SW_PATH_PASSIVE 1struct hp_sw_dh_data { -unsigned char sense[SCSI_SENSE_BUFFERSIZE ];int path_state;int retries;int retry_cnt;struct scsi_device *sdev; -activate_complete callback_fn; -void *callback_data; };static int hp_sw_start_stop (struct hp_sw_dh_data *);
@@ -56,43 +53,34 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *);* * Returns SCSI_DH_DEV_OFFLINED if the sdev is on the passive path */ -static int tur_done (struct scsi_device *sdev,unsigned char *sense) +static int tur_done (struct scsi_device *sdev,struct hp_sw_dh_data *h, +struct scsi_sense_hdr *sshdr) { -struct scsi_sense_hdr sshdr; -int ret; +int ret =SCSI_DH_IO ; - ret =scsi_normalize_sense (sense,SCSI_SENSE_BUFFERSIZE , &sshdr); -if (!ret) { -sdev_printk (KERN_WARNING , sdev, -"%s: sending tur failed, no sense available\n" , -HP_SW_NAME ); - ret =SCSI_DH_IO ; - goto done; - } -switch (sshdr.sense_key) { +switch (sshdr->sense_key) {case UNIT_ATTENTION : ret =SCSI_DH_IMM_RETRY ;break ;case NOT_READY : -if ((sshdr.asc ==0x04 ) && (sshdr.ascq ==2 )) { +if ((sshdr->asc ==0x04 ) && (sshdr->ascq ==2 )) {/* * LUN not ready - Initialization command required * * This is the passive path */ - ret =SCSI_DH_DEV_OFFLINED ; + h->path_state =HP_SW_PATH_PASSIVE ; + ret =SCSI_DH_OK ;break ; }/* Fallthrough */ default :sdev_printk (KERN_WARNING , sdev,"%s: sending tur failed, sense %x/%x/%x\n" , -HP_SW_NAME , sshdr.sense_key, sshdr.asc, - sshdr.ascq); +HP_SW_NAME , sshdr->sense_key, sshdr->asc, + sshdr->ascq);break ; } - -done:return ret; }
@@ -105,131 +93,34 @@ static int tur_done(struct scsi_device *sdev, unsigned char *sense)*/ static int hp_sw_tur (struct scsi_device *sdev,struct hp_sw_dh_data *h) { -struct request *req; -int ret; +unsigned char cmd[6 ] = {TEST_UNIT_READY }; +struct scsi_sense_hdr sshdr; +int ret =SCSI_DH_OK , res; retry: - req =blk_get_request (sdev->request_queue,WRITE ,GFP_NOIO ); -if (IS_ERR (req)) -return SCSI_DH_RES_TEMP_UNAVAIL ; - -blk_rq_set_block_pc (req); - req->cmd_flags |=REQ_FAILFAST_DEV |REQ_FAILFAST_TRANSPORT | -REQ_FAILFAST_DRIVER ; - req->cmd_len =COMMAND_SIZE (TEST_UNIT_READY ); - req->cmd[0 ] =TEST_UNIT_READY ; - req->timeout =HP_SW_TIMEOUT ; - req->sense = h->sense; -memset (req->sense,0 ,SCSI_SENSE_BUFFERSIZE ); - req->sense_len =0 ; - - ret =blk_execute_rq (req->q,NULL , req,1 ); -if (ret == -EIO ) { -if (req->sense_len >0 ) { - ret =tur_done (sdev, h->sense); - }else { + res =scsi_execute_req_flags (sdev, cmd,DMA_NONE ,NULL ,0 , &sshdr, +HP_SW_TIMEOUT ,HP_SW_RETRIES , +NULL ,REQ_FAILFAST_MASK ); +if (res) { +if (scsi_sense_valid (&sshdr)) + ret =tur_done (sdev, h, &sshdr); +else {sdev_printk (KERN_WARNING , sdev,"%s: sending tur failed with %x\n" , -HP_SW_NAME , req->errors); +HP_SW_NAME , res); ret =SCSI_DH_IO ; } }else { h->path_state =HP_SW_PATH_ACTIVE ; ret =SCSI_DH_OK ; } -if (ret ==SCSI_DH_IMM_RETRY ) { -blk_put_request (req); +if (ret ==SCSI_DH_IMM_RETRY ) goto retry; - } -if (ret ==SCSI_DH_DEV_OFFLINED ) { - h->path_state =HP_SW_PATH_PASSIVE ; - ret =SCSI_DH_OK ; - } - -blk_put_request (req);return ret; }/* -* start_done - Handle START STOP UNIT return status -* @sdev: sdev the command has been sent to -* @errors: blk error code -*/ -static int start_done (struct scsi_device *sdev,unsigned char *sense) -{ -struct scsi_sense_hdr sshdr; -int rc; - - rc =scsi_normalize_sense (sense,SCSI_SENSE_BUFFERSIZE , &sshdr); -if (!rc) { -sdev_printk (KERN_WARNING , sdev, -"%s: sending start_stop_unit failed, " -"no sense available\n" , -HP_SW_NAME ); -return SCSI_DH_IO ; - } -switch (sshdr.sense_key) { -case NOT_READY : -if ((sshdr.asc ==0x04 ) && (sshdr.ascq ==3 )) { -/* -* LUN not ready - manual intervention required -* -* Switch-over in progress, retry. -*/ - rc =SCSI_DH_RETRY ; -break ; - } -/* fall through */ -default : -sdev_printk (KERN_WARNING , sdev, -"%s: sending start_stop_unit failed, sense %x/%x/%x\n" , -HP_SW_NAME , sshdr.sense_key, sshdr.asc, - sshdr.ascq); - rc =SCSI_DH_IO ; - } - -return rc; -} - -static void start_stop_endio (struct request *req,int error) -{ -struct hp_sw_dh_data *h = req->end_io_data; -unsigned err =SCSI_DH_OK ; - -if (error ||host_byte (req->errors) !=DID_OK || -msg_byte (req->errors) !=COMMAND_COMPLETE ) { -sdev_printk (KERN_WARNING , h->sdev, -"%s: sending start_stop_unit failed with %x\n" , -HP_SW_NAME , req->errors); - err =SCSI_DH_IO ; - goto done; - } - -if (req->sense_len >0 ) { - err =start_done (h->sdev, h->sense); -if (err ==SCSI_DH_RETRY ) { - err =SCSI_DH_IO ; -if (--h->retry_cnt) { -blk_put_request (req); - err =hp_sw_start_stop (h); -if (err ==SCSI_DH_OK ) -return ; - } - } - } -done: - req->end_io_data =NULL ; -__blk_put_request (req->q, req); -if (h->callback_fn) { - h->callback_fn (h->callback_data, err); - h->callback_fn = h->callback_data =NULL ; - } -return ; - -} - -/* * hp_sw_start_stop - Send START STOP UNIT command * @sdev: sdev command should be sent to *
@@ -237,26 +128,46 @@ static void start_stop_endio(struct request *req, int error)*/ static int hp_sw_start_stop (struct hp_sw_dh_data *h) { -struct request *req; - - req =blk_get_request (h->sdev->request_queue,WRITE ,GFP_ATOMIC ); -if (IS_ERR (req)) -return SCSI_DH_RES_TEMP_UNAVAIL ; - -blk_rq_set_block_pc (req); - req->cmd_flags |=REQ_FAILFAST_DEV |REQ_FAILFAST_TRANSPORT | -REQ_FAILFAST_DRIVER ; - req->cmd_len =COMMAND_SIZE (START_STOP ); - req->cmd[0 ] =START_STOP ; - req->cmd[4 ] =1 ;/* Start spin cycle */ - req->timeout =HP_SW_TIMEOUT ; - req->sense = h->sense; -memset (req->sense,0 ,SCSI_SENSE_BUFFERSIZE ); - req->sense_len =0 ; - req->end_io_data = h; +unsigned char cmd[6 ] = {START_STOP ,0 ,0 ,0 ,1 ,0 };/* START_VALID */ +struct scsi_sense_hdr sshdr; +struct scsi_device *sdev = h->sdev; +int res, rc =SCSI_DH_OK ; +int retry_cnt =HP_SW_RETRIES ; -blk_execute_rq_nowait (req->q,NULL , req,1 , start_stop_endio); -return SCSI_DH_OK ; +retry: + res =scsi_execute_req_flags (sdev, cmd,DMA_NONE ,NULL ,0 , &sshdr, +HP_SW_TIMEOUT ,HP_SW_RETRIES , +NULL ,REQ_FAILFAST_MASK ); +if (res) { +if (!scsi_sense_valid (&sshdr)) { +sdev_printk (KERN_WARNING , sdev, +"%s: sending start_stop_unit failed, " +"no sense available\n" ,HP_SW_NAME ); +return SCSI_DH_IO ; + } +switch (sshdr.sense_key) { +case NOT_READY : +if ((sshdr.asc ==0x04 ) && (sshdr.ascq ==3 )) { +/* +* LUN not ready - manual intervention required +* +* Switch-over in progress, retry. +*/ +if (--retry_cnt) + goto retry; + rc =SCSI_DH_RETRY ; +break ; + } +/* fall through */ +default : +sdev_printk (KERN_WARNING , sdev, +"%s: sending start_stop_unit failed, " +"sense %x/%x/%x\n" ,HP_SW_NAME , + sshdr.sense_key, sshdr.asc, sshdr.ascq); + rc =SCSI_DH_IO ; + } + } +return rc; }static int hp_sw_prep_fn (struct scsi_device *sdev,struct request *req)
@@ -290,15 +201,8 @@ static int hp_sw_activate(struct scsi_device *sdev, ret =hp_sw_tur (sdev, h); -if (ret ==SCSI_DH_OK && h->path_state ==HP_SW_PATH_PASSIVE ) { - h->retry_cnt = h->retries; - h->callback_fn = fn; - h->callback_data = data; +if (ret ==SCSI_DH_OK && h->path_state ==HP_SW_PATH_PASSIVE ) ret =hp_sw_start_stop (h); -if (ret ==SCSI_DH_OK ) -return 0 ; - h->callback_fn = h->callback_data =NULL ; - }if (fn)fn (data, ret);
Signature · 1 line
2.6.6
PATCH 1/3 scsi_dh_rdac: switch to scsi_execute_req_flags()
In reply to Hannes ReineckeSwitch to using scsi_execute_req_flags() instead of using the block primitives.
--- drivers/scsi/device_handler/scsi_dh_rdac.c | 160 ++++++++--------------------- 1 file changed, 45 insertions(+), 115 deletions(-)
drivers/scsi/device_handler/scsi_dh_rdac.c +45 -115
@@ -205,7 +205,6 @@ struct rdac_dh_data {#define RDAC_NON_PREFERRED 1char preferred; -unsigned char sense[SCSI_SENSE_BUFFERSIZE ];union {struct c2_inquiry c2;struct c4_inquiry c4;
@@ -262,40 +261,12 @@ do { \ sdev_printk(KERN_INFO, sdev, RDAC_NAME ": " f "\n", ## arg); \ }while (0 ); -static struct request *get_rdac_req (struct scsi_device *sdev, -void *buffer,unsigned buflen,int rw) +static unsigned int rdac_failover_get (struct rdac_controller *ctlr, +struct list_head *list, +unsigned char *cdb) { -struct request *rq; -struct request_queue *q = sdev->request_queue; - - rq =blk_get_request (q, rw,GFP_NOIO ); - -if (IS_ERR (rq)) { -sdev_printk (KERN_INFO , sdev, -"get_rdac_req: blk_get_request failed.\n" ); -return NULL ; - } -blk_rq_set_block_pc (rq); - -if (buflen &&blk_rq_map_kern (q, rq, buffer, buflen,GFP_NOIO )) { -blk_put_request (rq); -sdev_printk (KERN_INFO , sdev, -"get_rdac_req: blk_rq_map_kern failed.\n" ); -return NULL ; - } - - rq->cmd_flags |=REQ_FAILFAST_DEV |REQ_FAILFAST_TRANSPORT | -REQ_FAILFAST_DRIVER ; - rq->retries =RDAC_RETRIES ; - rq->timeout =RDAC_TIMEOUT ; - -return rq; -} - -static struct request *rdac_failover_get (struct scsi_device *sdev, -struct rdac_dh_data *h,struct list_head *list) -{ -struct request *rq; +struct scsi_device *sdev = ctlr->ms_sdev; +struct rdac_dh_data *h = sdev->handler_data;struct rdac_mode_common *common;unsigned data_size;struct rdac_queue_data *qdata;
@@ -332,27 +303,17 @@ static struct request *rdac_failover_get(struct scsi_device *sdev, lun_table[qdata->h->lun] =0x81 ; } -/* get request for block layer packet command */ - rq =get_rdac_req (sdev, &h->ctlr->mode_select, data_size,WRITE ); -if (!rq) -return NULL ; -/* Prepare the command. */ if (h->ctlr->use_ms10) { - rq->cmd[0 ] =MODE_SELECT_10 ; - rq->cmd[7 ] = data_size >>8 ; - rq->cmd[8 ] = data_size &0xff ; + cdb[0 ] =MODE_SELECT_10 ; + cdb[7 ] = data_size >>8 ; + cdb[8 ] = data_size &0xff ; }else { - rq->cmd[0 ] =MODE_SELECT ; - rq->cmd[4 ] = data_size; + cdb[0 ] =MODE_SELECT ; + cdb[4 ] = data_size; } - rq->cmd_len =COMMAND_SIZE (rq->cmd[0 ]); - - rq->sense = h->sense; -memset (rq->sense,0 ,SCSI_SENSE_BUFFERSIZE ); - rq->sense_len =0 ; -return rq; +return data_size; }static void release_controller (struct kref *kref)
@@ -400,45 +361,14 @@ static struct rdac_controller *get_controller(int index, char *array_name,return ctlr; } -static int submit_inquiry (struct scsi_device *sdev,int page_code, -unsigned int len,struct rdac_dh_data *h) -{ -struct request *rq; -struct request_queue *q = sdev->request_queue; -int err =SCSI_DH_RES_TEMP_UNAVAIL ; - - rq =get_rdac_req (sdev, &h->inq, len,READ ); -if (!rq) - goto done; - -/* Prepare the command. */ - rq->cmd[0 ] =INQUIRY ; - rq->cmd[1 ] =1 ; - rq->cmd[2 ] = page_code; - rq->cmd[4 ] = len; - rq->cmd_len =COMMAND_SIZE (INQUIRY ); - - rq->sense = h->sense; -memset (rq->sense,0 ,SCSI_SENSE_BUFFERSIZE ); - rq->sense_len =0 ; - - err =blk_execute_rq (q,NULL , rq,1 ); -if (err == -EIO ) - err =SCSI_DH_IO ; - -blk_put_request (rq); -done: -return err; -} -static int get_lun_info (struct scsi_device *sdev,struct rdac_dh_data *h,char *array_name,u8 *array_id) { -int err, i; +int err =SCSI_DH_IO , i;struct c8_inquiry *inqp; - err =submit_inquiry (sdev,0xC8 ,sizeof (struct c8_inquiry ), h); -if (err ==SCSI_DH_OK ) { +if (!scsi_get_vpd_page (sdev,0xC8 , (unsigned char *)h, +sizeof (struct c8_inquiry ))) { inqp = &h->inq.c8;if (inqp->page_code !=0xc8 )return SCSI_DH_NOSYS ;
@@ -453,19 +383,20 @@ static int get_lun_info(struct scsi_device *sdev, struct rdac_dh_data *h, *(array_name+ARRAY_LABEL_LEN -1 ) ='\0' ;memset (array_id,0 ,UNIQUE_ID_LEN );memcpy (array_id, inqp->array_unique_id, inqp->array_uniq_id_len); + err =SCSI_DH_OK ; }return err; }static int check_ownership (struct scsi_device *sdev,struct rdac_dh_data *h) { -int err, access_state; +int err =SCSI_DH_IO , access_state;struct rdac_dh_data *tmp;struct c9_inquiry *inqp; h->state =RDAC_STATE_ACTIVE ; - err =submit_inquiry (sdev,0xC9 ,sizeof (struct c9_inquiry ), h); -if (err ==SCSI_DH_OK ) { +if (!scsi_get_vpd_page (sdev,0xC9 , (unsigned char *)h, +sizeof (struct c9_inquiry ))) { inqp = &h->inq.c9;/* detect the operating mode */ if ((inqp->avte_cvp >>5 ) &0x1 )
@@ -501,6 +432,7 @@ static int check_ownership(struct scsi_device *sdev, struct rdac_dh_data *h) tmp->sdev->access_state = access_state; }rcu_read_unlock (); + err =SCSI_DH_OK ; }return err;
@@ -509,11 +441,11 @@ static int check_ownership(struct scsi_device *sdev, struct rdac_dh_data *h)static int initialize_controller (struct scsi_device *sdev,struct rdac_dh_data *h,char *array_name,u8 *array_id) { -int err, index; +int err =SCSI_DH_IO , index;struct c4_inquiry *inqp; - err =submit_inquiry (sdev,0xC4 ,sizeof (struct c4_inquiry ), h); -if (err ==SCSI_DH_OK ) { +if (!scsi_get_vpd_page (sdev,0xC4 , (unsigned char *)h, +sizeof (struct c4_inquiry ))) { inqp = &h->inq.c4;/* get the controller index */ if (inqp->slot_id[1 ] ==0x31 )
@@ -530,17 +462,18 @@ static int initialize_controller(struct scsi_device *sdev, h->sdev = sdev; }spin_unlock (&list_lock); + err =SCSI_DH_OK ; }return err; }static int set_mode_select (struct scsi_device *sdev,struct rdac_dh_data *h) { -int err; +int err =SCSI_DH_IO ;struct c2_inquiry *inqp; - err =submit_inquiry (sdev,0xC2 ,sizeof (struct c2_inquiry ), h); -if (err ==SCSI_DH_OK ) { +if (!scsi_get_vpd_page (sdev,0xC2 , (unsigned char *)h, +sizeof (struct c2_inquiry ))) { inqp = &h->inq.c2;/* * If more than MODE6_MAX_LUN luns are supported, use
@@ -550,36 +483,35 @@ static int set_mode_select(struct scsi_device *sdev, struct rdac_dh_data *h) h->ctlr->use_ms10 =1 ; else h->ctlr->use_ms10 = 0; + err =SCSI_DH_OK ; }return err; }static int mode_select_handle_sense (struct scsi_device *sdev, -unsigned char *sensebuf) +struct scsi_sense_hdr *sense_hdr) { -struct scsi_sense_hdr sense_hdr; -int err =SCSI_DH_IO , ret; +int err =SCSI_DH_IO ;struct rdac_dh_data *h = sdev->handler_data; - ret =scsi_normalize_sense (sensebuf,SCSI_SENSE_BUFFERSIZE , &sense_hdr); -if (!ret) +if (!scsi_sense_valid (sense_hdr)) goto done; -switch (sense_hdr.sense_key) { +switch (sense_hdr->sense_key) {case NO_SENSE :case ABORTED_COMMAND :case UNIT_ATTENTION : err =SCSI_DH_RETRY ;break ;case NOT_READY : -if (sense_hdr.asc ==0x04 && sense_hdr.ascq ==0x01 ) +if (sense_hdr->asc ==0x04 && sense_hdr->ascq ==0x01 )/* LUN Not Ready and is in the Process of Becoming * Ready */ err =SCSI_DH_RETRY ;break ;case ILLEGAL_REQUEST : -if (sense_hdr.asc ==0x91 && sense_hdr.ascq ==0x36 ) +if (sense_hdr->asc ==0x91 && sense_hdr->ascq ==0x36 )/* * Command Lock contention */
@@ -592,7 +524,7 @@ static int mode_select_handle_sense(struct scsi_device *sdev,RDAC_LOG (RDAC_LOG_FAILOVER , sdev,"array %s, ctlr %d, " "MODE_SELECT returned with sense %02x/%02x/%02x" , (char *) h->ctlr->array_name, h->ctlr->index, - sense_hdr.sense_key, sense_hdr.asc, sense_hdr.ascq); + sense_hdr->sense_key, sense_hdr->asc, sense_hdr->ascq); done:return err;
@@ -602,13 +534,14 @@ static void send_mode_select(struct work_struct *work) {struct rdac_controller *ctlr = container_of(work, struct rdac_controller, ms_work); -struct request *rq;struct scsi_device *sdev = ctlr->ms_sdev;struct rdac_dh_data *h = sdev->handler_data; -struct request_queue *q = sdev->request_queue; -int err, retry_cnt =RDAC_RETRY_COUNT ; +int err =SCSI_DH_OK , retry_cnt =RDAC_RETRY_COUNT ;struct rdac_queue_data *tmp, *qdata;LIST_HEAD (list); +unsigned char cdb[COMMAND_SIZE (MODE_SELECT_10 )]; +struct scsi_sense_hdr sshdr; +unsigned int data_size;spin_lock (&ctlr->ms_lock);list_splice_init (&ctlr->ms_head, &list);
@@ -616,21 +549,19 @@ static void send_mode_select(struct work_struct *work) ctlr->ms_sdev =NULL ;spin_unlock (&ctlr->ms_lock); -retry: - err =SCSI_DH_RES_TEMP_UNAVAIL ; - rq =rdac_failover_get (sdev, h, &list); -if (!rq) - goto done; + retry: + data_size =rdac_failover_get (ctlr, &list, cdb);RDAC_LOG (RDAC_LOG_FAILOVER , sdev,"array %s, ctlr %d, " "%s MODE_SELECT command" , (char *) h->ctlr->array_name, h->ctlr->index, (retry_cnt ==RDAC_RETRY_COUNT ) ?"queueing" :"retrying" ); - err =blk_execute_rq (q,NULL , rq,1 ); -blk_put_request (rq); -if (err !=SCSI_DH_OK ) { - err =mode_select_handle_sense (sdev, h->sense); +if (scsi_execute_req_flags (sdev, cdb,DMA_TO_DEVICE , + &h->ctlr->mode_select, data_size, &sshdr, +RDAC_TIMEOUT *HZ , +RDAC_RETRIES ,NULL ,REQ_FAILFAST_MASK )) { + err =mode_select_handle_sense (sdev, &sshdr);if (err ==SCSI_DH_RETRY && retry_cnt--) goto retry;if (err ==SCSI_DH_IMM_RETRY )
@@ -643,7 +574,6 @@ static void send_mode_select(struct work_struct *work) (char *) h->ctlr->array_name, h->ctlr->index); } -done:list_for_each_entry_safe (qdata, tmp, &list, entry) {list_del (&qdata->entry);if (err ==SCSI_DH_OK )
Signature · 1 line
2.6.6
A little warning: scsi_execute_req_flags grew a new argument in the block tree to be able to specify the request-only flags. So any of these patches would create a (mostly harmless) conflict in linux-next.
Re: [PATCH 1/3] scsi_dh_rdac: switch to scsi_execute_req_flags()
In reply to Hannes ReineckeQuoted 2 lines · Hannes Reinecke
Switch to using
scsi_execute_req_flags()instead of using the block primitives.
__scsi_execute adds RQF_QUIET and RQF_PREEMPT to the request flags, which would be a change in behavior. A little analysis on why that's safe or even desireable would be nice. (This also applies to the other two patches I think).
drivers/scsi/device_handler/scsi_dh_rdac.c static struct rdac_controller *get_controller(int index, char *array_name, · line 371
Quoted 10 lines
static void
release_controller(struct kref *kref)
static int get_lun_info(structscsi_device*sdev, structrdac_dh_data*h,drivers/scsi/device_handler/scsi_dh_rdac.c +3
-0char *array_name, u8 *array_id) { + int err = SCSI_DH_IO, i;struct c8_inquiry *inqp; +if (!scsi_get_vpd_page (sdev,0xC8 , (unsigned char *)h, +sizeof (struct c8_inquiry ))) {
This looks completely bogus to me - h is a struct rdac_dh_data pointer, which is an in-kernel data structure that scsi_get_vpd_page would scramble over.
Quoted 4 lines · Christoph Hellwig
A little warning:
scsi_execute_req_flagsgrew a new argument in the block tree to be able to specify the request-only flags. So any of these patches would create a (mostly harmless) conflict in linux-next.
I don't mind creating the patches against the block tree. Martin? Jens? What's the preferred way here?
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
Re: [PATCH 1/3] scsi_dh_rdac: switch to scsi_execute_req_flags()
In reply to Christoph HellwigQuoted 9 lines · Christoph Hellwig
Quoted 2 lines · Hannes Reinecke
Switch to using
scsi_execute_req_flags()instead of using the block primitives.
__scsi_executeaddsRQF_QUIETandRQF_PREEMPTto the request flags, which would be a change in behavior. A little analysis on why that's safe or even desireable would be nice. (This also applies to the other two patches I think).
Hmm. Yeah, guess I'll need to reconcile that.
Quoted 8 lines
Quoted 8 lines
static void
release_controller(struct kref *kref)
static int get_lun_info(structscsi_device*sdev, structrdac_dh_data*h,drivers/scsi/device_handler/scsi_dh_rdac.c +1
-0char *array_name, u8 *array_id) { + int err = SCSI_DH_IO, i;struct c8_inquiry *inqp;
Quoted 7 lines
drivers/scsi/device_handler/scsi_dh_rdac.c static struct rdac_controller *get_controller(int index, char *array_name, · line 371
Quoted 2 lines
drivers/scsi/device_handler/scsi_dh_rdac.c +2
-0+if (!scsi_get_vpd_page (sdev,0xC8 , (unsigned char *)h, +sizeof (struct c8_inquiry ))) {This looks completely bogus to me - h is a struct
rdac_dh_datapointer, which is an in-kernel data structure thatscsi_get_vpd_pagewould scramble over.
Indeed, you are right. I'll be fixing it up.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)