static struct nvme_host *default_host;
+static void __nvme_free_host(nvme_host_t h);
+static void __nvme_free_ctrl(nvme_ctrl_t c);
static int nvme_subsystem_scan_namespace(struct nvme_subsystem *s, char *name);
static int nvme_scan_subsystem(struct nvme_root *r, char *name,
nvme_scan_filter_t f);
}
list_head_init(&r->hosts);
- r->refcount = 1;
nvme_scan_topology(r, f);
return r;
}
struct nvme_host *h, *_h;
nvme_for_each_host_safe(r, h, _h)
- nvme_free_host(h);
+ __nvme_free_host(h);
nvme_scan_topology(r, NULL);
}
struct nvme_host *h, *_h;
nvme_for_each_host_safe(r, h, _h)
- nvme_free_host(h);
+ __nvme_free_host(h);
nvme_scan_topology(r, NULL);
}
struct nvme_host *h, *_h;
nvme_for_each_host_safe(r, h, _h)
- nvme_free_host(h);
+ __nvme_free_host(h);
if (r->config_file)
free(r->config_file);
free(r);
return n ? list_next(&s->namespaces, n, entry) : NULL;
}
-void nvme_free_ns(struct nvme_ns *n)
+static void __nvme_free_ns(struct nvme_ns *n)
{
list_del_init(&n->entry);
close(n->fd);
free(n);
}
-void nvme_free_subsystem(struct nvme_subsystem *s)
+/* Stub for SWIG */
+void nvme_free_ns(struct nvme_ns *n)
+{
+}
+
+static void __nvme_free_subsystem(struct nvme_subsystem *s)
{
struct nvme_ctrl *c, *_c;
struct nvme_ns *n, *_n;
- if (--s->refcount > 0)
- return;
-
list_del_init(&s->entry);
nvme_subsystem_for_each_ctrl_safe(s, c, _c)
- nvme_free_ctrl(c);
+ __nvme_free_ctrl(c);
nvme_subsystem_for_each_ns_safe(s, n, _n)
- nvme_free_ns(n);
+ __nvme_free_ns(n);
free(s->name);
free(s->sysfs_dir);
free(s);
}
+/*
+ * Stub for SWIG
+ */
+void nvme_free_subsystem(nvme_subsystem_t s)
+{
+}
+
struct nvme_subsystem *nvme_lookup_subsystem(struct nvme_host *h,
const char *name,
const char *subsysnqn)
if (name && s->name &&
strcmp(s->name, name))
continue;
- s->refcount++;
return s;
}
s = calloc(1, sizeof(*s));
s->h = h;
s->subsysnqn = strdup(subsysnqn);
- s->refcount = 1;
list_head_init(&s->ctrls);
list_head_init(&s->namespaces);
list_node_init(&s->entry);
return s;
}
-void nvme_free_host(struct nvme_host *h)
+static void __nvme_free_host(struct nvme_host *h)
{
struct nvme_subsystem *s, *_s;
- if (--h->refcount > 0)
- return;
list_del_init(&h->entry);
nvme_for_each_subsystem_safe(h, s, _s)
- nvme_free_subsystem(s);
+ __nvme_free_subsystem(s);
free(h->hostnqn);
if (h->hostid)
free(h->hostid);
free(h);
}
+/* Stub for SWIG */
+void nvme_free_host(struct nvme_host *h)
+{
+}
+
struct nvme_host *nvme_lookup_host(nvme_root_t r, const char *hostnqn,
const char *hostid)
{
if (hostid &&
strcmp(h->hostid, hostid))
continue;
- h->refcount++;
return h;
}
h = calloc(1,sizeof(*h));
list_head_init(&h->subsystems);
list_node_init(&h->entry);
h->r = r;
- h->refcount = 1;
list_add(&r->hosts, &h->entry);
r->modified = true;
nvme_subsystem_scan_ctrls(s);
if (f && !f(s)) {
- nvme_free_subsystem(s);
+ __nvme_free_subsystem(s);
return -1;
}
c->s = NULL;
}
-void nvme_free_ctrl(nvme_ctrl_t c)
+static void __nvme_free_ctrl(nvme_ctrl_t c)
{
struct nvme_path *p, *_p;
struct nvme_ns *n, *_n;
- if (--c->refcount > 0)
- return;
-
nvme_unlink_ctrl(c);
nvme_ctrl_for_each_path_safe(c, p, _p)
nvme_free_path(p);
nvme_ctrl_for_each_ns_safe(c, n, _n)
- nvme_free_ns(n);
+ __nvme_free_ns(n);
if (c->fd >= 0)
close(c->fd);
free(c);
}
+/* Stub for SWIG */
+void nvme_free_ctrl(nvme_ctrl_t c)
+{
+}
+
#define ____stringify(x...) #x
#define __stringify(x...) ____stringify(x)
!strncmp(transport, "tcp", 3)) {
nvme_msg(LOG_ERR, "No trsvcid specified for '%s'\n",
transport);
- nvme_free_ctrl(c);
+ __nvme_free_ctrl(c);
c = NULL;
}
if (trsvcid && c->trsvcid &&
strcmp(c->trsvcid, trsvcid))
continue;
- c->refcount++;
return c;
}
c = nvme_create_ctrl(s->subsysnqn, transport, traddr,
host_traddr, host_iface, trsvcid);
if (c) {
c->s = s;
- c->refcount = 1;
list_add(&s->ctrls, &c->entry);
s->h->r->modified = true;
}