Whamcloud - gitweb
LU-14661 obdclass: Add peer/peer NI when processing llog 10/43510/6
authorChris Horn <chris.horn@hpe.com>
Thu, 3 Sep 2020 20:06:08 +0000 (15:06 -0500)
committerOleg Drokin <green@whamcloud.com>
Wed, 18 Aug 2021 01:58:59 +0000 (01:58 +0000)
Construct peers when processing the config log so that LNet has
complete information about peer info stored in the config log.

These are "temporary" peers which can be overwritten by discovery.

In client_import_add_nids_to_conn(), we do not need to hold the
import lock when adding NIDs to the obd_uuid, and LNet needs to take
the LNet API mutex when adding/modifying peers. We don't want to take
the mutex while a spin lock is already being held, so drop the spin
lock prior to calling class_add_nids_to_uuid().

HPE-bug-id: LUS-9293
Signed-off-by: Chris Horn <chris.horn@hpe.com>
Change-Id: Ie0e35434c9b76f917c1448064c5217c821b1ad87
Reviewed-on: https://review.whamcloud.com/43510
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Reviewed-by: Sergey Cheremencev <sergey.cheremencev@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ldlm/ldlm_lib.c
lustre/obdclass/lustre_peer.c

index 4f29756..7ce007b 100644 (file)
@@ -175,9 +175,10 @@ int client_import_add_nids_to_conn(struct obd_import *imp, lnet_nid_t *nids,
        list_for_each_entry(conn, &imp->imp_conn_list, oic_item) {
                if (class_check_uuid(&conn->oic_uuid, nids[0])) {
                        *uuid = conn->oic_uuid;
        list_for_each_entry(conn, &imp->imp_conn_list, oic_item) {
                if (class_check_uuid(&conn->oic_uuid, nids[0])) {
                        *uuid = conn->oic_uuid;
+                       spin_unlock(&imp->imp_lock);
                        rc = class_add_nids_to_uuid(&conn->oic_uuid, nids,
                                                    nid_count);
                        rc = class_add_nids_to_uuid(&conn->oic_uuid, nids,
                                                    nid_count);
-                       break;
+                       RETURN(rc);
                }
        }
        spin_unlock(&imp->imp_lock);
                }
        }
        spin_unlock(&imp->imp_lock);
index ace3da0..16b50f9 100644 (file)
@@ -79,6 +79,7 @@ int class_add_uuid(const char *uuid, __u64 nid)
 {
        struct uuid_nid_data *data, *entry;
        int found = 0;
 {
        struct uuid_nid_data *data, *entry;
        int found = 0;
+       int rc;
 
        LASSERT(nid != 0);  /* valid newconfig NID is never zero */
 
 
        LASSERT(nid != 0);  /* valid newconfig NID is never zero */
 
@@ -117,10 +118,17 @@ int class_add_uuid(const char *uuid, __u64 nid)
        if (found) {
                CDEBUG(D_INFO, "found uuid %s %s cnt=%d\n", uuid,
                       libcfs_nid2str(nid), entry->un_nid_count);
        if (found) {
                CDEBUG(D_INFO, "found uuid %s %s cnt=%d\n", uuid,
                       libcfs_nid2str(nid), entry->un_nid_count);
+               rc = LNetAddPeer(entry->un_nids, entry->un_nid_count);
+               CDEBUG(D_INFO, "Add peer %s rc = %d\n",
+                      libcfs_nid2str(data->un_nids[0]), rc);
                OBD_FREE(data, sizeof(*data));
        } else {
                CDEBUG(D_INFO, "add uuid %s %s\n", uuid, libcfs_nid2str(nid));
                OBD_FREE(data, sizeof(*data));
        } else {
                CDEBUG(D_INFO, "add uuid %s %s\n", uuid, libcfs_nid2str(nid));
+               rc = LNetAddPeer(data->un_nids, data->un_nid_count);
+               CDEBUG(D_INFO, "Add peer %s rc = %d\n",
+                      libcfs_nid2str(data->un_nids[0]), rc);
        }
        }
+
        return 0;
 }
 EXPORT_SYMBOL(class_add_uuid);
        return 0;
 }
 EXPORT_SYMBOL(class_add_uuid);
@@ -169,7 +177,8 @@ int class_add_nids_to_uuid(struct obd_uuid *uuid, lnet_nid_t *nids,
                           int nid_count)
 {
        struct uuid_nid_data *entry;
                           int nid_count)
 {
        struct uuid_nid_data *entry;
-       int i;
+       int i, rc;
+       bool matched = false;
 
        ENTRY;
 
 
        ENTRY;
 
@@ -186,6 +195,8 @@ int class_add_nids_to_uuid(struct obd_uuid *uuid, lnet_nid_t *nids,
 
                if (!obd_uuid_equals(&entry->un_uuid, uuid))
                        continue;
 
                if (!obd_uuid_equals(&entry->un_uuid, uuid))
                        continue;
+
+               matched = true;
                CDEBUG(D_NET, "Updating UUID '%s'\n", obd_uuid2str(uuid));
                for (i = 0; i < nid_count; i++)
                        entry->un_nids[i] = nids[i];
                CDEBUG(D_NET, "Updating UUID '%s'\n", obd_uuid2str(uuid));
                for (i = 0; i < nid_count; i++)
                        entry->un_nids[i] = nids[i];
@@ -193,6 +204,12 @@ int class_add_nids_to_uuid(struct obd_uuid *uuid, lnet_nid_t *nids,
                break;
        }
        spin_unlock(&g_uuid_lock);
                break;
        }
        spin_unlock(&g_uuid_lock);
+       if (matched) {
+               rc = LNetAddPeer(entry->un_nids, entry->un_nid_count);
+               CDEBUG(D_INFO, "Add peer %s rc = %d\n",
+                      libcfs_nid2str(entry->un_nids[0]), rc);
+       }
+
        RETURN(0);
 }
 EXPORT_SYMBOL(class_add_nids_to_uuid);
        RETURN(0);
 }
 EXPORT_SYMBOL(class_add_nids_to_uuid);