- /* iterate all nids to find one */
- /* find uuid by nid */
- /* create import entries if they don't exist */
- rc = -ENOENT;
- rc = client_import_add_nids_to_conn(obd->u.cli.cl_import,
- entry->u.nids,
- entry->mne_nid_count,
- (struct obd_uuid *)uuid);
-
- if (rc == -ENOENT && dynamic_nids) {
- /* create a new connection for this import */
- char *primary_nid = libcfs_nid2str(entry->u.nids[0]);
- int prim_nid_len = strlen(primary_nid) + 1;
- struct obd_uuid server_uuid;
-
- if (prim_nid_len > UUID_MAX)
- goto fail;
- strncpy(server_uuid.uuid, primary_nid, prim_nid_len);
-
- CDEBUG(D_INFO, "Adding a connection for %s\n",
- primary_nid);
-
- rc = client_import_dyn_add_conn(obd->u.cli.cl_import,
- &server_uuid,
- entry->u.nids[0], 1);
- if (rc < 0) {
- CERROR("%s: Failed to add new connection with NID '%s' to import: rc = %d\n",
- obd->obd_name, primary_nid, rc);
- goto fail;
- }
- rc = client_import_add_nids_to_conn(obd->u.cli.cl_import,
- entry->u.nids,
- entry->mne_nid_count,
- (struct obd_uuid *)uuid);
- if (rc < 0) {
- CERROR("%s: failed to lookup UUID: rc = %d\n",
- obd->obd_name, rc);
- goto fail;
+ /* osc.import = "connection=<Conn UUID>::<target instance>" */
+ ++pos;
+ params = buf + pos;
+ pos += sprintf(params, "%s.import=%s", cname, "connection=");
+ uuid = buf + pos;
+
+ with_imp_locked(obd, imp, rc) {
+ /* iterate all nids to find one */
+ /* find uuid by nid */
+ /* create import entries if they don't exist */
+ rc = client_import_add_nids_to_conn(
+ imp, entry->u.nids, entry->mne_nid_count,
+ (struct obd_uuid *)uuid);
+
+ if (rc == -ENOENT && dynamic_nids) {
+ /* create a new connection for this import */
+ char *primary_nid =
+ libcfs_nid2str(entry->u.nids[0]);
+ int prim_nid_len = strlen(primary_nid) + 1;
+ struct obd_uuid server_uuid;
+
+ if (prim_nid_len > UUID_MAX)
+ goto fail;
+ strncpy(server_uuid.uuid, primary_nid,
+ prim_nid_len);
+
+ CDEBUG(D_INFO, "Adding a connection for %s\n",
+ primary_nid);
+
+ rc = client_import_dyn_add_conn(
+ imp, &server_uuid, entry->u.nids[0], 1);
+ if (rc < 0) {
+ CERROR("%s: Failed to add new connection with NID '%s' to import: rc = %d\n",
+ obd->obd_name, primary_nid, rc);
+ goto fail;
+ }
+ rc = client_import_add_nids_to_conn(
+ imp, entry->u.nids,
+ entry->mne_nid_count,
+ (struct obd_uuid *)uuid);
+ if (rc < 0) {
+ CERROR("%s: failed to lookup UUID: rc = %d\n",
+ obd->obd_name, rc);
+ goto fail;
+ }