afsd -dynroot-sparse mode for hushed cells
authorDerrick Brashear <shadow@dementia.org>
Sat, 19 Jun 2010 15:26:49 +0000 (11:26 -0400)
committerDerrick Brashear <shadow@dementia.org>
Tue, 22 Jun 2010 15:48:31 +0000 (08:48 -0700)
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 <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

doc/man-pages/pod8/afsd.pod
src/afs/VNOPS/afs_vnop_lookup.c
src/afs/afs.h
src/afs/afs_call.c
src/afs/afs_cell.c
src/afs/afs_dynroot.c
src/afsd/afsd.c

index 22aa84e..c83c6c2 100644 (file)
@@ -15,8 +15,8 @@ B<afsd> [B<-afsdb>] [B<-backuptree>]
      S<<< [B<-confdir> <I<configuration directory>>] >>>
      S<<< [B<-daemons> <I<number of daemons to use>>] >>>
      S<<< [B<-dcache> <I<number of dcache entries>>] >>> [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> <I<files in cache>>] >>>
      S<<< [B<-files_per_subdir> <I<log(2) of files per dir>> ] >>>
      [B<-help>] S<<< [B<-logfile> <I<Place to keep the CM log>>] >>>
@@ -536,6 +536,13 @@ the F<CellAlias> 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
index 82e0234..4604397 100644 (file)
@@ -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);
index ae410b9..f660464 100644 (file)
@@ -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 */
index 8c7f75a..176f0b5 100644 (file)
@@ -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,
index 11c7f6a..89d385d 100644 (file)
@@ -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:
index 0f0d84b..9a4e1ad 100644 (file)
@@ -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);
index ffbfe25..2377c2a 100644 (file)
@@ -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