static void tmpfs_release(struct kref *kref) { struct tmpfs *tmpfs = container_of(kref, struct tmpfs, users); tfs_frontend_purge(&tmpfs->tfs, purge_cb); /* this is the ref from attach */ assert(kref_refcnt(&tmpfs->tfs.root->kref) == 1); tf_kref_put(tmpfs->tfs.root); /* ensures __tf_free() happens before tfs_destroy */ rcu_barrier(); tfs_destroy(&tmpfs->tfs); kfree(tmpfs); }
struct cname *addelem(struct cname *n, char *s) { int i, a; char *t; struct cname *new; if (s[0] == '.' && s[1] == '\0') return n; if (kref_refcnt(&n->ref) > 1) { /* copy on write */ new = newcname(n->s); cnameclose(n); n = new; }
void printchan(void (*putch) (int, void **), void **putdat, struct chan *c) { if (! c) return; printfmt(putch, putdat, "(%p): ", c); printfmt(putch, putdat, "%slocked ", spin_locked(&c->lock) ? "":"un"); printfmt(putch, putdat, "refs %p ", kref_refcnt(&c->ref)); // printfmt(putch, putdat, "%p ", struct chan *next, // printfmt(putch, putdat, "%p ", struct chan *link, printfmt(putch, putdat, "off %p ", c->offset); printfmt(putch, putdat, "type %p ", c->type); if (c->type != -1) printfmt(putch, putdat, "(#%s) ", devtab[c->type].name); printfmt(putch, putdat, "dev %p ", c->dev); printfmt(putch, putdat, "mode %p ", c->mode); printfmt(putch, putdat, "flag %p ", c->flag); printfmt(putch, putdat, "qid"); printqid(putch, putdat, &c->qid); printfmt(putch, putdat, " fid %p ", c->fid); printfmt(putch, putdat, "iounit %p ", c->iounit); printfmt(putch, putdat, "umh %p ", c->umh); printfmt(putch, putdat, "umc %p ", c->umc); // printfmt(putch, putdat, "%p ", qlock_t umqlock, printfmt(putch, putdat, "uri %p ", c->uri); printfmt(putch, putdat, "dri %p ", c->dri); printfmt(putch, putdat, "mountid %p ", c->mountid); printfmt(putch, putdat, "mntcache %p ", c->mcp); printfmt(putch, putdat, "mux %p ", c->mux); if (c->mux && c->mux->c) printfmt(putch, putdat, "mux->c %p ", c->mux->c); printfmt(putch, putdat, "aux %p ", c->aux); printfmt(putch, putdat, "mchan %p ", c->mchan); printfmt(putch, putdat, "mqid %p "); printqid(putch, putdat, &c->mqid); printfmt(putch, putdat, " cname "); printcname(putch, putdat, c->name); printfmt(putch, putdat, " ateof %p ", c->ateof); printfmt(putch, putdat, "buf %p ", c->buf); printfmt(putch, putdat, "bufused %p ", c->bufused); }
/* * Decrement reference for this address on this link. * Unlink from selftab if this is the last ref. * called with c locked */ static void remselfcache(struct Fs *f, struct Ipifc *ifc, struct Iplifc *lifc, uint8_t * a) { struct Ipself *p, **l; struct Iplink *link, **l_self, **l_lifc; qlock(&f->self->qlock); /* find the unique selftab entry */ l = &f->self->hash[hashipa(a)]; for (p = *l; p; p = *l) { if (ipcmp(p->a, a) == 0) break; l = &p->next; } if (p == NULL) goto out; /* * walk down links from an ifc looking for one * that matches the selftab entry */ l_lifc = &lifc->link; for (link = *l_lifc; link; link = *l_lifc) { if (link->self == p) break; l_lifc = &link->lifclink; } if (link == NULL) goto out; /* * walk down the links from the selftab looking for * the one we just found */ l_self = &p->link; for (link = *l_self; link; link = *l_self) { if (link == *(l_lifc)) break; l_self = &link->selflink; } if (link == NULL) panic("remselfcache"); if (kref_refcnt(&link->ref) > 1) goto out; if ((p->type & Rmulti) && ifc->m->remmulti != NULL) (*ifc->m->remmulti) (ifc, a, lifc->local); /* ref == 0, remove from both chains and free the link */ *l_lifc = link->lifclink; *l_self = link->selflink; iplinkfree(link); if (p->link != NULL) goto out; /* remove from routing table */ if (isv4(a)) v4delroute(f, a + IPv4off, IPallbits + IPv4off, 1); else v6delroute(f, a, IPallbits, 1); /* no more links, remove from hash and free */ *l = p->next; ipselffree(p); /* if IPnoaddr, forget */ if (ipcmp(a, v4prefix) == 0 || ipcmp(a, IPnoaddr) == 0) f->self->acceptall = 0; out: qunlock(&f->self->qlock); }
void printcname(void (*putch) (int, void **), void **putdat, struct cname *c) { if (c) printfmt(putch, putdat, "{ref %d, alen %d, len %d, s %s}", kref_refcnt(&c->ref), c->alen, c->len, c->s); }