viced: Avoid endless BCB loop
authorAndrew Deason <adeason@sinenomine.net>
Mon, 12 Aug 2013 22:37:29 +0000 (17:37 -0500)
committerDerrick Brashear <shadow@your-file-system.com>
Tue, 8 Oct 2013 12:50:32 +0000 (05:50 -0700)
commit47124f337b43f8731bfbe3bd71e42d046a4d1075
treee831b25cf69ab15cd925f7026d438d129a7311ac
parent2482340afb906a9719994742ef26500c6e67ccea
viced: Avoid endless BCB loop

Without this commit, when we break callbacks for a fid, we loop over
all callbacks for the fid, break a few of them, and then start over.
We do this repeatedly until we run out of callbacks. If a client sees
a callback break, and then establishes a new callback promise while
the fileserver is still breaking callbacks, the fileserver can break
the same callback for the same host again and again. This can continue
forever, if the client establishes its new callback promises quickly
enough.

So to avoid this, when we start breaking callbacks, flag all of the
callback structures that we want to look at. Then when we repeatedly
loop through all of the callbacks for the fid, only look at the
flagged callback structures.

This adds a 'flags' field to struct CallBack, and defines a single
flag, CBFLAG_BREAKING.

This is an alternative fix to the issue also fixed in 843d705c. This
implementation avoids allocating extra memory under locks, and has the
slight benefit of not breaking callbacks that were elsewhere deleted
during the BCB. This comes at the cost of a single extra traversal
through our callback list, and the cost of claiming one of the bits in
the CallBack structure.

Change-Id: I6418bd404de61ec7a531261ecf581eeea719a2d4
Reviewed-on: http://gerrit.openafs.org/10172
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
src/viced/callback.c
src/viced/callback.h