From: Derrick Brashear Date: Sat, 19 Jun 2010 15:26:49 +0000 (-0400) Subject: afsd -dynroot-sparse mode for hushed cells X-Git-Tag: openafs-devel-1_5_75~97 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=d8237165f73fec8eb51a96417c4cb5e9fbc09d65 afsd -dynroot-sparse mode for hushed cells if an admin specifies -dynroot-sparse (instead of dynroot) come up with just local cell and cell aliases showing. cell list is configured as normal. fs newcell works as normal. document it. Change-Id: Ie644ed0f9923a85da5451eafaa114ddf36daa671 Reviewed-on: http://gerrit.openafs.org/2217 Reviewed-by: Andrew Deason Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/doc/man-pages/pod8/afsd.pod b/doc/man-pages/pod8/afsd.pod index 22aa84e..c83c6c2 100644 --- a/doc/man-pages/pod8/afsd.pod +++ b/doc/man-pages/pod8/afsd.pod @@ -15,8 +15,8 @@ B [B<-afsdb>] [B<-backuptree>] S<<< [B<-confdir> >] >>> S<<< [B<-daemons> >] >>> S<<< [B<-dcache> >] >>> [B<-debug>] - [B<-dynroot>] [B<-enable_peer_stats>] [B<-enable_process_stats>] - [B<-fakestat>] [B<-fakestat-all>] + [B<-dynroot>] [B<-dynroot-sparse>] [B<-enable_peer_stats>] + [B<-enable_process_stats>] [B<-fakestat>] [B<-fakestat-all>] S<<< [B<-files> >] >>> S<<< [B<-files_per_subdir> > ] >>> [B<-help>] S<<< [B<-logfile> >] >>> @@ -536,6 +536,13 @@ the F file can be used to provide shortname for common AFS cells which provides equivalent functionality to the most commonly used symbolic links. +=item B<-dynroot-sparse> + +In addition to operating in the manner described for dynroot above, +cells other than the local cell are not shown by default until a lookup +occurs. Cell aliases as set in the CellAliases file are shown as normal, +although they may appear to be dangling links until traversed. + =item B<-enable_peer_stats> Activates the collection of Rx statistics and allocates memory for their diff --git a/src/afs/VNOPS/afs_vnop_lookup.c b/src/afs/VNOPS/afs_vnop_lookup.c index 82e0234..4604397 100644 --- a/src/afs/VNOPS/afs_vnop_lookup.c +++ b/src/afs/VNOPS/afs_vnop_lookup.c @@ -1636,7 +1636,21 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr if (!afs_InReadDir(adp)) afs_PutDCache(tdc); if (code == ENOENT && afs_IsDynroot(adp) && dynrootRetry && !tryEvalOnly) { + struct cell *tc; + char *cn = (tname[0] == '.') ? tname + 1 : tname; ReleaseReadLock(&adp->lock); + /* confirm it's not just hushed */ + tc = afs_GetCellByName(cn, WRITE_LOCK); + if (tc) { + if (tc->states & CHush) { + tc->states &= ~CHush; + ReleaseWriteLock(&tc->lock); + afs_DynrootInvalidate(); + goto redo; + } + ReleaseWriteLock(&tc->lock); + } + /* Allow a second dynroot retry if the cell was hushed before */ dynrootRetry = 0; if (tname[0] == '.') afs_LookupAFSDB(tname + 1); diff --git a/src/afs/afs.h b/src/afs/afs.h index ae410b9..f660464 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -269,6 +269,7 @@ struct afs_cbr { #define CNoAFSDB 0x08 /* never bother trying AFSDB */ #define CHasVolRef 0x10 /* volumes were referenced */ #define CLinkedCell 0x20 /* has a linked cell in lcellp */ +#define CHush 0x40 /* don't display until referenced */ struct cell { struct afs_q lruq; /* lru q next and prev */ diff --git a/src/afs/afs_call.c b/src/afs/afs_call.c index 8c7f75a..176f0b5 100644 --- a/src/afs/afs_call.c +++ b/src/afs/afs_call.c @@ -780,6 +780,9 @@ afs_syscall_call(long parm, long parm2, long parm3, cflags |= CLinkedCell; } } + if (parm4 & 8) { + cflags |= CHush; + } if (!code) code = afs_NewCell(tbuffer1, tcell->hosts, cflags, lcnamep, diff --git a/src/afs/afs_cell.c b/src/afs/afs_cell.c index 11c7f6a..89d385d 100644 --- a/src/afs/afs_cell.c +++ b/src/afs/afs_cell.c @@ -1005,7 +1005,8 @@ afs_NewCell(char *acellName, afs_int32 * acellHosts, int aflags, ReleaseWriteLock(&tc->lock); ReleaseWriteLock(&afs_xcell); afs_PutCell(tc, 0); - afs_DynrootInvalidate(); + if (!aflags & CHush) + afs_DynrootInvalidate(); return 0; bad: diff --git a/src/afs/afs_dynroot.c b/src/afs/afs_dynroot.c index 0f0d84b..9a4e1ad 100644 --- a/src/afs/afs_dynroot.c +++ b/src/afs/afs_dynroot.c @@ -341,9 +341,10 @@ afs_RebuildDynroot(void) c = afs_GetCellByIndex(cellidx, READ_LOCK); if (!c) break; - if (c->cellNum == afs_dynrootCell) + if ((c->cellNum == afs_dynrootCell) || (c->states & CHush)) { + afs_PutCell(c, READ_LOCK); continue; - + } dotLen = strlen(c->cellName) + 2; dotCell = afs_osi_Alloc(dotLen); strcpy(dotCell, "."); @@ -417,8 +418,10 @@ afs_RebuildDynroot(void) c = afs_GetCellByIndex(cellidx, READ_LOCK); if (!c) continue; - if (c->cellNum == afs_dynrootCell) + if ((c->cellNum == afs_dynrootCell) || (c->states & CHush)) { + afs_PutCell(c, READ_LOCK); continue; + } dotLen = strlen(c->cellName) + 2; dotCell = afs_osi_Alloc(dotLen); diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c index ffbfe25..2377c2a 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -1414,9 +1414,11 @@ ConfigCell(struct afsconf_cell *aci, void *arock, struct afsconf_dir *adir) /* figure out if this is the home cell */ isHomeCell = (strcmp(aci->name, LclCellName) == 0); - if (!isHomeCell) + if (!isHomeCell) { cellFlags = 2; /* not home, suid is forbidden */ - + if (enable_dynroot == 2) + cellFlags |= 8; /* don't display foreign cells until looked up */ + } /* build address list */ for (i = 0; i < MAXHOSTSPERCELL; i++) memcpy(&hosts[i], &aci->hostAddr[i].sin_addr, sizeof(afs_int32)); @@ -1906,6 +1908,10 @@ mainproc(struct cmd_syndesc *as, void *arock) /* -rxmaxmtu */ rxmaxmtu = atoi(as->parms[36].items->data); } + if (as->parms[37].items) { + /* -dynroot-sparse */ + enable_dynroot = 2; + } return 0; } @@ -2308,7 +2314,8 @@ afsd_run(void) if (enable_dynroot) { if (afsd_verbose) - printf("%s: Enabling dynroot support in kernel.\n", rn); + printf("%s: Enabling dynroot support in kernel%s.\n", rn, + (enable_dynroot==2)?", not showing cells.":""); code = afsd_call_syscall(AFSOP_SET_DYNROOT, 1); if (code) printf("%s: Error enabling dynroot support.\n", rn); @@ -2316,7 +2323,9 @@ afsd_run(void) if (enable_fakestat) { if (afsd_verbose) - printf("%s: Enabling fakestat support in kernel.\n", rn); + printf("%s: Enabling fakestat support in kernel%s.\n", rn, + (enable_fakestat==2)?" for all mountpoints." + :" for crosscell mountpoints"); code = afsd_call_syscall(AFSOP_SET_FAKESTAT, enable_fakestat); if (code) printf("%s: Error enabling fakestat support.\n", rn); @@ -2552,6 +2561,8 @@ afsd_init(void) cmd_AddParm(ts, "-disable-dynamic-vcaches", CMD_FLAG, CMD_OPTIONAL, "disable stat/vcache cache growing as needed"); cmd_AddParm(ts, "-rxmaxmtu", CMD_SINGLE, CMD_OPTIONAL, "set rx max MTU to use"); + cmd_AddParm(ts, "-dynroot-sparse", CMD_FLAG, CMD_OPTIONAL, + "Enable dynroot support with minimal cell list"); } int