int si_nodeopen(sinode *n, sr *r, sischeme *scheme, sspath *path) { int rc = ss_fileopen(&n->file, path->path); if (ssunlikely(rc == -1)) { sr_malfunction(r->e, "db file '%s' open error: %s", n->file.file, strerror(errno)); return -1; } rc = ss_fileseek(&n->file, n->file.size); if (ssunlikely(rc == -1)) { si_nodeclose(n, r); sr_malfunction(r->e, "db file '%s' seek error: %s", n->file.file, strerror(errno)); return -1; } rc = si_noderecover(n, r); if (ssunlikely(rc == -1)) si_nodeclose(n, r); if (scheme->mmap) { rc = si_nodemap(n, r); if (ssunlikely(rc == -1)) si_nodeclose(n, r); } return rc; }
int si_nodeopen(sinode *n, sr *r, sischeme *scheme, sspath *path, sdsnapshotnode *sn) { int rc = ss_fileopen(&n->file, path->path); if (ssunlikely(rc == -1)) { sr_malfunction(r->e, "db file '%s' open error: %s", ss_pathof(&n->file.path), strerror(errno)); return -1; } rc = ss_fileseek(&n->file, n->file.size); if (ssunlikely(rc == -1)) { sr_malfunction(r->e, "db file '%s' seek error: %s", ss_pathof(&n->file.path), strerror(errno)); goto error; } int in_memory = 0; if (scheme->storage == SI_SIN_MEMORY) in_memory = 1; rc = si_noderecover(n, r, sn, in_memory); if (ssunlikely(rc == -1)) goto error; if (scheme->mmap) { rc = si_nodemap(n, r); if (ssunlikely(rc == -1)) goto error; } return 0; error: si_nodeclose(n, r, 0); return -1; }
int si_nodefree(sinode *n, sr *r, int gc) { int rcret = 0; int rc; if (gc && n->file.file) { rc = ss_fileunlink(n->file.file); if (ssunlikely(rc == -1)) { sr_malfunction(r->e, "db file '%s' unlink error: %s", n->file.file, strerror(errno)); rcret = -1; } } si_nodefree_branches(n, r); rc = si_nodeclose(n, r); if (ssunlikely(rc == -1)) rcret = -1; ss_free(r->a, n); return rcret; }
int si_nodefree(sinode *n, sr *r, int gc) { int rcret = 0; int rc; if (gc && ss_pathis_set(&n->file.path)) { ss_fileadvise(&n->file, 0, 0, n->file.size); rc = ss_vfsunlink(r->vfs, ss_pathof(&n->file.path)); if (ssunlikely(rc == -1)) { sr_malfunction(r->e, "db file '%s' unlink error: %s", ss_pathof(&n->file.path), strerror(errno)); rcret = -1; } } si_nodefree_branches(n, r); rc = si_nodeclose(n, r, gc); if (ssunlikely(rc == -1)) rcret = -1; ss_free(r->a, n); return rcret; }