scsi: libfc: Stop using the SCSI pointer

Move the fc_fcp_pkt pointer, the residual length and the SCSI status into
the new data structure libfc_cmd_priv. This patch prepares for removal of
the SCSI pointer from struct scsi_cmnd.

The user of the libfc data path functions have been identified as follows:
$ git grep -lw fc_queuecommand | grep -v scsi/libfc/
drivers/scsi/fcoe/fcoe.c

Link: https://lore.kernel.org/r/20220218195117.25689-28-bvanassche@acm.org
Cc: Saurav Kashyap <skashyap@marvell.com>
Cc: Javed Hasan <jhasan@marvell.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Bart Van Assche 2022-02-18 11:50:55 -08:00 коммит произвёл Martin K. Petersen
Родитель 09cc102bb4
Коммит 5d21aa3636
3 изменённых файлов: 21 добавлений и 15 удалений

Просмотреть файл

@ -277,6 +277,7 @@ static struct scsi_host_template fcoe_shost_template = {
.sg_tablesize = SG_ALL, .sg_tablesize = SG_ALL,
.max_sectors = 0xffff, .max_sectors = 0xffff,
.track_queue_depth = 1, .track_queue_depth = 1,
.cmd_size = sizeof(struct libfc_cmd_priv),
}; };
/** /**

Просмотреть файл

@ -45,14 +45,10 @@ static struct kmem_cache *scsi_pkt_cachep;
#define FC_SRB_READ (1 << 1) #define FC_SRB_READ (1 << 1)
#define FC_SRB_WRITE (1 << 0) #define FC_SRB_WRITE (1 << 0)
/* static struct libfc_cmd_priv *libfc_priv(struct scsi_cmnd *cmd)
* The SCp.ptr should be tested and set under the scsi_pkt_queue lock {
*/ return scsi_cmd_priv(cmd);
#define CMD_SP(Cmnd) ((struct fc_fcp_pkt *)(Cmnd)->SCp.ptr) }
#define CMD_ENTRY_STATUS(Cmnd) ((Cmnd)->SCp.have_data_in)
#define CMD_COMPL_STATUS(Cmnd) ((Cmnd)->SCp.this_residual)
#define CMD_SCSI_STATUS(Cmnd) ((Cmnd)->SCp.Status)
#define CMD_RESID_LEN(Cmnd) ((Cmnd)->SCp.buffers_residual)
/** /**
* struct fc_fcp_internal - FCP layer internal data * struct fc_fcp_internal - FCP layer internal data
@ -1137,7 +1133,7 @@ static int fc_fcp_pkt_send(struct fc_lport *lport, struct fc_fcp_pkt *fsp)
unsigned long flags; unsigned long flags;
int rc; int rc;
fsp->cmd->SCp.ptr = (char *)fsp; libfc_priv(fsp->cmd)->fsp = fsp;
fsp->cdb_cmd.fc_dl = htonl(fsp->data_len); fsp->cdb_cmd.fc_dl = htonl(fsp->data_len);
fsp->cdb_cmd.fc_flags = fsp->req_flags & ~FCP_CFL_LEN_MASK; fsp->cdb_cmd.fc_flags = fsp->req_flags & ~FCP_CFL_LEN_MASK;
@ -1150,7 +1146,7 @@ static int fc_fcp_pkt_send(struct fc_lport *lport, struct fc_fcp_pkt *fsp)
rc = lport->tt.fcp_cmd_send(lport, fsp, fc_fcp_recv); rc = lport->tt.fcp_cmd_send(lport, fsp, fc_fcp_recv);
if (unlikely(rc)) { if (unlikely(rc)) {
spin_lock_irqsave(&si->scsi_queue_lock, flags); spin_lock_irqsave(&si->scsi_queue_lock, flags);
fsp->cmd->SCp.ptr = NULL; libfc_priv(fsp->cmd)->fsp = NULL;
list_del(&fsp->list); list_del(&fsp->list);
spin_unlock_irqrestore(&si->scsi_queue_lock, flags); spin_unlock_irqrestore(&si->scsi_queue_lock, flags);
} }
@ -1983,7 +1979,7 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
fc_fcp_can_queue_ramp_up(lport); fc_fcp_can_queue_ramp_up(lport);
sc_cmd = fsp->cmd; sc_cmd = fsp->cmd;
CMD_SCSI_STATUS(sc_cmd) = fsp->cdb_status; libfc_priv(sc_cmd)->status = fsp->cdb_status;
switch (fsp->status_code) { switch (fsp->status_code) {
case FC_COMPLETE: case FC_COMPLETE:
if (fsp->cdb_status == 0) { if (fsp->cdb_status == 0) {
@ -1992,7 +1988,7 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
*/ */
sc_cmd->result = DID_OK << 16; sc_cmd->result = DID_OK << 16;
if (fsp->scsi_resid) if (fsp->scsi_resid)
CMD_RESID_LEN(sc_cmd) = fsp->scsi_resid; libfc_priv(sc_cmd)->resid_len = fsp->scsi_resid;
} else { } else {
/* /*
* transport level I/O was ok but scsi * transport level I/O was ok but scsi
@ -2025,7 +2021,7 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
*/ */
FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml " FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml "
"due to FC_DATA_UNDRUN (scsi)\n"); "due to FC_DATA_UNDRUN (scsi)\n");
CMD_RESID_LEN(sc_cmd) = fsp->scsi_resid; libfc_priv(sc_cmd)->resid_len = fsp->scsi_resid;
sc_cmd->result = (DID_ERROR << 16) | fsp->cdb_status; sc_cmd->result = (DID_ERROR << 16) | fsp->cdb_status;
} }
break; break;
@ -2085,7 +2081,7 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
spin_lock_irqsave(&si->scsi_queue_lock, flags); spin_lock_irqsave(&si->scsi_queue_lock, flags);
list_del(&fsp->list); list_del(&fsp->list);
sc_cmd->SCp.ptr = NULL; libfc_priv(sc_cmd)->fsp = NULL;
spin_unlock_irqrestore(&si->scsi_queue_lock, flags); spin_unlock_irqrestore(&si->scsi_queue_lock, flags);
scsi_done(sc_cmd); scsi_done(sc_cmd);
@ -2121,7 +2117,7 @@ int fc_eh_abort(struct scsi_cmnd *sc_cmd)
si = fc_get_scsi_internal(lport); si = fc_get_scsi_internal(lport);
spin_lock_irqsave(&si->scsi_queue_lock, flags); spin_lock_irqsave(&si->scsi_queue_lock, flags);
fsp = CMD_SP(sc_cmd); fsp = libfc_priv(sc_cmd)->fsp;
if (!fsp) { if (!fsp) {
/* command completed while scsi eh was setting up */ /* command completed while scsi eh was setting up */
spin_unlock_irqrestore(&si->scsi_queue_lock, flags); spin_unlock_irqrestore(&si->scsi_queue_lock, flags);

Просмотреть файл

@ -351,6 +351,15 @@ struct fc_fcp_pkt {
struct completion tm_done; struct completion tm_done;
} ____cacheline_aligned_in_smp; } ____cacheline_aligned_in_smp;
/*
* @fsp should be tested and set under the scsi_pkt_queue lock
*/
struct libfc_cmd_priv {
struct fc_fcp_pkt *fsp;
u32 resid_len;
u8 status;
};
/* /*
* Structure and function definitions for managing Fibre Channel Exchanges * Structure and function definitions for managing Fibre Channel Exchanges
* and Sequences * and Sequences