+int class_add_nids_to_uuid(struct obd_uuid *uuid, struct lnet_nid *nidlist,
+ int nid_count, int nid_size)
+{
+ struct uuid_nid_data *entry;
+ int i, rc;
+ bool matched = false;
+
+ ENTRY;
+
+ if (nid_count >= MTI_NIDS_MAX) {
+ CDEBUG(D_NET, "too many NIDs (%d) for UUID '%s'\n",
+ nid_count, obd_uuid2str(uuid));
+ return -ENOSPC;
+ }
+
+ spin_lock(&g_uuid_lock);
+ list_for_each_entry(entry, &g_uuid_list, un_list) {
+ CDEBUG(D_NET, "Comparing %s with %s\n",
+ obd_uuid2str(uuid), obd_uuid2str(&entry->un_uuid));
+
+ if (!obd_uuid_equals(&entry->un_uuid, uuid))
+ continue;
+
+ matched = true;
+ entry->un_nid_count = 0;
+ CDEBUG(D_NET, "Updating UUID '%s'\n", obd_uuid2str(uuid));
+ for (i = 0; i < nid_count; i++) {
+ if (NID_BYTES(&nidlist[i]) > nid_size)
+ continue;
+
+ entry->un_nid_count++;
+ memset(&entry->un_nids[entry->un_nid_count], 0,
+ sizeof(entry->un_nids[entry->un_nid_count]));
+ memcpy(&entry->un_nids[entry->un_nid_count],
+ &nidlist[i], nid_size);
+ }
+ 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_nidstr(&entry->un_nids[0]), rc);
+ }
+
+ RETURN(0);
+}
+EXPORT_SYMBOL(class_add_nids_to_uuid);
+