]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
viced: Relax "h_TossStuff_r failed" warnings
authorAndrew Deason <adeason@sinenomine.net>
Fri, 17 Feb 2012 23:12:46 +0000 (17:12 -0600)
committerDerrick Brashear <shadow@dementix.org>
Thu, 23 Feb 2012 17:35:19 +0000 (09:35 -0800)
Currently, h_TossStuff_r bails out and logs a message if we detect
that somebody grabbed a reference or locked the host while we tried to
h_NBLock_r. The reasoning for this is that it is not legal for anyone
to h_Hold_r a host that has HOSTDELETED set (but the error is
detectable and recoverable); callers are supposed to check for
HOSTDELETED and not hold a host in that case.

However, HOSTDELETED may not be set when h_TossStuff_r is called,
since we call it if either HOSTDELETED _or_ CLIENTDELETED are set. If
CLIENTDELETED is set and HOSTDELETED is not, it's perfectly fine (and
necessary) for callers to grab a reference to the host. So, if that's
what is going on, don't log a message, since that's normal behavior.

Check for HOSTDELETED before we h_NBLock_r, since it is technically
possible (and legal) for someone to grab a reference to the host and
somehow set HOSTDELETED while we wait for h_NBLock_r to return. Also
log the flags when we see this message.

Reviewed-on: http://gerrit.openafs.org/6733
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit fe4e52655ce7e5a8e5f6c23cde678fc66c3db490)

Change-Id: Ic1b72c808aec158d99f088a3144e86adf969efcc
Reviewed-on: http://gerrit.openafs.org/6770
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
src/viced/host.c

index 1ecd98c877fbc8c6a8eec82fde673ae9143cf199..ee5c1620ed1e64004f7409ce0a31e6add316b425 100644 (file)
@@ -849,6 +849,11 @@ h_TossStuff_r(struct host *host)
 {
     struct client **cp, *client;
     int code;
+    int wasdeleted = 0;
+
+    if ((host->hostFlags & HOSTDELETED)) {
+       wasdeleted = 1;
+    }
 
     /* make sure host doesn't go away over h_NBLock_r */
     h_Hold_r(host);
@@ -861,9 +866,13 @@ h_TossStuff_r(struct host *host)
     /* if somebody still has this host locked */
     if (code != 0) {
        char hoststr[16];
-       ViceLog(0,
-               ("Warning:  h_TossStuff_r failed; Host %" AFS_PTR_FMT " (%s:%d) was locked.\n",
-                host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port)));
+       if (wasdeleted) {
+           /* someone locked the host while HOSTDELETED was set; that is bad */
+           ViceLog(0, ("Warning:  h_TossStuff_r failed; Host %" AFS_PTR_FMT
+                       " (%s:%d flags 0x%x) was locked.\n",
+                       host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port),
+                       (unsigned)host->hostFlags));
+       }
        return;
     } else {
        h_Unlock_r(host);
@@ -874,9 +883,13 @@ h_TossStuff_r(struct host *host)
      * reacquire H_LOCK */
     if (host->refCount > 0) {
        char hoststr[16];
-       ViceLog(0,
-               ("Warning:  h_TossStuff_r failed; Host %" AFS_PTR_FMT " (%s:%d) was held.\n",
-                host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port)));
+       if (wasdeleted) {
+           /* someone grabbed a ref while HOSTDELETED was set; that is bad */
+           ViceLog(0, ("Warning:  h_TossStuff_r failed; Host %" AFS_PTR_FMT
+                       " (%s:%d flags 0x%x) was held.\n",
+                       host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port),
+                       (unsigned)host->hostFlags));
+       }
        return;
     }