Exemple #1
0
int
cfs_wi_startup (void)
{
        int i;
        int n;
        int rc;

        cfs_wi_data.wi_nthreads = 0;
        cfs_wi_data.wi_nsched   = CFS_WI_NSCHED;
        LIBCFS_ALLOC(cfs_wi_data.wi_scheds,
                     cfs_wi_data.wi_nsched * sizeof(cfs_wi_sched_t));
        if (cfs_wi_data.wi_scheds == NULL)
                return -ENOMEM;

        cfs_spin_lock_init(&cfs_wi_data.wi_glock);
        for (i = 0; i < cfs_wi_data.wi_nsched; i++)
                cfs_wi_sched_init(&cfs_wi_data.wi_scheds[i]);

#ifdef __KERNEL__
        n = cfs_num_online_cpus();
        for (i = 0; i <= n; i++) {
                rc = cfs_wi_start_thread(cfs_wi_scheduler,
                                         (void *)(long_ptr_t)(i == n ? -1 : i));
                if (rc != 0) {
                        CERROR ("Can't spawn workitem scheduler: %d\n", rc);
                        cfs_wi_shutdown();
                        return rc;
                }
        }
#else
        n = rc = 0;
#endif

        return 0;
}
Exemple #2
0
static void exit_libcfs_module(void)
{
        int rc;

        remove_proc();

        CDEBUG(D_MALLOC, "before Portals cleanup: kmem %d\n",
               cfs_atomic_read(&libcfs_kmemory));

        cfs_wi_shutdown();
        rc = cfs_psdev_deregister(&libcfs_dev);
        if (rc)
                CERROR("misc_deregister error %d\n", rc);

#if LWT_SUPPORT
        lwt_fini();
#endif

        if (cfs_atomic_read(&libcfs_kmemory) != 0)
                CERROR("Portals memory leaked: %d bytes\n",
                       cfs_atomic_read(&libcfs_kmemory));

        rc = libcfs_debug_cleanup();
        if (rc)
                printk(CFS_KERN_ERR "LustreError: libcfs_debug_cleanup: %d\n",
                       rc);

        cfs_fini_rwsem(&ioctl_list_sem);
        cfs_fini_rwsem(&cfs_tracefile_sem);

        libcfs_arch_cleanup();
}
Exemple #3
0
static int init_libcfs_module(void)
{
        int rc;

        libcfs_arch_init();
        libcfs_init_nidstrings();
        cfs_init_rwsem(&cfs_tracefile_sem);
        cfs_init_mutex(&cfs_trace_thread_sem);
        cfs_init_rwsem(&ioctl_list_sem);
        CFS_INIT_LIST_HEAD(&ioctl_list);

        rc = libcfs_debug_init(5 * 1024 * 1024);
        if (rc < 0) {
                printk(CFS_KERN_ERR "LustreError: libcfs_debug_init: %d\n", rc);
                return (rc);
        }

#if LWT_SUPPORT
        rc = lwt_init();
        if (rc != 0) {
                CERROR("lwt_init: error %d\n", rc);
                goto cleanup_debug;
        }
#endif
        rc = cfs_psdev_register(&libcfs_dev);
        if (rc) {
                CERROR("misc_register: error %d\n", rc);
                goto cleanup_lwt;
        }

        rc = cfs_wi_startup();
        if (rc) {
                CERROR("startup workitem: error %d\n", rc);
                goto cleanup_deregister;
        }

        rc = insert_proc();
        if (rc) {
                CERROR("insert_proc: error %d\n", rc);
                goto cleanup_wi;
        }

        CDEBUG (D_OTHER, "portals setup OK\n");
        return (0);

 cleanup_wi:
        cfs_wi_shutdown();
 cleanup_deregister:
        cfs_psdev_deregister(&libcfs_dev);
 cleanup_lwt:
#if LWT_SUPPORT
        lwt_fini();
 cleanup_debug:
#endif
        libcfs_debug_cleanup();
        return rc;
}
Exemple #4
0
static void exit_libcfs_module(void)
{
	int rc;

	remove_proc();

	CDEBUG(D_MALLOC, "before Portals cleanup: kmem %d\n",
	       atomic_read(&libcfs_kmemory));

	if (cfs_sched_rehash != NULL) {
		cfs_wi_sched_destroy(cfs_sched_rehash);
		cfs_sched_rehash = NULL;
	}

	cfs_crypto_unregister();
	cfs_wi_shutdown();

	rc = misc_deregister(&libcfs_dev);
	if (rc)
		CERROR("misc_deregister error %d\n", rc);

#if LWT_SUPPORT
	lwt_fini();
#endif
	cfs_cpu_fini();

	if (atomic_read(&libcfs_kmemory) != 0)
		CERROR("Portals memory leaked: %d bytes\n",
		       atomic_read(&libcfs_kmemory));

	rc = libcfs_debug_cleanup();
	if (rc)
		printk(KERN_ERR "LustreError: libcfs_debug_cleanup: %d\n",
		       rc);

	fini_rwsem(&ioctl_list_sem);
	fini_rwsem(&cfs_tracefile_sem);

	libcfs_arch_cleanup();
}
Exemple #5
0
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;
}