void init_pipe_subsys(void) { pipestage_cache = umem_cache_create("pipestage-cache", sizeof(struct pipestage), 0, NULL, NULL, NULL, NULL, NULL, 0); ASSERT(pipestage_cache); pipeline_cache = umem_cache_create("pipeline-cache", sizeof(struct pipeline), 0, NULL, NULL, NULL, NULL, NULL, 0); ASSERT(pipeline_cache); }
int nvclock_init_subsys(void) { vclock_cache = umem_cache_create("vclock", sizeof(struct nvclock), 0, NULL, NULL, NULL, NULL, NULL, 0); return vclock_cache ? 0 : ENOMEM; }
int objstore_init(void) { int ret; vol_cache = umem_cache_create("vol", sizeof(struct objstore_vol), 0, NULL, NULL, NULL, NULL, NULL, 0); if (!vol_cache) return ENOMEM; ret = vg_init(); if (ret) goto err; ret = load_backend(&mem_backend, "mem"); if (ret) goto err; backend = &mem_backend; return 0; err: umem_cache_destroy(vol_cache); return ret; }
int vg_init(void) { struct objstore *filecache; vg_cache = umem_cache_create("vg", sizeof(struct objstore), 0, NULL, NULL, NULL, NULL, NULL, 0); if (!vg_cache) return ENOMEM; mxinit(&vgs_lock); list_create(&vgs, sizeof(struct objstore), offsetof(struct objstore, node)); filecache = objstore_vg_create("file$", OS_VG_SIMPLE); if (IS_ERR(filecache)) { umem_cache_destroy(vg_cache); return PTR_ERR(filecache); } return 0; }
static void server_main(int argc, char **argv) { int did; int c; struct statvfs vfsbuf; int imexit = 0; pid_t parent; char *root = NULL; char *sadmdir = NULL; hrtime_t delta; int dir = 0; int dfd; (void) set_prog_name("pkgserv"); openlog("pkgserv", LOG_PID | LOG_ODELAY, LOG_DAEMON); while ((c = getopt(argc, argv, "d:eoN:pP:R:r:")) != EOF) { switch (c) { case 'e': imexit = 1; break; case 'd': sadmdir = optarg; if (*sadmdir != '/' || strlen(sadmdir) >= PATH_MAX || access(sadmdir, X_OK) != 0) exit(99); break; case 'N': (void) set_prog_name(optarg); break; case 'o': one_shot = B_TRUE; verbose = 0; break; case 'p': /* * We are updating possibly many zones; so we're not * dumping based on a short timeout and we will not * exit. */ permanent = B_TRUE; dumptimeout = 3600; break; case 'P': client_pid = atoi(optarg); break; case 'R': root = optarg; if (*root != '/' || strlen(root) >= PATH_MAX || access(root, X_OK) != 0) exit(99); break; case 'r': read_only = B_TRUE; one_shot = B_TRUE; verbose = 0; door = optarg; break; default: exit(99); } } if (one_shot && permanent) { progerr(gettext("Incorrect Usage")); exit(99); } umem_nofail_callback(no_memory_abort); if (root != NULL && strcmp(root, "/") != 0) { if (snprintf(pkgdir, PATH_MAX, "%s%s", root, sadmdir == NULL ? SADM_DIR : sadmdir) >= PATH_MAX) { exit(99); } } else { if (sadmdir == NULL) (void) strcpy(pkgdir, SADM_DIR); else (void) strcpy(pkgdir, sadmdir); } if (chdir(pkgdir) != 0) { progerr(gettext("can't chdir to %s"), pkgdir); exit(2); } closefrom(3); if (!read_only && establish_lock(LOCK) < 0) { progerr(gettext( "couldn't lock in %s (server running?): %s"), pkgdir, strerror(errno)); exit(1); } did = door_create(pkg_door_srv, 0, DOOR_REFUSE_DESC); if (did == -1) { progerr("door_create: %s", strerror(errno)); exit(2); } (void) fdetach(door); if ((dfd = creat(door, 0644)) < 0 || close(dfd) < 0) { progerr("door_create: %s", strerror(errno)); exit(2); } (void) mutex_lock(&mtx); myuid = geteuid(); (void) sigset(SIGHUP, signal_handler); (void) sigset(SIGTERM, signal_handler); (void) sigset(SIGINT, signal_handler); (void) sigset(SIGQUIT, signal_handler); (void) signal(SIGPIPE, SIG_IGN); (void) atexit(finish); if (fattach(did, door) != 0) { progerr(gettext("attach door: %s"), strerror(errno)); exit(2); } (void) close(did); ecache = umem_cache_create("entry", sizeof (pkgentry_t), sizeof (char *), NULL, NULL, NULL, NULL, NULL, 0); avl_create(list, avlcmp, sizeof (pkgentry_t), offsetof(pkgentry_t, avl)); IS_ST0['\0'] = 1; IS_ST0[' '] = 1; IS_ST0['\t'] = 1; IS_ST0Q['\0'] = 1; IS_ST0Q[' '] = 1; IS_ST0Q['\t'] = 1; IS_ST0Q['='] = 1; parse_contents(); if (parse_log() > 0) pkgdump(); if (imexit) exit(0); if (statvfs(".", &vfsbuf) != 0) { progerr(gettext("statvfs: %s"), strerror(errno)); exit(2); } if (strcmp(vfsbuf.f_basetype, "zfs") == 0) flushbeforemark = 0; /* We've started, tell the parent */ parent = getppid(); if (parent != 1) (void) kill(parent, SIGUSR1); if (!one_shot) { int fd; (void) setsid(); fd = open("/dev/null", O_RDWR, 0); if (fd >= 0) { (void) dup2(fd, STDIN_FILENO); (void) dup2(fd, STDOUT_FILENO); (void) dup2(fd, STDERR_FILENO); if (fd > 2) (void) close(fd); } } lastcall = lastchange = gethrtime(); /* * Start the main thread, here is where we unlock the mutex. */ for (;;) { if (want_to_quit) { pkgdump(); exit(0); } /* Wait forever when root or when there's a running filter */ if (write_locked || (!one_shot && permanent && dir == changes)) { (void) cond_wait(&cv, &mtx); continue; } delta = time_since_(lastchange); /* Wait until DUMPTIMEOUT after last change before we pkgdump */ if (delta < dumptimeout * LLNANOSEC) { my_cond_reltimedwait(delta, dumptimeout); continue; } /* Client still around? Just wait then. */ if (client_pid > 1 && kill(client_pid, 0) == 0) { lastchange = lastcall = gethrtime(); continue; } /* Wait for another EXITTIMEOUT seconds before we exit */ if ((one_shot || !permanent) && dir == changes) { delta = time_since_(lastcall); if (delta < EXITTIMEOUT * LLNANOSEC) { my_cond_reltimedwait(delta, EXITTIMEOUT); continue; } exit(0); } pkgdump(); dir = changes; } /*NOTREACHED*/ }