Esempio n. 1
0
int
zfsslash2_init(void)
{
	struct pscfs_args args = PSCFS_ARGS_INIT(0, NULL);
	extern struct fuse_lowlevel_ops pscfs_fuse_ops;
	extern struct fuse_session *fuse_session;
	extern struct pollfd pflfs_fds[];
	extern int newfs_fd[2], pflfs_nfds;
	extern char *fuse_mount_options;
	int rc;

	if (pfl_systemf("umount %s", _PATH_KSTAT) == -1)
		psclog_warn("umount %s", _PATH_KSTAT);

	if (pipe(newfs_fd) == -1)
		psc_fatal("pipe");

	pflfs_fds[0].fd = newfs_fd[0];
	pflfs_fds[0].events = POLLIN;
	pflfs_nfds = 1;

	fuse_session = fuse_lowlevel_new(&args.pfa_av, &pscfs_fuse_ops,
	    sizeof(pscfs_fuse_ops), NULL);

	pscthr_init(SLMTHRT_ZFS_KSTAT, slmzfskstatmthr_main, 0,
	    "slmzfskstatmthr");

	fuse_mount_options = "";
	rc = libzfs_init_fusesocket();
	if (rc == 0)
		rc = libzfs_init();
	atexit(slm_unmount_kstat);
	return (rc);
}
Esempio n. 2
0
void
pscrpc_nbreapthr_spawn(struct pscrpc_request_set *set, int thrtype,
    int nthr, const char *thrname)
{
	struct pscrpc_nbreapthr *pnbt;
	struct psc_thread *thr;
	int i;

	for (i = 0; i < nthr; i++) {
		thr = pscthr_init(thrtype, pscrpc_nbreapthr_main, NULL,
		    sizeof(*pnbt), thrname, i);
		pnbt = thr->pscthr_private;
		pnbt->pnbt_set = set;
		pscthr_setready(thr);
	}
}
Esempio n. 3
0
void
slab_cache_init(void)
{
	size_t nbuf;

	psc_assert(SLASH_SLVR_SIZE <= LNET_MTU);

	if (slcfg_local->cfg_slab_cache_size < SLAB_CACHE_MIN)
		psc_fatalx("invalid slab_cache_size setting; "
		    "minimum allowed is %zu", SLAB_CACHE_MIN);

	nbuf = slcfg_local->cfg_slab_cache_size / SLASH_SLVR_SIZE;
	psc_poolmaster_init(&slab_poolmaster, struct slab,
	    slb_mgmt_lentry, PPMF_AUTO, nbuf, nbuf, nbuf,
	    slab_cache_reap, "slab",
	    NULL);
	slab_pool = psc_poolmaster_getmgr(&slab_poolmaster);

	pscthr_init(SLITHRT_BREAP, slibreapthr_main, 0, "slibreapthr");
}
Esempio n. 4
0
int
zfsslash2_init(void)
{
	struct pscfs_args args = PSCFS_ARGS_INIT(0, NULL);
	extern struct fuse_lowlevel_ops pscfs_fuse_ops;
	extern struct fuse_session *fuse_session;
	extern struct pollfd pscfs_fds[];
	extern int newfs_fd[2], pscfs_nfds;
	extern char *fuse_mount_options;
	char buf[BUFSIZ];
	int rc;

	rc = snprintf(buf, sizeof(buf), "umount %s", _PATH_KSTAT);
	if (rc == -1)
		psc_fatal("snprintf: umount %s", _PATH_KSTAT);
	if (rc >= (int)sizeof(buf))
		psc_fatalx("snprintf: umount %s: too long", _PATH_KSTAT);
	if (system(buf) == -1)
		psclog_warn("system(%s)", buf);

	if (pipe(newfs_fd) == -1)
		psc_fatal("pipe");

	pscfs_fds[0].fd = newfs_fd[0];
	pscfs_fds[0].events = POLLIN;
	pscfs_nfds = 1;

	fuse_session = fuse_lowlevel_new(&args.pfa_av, &pscfs_fuse_ops,
	    sizeof(pscfs_fuse_ops), NULL);

	pscthr_init(SLMTHRT_ZFS_KSTAT, slmzfskstatmthr_main, NULL, 0,
	    "slmzfskstatmthr");

	fuse_mount_options = "";
	rc = libzfs_init_fusesocket();
	if (rc == 0)
		rc = libzfs_init();
	atexit(slm_unmount_kstat);
	return (rc);
}
Esempio n. 5
0
int
main(int argc, char *argv[])
{
    int c, i, rc = 0;

    progname = argv[0];
    pfl_init();
    while ((c = getopt(argc, argv, "n:i:")) != -1)
        switch (c) {
        case 'n':
            nthreads = atoi(optarg);
            break;
        case 'i':
            iterations = atoi(optarg);
            break;
        default:
            usage();
        }
    argc -= optind;
    if (argc)
        usage();

    psclog_debug("nthreads = %d", nthreads);

    psc_waitq_init(&waitq);

    for (i = 0; i < nthreads; i++)
        pscthr_init(0, child_main, NULL, 0, "thr%d", i);

    sleep(1);
    psc_waitq_wakeall(&waitq);
    sleep(2);

    i = nthreads * iterations;
    while (i--) {
        psc_waitq_wakeone(&waitq);
        usleep(30);
    }
    return rc;
}
Esempio n. 6
0
int
main(int argc, char *argv[])
{
	int c, i, rc, verbose = 0, oflg = ODTBL_FLG_RDONLY, tflg = ODTBL_OPT_CRC;
	struct pfl_odt *t;
	char *p, *fn;

	pfl_init();
	pscthr_init(0, NULL, 0, "odtable");

	while ((c = getopt(argc, argv, "CcdF:n:osvX:z:")) != -1)
		switch (c) {
		case 'C':
			create_table = 1;
			break;
		case 'c':
			tflg |= ODTBL_OPT_CRC;
			break;
		case 'd':
			dump = 1;
			break;
		case 'F':
			num_free = atoi(optarg);
			oflg &= ~ODTBL_FLG_RDONLY;
			break;
		case 'n':
			num_puts = atoi(optarg);
			oflg &= ~ODTBL_FLG_RDONLY;
			break;
		case 'o':
			overwrite = 1;
			break;
		case 's':
			item_size = atoi(optarg);
			break;
		case 'v':
			verbose = 1;
			break;
		case 'X':
			fmt = optarg;
			break;
		case 'z':
			nitems = atoi(optarg);
			break;
		default:
			usage();
		}

	argc -= optind;
	argv += optind;
	if (argc != 1)
		usage();

	fn = argv[0];

	if (create_table) {
		rc = pfl_odt_create(fn, nitems, item_size, overwrite,
		    ODT_ITEM_START, 0, tflg);
		if (!rc && verbose)
			warnx("created od-table %s "
			    "(elemsize=%zu, nitems=%zu)",
			    fn, item_size, nitems);
		exit(0);
	}

	pfl_odt_load(&t, &pfl_odtops, oflg, fn, "%s", fn);
	pfl_odt_check(t, visit, &t);

	for (i = 0; i < num_puts; i++) {
		size_t elem;

		elem = pfl_odt_allocslot(t);
		pfl_odt_allocitem(t, (void **)&p);
		snprintf(p, item_size, "... put_number=%d ...", i);
		pfl_odt_putitem(t, elem, p, 1);
		PSCFREE(p);
	}

	/* XXX find in-use slot to free */
	for (i = 0; i < num_free; i++)
		pfl_odt_freeitem(t, i);

	pfl_odt_release(t);
	exit(0);
}
Esempio n. 7
0
int
main(int argc, char *argv[])
{
	char c, *p, *noncanon_mp, *cmd, *path_env, dir[PATH_MAX];
	struct pscfs_args args = PSCFS_ARGS_INIT(0, NULL);
	struct psc_dynarray startup_cmds = DYNARRAY_INIT;
	const char *progpath = argv[0];
	int rc, i, unmount_first = 0;

	pfl_init();

	pscfs_addarg(&args, "");		/* progname/argv[0] */
	pscfs_addarg(&args, "-o");
	pscfs_addarg(&args, STD_MOUNT_OPTIONS);

	p = getenv("CTL_SOCK_FILE");
	if (p)
		ctlsockfn = p;

	while ((c = getopt(argc, argv, "dL:o:S:U")) != -1)
		switch (c) {
		case 'd':
			pscfs_addarg(&args, "-odebug");
			break;
		case 'L':
			psc_dynarray_add(&startup_cmds, optarg);
			break;
		case 'o':
			if (!opt_lookup(optarg)) {
				pscfs_addarg(&args, "-o");
				pscfs_addarg(&args, optarg);
			}
			break;
		case 'S':
			ctlsockfn = optarg;
			break;
		case 'U':
			unmount_first = 1;
			break;
		default:
			usage();
		}
	argc -= optind;
	argv += optind;
	if (argc != 1)
		usage();

	pscthr_init(PFL_THRT_FSMGR, NULL, 0, "fsmgrthr");

	noncanon_mp = argv[0];
	if (unmount_first)
		unmount(noncanon_mp);

	/* canonicalize mount path */
	if (realpath(noncanon_mp, mountpoint) == NULL)
		psc_fatal("realpath %s", noncanon_mp);

	pscfs_mount(mountpoint, &args);
	pscfs_freeargs(&args);

	ctlthr_spawn();

	pfl_opstimerthr_spawn(PFL_THRT_OPSTIMER, "opstimerthr");
	pfl_workq_init(128, 1024, 1024);
	pfl_wkthr_spawn(PFL_THRT_WORKER, 4, 0, "wkthr%d");

	pscfs_entry_timeout = 8.;
	pscfs_attr_timeout = 8.;

	/*
	 * Here, $p = (directory this daemon binary resides in).
	 * Now we add the following to $PATH:
	 *
	 *   1) $p
	 *   2) $p/../wokctl (for developers)
	 */
	pfl_dirname(progpath, dir);
	p = getenv("PATH");
	rc = pfl_asprintf(&path_env, "%s:%s/../wokctl%s%s", dir, dir,
	    p ? ":" : "", p ? p : "");
	psc_assert(rc != -1);
	setenv("PATH", path_env, 1);

	/*
 	 * If wokctl (see file wokctl.c) misbehaves because it is given 
 	 * a wrong arugment, it is hard to debug from our end because 
 	 * we won't be receiving anything useful via the socket. This 
 	 * should be changed to a native call someday.
 	 *
 	 * If the client does not come up, double/triple checkout 
 	 * the name of your slash2 shared library. I wish I can
 	 * add more verbose debugging information.
 	 */
	DYNARRAY_FOREACH(cmd, i, &startup_cmds)
		pfl_systemf("wokctl -S %s %s", ctlsockfn, cmd);

	exit(pscfs_main(32, ""));
}
Esempio n. 8
0
void
slmbmaptimeothr_spawn(void)
{
	pscthr_init(SLMTHRT_BMAPTIMEO, slmbmaptimeothr_begin, NULL, 0,
	    "slmbmaptimeothr");
}
Esempio n. 9
0
void
psc_eqpollthr_spawn(int thrtype, const char *thrname)
{
	pscthr_init(thrtype, psc_eqpollthr_main, NULL, 0, thrname);
}