scsi: zfcp: Move fc_host updates during xport data handling into fenced function
authorBenjamin Block <bblock@linux.ibm.com>
Fri, 8 May 2020 17:23:30 +0000 (19:23 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 12 May 2020 03:19:48 +0000 (23:19 -0400)
When executing exchange port data for a FCP device for the first time, or
after an adapter recovery, we update several properties of the fibre
channel host object which represents that FCP device.

When moving the scsi host object allocation and registration - and thus
also the fibre channel host object allocation - to after the first exchange
config and exchange port data, this is not possible for the former case.

Move all these update into separate, and fenced function that first checks
whether the scsi host object already exists or not, before making the
updates.

During the first ever exchange port data in the adapter life cycle this
will make the exchange port data handler skip over this update step, but we
can repeat it later, after we allocated the scsi host object.

For any further recovery of that adapter the work flow is only changed
slightly because then the scsi host object already exists and we don't free
it until we release the adapter completely at the end of its life cycle.

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

index 4c4be754cf6e31def077f9b3634e8a942040ba72..5dc9bdc5803fa606a47350b7a7247c02d8aed352 100644 (file)
@@ -176,6 +176,9 @@ extern void zfcp_scsi_shost_update_config_data(
        struct zfcp_adapter *const adapter,
        const struct fsf_qtcb_bottom_config *const bottom,
        const bool bottom_incomplete);
+extern void zfcp_scsi_shost_update_port_data(
+       struct zfcp_adapter *const adapter,
+       const struct fsf_qtcb_bottom_port *const bottom);
 
 /* zfcp_sysfs.c */
 extern const struct attribute_group *zfcp_unit_attr_groups[];
index 54edfcbe84ce33b370c04ffe381af359c9979b65..bfb567a1d7bf21bf606b02e74448a556430bc1e2 100644 (file)
@@ -725,19 +725,10 @@ static void zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *req)
 {
        struct zfcp_adapter *adapter = req->adapter;
        struct fsf_qtcb_bottom_port *bottom = &req->qtcb->bottom.port;
-       struct Scsi_Host *shost = adapter->scsi_host;
 
        if (req->data)
                memcpy(req->data, bottom, sizeof(*bottom));
 
-       fc_host_permanent_port_name(shost) = bottom->wwpn;
-       fc_host_maxframe_size(shost) = bottom->maximum_frame_size;
-       fc_host_supported_speeds(shost) =
-               zfcp_fsf_convert_portspeed(bottom->supported_speed);
-       memcpy(fc_host_supported_fc4s(shost), bottom->supported_fc4_types,
-              FC_FC4_LIST_SIZE);
-       memcpy(fc_host_active_fc4s(shost), bottom->active_fc4_types,
-              FC_FC4_LIST_SIZE);
        if (adapter->adapter_features & FSF_FEATURE_FC_SECURITY)
                adapter->fc_security_algorithms =
                        bottom->fc_security_algorithms;
@@ -764,6 +755,7 @@ static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req)
                 */
                zfcp_diag_update_xdata(diag_hdr, bottom, false);
 
+               zfcp_scsi_shost_update_port_data(req->adapter, bottom);
                zfcp_fsf_exchange_port_evaluate(req);
                break;
        case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
@@ -772,6 +764,8 @@ static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req)
 
                zfcp_fsf_link_down_info_eval(req,
                        &qtcb->header.fsf_status_qual.link_down_info);
+
+               zfcp_scsi_shost_update_port_data(req->adapter, bottom);
                zfcp_fsf_exchange_port_evaluate(req);
                break;
        }
index e1281a1ce48832ea88fe0cbe62c147391128a0e8..f98e4015a0edebcb5a97b89ee80a54805ac694f1 100644 (file)
@@ -911,6 +911,25 @@ void zfcp_scsi_shost_update_config_data(
        }
 }
 
+void zfcp_scsi_shost_update_port_data(
+       struct zfcp_adapter *const adapter,
+       const struct fsf_qtcb_bottom_port *const bottom)
+{
+       struct Scsi_Host *const shost = adapter->scsi_host;
+
+       if (shost == NULL)
+               return;
+
+       fc_host_permanent_port_name(shost) = bottom->wwpn;
+       fc_host_maxframe_size(shost) = bottom->maximum_frame_size;
+       fc_host_supported_speeds(shost) =
+               zfcp_fsf_convert_portspeed(bottom->supported_speed);
+       memcpy(fc_host_supported_fc4s(shost), bottom->supported_fc4_types,
+              FC_FC4_LIST_SIZE);
+       memcpy(fc_host_active_fc4s(shost), bottom->active_fc4_types,
+              FC_FC4_LIST_SIZE);
+}
+
 struct fc_function_template zfcp_transport_functions = {
        .show_starget_port_id = 1,
        .show_starget_port_name = 1,