int ptlrpc_ni_init(void) { int rc; lnet_pid_t pid; pid = ptl_get_pid(); CDEBUG(D_NET, "My pid is: %x\n", pid); /* We're not passing any limits yet... */ rc = LNetNIInit(pid); if (rc < 0) { CDEBUG(D_NET, "Can't init network interface: %d\n", rc); return (-ENOENT); } /* CAVEAT EMPTOR: how we process portals events is _radically_ * different depending on... */ /* kernel LNet calls our master callback when there are new event, * because we are guaranteed to get every event via callback, * so we just set EQ size to 0 to avoid overhread of serializing * enqueue/dequeue operations in LNet. */ rc = LNetEQAlloc(0, ptlrpc_master_callback, &ptlrpc_eq_h); if (rc == 0) return 0; CERROR("Failed to allocate event queue: %d\n", rc); LNetNIFini(); return (-ENOMEM); }
static int lnet_configure(void *arg) { /* 'arg' only there so I can be passed to cfs_create_thread() */ int rc = 0; mutex_lock(&lnet_config_mutex); if (!the_lnet.ln_niinit_self) { rc = try_module_get(THIS_MODULE); if (rc != 1) goto out; rc = LNetNIInit(LNET_PID_LUSTRE); if (rc >= 0) { the_lnet.ln_niinit_self = 1; rc = 0; } else { module_put(THIS_MODULE); } } out: mutex_unlock(&lnet_config_mutex); return rc; }
int lnet_configure (void *arg) { /* 'arg' only there so I can be passed to cfs_create_thread() */ int rc = 0; LNET_MUTEX_LOCK(&lnet_config_mutex); if (!the_lnet.ln_niinit_self) { rc = LNetNIInit(LUSTRE_SRV_LNET_PID); if (rc >= 0) { the_lnet.ln_niinit_self = 1; rc = 0; } } LNET_MUTEX_UNLOCK(&lnet_config_mutex); return rc; }
static int lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_hdr *hdr) { int rc; switch (cmd) { case IOC_LIBCFS_CONFIGURE: { struct libcfs_ioctl_data *data = (struct libcfs_ioctl_data *)hdr; if (data->ioc_hdr.ioc_len < sizeof(*data)) return -EINVAL; the_lnet.ln_nis_from_mod_params = data->ioc_flags; return lnet_configure(NULL); } case IOC_LIBCFS_UNCONFIGURE: return lnet_unconfigure(); case IOC_LIBCFS_ADD_NET: return lnet_dyn_configure(hdr); case IOC_LIBCFS_DEL_NET: return lnet_dyn_unconfigure(hdr); default: /* * Passing LNET_PID_ANY only gives me a ref if the net is up * already; I'll need it to ensure the net can't go down while * I'm called into it */ rc = LNetNIInit(LNET_PID_ANY); if (rc >= 0) { rc = LNetCtl(cmd, hdr); LNetNIFini(); } return rc; } }
int lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data) { int rc; switch (cmd) { case IOC_LIBCFS_CONFIGURE: return lnet_configure(NULL); case IOC_LIBCFS_UNCONFIGURE: return lnet_unconfigure(); default: /* Passing LNET_PID_ANY only gives me a ref if the net is up * already; I'll need it to ensure the net can't go down while * I'm called into it */ rc = LNetNIInit(LNET_PID_ANY); if (rc >= 0) { rc = LNetCtl(cmd, data); LNetNIFini(); } return rc; } }