Re: [PATCH v3 28/48] scsi: libfc: Stop using the SCSI pointer

Hannes Reinecke
2022-02-14T11:56:13Z

On 2/11/22 23:32, Bart Van Assche wrote:
> 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 libfc users have been identified as follows:
>
> $ git grep -lw 'libfc_host_alloc' | grep -v /libfc
> drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> drivers/scsi/fcoe/fcoe.c
> drivers/scsi/fnic/fnic_main.c
> drivers/scsi/qedf/qedf_main.c
>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: Saurav Kashyap <skashyap@marvell.com>
> Cc: Javed Hasan <jhasan@marvell.com>
> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/scsi/bnx2fc/bnx2fc.h | 10 ++++++++--
> drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 1 +
> drivers/scsi/bnx2fc/bnx2fc_io.c | 24 ++++++++++++------------
> drivers/scsi/fcoe/fcoe.c | 1 +
> drivers/scsi/fnic/fnic.h | 1 +
> drivers/scsi/libfc/fc_fcp.c | 26 +++++++++++---------------
> drivers/scsi/qedf/qedf.h | 11 ++++++++++-
> drivers/scsi/qedf/qedf_io.c | 24 ++++++++++++------------
> drivers/scsi/qedf/qedf_main.c | 3 ++-
> include/scsi/libfc.h | 11 +++++++++++
> 10 files changed, 69 insertions(+), 43 deletions(-)
>
> diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
> index b4cea8b06ea1..08deed26c51e 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc.h
> +++ b/drivers/scsi/bnx2fc/bnx2fc.h
> @@ -137,8 +137,6 @@
> #define BNX2FC_FW_TIMEOUT (3 * HZ)
> #define PORT_MAX 2
>
> -#define CMD_SCSI_STATUS(Cmnd) ((Cmnd)->SCp.Status)
> -
> /* FC FCP Status */
> #define FC_GOOD 0
>
> @@ -493,7 +491,15 @@ struct bnx2fc_unsol_els {
> struct work_struct unsol_els_work;
> };
>
> +struct bnx2fc_priv {
> + struct libfc_cmd_priv libfc_data; /* must be the first member */
> + struct bnx2fc_cmd *io_req;
> +};
>
I had a closer look at the usage of SCp.ptr in the various FCoE drivers,
and it turns out that all have their own private use of SCp.ptr.
The only 'generic' use of SCp.ptr (where it points to 'struct
libfc_cmd_priv') is in fcoe/fcoe.c.
For the others (bnx2fc, qedf, and fnic) they point to their own,
private, data structure, and there's no overlap with libfc itself.
So no need to have a combined structure, and each driver should use
their own data structure only.
(IE bnx2fc_priv should just have the 'bnx2fc_cmd' pointer).

Cheers,

Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer