diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-08-09 21:16:10 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-08-09 21:16:10 +0200 |
commit | 9f4eac529243e21ae310ad3a07139d9981f1ce9c (patch) | |
tree | 87526675289ef6f56cb0882c38d45fab707d0fa3 /sys/src/9/port/pgrp.c | |
parent | 3af236b5e36951ba637d59e4d0362cdb0e428bd2 (diff) |
kernel: pgrpcpy(), simplify Mount structure
instead of ordering the source mount list, order the new destination
list which has the advantage that we do not need to wlock the source
namespace, so copying can be done in parallel and we do not need the
copy forward pointer in the Mount structure.
the Mhead back pointer in the Mount strcture was unused, removed.
Diffstat (limited to 'sys/src/9/port/pgrp.c')
-rw-r--r-- | sys/src/9/port/pgrp.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/sys/src/9/port/pgrp.c b/sys/src/9/port/pgrp.c index 430052db9..5de7c695f 100644 --- a/sys/src/9/port/pgrp.c +++ b/sys/src/9/port/pgrp.c @@ -115,11 +115,12 @@ pgrpinsert(Mount **order, Mount *m) void pgrpcpy(Pgrp *to, Pgrp *from) { - int i; Mount *n, *m, **link, *order; Mhead *f, **tom, **l, *mh; + int i; - wlock(&from->ns); + wlock(&to->ns); + rlock(&from->ns); order = nil; tom = to->mnthash; for(i = 0; i < MNTHASH; i++) { @@ -131,9 +132,14 @@ pgrpcpy(Pgrp *to, Pgrp *from) l = &mh->hash; link = &mh->mount; for(m = f->mount; m != nil; m = m->next) { - n = newmount(mh, m->to, m->mflag, m->spec); - m->copy = n; - pgrpinsert(&order, m); + n = smalloc(sizeof(Mount)); + n->mountid = m->mountid; + n->mflag = m->mflag; + n->to = m->to; + incref(n->to); + if(m->spec != nil) + kstrdup(&n->spec, m->spec); + pgrpinsert(&order, n); *link = n; link = &n->next; } @@ -144,8 +150,9 @@ pgrpcpy(Pgrp *to, Pgrp *from) * Allocate mount ids in the same sequence as the parent group */ for(m = order; m != nil; m = m->order) - m->copy->mountid = incref(&mountid); - wunlock(&from->ns); + m->mountid = incref(&mountid); + runlock(&from->ns); + wunlock(&to->ns); } Fgrp* @@ -246,12 +253,11 @@ forceclosefgrp(void) Mount* -newmount(Mhead *mh, Chan *to, int flag, char *spec) +newmount(Chan *to, int flag, char *spec) { Mount *m; m = smalloc(sizeof(Mount)); - m->head = mh; m->to = to; incref(to); m->mountid = incref(&mountid); |