static int lnet_selftest_init(void) { int nscheds; int rc; int i; rc = cfs_wi_sched_create("lst_s", lnet_cpt_table(), CFS_CPT_ANY, 1, &lst_sched_serial); if (rc != 0) { CERROR("Failed to create serial WI scheduler for LST\n"); return rc; } lst_init_step = LST_INIT_WI_SERIAL; nscheds = cfs_cpt_number(lnet_cpt_table()); LIBCFS_ALLOC(lst_sched_test, sizeof(lst_sched_test[0]) * nscheds); if (lst_sched_test == NULL) goto error; lst_init_step = LST_INIT_WI_TEST; for (i = 0; i < nscheds; i++) { int nthrs = cfs_cpt_weight(lnet_cpt_table(), i); /* reserve at least one CPU for LND */ nthrs = max(nthrs - 1, 1); rc = cfs_wi_sched_create("lst_t", lnet_cpt_table(), i, nthrs, &lst_sched_test[i]); if (rc != 0) { CERROR("Failed to create CPT affinity WI scheduler %d for LST\n", i); goto error; } } rc = srpc_startup(); if (rc != 0) { CERROR("LST can't startup rpc\n"); goto error; } lst_init_step = LST_INIT_RPC; rc = sfw_startup(); if (rc != 0) { CERROR("LST can't startup framework\n"); goto error; } lst_init_step = LST_INIT_FW; rc = lstcon_console_init(); if (rc != 0) { CERROR("LST can't startup console\n"); goto error; } lst_init_step = LST_INIT_CONSOLE; return 0; error: lnet_selftest_fini(); return rc; }
static int init_libcfs_module(void) { int rc; libcfs_arch_init(); libcfs_init_nidstrings(); init_rwsem(&cfs_tracefile_sem); mutex_init(&cfs_trace_thread_mutex); init_rwsem(&ioctl_list_sem); CFS_INIT_LIST_HEAD(&ioctl_list); init_waitqueue_head(&cfs_race_waitq); rc = libcfs_debug_init(5 * 1024 * 1024); if (rc < 0) { printk(KERN_ERR "LustreError: libcfs_debug_init: %d\n", rc); return (rc); } rc = cfs_cpu_init(); if (rc != 0) goto cleanup_debug; #if LWT_SUPPORT rc = lwt_init(); if (rc != 0) { CERROR("lwt_init: error %d\n", rc); goto cleanup_debug; } #endif rc = misc_register(&libcfs_dev); if (rc) { CERROR("misc_register: error %d\n", rc); goto cleanup_lwt; } rc = cfs_wi_startup(); if (rc) { CERROR("initialize workitem: error %d\n", rc); goto cleanup_deregister; } /* max to 4 threads, should be enough for rehash */ rc = min(cfs_cpt_weight(cfs_cpt_table, CFS_CPT_ANY), 4); rc = cfs_wi_sched_create("cfs_rh", cfs_cpt_table, CFS_CPT_ANY, rc, &cfs_sched_rehash); if (rc != 0) { CERROR("Startup workitem scheduler: error: %d\n", rc); goto cleanup_deregister; } rc = cfs_crypto_register(); if (rc) { CERROR("cfs_crypto_regster: error %d\n", rc); goto cleanup_wi; } rc = insert_proc(); if (rc) { CERROR("insert_proc: error %d\n", rc); goto cleanup_crypto; } CDEBUG (D_OTHER, "portals setup OK\n"); return 0; cleanup_crypto: cfs_crypto_unregister(); cleanup_wi: cfs_wi_shutdown(); cleanup_deregister: misc_deregister(&libcfs_dev); cleanup_lwt: #if LWT_SUPPORT lwt_fini(); #endif cleanup_debug: libcfs_debug_cleanup(); return rc; }