multibreak callbacks add host marking
authorDerrick Brashear <shadow@dementia.org>
Sat, 20 Mar 2010 14:59:20 +0000 (10:59 -0400)
committerDerrick Brashear <shadow@dementia.org>
Mon, 22 Mar 2010 18:42:59 +0000 (11:42 -0700)
to deal with refcounts, we have to mark hosts in a way other than holds.
do so. all other h_Enum callers don't use this feature.

FIXES 126497

Change-Id: I0fc008495b93d2c361d476c7fcb6b355c0dab825
Change-Id: I61128261b2e8c64fafbf7425d6a65dd48fd7e177
Reviewed-on: http://gerrit.openafs.org/1599
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/viced/callback.c
src/viced/host.h

index 9cfd1d5..0ecb5c4 100644 (file)
@@ -1125,11 +1125,12 @@ MultiBreakVolumeCallBack_r(struct host *host, int isheld,
 {
     char hoststr[16];
 
-    if (!isheld)
-       return isheld;          /* host is held only by h_Enumerate, do nothing */
     if (host->hostFlags & HOSTDELETED)
        return 0;               /* host is deleted, release hold */
 
+    if (!(host->hostFlags & HCBREAK))
+       return 0;               /* host is not flagged to notify */
+
     if (host->hostFlags & VENUSDOWN) {
        h_Lock_r(host);
         /* Do not care if the host is now HOSTDELETED */
@@ -1144,9 +1145,9 @@ MultiBreakVolumeCallBack_r(struct host *host, int isheld,
                                                 * selectively remember to
                                                 * delete the volume callbacks
                                                 * later */
-       host->hostFlags &= ~RESETDONE;  /* Do InitCallBackState when host returns */
+       host->hostFlags &= ~(RESETDONE|HCBREAK);        /* Do InitCallBackState when host returns */
        h_Unlock_r(host);
-       return 0;               /* release hold */
+       return 0;               /* parent will release hold */
     }
     assert(parms->ncbas <= MAX_CB_HOSTS);
 
@@ -1166,7 +1167,8 @@ MultiBreakVolumeCallBack_r(struct host *host, int isheld,
     }
     parms->cba[parms->ncbas].hp = host;
     parms->cba[(parms->ncbas)++].thead = parms->thead;
-    return 1;                  /* DON'T release hold, because we still need it. */
+    host->hostFlags &= ~HCBREAK;
+    return 1;          /* parent shouldn't release hold, more work to do */
 }
 
 /*
@@ -1236,7 +1238,8 @@ BreakVolumeCallBacks(afs_uint32 volume)
                    host = h_itoh(cb->hhead);
 
                    if (!(host->hostFlags & HOSTDELETED)) {
-                       h_Hold_r(host);
+                       /* mark this host for notification */
+                       host->hostFlags |= HCBREAK;
                        if (!tthead || (TNorm(tthead) < TNorm(cb->thead))) {
                            tthead = cb->thead;
                        }
@@ -1245,7 +1248,7 @@ BreakVolumeCallBacks(afs_uint32 volume)
                    TDel(cb);
                    HDel(cb);
                    FreeCB(cb);
-                   /* leave hold for MultiBreakVolumeCallBack to clear */
+                   /* leave flag for MultiBreakVolumeCallBack to clear */
                }
                *feip = fe->fnext;
                FreeFE(fe);
@@ -1389,7 +1392,8 @@ BreakLaterCallBacks(void)
            host = h_itoh(cb->hhead);
            if (cb->status == CB_DELAYED) {
                if (!(host->hostFlags & HOSTDELETED)) {
-                   h_Hold_r(host);
+                   /* mark this host for notification */
+                   host->hostFlags |= HCBREAK;
                    if (!tthead || (TNorm(tthead) < TNorm(cb->thead))) {
                        tthead = cb->thead;
                    }
@@ -1397,7 +1401,7 @@ BreakLaterCallBacks(void)
                TDel(cb);
                HDel(cb);
                CDel(cb, 0);    /* Don't let CDel clean up the fe */
-               /* leave hold for MultiBreakVolumeCallBack to clear */
+               /* leave flag for MultiBreakVolumeCallBack to clear */
            } else {
                ViceLog(125,
                        ("Found host %p (%s:%d) non-DELAYED cb for %u:%u:%u\n",
index 73e5dd4..9c82d5a 100644 (file)
@@ -292,4 +292,5 @@ struct host *(hosttableptrs[h_MAXHOSTTABLES]);      /* Used by h_itoh */
 #define HFE_LATER                       0x80   /* host has FE_LATER callbacks */
 #define HERRORTRANS                    0x100   /* do error translation */
 #define HWHO_INPROGRESS                0x200    /* set when WhoAreYou running */
+#define HCBREAK                        0x400    /* flag for a multi CB break */
 #endif /* _AFS_VICED_HOST_H */