scsi: zfcp: Change the type of all fsf request id fields and variables to u64
authorBenjamin Block <bblock@linux.ibm.com>
Tue, 21 Feb 2023 17:55:59 +0000 (18:55 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 22 Feb 2023 03:00:51 +0000 (22:00 -0500)
We use different integer types throughout zfcp to store the FSF request ID
and related values; some places use 'unsigned long' and others 'u64'.  On
s390x these are effectively the same type, but this might cause confusions
and is generally inconsistent.

The specification for the used hardware specifies this value as a 64-bit
number, and ultimately we use this value to communicate with the hardware,
so it makes sense to change the type of all these variables to 'u64' where
we can.  The only exception being when we store it in the 'host_scribble'
field of a 'struct scsi_cmnd'; for this case we add a build time check to
make sure they are compatible.

Link: https://lore.kernel.org/r/9c9cbe5acc2b419a22dce2fed847e3db91b60201.1677000450.git.bblock@linux.ibm.com
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/s390/scsi/zfcp_dbf.c
drivers/s390/scsi/zfcp_def.h
drivers/s390/scsi/zfcp_fsf.c
drivers/s390/scsi/zfcp_qdio.h
drivers/s390/scsi/zfcp_reqlist.h
drivers/s390/scsi/zfcp_scsi.c

index cbc3b62..d28c55a 100644 (file)
@@ -649,7 +649,7 @@ void zfcp_dbf_scsi_common(char *tag, int level, struct scsi_device *sdev,
                rec->scsi_id = sc->device->id;
                rec->scsi_lun = (u32)sc->device->lun;
                rec->scsi_lun_64_hi = (u32)(sc->device->lun >> 32);
-               rec->host_scribble = (unsigned long)sc->host_scribble;
+               rec->host_scribble = (u64)sc->host_scribble;
 
                memcpy(rec->scsi_opcode, sc->cmnd,
                       min_t(int, sc->cmd_len, ZFCP_DBF_SCSI_OPCODE));
index 94de553..6c76129 100644 (file)
@@ -129,7 +129,7 @@ struct zfcp_erp_action {
        struct scsi_device *sdev;
        u32             status;       /* recovery status */
        enum zfcp_erp_steps     step;   /* active step of this erp action */
-       unsigned long           fsf_req_id;
+       u64                     fsf_req_id;
        struct timer_list timer;
 };
 
@@ -163,7 +163,7 @@ struct zfcp_adapter {
        struct Scsi_Host        *scsi_host;        /* Pointer to mid-layer */
        struct list_head        port_list;         /* remote port list */
        rwlock_t                port_list_lock;    /* port list lock */
-       unsigned long           req_no;            /* unique FSF req number */
+       u64                     req_no;            /* unique FSF req number */
        struct zfcp_reqlist     *req_list;
        u32                     fsf_req_seq_no;    /* FSF cmnd seq number */
        rwlock_t                abort_lock;        /* Protects against SCSI
@@ -325,7 +325,7 @@ static inline u64 zfcp_scsi_dev_lun(struct scsi_device *sdev)
  */
 struct zfcp_fsf_req {
        struct list_head        list;
-       unsigned long           req_id;
+       u64                     req_id;
        struct zfcp_adapter     *adapter;
        struct zfcp_qdio_req    qdio_req;
        struct completion       completion;
index ab3ea52..71eabcc 100644 (file)
@@ -884,7 +884,7 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *req)
        const bool is_srb = zfcp_fsf_req_is_status_read_buffer(req);
        struct zfcp_adapter *adapter = req->adapter;
        struct zfcp_qdio *qdio = adapter->qdio;
-       unsigned long req_id = req->req_id;
+       u64 req_id = req->req_id;
 
        zfcp_reqlist_add(adapter->req_list, req);
 
@@ -1042,7 +1042,7 @@ struct zfcp_fsf_req *zfcp_fsf_abort_fcp_cmnd(struct scsi_cmnd *scmnd)
        struct scsi_device *sdev = scmnd->device;
        struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
        struct zfcp_qdio *qdio = zfcp_sdev->port->adapter->qdio;
-       unsigned long old_req_id = (unsigned long) scmnd->host_scribble;
+       u64 old_req_id = (u64) scmnd->host_scribble;
 
        spin_lock_irq(&qdio->req_q_lock);
        if (zfcp_qdio_sbal_get(qdio))
@@ -1065,7 +1065,7 @@ struct zfcp_fsf_req *zfcp_fsf_abort_fcp_cmnd(struct scsi_cmnd *scmnd)
        req->handler = zfcp_fsf_abort_fcp_command_handler;
        req->qtcb->header.lun_handle = zfcp_sdev->lun_handle;
        req->qtcb->header.port_handle = zfcp_sdev->port->handle;
-       req->qtcb->bottom.support.req_handle = (u64) old_req_id;
+       req->qtcb->bottom.support.req_handle = old_req_id;
 
        zfcp_fsf_start_timer(req, ZFCP_FSF_SCSI_ER_TIMEOUT);
        if (!zfcp_fsf_req_send(req)) {
@@ -1919,7 +1919,7 @@ int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port)
 {
        struct zfcp_qdio *qdio = wka_port->adapter->qdio;
        struct zfcp_fsf_req *req;
-       unsigned long req_id = 0;
+       u64 req_id = 0;
        int retval = -EIO;
 
        spin_lock_irq(&qdio->req_q_lock);
@@ -1978,7 +1978,7 @@ int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port)
 {
        struct zfcp_qdio *qdio = wka_port->adapter->qdio;
        struct zfcp_fsf_req *req;
-       unsigned long req_id = 0;
+       u64 req_id = 0;
        int retval = -EIO;
 
        spin_lock_irq(&qdio->req_q_lock);
@@ -2587,6 +2587,7 @@ int zfcp_fsf_fcp_cmnd(struct scsi_cmnd *scsi_cmnd)
                goto out;
        }
 
+       BUILD_BUG_ON(sizeof(scsi_cmnd->host_scribble) < sizeof(req->req_id));
        scsi_cmnd->host_scribble = (unsigned char *) req->req_id;
 
        io = &req->qtcb->bottom.io;
@@ -2732,7 +2733,7 @@ void zfcp_fsf_reqid_check(struct zfcp_qdio *qdio, int sbal_idx)
        struct qdio_buffer *sbal = qdio->res_q[sbal_idx];
        struct qdio_buffer_element *sbale;
        struct zfcp_fsf_req *fsf_req;
-       unsigned long req_id;
+       u64 req_id;
        int idx;
 
        for (idx = 0; idx < QDIO_MAX_ELEMENTS_PER_BUFFER; idx++) {
@@ -2747,7 +2748,7 @@ void zfcp_fsf_reqid_check(struct zfcp_qdio *qdio, int sbal_idx)
                         * corruption and must stop the machine immediately.
                         */
                        zfcp_qdio_siosl(adapter);
-                       panic("error: unknown req_id (%lx) on adapter %s.\n",
+                       panic("error: unknown req_id (%llx) on adapter %s.\n",
                              req_id, dev_name(&adapter->ccw_device->dev));
                }
 
index 3907068..90134d9 100644 (file)
@@ -115,7 +115,7 @@ zfcp_qdio_sbale_curr(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
  */
 static inline
 void zfcp_qdio_req_init(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
-                       unsigned long req_id, u8 sbtype, void *data, u32 len)
+                       u64 req_id, u8 sbtype, void *data, u32 len)
 {
        struct qdio_buffer_element *sbale;
        int count = min(atomic_read(&qdio->req_q_free),
index f4bac61..59fbb1b 100644 (file)
@@ -26,7 +26,7 @@ struct zfcp_reqlist {
        struct list_head buckets[ZFCP_REQ_LIST_BUCKETS];
 };
 
-static inline size_t zfcp_reqlist_hash(unsigned long req_id)
+static inline size_t zfcp_reqlist_hash(u64 req_id)
 {
        return req_id % ZFCP_REQ_LIST_BUCKETS;
 }
@@ -83,7 +83,7 @@ static inline void zfcp_reqlist_free(struct zfcp_reqlist *rl)
 }
 
 static inline struct zfcp_fsf_req *
-_zfcp_reqlist_find(struct zfcp_reqlist *rl, unsigned long req_id)
+_zfcp_reqlist_find(struct zfcp_reqlist *rl, u64 req_id)
 {
        struct zfcp_fsf_req *req;
        size_t i;
@@ -104,7 +104,7 @@ _zfcp_reqlist_find(struct zfcp_reqlist *rl, unsigned long req_id)
  * or NULL if there is no known FSF request with this id.
  */
 static inline struct zfcp_fsf_req *
-zfcp_reqlist_find(struct zfcp_reqlist *rl, unsigned long req_id)
+zfcp_reqlist_find(struct zfcp_reqlist *rl, u64 req_id)
 {
        unsigned long flags;
        struct zfcp_fsf_req *req;
@@ -129,7 +129,7 @@ zfcp_reqlist_find(struct zfcp_reqlist *rl, unsigned long req_id)
  * NULL if it has not been found.
  */
 static inline struct zfcp_fsf_req *
-zfcp_reqlist_find_rm(struct zfcp_reqlist *rl, unsigned long req_id)
+zfcp_reqlist_find_rm(struct zfcp_reqlist *rl, u64 req_id)
 {
        unsigned long flags;
        struct zfcp_fsf_req *req;
index 526ac24..3dbf4b2 100644 (file)
@@ -170,7 +170,7 @@ static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
                (struct zfcp_adapter *) scsi_host->hostdata[0];
        struct zfcp_fsf_req *old_req, *abrt_req;
        unsigned long flags;
-       unsigned long old_reqid = (unsigned long) scpnt->host_scribble;
+       u64 old_reqid = (u64) scpnt->host_scribble;
        int retval = SUCCESS, ret;
        int retry = 3;
        char *dbf_tag;