Convert FibreChannel bsg code to use bsg-lib
Subsystems (10)
PATCH v4 1/15 scsi: Get rid of struct fc_bsg_buffer
In reply to Johannes Thumshirnstruct fc_bsg_buffer is just a clone of struct bsg_buffer from bsg-lib, so use this one instead.
--- drivers/scsi/lpfc/lpfc_bsg.c | 3 ++- drivers/scsi/scsi_transport_fc.c | 2 +- include/scsi/scsi_transport_fc.h | 12 +++--------- 3 files changed, 6 insertions(+), 11 deletions(-)
drivers/scsi/lpfc/lpfc_bsg.c +2 -1
@@ -24,6 +24,7 @@#include <linux/slab.h> #include <linux/delay.h> #include <linux/list.h> +#include <linux/bsg-lib.h> #include <scsi/scsi.h> #include <scsi/scsi_host.h>
@@ -211,7 +212,7 @@ struct lpfc_dmabufext {static unsigned int lpfc_bsg_copy_data (struct lpfc_dmabuf *dma_buffers, -struct fc_bsg_buffer *bsg_buffers, +struct bsg_buffer *bsg_buffers,unsigned int bytes_to_transfer,int to_buffers) {
drivers/scsi/scsi_transport_fc.c +1 -1
@@ -3671,7 +3671,7 @@ static void fc_bsg_softirq_done(struct request *rq) }static int -fc_bsg_map_buffer (struct fc_bsg_buffer *buf,struct request *req) +fc_bsg_map_buffer (struct bsg_buffer *buf,struct request *req) {size_t sz = (sizeof (struct scatterlist ) * req->nr_phys_segments);
include/scsi/scsi_transport_fc.h +3 -9
@@ -28,6 +28,7 @@#define SCSI_TRANSPORT_FC_H #include <linux/sched.h> +#include <linux/bsg-lib.h> #include <asm/unaligned.h> #include <scsi/scsi.h> #include <scsi/scsi_netlink.h>
@@ -624,13 +625,6 @@ struct fc_host_attrs {#define fc_host_dev_loss_tmo (x) \ (((struct fc_host_attrs *)(x)->shost_data)->dev_loss_tmo) - -struct fc_bsg_buffer { -unsigned int payload_len; -int sg_cnt; -struct scatterlist *sg_list; -}; -/* Values for fc_bsg_job->state_flags (bitflags) */ #define FC_RQST_STATE_INPROGRESS 0#define FC_RQST_STATE_DONE 1
@@ -659,8 +653,8 @@ struct fc_bsg_job {*/ /* DMA payloads for the request/response */ -struct fc_bsg_buffer request_payload; -struct fc_bsg_buffer reply_payload; +struct bsg_buffer request_payload; +struct bsg_buffer reply_payload;void *dd_data;/* Used for driver-specific storage */ };
Signature · 1 line
1.8.5.6
PATCH v4 2/15 scsi: don't use fc_bsg_job::request and fc_bsg_job::reply directly
In reply to Johannes ThumshirnDon't use fc_bsg_job::request and fc_bsg_job::reply directly, but use helper variables bsg_request and bsg_reply. This will be helpfull when transitioning to bsg-lib.
--- drivers/s390/scsi/zfcp_fc.c | 9 +- drivers/scsi/bfa/bfad_bsg.c | 40 +++--- drivers/scsi/ibmvscsi/ibmvfc.c | 22 ++-- drivers/scsi/libfc/fc_lport.c | 23 ++-- drivers/scsi/lpfc/lpfc_bsg.c | 199 ++++++++++++++++++----------- drivers/scsi/qla2xxx/qla_bsg.c | 264 ++++++++++++++++++++++----------------- drivers/scsi/qla2xxx/qla_iocb.c | 5 +- drivers/scsi/qla2xxx/qla_isr.c | 46 ++++--- drivers/scsi/qla2xxx/qla_mr.c | 10 +- drivers/scsi/scsi_transport_fc.c | 55 ++++---- 10 files changed, 398 insertions(+), 275 deletions(-)
drivers/s390/scsi/zfcp_fc.c +6 -3
@@ -900,8 +900,9 @@ static struct zfcp_fc_wka_port *zfcp_fc_job_wka_port(struct fc_bsg_job *job)u32 preamble_word1;u8 gs_type;struct zfcp_adapter *adapter; +struct fc_bsg_request *bsg_request = job->request; - preamble_word1 = job->request->rqst_data.r_ct.preamble_word1; + preamble_word1 = bsg_request->rqst_data.r_ct.preamble_word1; gs_type = (preamble_word1 &0xff000000 ) >>24 ; adapter = (struct zfcp_adapter *) job->shost->hostdata[0 ];
@@ -938,6 +939,7 @@ static int zfcp_fc_exec_els_job(struct fc_bsg_job *job, {struct zfcp_fsf_ct_els *els = job->dd_data;struct fc_rport *rport = job->rport; +struct fc_bsg_request *bsg_request = job->request;struct zfcp_port *port;u32 d_id;
@@ -949,7 +951,7 @@ static int zfcp_fc_exec_els_job(struct fc_bsg_job *job, d_id = port->d_id;put_device (&port->dev); }else - d_id =ntoh24 (job->request->rqst_data.h_els.port_id); + d_id =ntoh24 (bsg_request->rqst_data.h_els.port_id); els->handler = zfcp_fc_ct_els_job_handler;return zfcp_fsf_send_els (adapter, d_id, els, job->req->timeout /HZ );
@@ -983,6 +985,7 @@ int zfcp_fc_exec_bsg_job(struct fc_bsg_job *job)struct Scsi_Host *shost;struct zfcp_adapter *adapter;struct zfcp_fsf_ct_els *ct_els = job->dd_data; +struct fc_bsg_request *bsg_request = job->request; shost = job->rport ?rport_to_shost (job->rport) : job->shost; adapter = (struct zfcp_adapter *)shost->hostdata[0 ];
@@ -994,7 +997,7 @@ int zfcp_fc_exec_bsg_job(struct fc_bsg_job *job) ct_els->resp = job->reply_payload.sg_list; ct_els->handler_data = job; -switch (job->request->msgcode) { +switch (bsg_request->msgcode) {case FC_BSG_RPT_ELS :case FC_BSG_HST_ELS_NOLOGIN :return zfcp_fc_exec_els_job (job, adapter);
drivers/scsi/bfa/bfad_bsg.c +23 -17
@@ -3132,7 +3132,9 @@static int bfad_im_bsg_vendor_request (struct fc_bsg_job *job) { -uint32_t vendor_cmd = job->request->rqst_data.h_vendor.vendor_cmd[0 ]; +struct fc_bsg_request *bsg_request = job->request; +struct fc_bsg_reply *bsg_reply = job->reply; +uint32_t vendor_cmd = bsg_request->rqst_data.h_vendor.vendor_cmd[0 ];struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) job->shost->hostdata[0 ];struct bfad_s *bfad = im_port->bfad;
@@ -3175,8 +3177,8 @@/* Fill the BSG job reply data */ job->reply_len = job->reply_payload.payload_len; - job->reply->reply_payload_rcv_len = job->reply_payload.payload_len; - job->reply->result = rc; + bsg_reply->reply_payload_rcv_len = job->reply_payload.payload_len; + bsg_reply->result = rc; job->job_done (job);return rc;
@@ -3184,9 +3186,9 @@/* free the command buffer */ kfree (payload_kbuf); out: - job->reply->result = rc; + bsg_reply->result = rc; job->reply_len =sizeof (uint32_t ); - job->reply->reply_payload_rcv_len =0 ; + bsg_reply->reply_payload_rcv_len =0 ;return rc; }
@@ -3362,18 +3364,20 @@ struct bfad_buf_info *struct bfad_fcxp *drv_fcxp;struct bfa_fcs_lport_s *fcs_port;struct bfa_fcs_rport_s *fcs_rport; -uint32_t command_type = job->request->msgcode; +struct fc_bsg_request *bsg_request = bsg_request; +struct fc_bsg_reply *bsg_reply = job->reply; +uint32_t command_type = bsg_request->msgcode;unsigned long flags;struct bfad_buf_info *rsp_buf_info;void *req_kbuf =NULL , *rsp_kbuf =NULL ;int rc = -EINVAL ; job->reply_len =sizeof (uint32_t );/* Atleast uint32_t reply_len */ - job->reply->reply_payload_rcv_len =0 ; + bsg_reply->reply_payload_rcv_len =0 ;/* Get the payload passed in from userspace */ - bsg_data = (struct bfa_bsg_data *) (((char *)job->request) + -sizeof (struct fc_bsg_request )); + bsg_data = (struct bfa_bsg_data *) (((char *)bsg_request) + +sizeof (struct fc_bsg_request ));if (bsg_data ==NULL ) goto out;
@@ -3517,13 +3521,13 @@ struct bfad_buf_info */* fill the job->reply data */ if (drv_fcxp->req_status ==BFA_STATUS_OK ) { job->reply_len = drv_fcxp->rsp_len; - job->reply->reply_payload_rcv_len = drv_fcxp->rsp_len; - job->reply->reply_data.ctels_reply.status =FC_CTELS_STATUS_OK ; + bsg_reply->reply_payload_rcv_len = drv_fcxp->rsp_len; + bsg_reply->reply_data.ctels_reply.status =FC_CTELS_STATUS_OK ; }else { - job->reply->reply_payload_rcv_len = + bsg_reply->reply_payload_rcv_len =sizeof (struct fc_bsg_ctels_reply ); job->reply_len =sizeof (uint32_t ); - job->reply->reply_data.ctels_reply.status = + bsg_reply->reply_data.ctels_reply.status =FC_CTELS_STATUS_REJECT ; }
@@ -3549,7 +3553,7 @@ struct bfad_buf_info *kfree (bsg_fcpt);kfree (drv_fcxp); out: - job->reply->result = rc; + bsg_reply->result = rc;if (rc ==BFA_STATUS_OK ) job->job_done (job);
@@ -3560,9 +3564,11 @@ struct bfad_buf_info *int bfad_im_bsg_request (struct fc_bsg_job *job) { +struct fc_bsg_request *bsg_request = job->request; +struct fc_bsg_reply *bsg_reply = job->reply;uint32_t rc =BFA_STATUS_OK ; -switch (job->request->msgcode) { +switch (bsg_request->msgcode) {case FC_BSG_HST_VENDOR :/* Process BSG HST Vendor requests */ rc =bfad_im_bsg_vendor_request (job);
@@ -3575,8 +3581,8 @@ struct bfad_buf_info * rc =bfad_im_bsg_els_ct_request (job);break ;default : - job->reply->result = rc = -EINVAL ; - job->reply->reply_payload_rcv_len =0 ; + bsg_reply->result = rc = -EINVAL ; + bsg_reply->reply_payload_rcv_len =0 ;break ; }
drivers/scsi/ibmvscsi/ibmvfc.c +12 -10
@@ -1827,28 +1827,30 @@ static int ibmvfc_bsg_request(struct fc_bsg_job *job)struct ibmvfc_event *evt;union ibmvfc_iu rsp_iu;unsigned long flags, port_id =-1 ; -unsigned int code = job->request->msgcode; +struct fc_bsg_request *bsg_request = job->request; +struct fc_bsg_reply *bsg_reply = job->reply; +unsigned int code = bsg_request->msgcode;int rc =0 , req_seg, rsp_seg, issue_login =0 ;u32 fc_flags, rsp_len;ENTER ; - job->reply->reply_payload_rcv_len =0 ; + bsg_reply->reply_payload_rcv_len =0 ;if (rport) port_id = rport->port_id;switch (code) {case FC_BSG_HST_ELS_NOLOGIN : - port_id = (job->request->rqst_data.h_els.port_id[0 ] <<16 ) | - (job->request->rqst_data.h_els.port_id[1 ] <<8 ) | - job->request->rqst_data.h_els.port_id[2 ]; + port_id = (bsg_request->rqst_data.h_els.port_id[0 ] <<16 ) | + (bsg_request->rqst_data.h_els.port_id[1 ] <<8 ) | + bsg_request->rqst_data.h_els.port_id[2 ];case FC_BSG_RPT_ELS : fc_flags =IBMVFC_FC_ELS ;break ;case FC_BSG_HST_CT : issue_login =1 ; - port_id = (job->request->rqst_data.h_ct.port_id[0 ] <<16 ) | - (job->request->rqst_data.h_ct.port_id[1 ] <<8 ) | - job->request->rqst_data.h_ct.port_id[2 ]; + port_id = (bsg_request->rqst_data.h_ct.port_id[0 ] <<16 ) | + (bsg_request->rqst_data.h_ct.port_id[1 ] <<8 ) | + bsg_request->rqst_data.h_ct.port_id[2 ];case FC_BSG_RPT_CT : fc_flags =IBMVFC_FC_CT_IU ;break ;
@@ -1937,12 +1939,12 @@ static int ibmvfc_bsg_request(struct fc_bsg_job *job)if (rsp_iu.passthru.common.status) rc = -EIO ;else - job->reply->reply_payload_rcv_len = rsp_len; + bsg_reply->reply_payload_rcv_len = rsp_len;spin_lock_irqsave (vhost->host->host_lock, flags);ibmvfc_free_event (evt);spin_unlock_irqrestore (vhost->host->host_lock, flags); - job->reply->result = rc; + bsg_reply->result = rc; job->job_done (job); rc =0 ; out:
drivers/scsi/libfc/fc_lport.c +13 -10
@@ -1902,13 +1902,14 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp, {struct fc_bsg_info *info = info_arg;struct fc_bsg_job *job = info->job; +struct fc_bsg_reply *bsg_reply = job->reply;struct fc_lport *lport = info->lport;struct fc_frame_header *fh;size_t len;void *buf;if (IS_ERR (fp)) { - job->reply->result = (PTR_ERR (fp) == -FC_EX_CLOSED ) ? + bsg_reply->result = (PTR_ERR (fp) == -FC_EX_CLOSED ) ? -ECONNABORTED : -ETIMEDOUT ; job->reply_len =sizeof (uint32_t ); job->state_flags |=FC_RQST_STATE_DONE ;
@@ -1929,23 +1930,23 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp, (unsigned short )fc_frame_payload_op (fp);/* Save the reply status of the job */ - job->reply->reply_data.ctels_reply.status = + bsg_reply->reply_data.ctels_reply.status = (cmd == info->rsp_code) ?FC_CTELS_STATUS_OK :FC_CTELS_STATUS_REJECT ; } - job->reply->reply_payload_rcv_len += + bsg_reply->reply_payload_rcv_len +=fc_copy_buffer_to_sglist (buf, len, info->sg, &info->nents, &info->offset,NULL );if (fr_eof (fp) ==FC_EOF_T && (ntoh24 (fh->fh_f_ctl) & (FC_FC_LAST_SEQ |FC_FC_END_SEQ )) == (FC_FC_LAST_SEQ |FC_FC_END_SEQ )) { -if (job->reply->reply_payload_rcv_len > +if (bsg_reply->reply_payload_rcv_len > job->reply_payload.payload_len) - job->reply->reply_payload_rcv_len = + bsg_reply->reply_payload_rcv_len = job->reply_payload.payload_len; - job->reply->result =0 ; + bsg_reply->result =0 ; job->state_flags |=FC_RQST_STATE_DONE ; job->job_done (job);kfree (info);
@@ -2082,6 +2083,8 @@ static int fc_lport_ct_request(struct fc_bsg_job *job,*/ int fc_lport_bsg_request (struct fc_bsg_job *job) { +struct fc_bsg_request *bsg_request = job->request; +struct fc_bsg_reply *bsg_reply = job->reply;struct request *rsp = job->req->next_rq;struct Scsi_Host *shost = job->shost;struct fc_lport *lport =shost_priv (shost);
@@ -2090,13 +2093,13 @@ int fc_lport_bsg_request(struct fc_bsg_job *job)int rc = -EINVAL ;u32 did, tov; - job->reply->reply_payload_rcv_len =0 ; + bsg_reply->reply_payload_rcv_len =0 ;if (rsp) rsp->resid_len = job->reply_payload.payload_len;mutex_lock (&lport->lp_mutex); -switch (job->request->msgcode) { +switch (bsg_request->msgcode) {case FC_BSG_RPT_ELS : rport = job->rport;if (!rport)
@@ -2118,7 +2121,7 @@ int fc_lport_bsg_request(struct fc_bsg_job *job)break ;case FC_BSG_HST_CT : - did =ntoh24 (job->request->rqst_data.h_ct.port_id); + did =ntoh24 (bsg_request->rqst_data.h_ct.port_id);if (did ==FC_FID_DIR_SERV ) { rdata = lport->dns_rdata;if (!rdata)
@@ -2136,7 +2139,7 @@ int fc_lport_bsg_request(struct fc_bsg_job *job)break ;case FC_BSG_HST_ELS_NOLOGIN : - did =ntoh24 (job->request->rqst_data.h_els.port_id); + did =ntoh24 (bsg_request->rqst_data.h_els.port_id); rc =fc_lport_els_request (job, lport, did, lport->e_d_tov);break ; }
drivers/scsi/lpfc/lpfc_bsg.c +124 -75
806 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_bsg.c +152 -112
918 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_iocb.c +3 -2
@@ -2198,6 +2198,7 @@ static void qla25xx_set_que(srb_t *sp, struct rsp_que **rsp) qla24xx_els_iocb(srb_t *sp, struct els_entry_24xx *els_iocb) {struct fc_bsg_job *bsg_job = sp->u.bsg_job; +struct fc_bsg_request *bsg_request = bsg_job->request; els_iocb->entry_type =ELS_IOCB_TYPE ; els_iocb->entry_count =1 ;
@@ -2212,8 +2213,8 @@ static void qla25xx_set_que(srb_t *sp, struct rsp_que **rsp) els_iocb->opcode = sp->type ==SRB_ELS_CMD_RPT ? - bsg_job->request->rqst_data.r_els.els_code : - bsg_job->request->rqst_data.h_els.command_code; + bsg_request->rqst_data.r_els.els_code : + bsg_request->rqst_data.h_els.command_code; els_iocb->port_id[0 ] = sp->fcport->d_id.b.al_pa; els_iocb->port_id[1 ] = sp->fcport->d_id.b.area; els_iocb->port_id[2 ] = sp->fcport->d_id.b.domain;
drivers/scsi/qla2xxx/qla_isr.c +27 -19
158 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_mr.c +7 -3
@@ -2207,6 +2207,7 @@const char func[] ="IOSB_IOCB" ;srb_t *sp;struct fc_bsg_job *bsg_job; +struct fc_bsg_reply *bsg_reply;struct srb_iocb *iocb_job;int res;struct qla_mt_iocb_rsp_fx00 fstatus;
@@ -2226,6 +2227,7 @@ pkt->dataword_r; }else { bsg_job = sp->u.bsg_job; + bsg_reply = bsg_job->reply;memset (&fstatus,0 ,sizeof (struct qla_mt_iocb_rsp_fx00 ));
@@ -2257,8 +2259,8 @@ sp->fcport->vha,0x5074 , (uint8_t *)fw_sts_ptr, sizeof(struct qla_mt_iocb_rsp_fx00)); - res = bsg_job->reply->result =DID_OK <<16 ; - bsg_job->reply->reply_payload_rcv_len = + res = bsg_reply->result =DID_OK <<16 ; + bsg_reply->reply_payload_rcv_len = bsg_job->reply_payload.payload_len; } sp->done (vha, sp, res);
@@ -3253,6 +3255,7 @@struct srb_iocb *fxio = &sp->u.iocb_cmd;struct qla_mt_iocb_rqst_fx00 *piocb_rqst;struct fc_bsg_job *bsg_job; +struct fc_bsg_request *bsg_request;struct fxdisc_entry_fx00 fx_iocb;uint8_t entry_cnt =1 ;
@@ -3301,8 +3304,9 @@ }else {struct scatterlist *sg; bsg_job = sp->u.bsg_job; + bsg_request = bsg_job->request; piocb_rqst = (struct qla_mt_iocb_rqst_fx00 *) - &bsg_job->request->rqst_data.h_vendor.vendor_cmd[1 ]; + &bsg_request->rqst_data.h_vendor.vendor_cmd[1 ]; fx_iocb.func_num = piocb_rqst->func_type; fx_iocb.adapid = piocb_rqst->adapid;
drivers/scsi/scsi_transport_fc.c +31 -24
133 lines not on this page · raw message
Signature · 1 line
1.8.5.6
PATCH v4 3/15 scsi: fc: Export fc_bsg_jobdone and use it in FC drivers
In reply to Johannes ThumshirnExport fc_bsg_jobdone so drivers can use it directly instead of doing the round-trip via struct fc_bsg_job::job_done() and use it in the LLDDs. That way we can also unify the interfaces of fc_bsg_jobdone and bsg_job_done.
As we've converted all LLDDs over to use fc_bsg_jobdone() directly, we can remove the function pointer from struct fc_bsg_job as well.
--- drivers/s390/scsi/zfcp_fc.c | 2 +- drivers/scsi/bfa/bfad_bsg.c | 6 ++-- drivers/scsi/ibmvscsi/ibmvfc.c | 3 +- drivers/scsi/libfc/fc_lport.c | 6 ++-- drivers/scsi/lpfc/lpfc_bsg.c | 71 +++++++++++++++++++++++++++------------- drivers/scsi/qla2xxx/qla_bsg.c | 66 ++++++++++++++++++++++++------------- drivers/scsi/scsi_transport_fc.c | 25 +++++++------- include/scsi/scsi_transport_fc.h | 3 +- 8 files changed, 119 insertions(+), 63 deletions(-)
drivers/s390/scsi/zfcp_fc.c +1 -1
@@ -892,7 +892,7 @@ static void zfcp_fc_ct_els_job_handler(void *data) jr->reply_payload_rcv_len = job->reply_payload.payload_len; jr->reply_data.ctels_reply.status =FC_CTELS_STATUS_OK ; jr->result = zfcp_ct_els->status ? -EIO :0 ; - job->job_done (job); +fc_bsg_jobdone (job, jr->result, jr->reply_payload_rcv_len); }static struct zfcp_fc_wka_port *zfcp_fc_job_wka_port (struct fc_bsg_job *job)
drivers/scsi/bfa/bfad_bsg.c +4 -2
@@ -3180,7 +3180,8 @@ bsg_reply->reply_payload_rcv_len = job->reply_payload.payload_len; bsg_reply->result = rc; - job->job_done (job); +fc_bsg_jobdone (job, bsg_reply->result, + bsg_reply->reply_payload_rcv_len);return rc; error:/* free the command buffer */
@@ -3556,7 +3557,8 @@ struct bfad_buf_info * bsg_reply->result = rc;if (rc ==BFA_STATUS_OK ) - job->job_done (job); +fc_bsg_jobdone (job, bsg_reply->result, + bsg_reply->reply_payload_rcv_len);return rc; }
drivers/scsi/ibmvscsi/ibmvfc.c +2 -1
@@ -1945,7 +1945,8 @@ static int ibmvfc_bsg_request(struct fc_bsg_job *job)ibmvfc_free_event (evt);spin_unlock_irqrestore (vhost->host->host_lock, flags); bsg_reply->result = rc; - job->job_done (job); +fc_bsg_jobdone (job, bsg_reply->result, + bsg_reply->reply_payload_rcv_len); rc =0 ; out: dma_unmap_sg(vhost->dev, job->request_payload.sg_list,
drivers/scsi/libfc/fc_lport.c +4 -2
@@ -1913,7 +1913,8 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp, -ECONNABORTED : -ETIMEDOUT; job->reply_len =sizeof (uint32_t ); job->state_flags |=FC_RQST_STATE_DONE ; - job->job_done (job); +fc_bsg_jobdone (job, bsg_reply->result, + bsg_reply->reply_payload_rcv_len);kfree (info);return ; }
@@ -1948,7 +1949,8 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp, job->reply_payload.payload_len; bsg_reply->result =0 ; job->state_flags |=FC_RQST_STATE_DONE ; - job->job_done (job); +fc_bsg_jobdone (job, bsg_reply->result, + bsg_reply->reply_payload_rcv_len);kfree (info); }fc_frame_free (fp);
drivers/scsi/lpfc/lpfc_bsg.c +48 -23
203 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_bsg.c +44 -22
198 lines not on this page · raw message
drivers/scsi/scsi_transport_fc.c +14 -11
@@ -3582,16 +3582,17 @@ struct fc_vport ** fc_bsg_jobdone - completion routine for bsg requests that the LLD has * completed * @job: fc_bsg_job that is complete +* @result: job reply result +* @reply_payload_rcv_len: length of payload received */ -static void -fc_bsg_jobdone (struct fc_bsg_job *job) +void fc_bsg_jobdone (struct fc_bsg_job *job,int result, +unsigned int reply_payload_rcv_len) {struct request *req = job->req;struct request *rsp = req->next_rq; -struct fc_bsg_reply *bsg_reply = job->reply;int err; - err = job->req->errors = bsg_reply->result; + err = job->req->errors = result;if (err <0 )/* we're only returning the result field in the reply */
@@ -3603,14 +3604,14 @@ struct fc_vport * req->resid_len =0 ;if (rsp) { -WARN_ON (bsg_reply->reply_payload_rcv_len > rsp->resid_len); +WARN_ON (reply_payload_rcv_len > rsp->resid_len);/* set reply (bidi) residual */ - rsp->resid_len -=min (bsg_reply->reply_payload_rcv_len, - rsp->resid_len); + rsp->resid_len -=min (reply_payload_rcv_len, rsp->resid_len); }blk_complete_request (req); } +EXPORT_SYMBOL_GPL (fc_bsg_jobdone);/** * fc_bsg_softirq_done - softirq done routine for destroying the bsg requests
@@ -3742,7 +3743,6 @@ static void fc_bsg_softirq_done(struct request *rq)if (ret) goto failjob_rls_rqst_payload; } - job->job_done = fc_bsg_jobdone;if (rport) job->dev = &rport->dev;else
@@ -3846,7 +3846,8 @@ enum fc_dispatch_result { bsg_reply->reply_payload_rcv_len =0 ; bsg_reply->result = ret; job->reply_len =sizeof (uint32_t ); -fc_bsg_jobdone (job); +fc_bsg_jobdone (job, bsg_reply->result, + bsg_reply->reply_payload_rcv_len);return FC_DISPATCH_UNLOCKED ; }
@@ -3923,7 +3924,8 @@ enum fc_dispatch_result { bsg_reply->reply_payload_rcv_len =0 ; bsg_reply->result = ret; job->reply_len =sizeof (uint32_t ); -fc_bsg_jobdone (job); +fc_bsg_jobdone (job, bsg_reply->result, + bsg_reply->reply_payload_rcv_len);return FC_DISPATCH_UNLOCKED ; }
@@ -3983,7 +3985,8 @@ enum fc_dispatch_result { bsg_reply->reply_payload_rcv_len =0 ; bsg_reply->result = -ENOMSG ; job->reply_len =sizeof (uint32_t ); -fc_bsg_jobdone (job); +fc_bsg_jobdone (job, bsg_reply->result, + bsg_reply->reply_payload_rcv_len);spin_lock_irq (q->queue_lock);continue ; }
include/scsi/scsi_transport_fc.h +2 -1
@@ -637,7 +637,6 @@ struct fc_bsg_job {spinlock_t job_lock;unsigned int state_flags;unsigned int ref_cnt; -void (*job_done)(struct fc_bsg_job *);struct fc_bsg_request *request;struct fc_bsg_reply *reply;
@@ -842,5 +841,7 @@ struct fc_vport *fc_vport_create(struct Scsi_Host *shost, int channel, struct fc_vport_identifiers *);int fc_vport_terminate (struct fc_vport *vport);int fc_block_scsi_eh (struct scsi_cmnd *cmnd); +void fc_bsg_jobdone (struct fc_bsg_job *job,int result, +unsigned int reply_payload_rcv_len);#endif /* SCSI_TRANSPORT_FC_H */
Signature · 1 line
1.8.5.6
PATCH v4 4/15 scsi: fc: provide fc_bsg_to_shost() helper
In reply to Johannes ThumshirnProvide fc_bsg_to_shost() helper that will become handy when we're moving from struct fc_bsg_job to a plain struct bsg_job. Also use this little helper in the LLDDs.
--- drivers/s390/scsi/zfcp_fc.c | 6 +++-- drivers/scsi/bfa/bfad_bsg.c | 6 ++--- drivers/scsi/ibmvscsi/ibmvfc.c | 4 +-- drivers/scsi/libfc/fc_lport.c | 2 +- drivers/scsi/lpfc/lpfc_bsg.c | 34 ++++++++++++------------- drivers/scsi/qla2xxx/qla_bsg.c | 54 ++++++++++++++++++++-------------------- drivers/scsi/scsi_transport_fc.c | 2 +- include/scsi/scsi_transport_fc.h | 5 ++++ 8 files changed, 59 insertions(+), 54 deletions(-)
drivers/s390/scsi/zfcp_fc.c +4 -2
@@ -901,11 +901,13 @@ static struct zfcp_fc_wka_port *zfcp_fc_job_wka_port(struct fc_bsg_job *job)u8 gs_type;struct zfcp_adapter *adapter;struct fc_bsg_request *bsg_request = job->request; +struct Scsi_Host *shost; preamble_word1 = bsg_request->rqst_data.r_ct.preamble_word1; gs_type = (preamble_word1 &0xff000000 ) >>24 ; - adapter = (struct zfcp_adapter *) job->shost->hostdata[0 ]; + shost =fc_bsg_to_shost (job); + adapter = (struct zfcp_adapter *) shost->hostdata[0 ];switch (gs_type) {case FC_FST_ALIAS :
@@ -987,7 +989,7 @@ int zfcp_fc_exec_bsg_job(struct fc_bsg_job *job)struct zfcp_fsf_ct_els *ct_els = job->dd_data;struct fc_bsg_request *bsg_request = job->request; - shost = job->rport ?rport_to_shost (job->rport) : job->shost; + shost = job->rport ?rport_to_shost (job->rport) :fc_bsg_to_shost (job); adapter = (struct zfcp_adapter *)shost->hostdata[0 ];if (!(atomic_read (&adapter->status) &ZFCP_STATUS_COMMON_OPEN ))
drivers/scsi/bfa/bfad_bsg.c +2 -4
@@ -3135,8 +3135,7 @@struct fc_bsg_request *bsg_request = job->request;struct fc_bsg_reply *bsg_reply = job->reply;uint32_t vendor_cmd = bsg_request->rqst_data.h_vendor.vendor_cmd[0 ]; -struct bfad_im_port_s *im_port = - (struct bfad_im_port_s *) job->shost->hostdata[0 ]; +struct bfad_im_port_s *im_port =shost_priv (fc_bsg_to_shost (job));struct bfad_s *bfad = im_port->bfad;struct request_queue *request_q = job->req->q;void *payload_kbuf;
@@ -3358,8 +3357,7 @@ struct bfad_buf_info * bfad_im_bsg_els_ct_request(struct fc_bsg_job *job) {struct bfa_bsg_data *bsg_data; -struct bfad_im_port_s *im_port = - (struct bfad_im_port_s *) job->shost->hostdata[0 ]; +struct bfad_im_port_s *im_port =shost_priv (fc_bsg_to_shost (job));struct bfad_s *bfad = im_port->bfad;bfa_bsg_fcpt_t *bsg_fcpt;struct bfad_fcxp *drv_fcxp;
drivers/scsi/ibmvscsi/ibmvfc.c +2 -2
@@ -1708,7 +1708,7 @@ static void ibmvfc_bsg_timeout_done(struct ibmvfc_event *evt)**/ static int ibmvfc_bsg_timeout (struct fc_bsg_job *job) { -struct ibmvfc_host *vhost =shost_priv (job->shost); +struct ibmvfc_host *vhost =shost_priv (fc_bsg_to_shost (job));unsigned long port_id = (unsigned long )job->dd_data;struct ibmvfc_event *evt;struct ibmvfc_tmf *tmf;
@@ -1821,7 +1821,7 @@ static int ibmvfc_bsg_plogi(struct ibmvfc_host *vhost, unsigned int port_id)**/ static int ibmvfc_bsg_request (struct fc_bsg_job *job) { -struct ibmvfc_host *vhost =shost_priv (job->shost); +struct ibmvfc_host *vhost =shost_priv (fc_bsg_to_shost (job));struct fc_rport *rport = job->rport;struct ibmvfc_passthru_mad *mad;struct ibmvfc_event *evt;
drivers/scsi/libfc/fc_lport.c +1 -1
@@ -2088,7 +2088,7 @@ int fc_lport_bsg_request(struct fc_bsg_job *job)struct fc_bsg_request *bsg_request = job->request;struct fc_bsg_reply *bsg_reply = job->reply;struct request *rsp = job->req->next_rq; -struct Scsi_Host *shost = job->shost; +struct Scsi_Host *shost =fc_bsg_to_shost (job);struct fc_lport *lport =shost_priv (shost);struct fc_rport *rport;struct fc_rport_priv *rdata;
drivers/scsi/lpfc/lpfc_bsg.c +17 -17
@@ -384,7 +384,7 @@ struct lpfc_dmabufext {static int lpfc_bsg_send_mgmt_cmd (struct fc_bsg_job *job) { -struct lpfc_vport *vport = (struct lpfc_vport *)job->shost->hostdata; +struct lpfc_vport *vport =shost_priv (fc_bsg_to_shost (job));struct lpfc_hba *phba = vport->phba;struct lpfc_rport_data *rdata = job->rport->dd_data;struct lpfc_nodelist *ndlp = rdata->pnode;
@@ -658,7 +658,7 @@ struct lpfc_dmabufext {static int lpfc_bsg_rport_els (struct fc_bsg_job *job) { -struct lpfc_vport *vport = (struct lpfc_vport *)job->shost->hostdata; +struct lpfc_vport *vport =shost_priv (fc_bsg_to_shost (job));struct lpfc_hba *phba = vport->phba;struct lpfc_rport_data *rdata = job->rport->dd_data;struct lpfc_nodelist *ndlp = rdata->pnode;
@@ -1202,7 +1202,7 @@ struct lpfc_dmabufext {static int lpfc_bsg_hba_set_event (struct fc_bsg_job *job) { -struct lpfc_vport *vport = (struct lpfc_vport *)job->shost->hostdata; +struct lpfc_vport *vport =shost_priv (fc_bsg_to_shost (job));struct lpfc_hba *phba = vport->phba;struct fc_bsg_request *bsg_request = job->request;struct set_ct_event *event_req;
@@ -1287,7 +1287,7 @@ struct lpfc_dmabufext {static int lpfc_bsg_hba_get_event (struct fc_bsg_job *job) { -struct lpfc_vport *vport = (struct lpfc_vport *)job->shost->hostdata; +struct lpfc_vport *vport =shost_priv (fc_bsg_to_shost (job));struct lpfc_hba *phba = vport->phba;struct fc_bsg_request *bsg_request = job->request;struct fc_bsg_reply *bsg_reply = job->reply;
@@ -1625,7 +1625,7 @@ struct lpfc_dmabufext {static int lpfc_bsg_send_mgmt_rsp (struct fc_bsg_job *job) { -struct lpfc_vport *vport = (struct lpfc_vport *)job->shost->hostdata; +struct lpfc_vport *vport =shost_priv (fc_bsg_to_shost (job));struct lpfc_hba *phba = vport->phba;struct fc_bsg_request *bsg_request = job->request;struct fc_bsg_reply *bsg_reply = job->reply;
@@ -2201,10 +2201,10 @@ struct lpfc_dmabufext {struct lpfc_hba *phba;int rc; - shost = job->shost; + shost =fc_bsg_to_shost (job);if (!shost)return -ENODEV ; - vport = (struct lpfc_vport *)job->shost->hostdata; + vport =shost_priv (shost);if (!vport)return -ENODEV ; phba = vport->phba;
@@ -2241,10 +2241,10 @@ struct lpfc_dmabufext {uint32_t timeout;int rc, i; - shost = job->shost; + shost =fc_bsg_to_shost (job);if (!shost)return -ENODEV ; - vport = (struct lpfc_vport *)job->shost->hostdata; + vport =shost_priv (shost);if (!vport)return -ENODEV ; phba = vport->phba;
@@ -2325,12 +2325,12 @@ struct lpfc_dmabufext {struct diag_status *diag_status_reply;int mbxstatus, rc =0 ; - shost = job->shost; + shost =fc_bsg_to_shost (job);if (!shost) { rc = -ENODEV ; goto job_error; } - vport = (struct lpfc_vport *)job->shost->hostdata; + vport =shost_priv (shost);if (!vport) { rc = -ENODEV ; goto job_error;
@@ -3018,7 +3018,7 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri,static int lpfc_bsg_diag_loopback_run (struct fc_bsg_job *job) { -struct lpfc_vport *vport = (struct lpfc_vport *)job->shost->hostdata; +struct lpfc_vport *vport =shost_priv (fc_bsg_to_shost (job));struct fc_bsg_reply *bsg_reply = job->reply;struct lpfc_hba *phba = vport->phba;struct lpfc_bsg_event *evt;
@@ -3322,7 +3322,7 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri,static int lpfc_bsg_get_dfc_rev (struct fc_bsg_job *job) { -struct lpfc_vport *vport = (struct lpfc_vport *)job->shost->hostdata; +struct lpfc_vport *vport =shost_priv (fc_bsg_to_shost (job));struct fc_bsg_reply *bsg_reply = job->reply;struct lpfc_hba *phba = vport->phba;struct get_mgmt_rev_reply *event_reply;
@@ -4933,7 +4933,7 @@ static int lpfc_bsg_check_cmd_access(struct lpfc_hba *phba,static int lpfc_bsg_mbox_cmd (struct fc_bsg_job *job) { -struct lpfc_vport *vport = (struct lpfc_vport *)job->shost->hostdata; +struct lpfc_vport *vport =shost_priv (fc_bsg_to_shost (job));struct fc_bsg_request *bsg_request = job->request;struct fc_bsg_reply *bsg_reply = job->reply;struct lpfc_hba *phba = vport->phba;
@@ -5093,7 +5093,7 @@ static int lpfc_bsg_check_cmd_access(struct lpfc_hba *phba,static int lpfc_menlo_cmd (struct fc_bsg_job *job) { -struct lpfc_vport *vport = (struct lpfc_vport *)job->shost->hostdata; +struct lpfc_vport *vport =shost_priv (fc_bsg_to_shost (job));struct fc_bsg_request *bsg_request = job->request;struct fc_bsg_reply *bsg_reply = job->reply;struct lpfc_hba *phba = vport->phba;
@@ -5257,7 +5257,7 @@ static int lpfc_bsg_check_cmd_access(struct lpfc_hba *phba,static int lpfc_forced_link_speed (struct fc_bsg_job *job) { -struct Scsi_Host *shost = job->shost; +struct Scsi_Host *shost =fc_bsg_to_shost (job);struct lpfc_vport *vport =shost_priv (shost);struct lpfc_hba *phba = vport->phba;struct fc_bsg_reply *bsg_reply = job->reply;
@@ -5400,7 +5400,7 @@ static int lpfc_bsg_check_cmd_access(struct lpfc_hba *phba,int lpfc_bsg_timeout (struct fc_bsg_job *job) { -struct lpfc_vport *vport = (struct lpfc_vport *)job->shost->hostdata; +struct lpfc_vport *vport =shost_priv (fc_bsg_to_shost (job));struct lpfc_hba *phba = vport->phba;struct lpfc_iocbq *cmdiocb;struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING ];
drivers/scsi/qla2xxx/qla_bsg.c +27 -27
213 lines not on this page · raw message
drivers/scsi/scsi_transport_fc.c +1 -1
@@ -3639,7 +3639,7 @@ static void fc_bsg_softirq_done(struct request *rq) fc_bsg_job_timeout(struct request *req) {struct fc_bsg_job *job = (void *) req->special; -struct Scsi_Host *shost = job->shost; +struct Scsi_Host *shost =fc_bsg_to_shost (job);struct fc_internal *i =to_fc_internal (shost->transportt);unsigned long flags;int err =0 , done =0 ;
include/scsi/scsi_transport_fc.h +5 -0
@@ -819,6 +819,11 @@ static inline void u64_to_wwn(u64 inm, u8 *wwn) vport->vport_state = new_state; } +static inline struct Scsi_Host *fc_bsg_to_shost (struct fc_bsg_job *job) +{ +return job->shost; +} +struct scsi_transport_template *fc_attach_transport (struct fc_function_template *);void fc_release_transport (struct scsi_transport_template *);
Signature · 1 line
1.8.5.6
PATCH v4 5/15 scsi: fc: provide fc_bsg_to_rport() helper
In reply to Johannes ThumshirnProvide fc_bsg_to_rport() helper that will become handy when we're moving from struct fc_bsg_job to a plain struct bsg_job. Also move all LLDDs to use the new helper.
--- drivers/s390/scsi/zfcp_fc.c | 8 +++++--- drivers/scsi/ibmvscsi/ibmvfc.c | 2 +- drivers/scsi/libfc/fc_lport.c | 4 ++-- drivers/scsi/lpfc/lpfc_bsg.c | 4 ++-- drivers/scsi/qla2xxx/qla_bsg.c | 4 ++-- drivers/scsi/scsi_transport_fc.c | 3 ++- include/scsi/scsi_transport_fc.h | 5 +++++ 7 files changed, 19 insertions(+), 11 deletions(-)
drivers/s390/scsi/zfcp_fc.c +5 -3
@@ -901,12 +901,13 @@ static struct zfcp_fc_wka_port *zfcp_fc_job_wka_port(struct fc_bsg_job *job)u8 gs_type;struct zfcp_adapter *adapter;struct fc_bsg_request *bsg_request = job->request; +struct fc_rport *rport =fc_bsg_to_rport (job);struct Scsi_Host *shost; preamble_word1 = bsg_request->rqst_data.r_ct.preamble_word1; gs_type = (preamble_word1 &0xff000000 ) >>24 ; - shost =fc_bsg_to_shost (job); + shost = rport ?rport_to_shost (rport) :fc_bsg_to_shost (job); adapter = (struct zfcp_adapter *) shost->hostdata[0 ];switch (gs_type) {
@@ -940,7 +941,7 @@ static int zfcp_fc_exec_els_job(struct fc_bsg_job *job, struct zfcp_adapter *adapter) {struct zfcp_fsf_ct_els *els = job->dd_data; -struct fc_rport *rport = job->rport; +struct fc_rport *rport =fc_bsg_to_rport (job);struct fc_bsg_request *bsg_request = job->request;struct zfcp_port *port;u32 d_id;
@@ -988,8 +989,9 @@ int zfcp_fc_exec_bsg_job(struct fc_bsg_job *job)struct zfcp_adapter *adapter;struct zfcp_fsf_ct_els *ct_els = job->dd_data;struct fc_bsg_request *bsg_request = job->request; +struct fc_rport *rport =fc_bsg_to_rport (job); - shost = job->rport ?rport_to_shost (job->rport) :fc_bsg_to_shost (job); + shost = rport ?rport_to_shost (rport) :fc_bsg_to_shost (job); adapter = (struct zfcp_adapter *)shost->hostdata[0 ];if (!(atomic_read (&adapter->status) &ZFCP_STATUS_COMMON_OPEN ))
drivers/scsi/ibmvscsi/ibmvfc.c +1 -1
@@ -1822,7 +1822,7 @@ static int ibmvfc_bsg_plogi(struct ibmvfc_host *vhost, unsigned int port_id)static int ibmvfc_bsg_request (struct fc_bsg_job *job) {struct ibmvfc_host *vhost =shost_priv (fc_bsg_to_shost (job)); -struct fc_rport *rport = job->rport; +struct fc_rport *rport =fc_bsg_to_rport (job);struct ibmvfc_passthru_mad *mad;struct ibmvfc_event *evt;union ibmvfc_iu rsp_iu;
drivers/scsi/libfc/fc_lport.c +2 -2
@@ -2103,7 +2103,7 @@ int fc_lport_bsg_request(struct fc_bsg_job *job)switch (bsg_request->msgcode) {case FC_BSG_RPT_ELS : - rport = job->rport; + rport =fc_bsg_to_rport (job);if (!rport)break ;
@@ -2113,7 +2113,7 @@ int fc_lport_bsg_request(struct fc_bsg_job *job)break ;case FC_BSG_RPT_CT : - rport = job->rport; + rport =fc_bsg_to_rport (job);if (!rport)break ;
drivers/scsi/lpfc/lpfc_bsg.c +2 -2
@@ -386,7 +386,7 @@ struct lpfc_dmabufext { {struct lpfc_vport *vport =shost_priv (fc_bsg_to_shost (job));struct lpfc_hba *phba = vport->phba; -struct lpfc_rport_data *rdata = job->rport->dd_data; +struct lpfc_rport_data *rdata =fc_bsg_to_rport (job)->dd_data;struct lpfc_nodelist *ndlp = rdata->pnode;struct fc_bsg_reply *bsg_reply = job->reply;struct ulp_bde64 *bpl =NULL ;
@@ -660,7 +660,7 @@ struct lpfc_dmabufext { {struct lpfc_vport *vport =shost_priv (fc_bsg_to_shost (job));struct lpfc_hba *phba = vport->phba; -struct lpfc_rport_data *rdata = job->rport->dd_data; +struct lpfc_rport_data *rdata =fc_bsg_to_rport (job)->dd_data;struct lpfc_nodelist *ndlp = rdata->pnode;struct fc_bsg_request *bsg_request = job->request;struct fc_bsg_reply *bsg_reply = job->reply;
drivers/scsi/qla2xxx/qla_bsg.c +2 -2
@@ -264,7 +264,7 @@uint16_t nextlid =0 ;if (bsg_request->msgcode ==FC_BSG_RPT_ELS ) { - rport = bsg_job->rport; + rport =fc_bsg_to_rport (bsg_job); fcport = *(fc_port_t **) rport->dd_data; host =rport_to_shost (rport); vha =shost_priv (host);
@@ -2485,7 +2485,7 @@ bsg_reply->reply_payload_rcv_len =0 ;if (bsg_request->msgcode ==FC_BSG_RPT_ELS ) { - rport = bsg_job->rport; + rport =fc_bsg_to_rport (bsg_job); host =rport_to_shost (rport); vha =shost_priv (host); }else {
drivers/scsi/scsi_transport_fc.c +2 -1
@@ -3640,11 +3640,12 @@ static void fc_bsg_softirq_done(struct request *rq) {struct fc_bsg_job *job = (void *) req->special;struct Scsi_Host *shost =fc_bsg_to_shost (job); +struct fc_rport *rport =fc_bsg_to_rport (job);struct fc_internal *i =to_fc_internal (shost->transportt);unsigned long flags;int err =0 , done =0 ; -if (job->rport && job->rport->port_state ==FC_PORTSTATE_BLOCKED ) +if (rport && rport->port_state ==FC_PORTSTATE_BLOCKED )return BLK_EH_RESET_TIMER ;spin_lock_irqsave (&job->job_lock, flags);
include/scsi/scsi_transport_fc.h +5 -0
@@ -824,6 +824,11 @@ static inline struct Scsi_Host *fc_bsg_to_shost(struct fc_bsg_job *job)return job->shost; } +static inline struct fc_rport *fc_bsg_to_rport (struct fc_bsg_job *job) +{ +return job->rport; +} +struct scsi_transport_template *fc_attach_transport (struct fc_function_template *);void fc_release_transport (struct scsi_transport_template *);
Signature · 1 line
1.8.5.6
PATCH v4 6/15 scsi: libfc: don't set FC_RQST_STATE_DONE before calling fc_bsg_jobdone()
In reply to Johannes ThumshirnDon't set FC_RQST_STATE_DONE before calling fc_bsg_jobdone() as fc_bsg_jobdone() calls blk_complete_requeust() which raises a soft-IRQ that ends up in fc_bsg_sofirq_done() and fc_bsg_softirq_done() sets the FC_RQST_STATE_DONE flag.
--- drivers/scsi/libfc/fc_lport.c | 2 -- 1 file changed, 2 deletions(-)
drivers/scsi/libfc/fc_lport.c +0 -2
@@ -1912,7 +1912,6 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp, bsg_reply->result = (PTR_ERR (fp) == -FC_EX_CLOSED ) ? -ECONNABORTED : -ETIMEDOUT ; job->reply_len =sizeof (uint32_t ); - job->state_flags |=FC_RQST_STATE_DONE ;fc_bsg_jobdone (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);kfree (info);
@@ -1948,7 +1947,6 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp, bsg_reply->reply_payload_rcv_len = job->reply_payload.payload_len; bsg_reply->result =0 ; - job->state_flags |=FC_RQST_STATE_DONE ;fc_bsg_jobdone (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);kfree (info);
Signature · 1 line
1.8.5.6
PATCH v4 9/15 scsi: change FC drivers to use 'struct bsg_job'
In reply to Johannes ThumshirnChange FC drivers to use 'struct bsg_job' from bsg-lib.h instead of 'struct fc_bsg_job' from scsi_transport_fc.h and remove 'struct fc_bsg_job'.
--- drivers/s390/scsi/zfcp_ext.h | 4 +-- drivers/s390/scsi/zfcp_fc.c | 15 ++++---- drivers/scsi/bfa/bfad_bsg.c | 10 +++--- drivers/scsi/bfa/bfad_im.h | 4 +-- drivers/scsi/ibmvscsi/ibmvfc.c | 9 ++--- drivers/scsi/libfc/fc_lport.c | 10 +++--- drivers/scsi/lpfc/lpfc_bsg.c | 76 ++++++++++++++++++++-------------------- drivers/scsi/lpfc/lpfc_crtn.h | 4 +-- drivers/scsi/qla2xxx/qla_bsg.c | 61 ++++++++++++++++---------------- drivers/scsi/qla2xxx/qla_def.h | 2 +- drivers/scsi/qla2xxx/qla_gbl.h | 4 +-- drivers/scsi/qla2xxx/qla_iocb.c | 8 ++--- drivers/scsi/qla2xxx/qla_isr.c | 6 ++-- drivers/scsi/qla2xxx/qla_mr.c | 5 +-- drivers/scsi/scsi_transport_fc.c | 20 +++++------ include/scsi/libfc.h | 2 +- include/scsi/scsi_transport_fc.h | 63 ++++++++++----------------------- 17 files changed, 139 insertions(+), 164 deletions(-)
drivers/s390/scsi/zfcp_ext.h +2 -2
@@ -84,8 +84,8 @@ extern void zfcp_fc_enqueue_event(struct zfcp_adapter *,extern void zfcp_fc_wka_ports_force_offline (struct zfcp_fc_wka_ports *);extern int zfcp_fc_gs_setup (struct zfcp_adapter *);extern void zfcp_fc_gs_destroy (struct zfcp_adapter *); -extern int zfcp_fc_exec_bsg_job (struct fc_bsg_job *); -extern int zfcp_fc_timeout_bsg_job (struct fc_bsg_job *); +extern int zfcp_fc_exec_bsg_job (struct bsg_job *); +extern int zfcp_fc_timeout_bsg_job (struct bsg_job *);extern void zfcp_fc_sym_name_update (struct work_struct *);extern unsigned int zfcp_fc_port_scan_backoff (void );extern void zfcp_fc_conditional_port_scan (struct zfcp_adapter *);
drivers/s390/scsi/zfcp_fc.c +8 -7
@@ -13,6 +13,7 @@#include <linux/slab.h> #include <linux/utsname.h> #include <linux/random.h> +#include <linux/bsg-lib.h> #include <scsi/fc/fc_els.h> #include <scsi/libfc.h> #include "zfcp_ext.h"
@@ -885,7 +886,7 @@ void zfcp_fc_sym_name_update(struct work_struct *work)static void zfcp_fc_ct_els_job_handler (void *data) { -struct fc_bsg_job *job = data; +struct bsg_job *job = data;struct zfcp_fsf_ct_els *zfcp_ct_els = job->dd_data;struct fc_bsg_reply *jr = job->reply;
@@ -895,7 +896,7 @@ static void zfcp_fc_ct_els_job_handler(void *data)fc_bsg_jobdone (job, jr->result, jr->reply_payload_rcv_len); } -static struct zfcp_fc_wka_port *zfcp_fc_job_wka_port (struct fc_bsg_job *job) +static struct zfcp_fc_wka_port *zfcp_fc_job_wka_port (struct bsg_job *job) {u32 preamble_word1;u8 gs_type;
@@ -928,7 +929,7 @@ static struct zfcp_fc_wka_port *zfcp_fc_job_wka_port(struct fc_bsg_job *job)static void zfcp_fc_ct_job_handler (void *data) { -struct fc_bsg_job *job = data; +struct bsg_job *job = data;struct zfcp_fc_wka_port *wka_port; wka_port =zfcp_fc_job_wka_port (job);
@@ -937,7 +938,7 @@ static void zfcp_fc_ct_job_handler(void *data)zfcp_fc_ct_els_job_handler (data); } -static int zfcp_fc_exec_els_job (struct fc_bsg_job *job, +static int zfcp_fc_exec_els_job (struct bsg_job *job,struct zfcp_adapter *adapter) {struct zfcp_fsf_ct_els *els = job->dd_data;
@@ -960,7 +961,7 @@ static int zfcp_fc_exec_els_job(struct fc_bsg_job *job,return zfcp_fsf_send_els (adapter, d_id, els, job->req->timeout /HZ ); } -static int zfcp_fc_exec_ct_job (struct fc_bsg_job *job, +static int zfcp_fc_exec_ct_job (struct bsg_job *job,struct zfcp_adapter *adapter) {int ret;
@@ -983,7 +984,7 @@ static int zfcp_fc_exec_ct_job(struct fc_bsg_job *job,return ret; } -int zfcp_fc_exec_bsg_job (struct fc_bsg_job *job) +int zfcp_fc_exec_bsg_job (struct bsg_job *job) {struct Scsi_Host *shost;struct zfcp_adapter *adapter;
@@ -1013,7 +1014,7 @@ int zfcp_fc_exec_bsg_job(struct fc_bsg_job *job) } } -int zfcp_fc_timeout_bsg_job (struct fc_bsg_job *job) +int zfcp_fc_timeout_bsg_job (struct bsg_job *job) {/* hardware tracks timeout, reset bsg timeout to not interfere */ return -EAGAIN ;
drivers/scsi/bfa/bfad_bsg.c +5 -5
@@ -3130,7 +3130,7 @@ }static int -bfad_im_bsg_vendor_request (struct fc_bsg_job *job) +bfad_im_bsg_vendor_request (struct bsg_job *job) {struct fc_bsg_request *bsg_request = job->request;struct fc_bsg_reply *bsg_reply = job->reply;
@@ -3314,7 +3314,7 @@ struct bfad_buf_info * }int -bfad_fcxp_bsg_send (struct fc_bsg_job *job,struct bfad_fcxp *drv_fcxp, +bfad_fcxp_bsg_send (struct bsg_job *job,struct bfad_fcxp *drv_fcxp,bfa_bsg_fcpt_t *bsg_fcpt) {struct bfa_fcxp_s *hal_fcxp;
@@ -3354,7 +3354,7 @@ struct bfad_buf_info * }int -bfad_im_bsg_els_ct_request (struct fc_bsg_job *job) +bfad_im_bsg_els_ct_request (struct bsg_job *job) {struct bfa_bsg_data *bsg_data;struct bfad_im_port_s *im_port =shost_priv (fc_bsg_to_shost (job));
@@ -3562,7 +3562,7 @@ struct bfad_buf_info * }int -bfad_im_bsg_request (struct fc_bsg_job *job) +bfad_im_bsg_request (struct bsg_job *job) {struct fc_bsg_request *bsg_request = job->request;struct fc_bsg_reply *bsg_reply = job->reply;
@@ -3590,7 +3590,7 @@ struct bfad_buf_info * }int -bfad_im_bsg_timeout (struct fc_bsg_job *job) +bfad_im_bsg_timeout (struct bsg_job *job) {/* Don't complete the BSG job request - return -EAGAIN * to reset bsg job timeout : for ELS/CT pass thru we
drivers/scsi/bfa/bfad_im.h +2 -2
@@ -166,8 +166,8 @@ void bfad_ramp_up_qdepth(struct bfad_itnim_s *itnim,irqreturn_t bfad_intx (int irq,void *dev_id); -int bfad_im_bsg_request (struct fc_bsg_job *job); -int bfad_im_bsg_timeout (struct fc_bsg_job *job); +int bfad_im_bsg_request (struct bsg_job *job); +int bfad_im_bsg_timeout (struct bsg_job *job);/* * Macro to set the SCSI device sdev_bflags - sdev_bflags are used by the
drivers/scsi/ibmvscsi/ibmvfc.c +5 -4
@@ -32,6 +32,7 @@#include <linux/of.h> #include <linux/pm.h> #include <linux/stringify.h> +#include <linux/bsg-lib.h> #include <asm/firmware.h> #include <asm/irq.h> #include <asm/vio.h>
@@ -1701,12 +1702,12 @@ static void ibmvfc_bsg_timeout_done(struct ibmvfc_event *evt)/** * ibmvfc_bsg_timeout - Handle a BSG timeout -* @job: struct fc_bsg_job that timed out +* @job: struct bsg_job that timed out * * Returns: * 0 on success / other on failure **/ -static int ibmvfc_bsg_timeout (struct fc_bsg_job *job) +static int ibmvfc_bsg_timeout (struct bsg_job *job) {struct ibmvfc_host *vhost =shost_priv (fc_bsg_to_shost (job));unsigned long port_id = (unsigned long )job->dd_data;
@@ -1814,12 +1815,12 @@ static int ibmvfc_bsg_plogi(struct ibmvfc_host *vhost, unsigned int port_id)/** * ibmvfc_bsg_request - Handle a BSG request -* @job: struct fc_bsg_job to be executed +* @job: struct bsg_job to be executed * * Returns: * 0 on success / other on failure **/ -static int ibmvfc_bsg_request (struct fc_bsg_job *job) +static int ibmvfc_bsg_request (struct bsg_job *job) {struct ibmvfc_host *vhost =shost_priv (fc_bsg_to_shost (job));struct fc_rport *rport =fc_bsg_to_rport (job);
drivers/scsi/libfc/fc_lport.c +5 -5
@@ -149,7 +149,7 @@* @offset: The offset into the response data */ struct fc_bsg_info { -struct fc_bsg_job *job; +struct bsg_job *job;struct fc_lport *lport;u16 rsp_code;struct scatterlist *sg;
@@ -1901,7 +1901,7 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp, void *info_arg) {struct fc_bsg_info *info = info_arg; -struct fc_bsg_job *job = info->job; +struct bsg_job *job = info->job;struct fc_bsg_reply *bsg_reply = job->reply;struct fc_lport *lport = info->lport;struct fc_frame_header *fh;
@@ -1964,7 +1964,7 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp,* Locking Note: The lport lock is expected to be held before calling * this routine. */ -static int fc_lport_els_request (struct fc_bsg_job *job, +static int fc_lport_els_request (struct bsg_job *job,struct fc_lport *lport,u32 did,u32 tov) {
@@ -2025,7 +2025,7 @@ static int fc_lport_els_request(struct fc_bsg_job *job,* Locking Note: The lport lock is expected to be held before calling * this routine. */ -static int fc_lport_ct_request (struct fc_bsg_job *job, +static int fc_lport_ct_request (struct bsg_job *job,struct fc_lport *lport,u32 did,u32 tov) {struct fc_bsg_info *info;
@@ -2081,7 +2081,7 @@ static int fc_lport_ct_request(struct fc_bsg_job *job,* FC Passthrough requests * @job: The BSG passthrough job */ -int fc_lport_bsg_request (struct fc_bsg_job *job) +int fc_lport_bsg_request (struct bsg_job *job) {struct fc_bsg_request *bsg_request = job->request;struct fc_bsg_reply *bsg_reply = job->reply;
drivers/scsi/lpfc/lpfc_bsg.c +38 -38
301 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_crtn.h +2 -2
@@ -429,8 +429,8 @@ int lpfc_sli4_get_avail_extnt_rsrc(struct lpfc_hba *, uint16_t,#define HBA_EVENT_LINK_DOWN 3/* functions to support SGIOv4/bsg interface */ -int lpfc_bsg_request (struct fc_bsg_job *); -int lpfc_bsg_timeout (struct fc_bsg_job *); +int lpfc_bsg_request (struct bsg_job *); +int lpfc_bsg_timeout (struct bsg_job *);int lpfc_bsg_ct_unsol_event (struct lpfc_hba *,struct lpfc_sli_ring *,struct lpfc_iocbq *);int lpfc_bsg_ct_unsol_abort (struct lpfc_hba *,struct hbq_dmabuf *);
drivers/scsi/qla2xxx/qla_bsg.c +31 -30
247 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_def.h +1 -1
@@ -403,7 +403,7 @@ struct srb_iocb {int iocbs;union {struct srb_iocb iocb_cmd; -struct fc_bsg_job *bsg_job; +struct bsg_job *bsg_job;struct srb_cmd scmd; } u;void (*done)(void *,void *,int );
drivers/scsi/qla2xxx/qla_gbl.h +2 -2
@@ -733,8 +733,8 @@ extern void qla2x00_set_model_info(scsi_qla_host_t *, uint8_t *,extern int qla8044_read_temperature (scsi_qla_host_t *);/* BSG related functions */ -extern int qla24xx_bsg_request (struct fc_bsg_job *); -extern int qla24xx_bsg_timeout (struct fc_bsg_job *); +extern int qla24xx_bsg_request (struct bsg_job *); +extern int qla24xx_bsg_timeout (struct bsg_job *);extern int qla84xx_reset_chip (scsi_qla_host_t *,uint16_t );extern int qla2x00_issue_iocb_timeout (scsi_qla_host_t *,void *,dma_addr_t ,size_t ,uint32_t );
drivers/scsi/qla2xxx/qla_iocb.c +4 -4
@@ -2197,7 +2197,7 @@ static void qla25xx_set_que(srb_t *sp, struct rsp_que **rsp)static void qla24xx_els_iocb (srb_t *sp,struct els_entry_24xx *els_iocb) { -struct fc_bsg_job *bsg_job = sp->u.bsg_job; +struct bsg_job *bsg_job = sp->u.bsg_job;struct fc_bsg_request *bsg_request = bsg_job->request; els_iocb->entry_type =ELS_IOCB_TYPE ;
@@ -2251,7 +2251,7 @@ static void qla25xx_set_que(srb_t *sp, struct rsp_que **rsp)uint16_t tot_dsds;scsi_qla_host_t *vha = sp->fcport->vha;struct qla_hw_data *ha = vha->hw; -struct fc_bsg_job *bsg_job = sp->u.bsg_job; +struct bsg_job *bsg_job = sp->u.bsg_job;int loop_iterartion =0 ;int entry_count =1 ;
@@ -2328,7 +2328,7 @@ static void qla25xx_set_que(srb_t *sp, struct rsp_que **rsp)uint16_t tot_dsds;scsi_qla_host_t *vha = sp->fcport->vha;struct qla_hw_data *ha = vha->hw; -struct fc_bsg_job *bsg_job = sp->u.bsg_job; +struct bsg_job *bsg_job = sp->u.bsg_job;int loop_iterartion =0 ;int entry_count =1 ;
@@ -2834,7 +2834,7 @@ static void qla25xx_set_que(srb_t *sp, struct rsp_que **rsp)struct scatterlist *sg;int index;int entry_count =1 ; -struct fc_bsg_job *bsg_job = sp->u.bsg_job; +struct bsg_job *bsg_job = sp->u.bsg_job;/*Update entry type to indicate bidir command */ *((uint32_t *)(&cmd_pkt->entry_type)) =
drivers/scsi/qla2xxx/qla_isr.c +3 -3
@@ -1356,7 +1356,7 @@ static void qla_irq_affinity_notify(struct irq_affinity_notify *,const char func[] ="CT_IOCB" ;const char *type;srb_t *sp; -struct fc_bsg_job *bsg_job; +struct bsg_job *bsg_job;struct fc_bsg_reply *bsg_reply;uint16_t comp_status;int res;
@@ -1415,7 +1415,7 @@ static void qla_irq_affinity_notify(struct irq_affinity_notify *,const char func[] ="ELS_CT_IOCB" ;const char *type;srb_t *sp; -struct fc_bsg_job *bsg_job; +struct bsg_job *bsg_job;struct fc_bsg_reply *bsg_reply;uint16_t comp_status;uint32_t fw_status[3 ];
@@ -1908,7 +1908,7 @@ struct scsi_dif_tuple {uint16_t scsi_status;uint16_t thread_id;uint32_t rval =EXT_STATUS_OK ; -struct fc_bsg_job *bsg_job =NULL ; +struct bsg_job *bsg_job =NULL ;struct fc_bsg_request *bsg_request;struct fc_bsg_reply *bsg_reply;sts_entry_t *sts;
drivers/scsi/qla2xxx/qla_mr.c +3 -2
@@ -10,6 +10,7 @@#include <linux/pci.h> #include <linux/ratelimit.h> #include <linux/vmalloc.h> +#include <linux/bsg-lib.h> #include <scsi/scsi_tcq.h> #include <linux/utsname.h>
@@ -2206,7 +2207,7 @@ {const char func[] ="IOSB_IOCB" ;srb_t *sp; -struct fc_bsg_job *bsg_job; +struct bsg_job *bsg_job;struct fc_bsg_reply *bsg_reply;struct srb_iocb *iocb_job;int res;
@@ -3254,7 +3255,7 @@ {struct srb_iocb *fxio = &sp->u.iocb_cmd;struct qla_mt_iocb_rqst_fx00 *piocb_rqst; -struct fc_bsg_job *bsg_job; +struct bsg_job *bsg_job;struct fc_bsg_request *bsg_request;struct fxdisc_entry_fx00 fx_iocb;uint8_t entry_cnt =1 ;
drivers/scsi/scsi_transport_fc.c +9 -11
@@ -3562,7 +3562,7 @@ struct fc_vport *static void fc_destroy_bsgjob (struct kref *kref) { - struct fc_bsg_job *job = container_of(kref, struct fc_bsg_job, kref); + struct bsg_job *job = container_of(kref, struct bsg_job, kref);struct request *rq = job->req;blk_end_request_all (rq, rq->errors);
@@ -3581,7 +3581,7 @@ struct fc_vport ** @result: job reply result * @reply_payload_rcv_len: length of payload received */ -void fc_bsg_jobdone (struct fc_bsg_job *job,int result, +void fc_bsg_jobdone (struct bsg_job *job,int result,unsigned int reply_payload_rcv_len) {struct request *req = job->req;
@@ -3615,7 +3615,7 @@ void fc_bsg_jobdone(struct fc_bsg_job *job, int result,*/ static void fc_bsg_softirq_done (struct request *rq) { -struct fc_bsg_job *job = rq->special; +struct bsg_job *job = rq->special;kref_put (&job->kref, fc_destroy_bsgjob); }
@@ -3627,7 +3627,7 @@ static void fc_bsg_softirq_done(struct request *rq)static enum blk_eh_timer_return fc_bsg_job_timeout (struct request *req) { -struct fc_bsg_job *job = (void *) req->special; +struct bsg_job *job = (void *) req->special;struct Scsi_Host *shost =fc_bsg_to_shost (job);struct fc_rport *rport =fc_bsg_to_rport (job);struct fc_internal *i =to_fc_internal (shost->transportt);
@@ -3686,12 +3686,12 @@ static void fc_bsg_softirq_done(struct request *rq) {struct fc_internal *i =to_fc_internal (shost->transportt);struct request *rsp = req->next_rq; -struct fc_bsg_job *job; +struct bsg_job *job;int ret;BUG_ON (req->special); - job =kzalloc (sizeof (struct fc_bsg_job ) + i->f->dd_bsg_size, + job =kzalloc (sizeof (struct bsg_job ) + i->f->dd_bsg_size,GFP_KERNEL );if (!job)return -ENOMEM ;
@@ -3706,8 +3706,6 @@ static void fc_bsg_softirq_done(struct request *rq)*/ req->special = job; - job->shost = shost; - job->rport = rport; job->req = req;if (i->f->dd_bsg_size) job->dd_data = (void *)&job[1 ];
@@ -3760,7 +3758,7 @@ enum fc_dispatch_result {*/ static enum fc_dispatch_result fc_bsg_host_dispatch (struct request_queue *q,struct Scsi_Host *shost, -struct fc_bsg_job *job) +struct bsg_job *job) {struct fc_internal *i =to_fc_internal (shost->transportt);struct fc_bsg_request *bsg_request = job->request;
@@ -3862,7 +3860,7 @@ enum fc_dispatch_result {*/ static enum fc_dispatch_result fc_bsg_rport_dispatch (struct request_queue *q,struct Scsi_Host *shost, -struct fc_rport *rport,struct fc_bsg_job *job) +struct fc_rport *rport,struct bsg_job *job) {struct fc_internal *i =to_fc_internal (shost->transportt);struct fc_bsg_request *bsg_request = job->request;
@@ -3925,7 +3923,7 @@ enum fc_dispatch_result { struct fc_rport *rport, struct device *dev) { struct request *req; -struct fc_bsg_job *job; +struct bsg_job *job;enum fc_dispatch_result ret;struct fc_bsg_reply *bsg_reply;
include/scsi/libfc.h +1 -1
@@ -912,7 +912,7 @@ static inline bool fc_fcp_is_read(const struct fc_fcp_pkt *fsp)int fc_set_mfs (struct fc_lport *,u32 mfs);struct fc_lport *libfc_vport_create (struct fc_vport *,int privsize);struct fc_lport *fc_vport_id_lookup (struct fc_lport *,u32 port_id); -int fc_lport_bsg_request (struct fc_bsg_job *); +int fc_lport_bsg_request (struct bsg_job *);void fc_lport_set_local_id (struct fc_lport *,u32 port_id);void fc_lport_iterate (void (*func)(struct fc_lport *,void *),void *);
include/scsi/scsi_transport_fc.h +18 -45
93 lines not on this page · raw message
Signature · 1 line
1.8.5.6
PATCH v4 10/15 scsi: fc: Use bsg_destroy_job
In reply to Johannes Thumshirnfc_destroy_bsgjob() and bsg_destroy_job() are now 1:1 copies, so use the later. As bsg_destroy_job() comes from bsg-lib we need to select it in Kconfig once CONFOG_SCSI_FC_ATTRS is active.
--- block/bsg-lib.c | 7 +++++-- drivers/scsi/Kconfig | 1 + drivers/scsi/scsi_transport_fc.c | 25 +++---------------------- include/linux/bsg-lib.h | 1 + 4 files changed, 10 insertions(+), 24 deletions(-)
block/bsg-lib.c +5 -2
@@ -32,9 +32,12 @@* bsg_destroy_job - routine to teardown/delete a bsg job * @job: bsg_job that is to be torn down */ -static void bsg_destroy_job (struct kref *kref) +void bsg_destroy_job (struct kref *kref) { struct bsg_job *job = container_of(kref, struct bsg_job, kref); +struct request *rq = job->req; + +blk_end_request_all (rq, rq->errors);put_device (job->dev);/* release reference for the request */
@@ -42,6 +45,7 @@ static void bsg_destroy_job(struct kref *kref)kfree (job->reply_payload.sg_list);kfree (job); } +EXPORT_SYMBOL_GPL (bsg_destroy_job);/** * bsg_job_done - completion routine for bsg requests
@@ -85,7 +89,6 @@ static void bsg_softirq_done(struct request *rq) {struct bsg_job *job = rq->special; -blk_end_request_all (rq, rq->errors);kref_put (&job->kref, bsg_destroy_job); }
drivers/scsi/Kconfig +1 -0
@@ -263,6 +263,7 @@ config SCSI_SPI_ATTRS config SCSI_FC_ATTRS tristate "FiberChannel Transport Attributes" depends on SCSI && NET + select BLK_DEV_BSGLIB select SCSI_NETLINK help If you wish to export transport-specific information about
drivers/scsi/scsi_transport_fc.c +3 -22
@@ -30,6 +30,7 @@#include <linux/slab.h> #include <linux/delay.h> #include <linux/kernel.h> +#include <linux/bsg-lib.h> #include <scsi/scsi_device.h> #include <scsi/scsi_host.h> #include <scsi/scsi_transport.h>
@@ -3554,26 +3555,6 @@ struct fc_vport ** BSG support */ - -/** -* fc_destroy_bsgjob - routine to teardown/delete a fc bsg job -* @job: fc_bsg_job that is to be torn down -*/ -static void -fc_destroy_bsgjob (struct kref *kref) -{ - struct bsg_job *job = container_of(kref, struct bsg_job, kref); -struct request *rq = job->req; - -blk_end_request_all (rq, rq->errors); - -put_device (job->dev);/* release reference for the request */ - -kfree (job->request_payload.sg_list); -kfree (job->reply_payload.sg_list); -kfree (job); -} -/** * fc_bsg_jobdone - completion routine for bsg requests that the LLD has * completed
@@ -3617,7 +3598,7 @@ static void fc_bsg_softirq_done(struct request *rq) {struct bsg_job *job = rq->special; -kref_put (&job->kref, fc_destroy_bsgjob); +kref_put (&job->kref, bsg_destroy_job); }/**
@@ -3642,7 +3623,7 @@ static void fc_bsg_softirq_done(struct request *rq)/* call LLDD to abort the i/o as it has timed out */ err = i->f->bsg_timeout (job);if (err == -EAGAIN ) { -kref_put (&job->kref, fc_destroy_bsgjob); +kref_put (&job->kref, bsg_destroy_job);return BLK_EH_RESET_TIMER ; }else if (err) printk(KERN_ERR "ERROR: FC BSG request timeout - LLD "
include/linux/bsg-lib.h +1 -0
@@ -69,5 +69,6 @@ void bsg_job_done(struct bsg_job *job, int result,int bsg_setup_queue (struct device *dev,struct request_queue *q,char *name,bsg_job_fn *job_fn,int dd_job_size);void bsg_request_fn (struct request_queue *q); +void bsg_destroy_job (struct kref *kref);#endif
Signature · 1 line
1.8.5.6
PATCH v4 12/15 scsi: fc: use bsg_job_done
In reply to Johannes Thumshirnfc_bsg_jobdone() and bsg_job_done() are 1:1 copies now so use the bsg-lib one instead of the FC private implementation.
--- drivers/s390/scsi/zfcp_fc.c | 2 +- drivers/scsi/bfa/bfad_bsg.c | 4 ++-- drivers/scsi/ibmvscsi/ibmvfc.c | 2 +- drivers/scsi/libfc/fc_lport.c | 4 ++-- drivers/scsi/lpfc/lpfc_bsg.c | 40 ++++++++++++++++++------------------ drivers/scsi/qla2xxx/qla_bsg.c | 44 ++++++++++++++++++++-------------------- drivers/scsi/scsi_transport_fc.c | 41 +++---------------------------------- include/scsi/scsi_transport_fc.h | 2 -- 8 files changed, 51 insertions(+), 88 deletions(-)
drivers/s390/scsi/zfcp_fc.c +1 -1
@@ -893,7 +893,7 @@ static void zfcp_fc_ct_els_job_handler(void *data) jr->reply_payload_rcv_len = job->reply_payload.payload_len; jr->reply_data.ctels_reply.status =FC_CTELS_STATUS_OK ; jr->result = zfcp_ct_els->status ? -EIO :0 ; -fc_bsg_jobdone (job, jr->result, jr->reply_payload_rcv_len); +bsg_job_done (job, jr->result, jr->reply_payload_rcv_len); }static struct zfcp_fc_wka_port *zfcp_fc_job_wka_port (struct bsg_job *job)
drivers/scsi/bfa/bfad_bsg.c +2 -2
@@ -3179,7 +3179,7 @@ bsg_reply->reply_payload_rcv_len = job->reply_payload.payload_len; bsg_reply->result = rc; -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);return rc; error:
@@ -3555,7 +3555,7 @@ struct bfad_buf_info * bsg_reply->result = rc;if (rc ==BFA_STATUS_OK ) -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);return rc;
drivers/scsi/ibmvscsi/ibmvfc.c +1 -1
@@ -1946,7 +1946,7 @@ static int ibmvfc_bsg_request(struct bsg_job *job)ibmvfc_free_event (evt);spin_unlock_irqrestore (vhost->host->host_lock, flags); bsg_reply->result = rc; -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len); rc =0 ; out:
drivers/scsi/libfc/fc_lport.c +2 -2
@@ -1912,7 +1912,7 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp, bsg_reply->result = (PTR_ERR (fp) == -FC_EX_CLOSED ) ? -ECONNABORTED : -ETIMEDOUT ; job->reply_len =sizeof (uint32_t ); -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);kfree (info);return ;
@@ -1947,7 +1947,7 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp, bsg_reply->reply_payload_rcv_len = job->reply_payload.payload_len; bsg_reply->result =0 ; -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);kfree (info); }
drivers/scsi/lpfc/lpfc_bsg.c +20 -20
@@ -371,7 +371,7 @@ struct lpfc_dmabufext {if (job) { bsg_reply->result = rc; -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len); }return ;
@@ -645,7 +645,7 @@ struct lpfc_dmabufext {if (job) { bsg_reply->result = rc; -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len); }return ;
@@ -1138,7 +1138,7 @@ struct lpfc_dmabufext { job->dd_data =NULL ;/* complete the job back to userspace */ spin_unlock_irqrestore (&phba->ct_ev_lock, flags); -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);spin_lock_irqsave (&phba->ct_ev_lock, flags); }
@@ -1364,7 +1364,7 @@ struct lpfc_dmabufext {spin_unlock_irqrestore (&phba->ct_ev_lock, flags); job->dd_data =NULL ; bsg_reply->result =0 ; -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);return 0 ;
@@ -1462,7 +1462,7 @@ struct lpfc_dmabufext {if (job) { bsg_reply->result = rc; -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len); }return ;
@@ -1891,7 +1891,7 @@ struct lpfc_dmabufext { bsg_reply->result = rc;/* complete the job back to userspace if no error */ if (rc ==0 ) -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);return rc; }
@@ -2181,7 +2181,7 @@ struct lpfc_dmabufext { bsg_reply->result = rc;/* complete the job back to userspace if no error */ if (rc ==0 ) -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);return rc; }
@@ -2296,7 +2296,7 @@ struct lpfc_dmabufext { bsg_reply->result = rc;/* complete the job back to userspace if no error */ if (rc ==0 ) -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);return rc; }
@@ -2449,7 +2449,7 @@ struct lpfc_dmabufext { bsg_reply->result = rc;/* complete the job back to userspace if no error */ if (rc ==0 ) -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);return rc; }
@@ -3310,7 +3310,7 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri, job->dd_data =NULL ;/* complete the job back to userspace if no error */ if (rc ==IOCB_SUCCESS ) -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);return rc; }
@@ -3354,7 +3354,7 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri, job_error: bsg_reply->result = rc;if (rc ==0 ) -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);return rc; }
@@ -3420,7 +3420,7 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri,if (job) { bsg_reply->result =0 ; -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len); }return ;
@@ -3669,7 +3669,7 @@ static int lpfc_bsg_check_cmd_access(struct lpfc_hba *phba,/* if the job is still active, call job done */ if (job) { bsg_reply = job->reply; -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len); }return ;
@@ -3707,7 +3707,7 @@ static int lpfc_bsg_check_cmd_access(struct lpfc_hba *phba,/* if the job is still active, call job done */ if (job) { bsg_reply = job->reply; -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len); }
@@ -4150,7 +4150,7 @@ static int lpfc_bsg_check_cmd_access(struct lpfc_hba *phba,/* wait for additoinal external buffers */ bsg_reply->result =0 ; -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);return SLI_CONFIG_HANDLED ;
@@ -4377,7 +4377,7 @@ static int lpfc_bsg_check_cmd_access(struct lpfc_hba *phba, } bsg_reply->result =0 ; -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);return SLI_CONFIG_HANDLED ;
@@ -4494,7 +4494,7 @@ static int lpfc_bsg_check_cmd_access(struct lpfc_hba *phba,/* wait for additoinal external buffers */ bsg_reply->result =0 ; -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);return SLI_CONFIG_HANDLED ;
@@ -4963,7 +4963,7 @@ static int lpfc_bsg_check_cmd_access(struct lpfc_hba *phba,/* job done */ bsg_reply->result =0 ; job->dd_data =NULL ; -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len); }else if (rc ==1 )/* job submitted, will complete later*/
@@ -5074,7 +5074,7 @@ static int lpfc_bsg_check_cmd_access(struct lpfc_hba *phba,if (job) { bsg_reply->result = rc; -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len); }
@@ -5293,7 +5293,7 @@ static int lpfc_bsg_check_cmd_access(struct lpfc_hba *phba, job_error: bsg_reply->result = rc;if (rc ==0 ) -fc_bsg_jobdone (job, bsg_reply->result, +bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);return rc; }
drivers/scsi/qla2xxx/qla_bsg.c +22 -22
176 lines not on this page · raw message
drivers/scsi/scsi_transport_fc.c +3 -38
65 lines not on this page · raw message
include/scsi/scsi_transport_fc.h +0 -2
@@ -808,8 +808,6 @@ struct fc_vport *fc_vport_create(struct Scsi_Host *shost, int channel, struct fc_vport_identifiers *);int fc_vport_terminate (struct fc_vport *vport);int fc_block_scsi_eh (struct scsi_cmnd *cmnd); -void fc_bsg_jobdone (struct bsg_job *job,int result, -unsigned int reply_payload_rcv_len);static inline struct Scsi_Host *fc_bsg_to_shost (struct bsg_job *job) {
Signature · 1 line
1.8.5.6
PATCH v4 13/15 block: add bsg_job_put() and bsg_job_get()
In reply to Johannes ThumshirnAdd bsg_job_put() and bsg_job_get() so don't need to export bsg_destroy_job() any more.
--- block/bsg-lib.c | 17 ++++++++++++++--- drivers/scsi/scsi_transport_fc.c | 4 ++-- include/linux/bsg-lib.h | 3 ++- 3 files changed, 18 insertions(+), 6 deletions(-)
block/bsg-lib.c +14 -3
@@ -32,7 +32,7 @@* bsg_destroy_job - routine to teardown/delete a bsg job * @job: bsg_job that is to be torn down */ -void bsg_destroy_job (struct kref *kref) +static void bsg_destroy_job (struct kref *kref) { struct bsg_job *job = container_of(kref, struct bsg_job, kref);struct request *rq = job->req;
@@ -45,7 +45,18 @@ void bsg_destroy_job(struct kref *kref)kfree (job->reply_payload.sg_list);kfree (job); } -EXPORT_SYMBOL_GPL (bsg_destroy_job); + +void bsg_job_put (struct bsg_job *job) +{ +kref_put (&job->kref, bsg_destroy_job); +} +EXPORT_SYMBOL_GPL (bsg_job_put); + +int bsg_job_get (struct bsg_job *job) +{ +return kref_get_unless_zero (&job->kref); +} +EXPORT_SYMBOL_GPL (bsg_job_get);/** * bsg_job_done - completion routine for bsg requests
@@ -89,7 +100,7 @@ void bsg_softirq_done(struct request *rq) {struct bsg_job *job = rq->special; -kref_put (&job->kref, bsg_destroy_job); +bsg_job_put (job); }EXPORT_SYMBOL_GPL (bsg_softirq_done);
drivers/scsi/scsi_transport_fc.c +2 -2
@@ -3571,13 +3571,13 @@ struct fc_vport *if (rport && rport->port_state ==FC_PORTSTATE_BLOCKED )return BLK_EH_RESET_TIMER ; - inflight =kref_get_unless_zero (&job->kref); + inflight =bsg_job_get (job);if (inflight && i->f->bsg_timeout) {/* call LLDD to abort the i/o as it has timed out */ err = i->f->bsg_timeout (job);if (err == -EAGAIN ) { -kref_put (&job->kref, bsg_destroy_job); +bsg_job_put (job);return BLK_EH_RESET_TIMER ; }else if (err) printk(KERN_ERR "ERROR: FC BSG request timeout - LLD "
include/linux/bsg-lib.h +2 -1
@@ -69,7 +69,8 @@ void bsg_job_done(struct bsg_job *job, int result,int bsg_setup_queue (struct device *dev,struct request_queue *q,char *name,bsg_job_fn *job_fn,int dd_job_size);void bsg_request_fn (struct request_queue *q); -void bsg_destroy_job (struct kref *kref);void bsg_softirq_done (struct request *rq); +void bsg_job_put (struct bsg_job *job); +int __must_check bsg_job_get (struct bsg_job *job);#endif
Signature · 1 line
1.8.5.6
PATCH v4 7/15 scsi: fc: implement kref backed reference counting
In reply to Johannes ThumshirnImplement kref backed reference counting instead of rolling our own. This elimnates the need of the following fields in 'struct fc_bsg_job':
* ref_cnt
* state_flags
* job_lock
bringing us close to unification of 'struct fc_bsg_job' and 'struct bsg_job'.
--- drivers/scsi/scsi_transport_fc.c | 40 +++++++++++----------------------------- include/scsi/scsi_transport_fc.h | 4 +--- 2 files changed, 12 insertions(+), 32 deletions(-)
drivers/scsi/scsi_transport_fc.c +11 -29
@@ -3560,16 +3560,12 @@ struct fc_vport ** @job: fc_bsg_job that is to be torn down */ static void -fc_destroy_bsgjob (struct fc_bsg_job *job) +fc_destroy_bsgjob (struct kref *kref) { -unsigned long flags; + struct fc_bsg_job *job = container_of(kref, struct fc_bsg_job, kref); +struct request *rq = job->req; -spin_lock_irqsave (&job->job_lock, flags); -if (job->ref_cnt) { -spin_unlock_irqrestore (&job->job_lock, flags); -return ; - } -spin_unlock_irqrestore (&job->job_lock, flags); +blk_end_request_all (rq, rq->errors);put_device (job->dev);/* release reference for the request */
@@ -3620,15 +3616,8 @@ void fc_bsg_jobdone(struct fc_bsg_job *job, int result,static void fc_bsg_softirq_done (struct request *rq) {struct fc_bsg_job *job = rq->special; -unsigned long flags; -spin_lock_irqsave (&job->job_lock, flags); - job->state_flags |=FC_RQST_STATE_DONE ; - job->ref_cnt--; -spin_unlock_irqrestore (&job->job_lock, flags); - -blk_end_request_all (rq, rq->errors); -fc_destroy_bsgjob (job); +kref_put (&job->kref, fc_destroy_bsgjob); }/**
@@ -3642,24 +3631,18 @@ static void fc_bsg_softirq_done(struct request *rq)struct Scsi_Host *shost =fc_bsg_to_shost (job);struct fc_rport *rport =fc_bsg_to_rport (job);struct fc_internal *i =to_fc_internal (shost->transportt); -unsigned long flags; -int err =0 , done =0 ; +int err =0 , inflight =0 ;if (rport && rport->port_state ==FC_PORTSTATE_BLOCKED )return BLK_EH_RESET_TIMER ; -spin_lock_irqsave (&job->job_lock, flags); -if (job->state_flags &FC_RQST_STATE_DONE ) - done =1 ; -else - job->ref_cnt++; -spin_unlock_irqrestore (&job->job_lock, flags); + inflight =kref_get_unless_zero (&job->kref); -if (!done && i->f->bsg_timeout) { +if (inflight && i->f->bsg_timeout) {/* call LLDD to abort the i/o as it has timed out */ err = i->f->bsg_timeout (job);if (err == -EAGAIN ) { - job->ref_cnt--; +kref_put (&job->kref, fc_destroy_bsgjob);return BLK_EH_RESET_TIMER ; }else if (err) printk(KERN_ERR "ERROR: FC BSG request timeout - LLD "
@@ -3667,7 +3650,7 @@ static void fc_bsg_softirq_done(struct request *rq) }/* the blk_end_sync_io() doesn't check the error */ -if (done) +if (!inflight)return BLK_EH_NOT_HANDLED ;else return BLK_EH_HANDLED ;
@@ -3728,7 +3711,6 @@ static void fc_bsg_softirq_done(struct request *rq) job->req = req;if (i->f->dd_bsg_size) job->dd_data = (void *)&job[1 ]; -spin_lock_init (&job->job_lock); job->request = (struct fc_bsg_request *)req->cmd; job->request_len = req->cmd_len; job->reply = req->sense;
@@ -3750,7 +3732,7 @@ static void fc_bsg_softirq_done(struct request *rq) job->dev = &shost->shost_gendev;get_device (job->dev);/* take a reference for the request */ - job->ref_cnt =1 ; +kref_init (&job->kref);return 0 ;
include/scsi/scsi_transport_fc.h +1 -3
@@ -634,9 +634,7 @@ struct fc_bsg_job {struct fc_rport *rport;struct device *dev;struct request *req; -spinlock_t job_lock; -unsigned int state_flags; -unsigned int ref_cnt; +struct kref kref;struct fc_bsg_request *request;struct fc_bsg_reply *reply;
Signature · 1 line
1.8.5.6
PATCH v4 11/15 scsi: fc: use bsg_softirq_done
In reply to Johannes Thumshirnbsg_softirq_done() and fc_bsg_softirq_done() are copies of each other, so ditch the fc specific one.
--- block/bsg-lib.c | 3 ++- drivers/scsi/scsi_transport_fc.c | 15 ++------------- include/linux/bsg-lib.h | 1 + 3 files changed, 5 insertions(+), 14 deletions(-)
block/bsg-lib.c +2 -1
@@ -85,12 +85,13 @@ void bsg_job_done(struct bsg_job *job, int result,* bsg_softirq_done - softirq done routine for destroying the bsg requests * @rq: BSG request that holds the job to be destroyed */ -static void bsg_softirq_done (struct request *rq) +void bsg_softirq_done (struct request *rq) {struct bsg_job *job = rq->special;kref_put (&job->kref, bsg_destroy_job); } +EXPORT_SYMBOL_GPL (bsg_softirq_done);static int bsg_map_buffer (struct bsg_buffer *buf,struct request *req) {
drivers/scsi/scsi_transport_fc.c +2 -13
@@ -3591,17 +3591,6 @@ void fc_bsg_jobdone(struct bsg_job *job, int result,EXPORT_SYMBOL_GPL (fc_bsg_jobdone);/** -* fc_bsg_softirq_done - softirq done routine for destroying the bsg requests -* @rq: BSG request that holds the job to be destroyed -*/ -static void fc_bsg_softirq_done (struct request *rq) -{ -struct bsg_job *job = rq->special; - -kref_put (&job->kref, bsg_destroy_job); -} - -/** * fc_bsg_job_timeout - handler for when a bsg request timesout * @req: request that timed out */
@@ -4033,7 +4022,7 @@ enum fc_dispatch_result { q->queuedata = shost;queue_flag_set_unlocked (QUEUE_FLAG_BIDI , q); -blk_queue_softirq_done (q, fc_bsg_softirq_done); +blk_queue_softirq_done (q, bsg_softirq_done);blk_queue_rq_timed_out (q, fc_bsg_job_timeout);blk_queue_rq_timeout (q,FC_DEFAULT_BSG_TIMEOUT );
@@ -4079,7 +4068,7 @@ enum fc_dispatch_result { q->queuedata = rport;queue_flag_set_unlocked (QUEUE_FLAG_BIDI , q); -blk_queue_softirq_done (q, fc_bsg_softirq_done); +blk_queue_softirq_done (q, bsg_softirq_done);blk_queue_rq_timed_out (q, fc_bsg_job_timeout);blk_queue_rq_timeout (q,BLK_DEFAULT_SG_TIMEOUT );
include/linux/bsg-lib.h +1 -0
@@ -70,5 +70,6 @@ int bsg_setup_queue(struct device *dev, struct request_queue *q, char *name, bsg_job_fn *job_fn, int dd_job_size);void bsg_request_fn (struct request_queue *q);void bsg_destroy_job (struct kref *kref); +void bsg_softirq_done (struct request *rq);#endif
Signature · 1 line
1.8.5.6
PATCH v4 14/15 scsi: fc: move FC transport's bsg code to bsg-lib
In reply to Johannes ThumshirnNow that all conversions are done, move the FibreChannel bsg code over to the bsg library.
This patch is derived from work done by Mike Christie in 2011 [1] but only the iscsi parts got merged back then.
[1] http://marc.info/?l=linux-scsi&m=131149780921009&w=2
--- drivers/scsi/scsi_transport_fc.c | 285 ++++++--------------------------------- 1 file changed, 43 insertions(+), 242 deletions(-)
drivers/scsi/scsi_transport_fc.c +43 -242
@@ -3591,109 +3591,12 @@ struct fc_vport *return BLK_EH_HANDLED ; } -static int -fc_bsg_map_buffer (struct bsg_buffer *buf,struct request *req) -{ -size_t sz = (sizeof (struct scatterlist ) * req->nr_phys_segments); - -BUG_ON (!req->nr_phys_segments); - - buf->sg_list =kzalloc (sz,GFP_KERNEL ); -if (!buf->sg_list) -return -ENOMEM ; -sg_init_table (buf->sg_list, req->nr_phys_segments); - buf->sg_cnt =blk_rq_map_sg (req->q, req, buf->sg_list); - buf->payload_len =blk_rq_bytes (req); -return 0 ; -} - - -/** -* fc_req_to_bsgjob - Allocate/create the fc_bsg_job structure for the -* bsg request -* @shost: SCSI Host corresponding to the bsg object -* @rport: (optional) FC Remote Port corresponding to the bsg object -* @req: BSG request that needs a job structure -*/ -static int -fc_req_to_bsgjob (struct Scsi_Host *shost,struct fc_rport *rport, -struct request *req) -{ -struct fc_internal *i =to_fc_internal (shost->transportt); -struct request *rsp = req->next_rq; -struct bsg_job *job; -int ret; - -BUG_ON (req->special); - - job =kzalloc (sizeof (struct bsg_job ) + i->f->dd_bsg_size, -GFP_KERNEL ); -if (!job) -return -ENOMEM ; - -/* -* Note: this is a bit silly. -* The request gets formatted as a SGIO v4 ioctl request, which -* then gets reformatted as a blk request, which then gets -* reformatted as a fc bsg request. And on completion, we have -* to wrap return results such that SGIO v4 thinks it was a scsi -* status. I hope this was all worth it. -*/ - - req->special = job; - job->req = req; -if (i->f->dd_bsg_size) - job->dd_data = (void *)&job[1 ]; - job->request = (struct fc_bsg_request *)req->cmd; - job->request_len = req->cmd_len; - job->reply = req->sense; - job->reply_len =SCSI_SENSE_BUFFERSIZE ;/* Size of sense buffer -* allocated */ -if (req->bio) { - ret =fc_bsg_map_buffer (&job->request_payload, req); -if (ret) - goto failjob_rls_job; - } -if (rsp && rsp->bio) { - ret =fc_bsg_map_buffer (&job->reply_payload, rsp); -if (ret) - goto failjob_rls_rqst_payload; - } -if (rport) - job->dev = &rport->dev; -else - job->dev = &shost->shost_gendev; -get_device (job->dev);/* take a reference for the request */ - -kref_init (&job->kref); - -return 0 ; - - -failjob_rls_rqst_payload: -kfree (job->request_payload.sg_list); -failjob_rls_job: -kfree (job); -return -ENOMEM ; -} - - -enum fc_dispatch_result { -FC_DISPATCH_BREAK ,/* on return, q is locked, break from q loop */ -FC_DISPATCH_LOCKED ,/* on return, q is locked, continue on */ -FC_DISPATCH_UNLOCKED ,/* on return, q is unlocked, continue on */ -}; - -/** * fc_bsg_host_dispatch - process fc host bsg requests and dispatch to LLDD -* @q: fc host request queue * @shost: scsi host rport attached to * @job: bsg job to be processed */ -static enum fc_dispatch_result -fc_bsg_host_dispatch (struct request_queue *q,struct Scsi_Host *shost, -struct bsg_job *job) +static int fc_bsg_host_dispatch (struct Scsi_Host *shost,struct bsg_job *job) {struct fc_internal *i =to_fc_internal (shost->transportt);struct fc_bsg_request *bsg_request = job->request;
@@ -3754,7 +3657,7 @@ enum fc_dispatch_result { ret = i->f->bsg_request (job);if (!ret) -return FC_DISPATCH_UNLOCKED ; +return 0 ; fail_host_msg:/* return the errno failure code as the only status */
@@ -3764,7 +3667,7 @@ enum fc_dispatch_result { job->reply_len =sizeof (uint32_t );bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len); -return FC_DISPATCH_UNLOCKED ; +return 0 ; }
@@ -3788,14 +3691,10 @@ enum fc_dispatch_result {/** * fc_bsg_rport_dispatch - process rport bsg requests and dispatch to LLDD -* @q: rport request queue * @shost: scsi host rport attached to -* @rport: rport request destined to * @job: bsg job to be processed */ -static enum fc_dispatch_result -fc_bsg_rport_dispatch (struct request_queue *q,struct Scsi_Host *shost, -struct fc_rport *rport,struct bsg_job *job) +static int fc_bsg_rport_dispatch (struct Scsi_Host *shost,struct bsg_job *job) {struct fc_internal *i =to_fc_internal (shost->transportt);struct fc_bsg_request *bsg_request = job->request;
@@ -3832,7 +3731,7 @@ enum fc_dispatch_result { ret = i->f->bsg_request (job);if (!ret) -return FC_DISPATCH_UNLOCKED ; +return 0 ; fail_rport_msg:/* return the errno failure code as the only status */
@@ -3842,119 +3741,19 @@ enum fc_dispatch_result { job->reply_len =sizeof (uint32_t );bsg_job_done (job, bsg_reply->result, bsg_reply->reply_payload_rcv_len); -return FC_DISPATCH_UNLOCKED ; -} - - -/** -* fc_bsg_request_handler - generic handler for bsg requests -* @q: request queue to manage -* @shost: Scsi_Host related to the bsg object -* @rport: FC remote port related to the bsg object (optional) -* @dev: device structure for bsg object -*/ -static void -fc_bsg_request_handler (struct request_queue *q,struct Scsi_Host *shost, -struct fc_rport *rport,struct device *dev) -{ -struct request *req; -struct bsg_job *job; -enum fc_dispatch_result ret; -struct fc_bsg_reply *bsg_reply; - -if (!get_device (dev)) -return ; - -while (1 ) { -if (rport && (rport->port_state ==FC_PORTSTATE_BLOCKED ) && - !(rport->flags &FC_RPORT_FAST_FAIL_TIMEDOUT )) -break ; - - req =blk_fetch_request (q); -if (!req) -break ; - -if (rport && (rport->port_state !=FC_PORTSTATE_ONLINE )) { - req->errors = -ENXIO ; -spin_unlock_irq (q->queue_lock); -blk_end_request_all (req, -ENXIO ); -spin_lock_irq (q->queue_lock); -continue ; - } - -spin_unlock_irq (q->queue_lock); - - ret =fc_req_to_bsgjob (shost, rport, req); -if (ret) { - req->errors = ret; -blk_end_request_all (req, ret); -spin_lock_irq (q->queue_lock); -continue ; - } - - job = req->special; - -/* check if we have the msgcode value at least */ -if (job->request_len <sizeof (uint32_t )) { -BUG_ON (job->reply_len <sizeof (uint32_t )); - bsg_reply = job->reply; - bsg_reply->reply_payload_rcv_len =0 ; - bsg_reply->result = -ENOMSG ; - job->reply_len =sizeof (uint32_t ); -bsg_job_done (job, bsg_reply->result, - bsg_reply->reply_payload_rcv_len); -spin_lock_irq (q->queue_lock); -continue ; - } - -/* the dispatch routines will unlock the queue_lock */ -if (rport) - ret =fc_bsg_rport_dispatch (q, shost, rport, job); -else - ret =fc_bsg_host_dispatch (q, shost, job); - -/* did dispatcher hit state that can't process any more */ -if (ret ==FC_DISPATCH_BREAK ) -break ; - -/* did dispatcher had released the lock */ -if (ret ==FC_DISPATCH_UNLOCKED ) -spin_lock_irq (q->queue_lock); - } - -spin_unlock_irq (q->queue_lock); -put_device (dev); -spin_lock_irq (q->queue_lock); -} - - -/** -* fc_bsg_host_handler - handler for bsg requests for a fc host -* @q: fc host request queue -*/ -static void -fc_bsg_host_handler (struct request_queue *q) -{ -struct Scsi_Host *shost = q->queuedata; - -fc_bsg_request_handler (q, shost,NULL , &shost->shost_gendev); +return 0 ; } - -/** -* fc_bsg_rport_handler - handler for bsg requests for a fc rport -* @q: rport request queue -*/ -static void -fc_bsg_rport_handler (struct request_queue *q) +static int fc_bsg_dispatch (struct bsg_job *job) { -struct fc_rport *rport = q->queuedata; -struct Scsi_Host *shost =rport_to_shost (rport); +struct Scsi_Host *shost =fc_bsg_to_shost (job); -fc_bsg_request_handler (q, shost, rport, &rport->dev); +if (scsi_is_fc_rport (job->dev)) +return fc_bsg_rport_dispatch (shost, job); +else +return fc_bsg_host_dispatch (shost, job); } -/** * fc_bsg_hostadd - Create and add the bsg hooks so we can receive requests * @shost: shost for fc_host
@@ -3977,33 +3776,42 @@ enum fc_dispatch_result {snprintf (bsg_name,sizeof (bsg_name),"fc_host%d" , shost->host_no); - q =__scsi_alloc_queue (shost, fc_bsg_host_handler); + q =__scsi_alloc_queue (shost, bsg_request_fn);if (!q) { -printk (KERN_ERR "fc_host%d: bsg interface failed to " -"initialize - no request queue\n" , - shost->host_no); +dev_err (dev, +"fc_host%d: bsg interface failed to initialize - no request queue\n" , + shost->host_no);return -ENOMEM ; } - q->queuedata = shost; -queue_flag_set_unlocked (QUEUE_FLAG_BIDI , q); -blk_queue_softirq_done (q, bsg_softirq_done); -blk_queue_rq_timed_out (q, fc_bsg_job_timeout); -blk_queue_rq_timeout (q,FC_DEFAULT_BSG_TIMEOUT ); - - err =bsg_register_queue (q, dev, bsg_name,NULL ); + err =bsg_setup_queue (dev, q, bsg_name, fc_bsg_dispatch, + i->f->dd_bsg_size);if (err) { -printk (KERN_ERR "fc_host%d: bsg interface failed to " -"initialize - register queue\n" , - shost->host_no); +dev_err (dev, +"fc_host%d: bsg interface failed to initialize - setup queue\n" , + shost->host_no);blk_cleanup_queue (q);return err; } - +blk_queue_rq_timed_out (q, fc_bsg_job_timeout); +blk_queue_rq_timeout (q,FC_DEFAULT_BSG_TIMEOUT ); fc_host->rqst_q = q;return 0 ; } +static int fc_bsg_rport_prep (struct request_queue *q,struct request *req) +{ +struct fc_rport *rport =dev_to_rport (q->queuedata); + +if (rport->port_state ==FC_PORTSTATE_BLOCKED && + !(rport->flags &FC_RPORT_FAST_FAIL_TIMEDOUT )) +return BLKPREP_DEFER ; + +if (rport->port_state !=FC_PORTSTATE_ONLINE ) +return BLKPREP_KILL ; + +return BLKPREP_OK ; +}/** * fc_bsg_rportadd - Create and add the bsg hooks so we can receive requests
@@ -4023,29 +3831,22 @@ enum fc_dispatch_result {if (!i->f->bsg_request)return -ENOTSUPP ; - q =__scsi_alloc_queue (shost, fc_bsg_rport_handler); + q =__scsi_alloc_queue (shost, bsg_request_fn);if (!q) { -printk (KERN_ERR "%s: bsg interface failed to " -"initialize - no request queue\n" , - dev->kobj.name); +dev_err (dev,"bsg interface failed to initialize - no request queue\n" );return -ENOMEM ; } - q->queuedata = rport; -queue_flag_set_unlocked (QUEUE_FLAG_BIDI , q); -blk_queue_softirq_done (q, bsg_softirq_done); -blk_queue_rq_timed_out (q, fc_bsg_job_timeout); -blk_queue_rq_timeout (q,BLK_DEFAULT_SG_TIMEOUT ); - - err =bsg_register_queue (q, dev,NULL ,NULL ); + err =bsg_setup_queue (dev, q,NULL , fc_bsg_dispatch, i->f->dd_bsg_size);if (err) { -printk (KERN_ERR "%s: bsg interface failed to " -"initialize - register queue\n" , - dev->kobj.name); +dev_err (dev,"failed to setup bsg queue\n" );blk_cleanup_queue (q);return err; } +blk_queue_prep_rq (q, fc_bsg_rport_prep); +blk_queue_rq_timed_out (q, fc_bsg_job_timeout); +blk_queue_rq_timeout (q,BLK_DEFAULT_SG_TIMEOUT ); rport->rqst_q = q;return 0 ; }
Signature · 1 line
1.8.5.6
PATCH v4 8/15 block: add reference counting for struct bsg_job
In reply to Johannes ThumshirnAdd reference counting to 'struct bsg_job' so we can implement a reuqest timeout handler for bsg_jobs, which is needed for Fibre Channel.
--- block/bsg-lib.c | 7 +++++-- include/linux/bsg-lib.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-)
block/bsg-lib.c +5 -2
@@ -32,8 +32,10 @@* bsg_destroy_job - routine to teardown/delete a bsg job * @job: bsg_job that is to be torn down */ -static void bsg_destroy_job (struct bsg_job *job) +static void bsg_destroy_job (struct kref *kref) { + struct bsg_job *job = container_of(kref, struct bsg_job, kref); +put_device (job->dev);/* release reference for the request */ kfree (job->request_payload.sg_list);
@@ -84,7 +86,7 @@ static void bsg_softirq_done(struct request *rq)struct bsg_job *job = rq->special;blk_end_request_all (rq, rq->errors); -bsg_destroy_job (job); +kref_put (&job->kref, bsg_destroy_job); }static int bsg_map_buffer (struct bsg_buffer *buf,struct request *req)
@@ -142,6 +144,7 @@ static int bsg_create_job(struct device *dev, struct request *req) job->dev = dev;/* take a reference for the request */ get_device (job->dev); +kref_init (&job->kref);return 0 ; failjob_rls_rqst_payload:
include/linux/bsg-lib.h +2 -0
@@ -40,6 +40,8 @@ struct bsg_job {struct device *dev;struct request *req; +struct kref kref; +/* Transport/driver specific request/reply structs */ void *request;void *reply;
Signature · 1 line
1.8.5.6
PATCH v4 15/15 block: unexport bsg_softirq_done() again
In reply to Johannes ThumshirnUnexport bsg_softirq_done() again, we don't need it outside of bsg-lib.c anymore now that scsi_transport_fc is a pure bsg-lib client.
--- block/bsg-lib.c | 3 +-- include/linux/bsg-lib.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-)
block/bsg-lib.c +1 -2
@@ -96,13 +96,12 @@ void bsg_job_done(struct bsg_job *job, int result,* bsg_softirq_done - softirq done routine for destroying the bsg requests * @rq: BSG request that holds the job to be destroyed */ -void bsg_softirq_done (struct request *rq) +static void bsg_softirq_done (struct request *rq) {struct bsg_job *job = rq->special;bsg_job_put (job); } -EXPORT_SYMBOL_GPL (bsg_softirq_done);static int bsg_map_buffer (struct bsg_buffer *buf,struct request *req) {
include/linux/bsg-lib.h +0 -1
@@ -69,7 +69,6 @@ void bsg_job_done(struct bsg_job *job, int result,int bsg_setup_queue (struct device *dev,struct request_queue *q,char *name,bsg_job_fn *job_fn,int dd_job_size);void bsg_request_fn (struct request_queue *q); -void bsg_softirq_done (struct request *rq);void bsg_job_put (struct bsg_job *job);int __must_check bsg_job_get (struct bsg_job *job);
Signature · 1 line
1.8.5.6
Re: [PATCH v4 07/15] scsi: fc: implement kref backed reference counting
In reply to Johannes ThumshirnQuoted 7 lines · Johannes Thumshirn
Implement kref backed reference counting instead of rolling our own. This elimnates the need of the following fields in 'struct
fc_bsg_job':
*ref_cnt
*state_flags
*job_lock
bringing us close to unification of 'structfc_bsg_job' and 'structbsg_job'.
Quoted 6 lines
Signed-off-by Johannes Thumshirn <[email protected]>--- drivers/scsi/scsi_transport_fc.c | 40 +++++++++++----------------------------- include/scsi/scsi_transport_fc.h | 4 +--- 2 files changed, 12 insertions(+), 32 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
v4 cover Convert FibreChannel bsg code to use bsg-lib
This series converts the current bsg usage in the FibreChannel drivers over to use bsg-lib. SAS will follow once FC is in a good enough shape.
I did take some inspiration from a similar patchset from Mike Christie dating back to 2011 but it's not a 1:1 copy. Patch 15/16 is heavily based on his series and attribution is given to him in the commit message.
It is currently regression tested on FCoE and lpfc using the 'fcns', 'fcrls' and 'fcping' (see my FC_BSG_RPT_ELS patch for fcping) utilities and zfcp_show/zfcp_ping on s390x.
The idea for this change arose when discussing racy sysfs handling the FC bsg code with Christoph and is a next step in moving all bsg clients to bsg-lib to eventually clean up the in kernel bsg API.
Changes to v1:
* Reduce the number of individual patches (44 -> 16)
* Fix s390 build failure (forgotten to kill fc_bsg_job from zfcp_ext.h)
* Fix build failure on configs without CONFIG_BLK_DEV_BSGLIB
* Make bsg_job_get() call kref_get_unless_zero() and use it in scsi_transport_fc.c
Changes to v2:
* Add Hannes' Reviewd-by tags
* Address Hannes' comment about kref handling in 8/16
* Move CONFIG_BLK_DEV_BSGLIB dependency to patch 12/16 as per 0day results
Changes to v3:
* Rebase on mkp/4.10/scsi-queue (and fixup the new lpfc bsg function)
* Move checks for request and reply len before accessing them (hopefully fixes zfcp)
* Added Tyrel's Acked-bys
* Added Christoph's Reviewed-bys
* Squashed bsg_job_done patches as requested by Christoph
* Fixed the hopefully last bisection breaking point
* Fixed kernel panic on s390 with patch 2/15
* Fixed kernel panic on s390 with patch 5/15
* Fixed zfcp_show output on s390 with patch 4/15
Johannes Thumshirn (15):
scsi: Get rid of struct fc_bsg_buffer
scsi: don't use fc_bsg_job::request and fc_bsg_job::reply directly
scsi: fc: Export fc_bsg_jobdone and use it in FC drivers
scsi: fc: provide fc_bsg_to_shost() helper
scsi: fc: provide fc_bsg_to_rport() helper
scsi: libfc: don't set FC_RQST_STATE_DONE before calling
fc_bsg_jobdone()
scsi: fc: implement kref backed reference counting
block: add reference counting for struct bsg_job
scsi: change FC drivers to use 'struct bsg_job'
scsi: fc: Use bsg_destroy_job
scsi: fc: use bsg_softirq_done
scsi: fc: use bsg_job_done
block: add bsg_job_put() and bsg_job_get()
scsi: fc: move FC transport's bsg code to bsg-lib
block: unexport bsg_softirq_done() again
block/bsg-lib.c | 23 +- drivers/s390/scsi/zfcp_ext.h | 4 +- drivers/s390/scsi/zfcp_fc.c | 36 ++-- drivers/scsi/Kconfig | 1 + drivers/scsi/bfa/bfad_bsg.c | 62 +++--- drivers/scsi/bfa/bfad_im.h | 4 +- drivers/scsi/ibmvscsi/ibmvfc.c | 40 ++-- drivers/scsi/libfc/fc_lport.c | 47 ++-- drivers/scsi/lpfc/lpfc_bsg.c | 387 +++++++++++++++++++-------------- drivers/scsi/lpfc/lpfc_crtn.h | 4 +- drivers/scsi/qla2xxx/qla_bsg.c | 449 ++++++++++++++++++++++----------------- drivers/scsi/qla2xxx/qla_def.h | 2 +- drivers/scsi/qla2xxx/qla_gbl.h | 4 +- drivers/scsi/qla2xxx/qla_iocb.c | 13 +- drivers/scsi/qla2xxx/qla_isr.c | 52 +++-- drivers/scsi/qla2xxx/qla_mr.c | 15 +- drivers/scsi/scsi_transport_fc.c | 433 +++++++------------------------------ include/linux/bsg-lib.h | 4 + include/scsi/libfc.h | 2 +- include/scsi/scsi_transport_fc.h | 62 ++---- 20 files changed, 770 insertions(+), 874 deletions(-)
Signature · 1 line
1.8.5.6
PATCH RESEND v4 8/15 block: add reference counting for struct bsg_job
Add reference counting to 'struct bsg_job' so we can implement a reuqest timeout handler for bsg_jobs, which is needed for Fibre Channel.
--- block/bsg-lib.c | 7 +++++-- include/linux/bsg-lib.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-)
block/bsg-lib.c +5 -2
@@ -32,8 +32,10 @@* bsg_destroy_job - routine to teardown/delete a bsg job * @job: bsg_job that is to be torn down */ -static void bsg_destroy_job (struct bsg_job *job) +static void bsg_destroy_job (struct kref *kref) { + struct bsg_job *job = container_of(kref, struct bsg_job, kref); +put_device (job->dev);/* release reference for the request */ kfree (job->request_payload.sg_list);
@@ -84,7 +86,7 @@ static void bsg_softirq_done(struct request *rq)struct bsg_job *job = rq->special;blk_end_request_all (rq, rq->errors); -bsg_destroy_job (job); +kref_put (&job->kref, bsg_destroy_job); }static int bsg_map_buffer (struct bsg_buffer *buf,struct request *req)
@@ -142,6 +144,7 @@ static int bsg_create_job(struct device *dev, struct request *req) job->dev = dev;/* take a reference for the request */ get_device (job->dev); +kref_init (&job->kref);return 0 ; failjob_rls_rqst_payload:
include/linux/bsg-lib.h +2 -0
@@ -40,6 +40,8 @@ struct bsg_job {struct device *dev;struct request *req; +struct kref kref; +/* Transport/driver specific request/reply structs */ void *request;void *reply;
Signature · 1 line
1.8.5.6
PATCH RESEND v4 15/15 block: unexport bsg_softirq_done() again
In reply to Johannes ThumshirnUnexport bsg_softirq_done() again, we don't need it outside of bsg-lib.c anymore now that scsi_transport_fc is a pure bsg-lib client.
--- block/bsg-lib.c | 3 +-- include/linux/bsg-lib.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-)
block/bsg-lib.c +1 -2
@@ -96,13 +96,12 @@ void bsg_job_done(struct bsg_job *job, int result,* bsg_softirq_done - softirq done routine for destroying the bsg requests * @rq: BSG request that holds the job to be destroyed */ -void bsg_softirq_done (struct request *rq) +static void bsg_softirq_done (struct request *rq) {struct bsg_job *job = rq->special;bsg_job_put (job); } -EXPORT_SYMBOL_GPL (bsg_softirq_done);static int bsg_map_buffer (struct bsg_buffer *buf,struct request *req) {
include/linux/bsg-lib.h +0 -1
@@ -69,7 +69,6 @@ void bsg_job_done(struct bsg_job *job, int result,int bsg_setup_queue (struct device *dev,struct request_queue *q,char *name,bsg_job_fn *job_fn,int dd_job_size);void bsg_request_fn (struct request_queue *q); -void bsg_softirq_done (struct request *rq);void bsg_job_put (struct bsg_job *job);int __must_check bsg_job_get (struct bsg_job *job);
Signature · 1 line
1.8.5.6
Re: [PATCH RESEND v4 02/15] scsi: don't use fc_bsg_job::request and fc_bsg_job::reply directly
In reply to Johannes ThumshirnQuoted 6 lines · Johannes Thumshirn
Don't use
fc_bsg_job::requestandfc_bsg_job::replydirectly, but use helper variablesbsg_requestandbsg_reply. This will be helpfull when transitioning to bsg-lib.Signed-off-by Johannes Thumshirn <[email protected]>Reviewed-by Hannes Reinecke <[email protected]>
Quoted 12 lines
--- drivers/s390/scsi/zfcp_fc.c | 9 +- drivers/scsi/bfa/bfad_bsg.c | 40 +++--- drivers/scsi/ibmvscsi/ibmvfc.c | 22 ++-- drivers/scsi/libfc/fc_lport.c | 23 ++-- drivers/scsi/lpfc/lpfc_bsg.c | 199 ++++++++++++++++++----------- drivers/scsi/qla2xxx/qla_bsg.c | 264 ++++++++++++++++++++++----------------- drivers/scsi/qla2xxx/qla_iocb.c | 5 +- drivers/scsi/qla2xxx/qla_isr.c | 46 ++++--- drivers/scsi/qla2xxx/qla_mr.c | 10 +- drivers/scsi/scsi_transport_fc.c | 55 ++++---- 10 files changed, 398 insertions(+), 275 deletions(-)
For ibmvfc portion...