[OpenAFS-devel] STABLE14-background-fsync-consistency-issues-20090522 - can this be?

Jeffrey Altman jaltman@secure-endpoints.com
Thu, 02 Jul 2009 07:24:43 -0400


Rainer Toebbicke wrote:
> 
> STABLE14-background-fsync-consistency-issues-20090522 introduces
> ih_refcnt++ in ih_reallyclose(). Now, when  ih_refcnt was >= 1 on entry
> (as it would happen when called from VCloseVolumeHandles_r()) it would
> end up 2, hence after closing the file descriptor it would simply be
> decremented but ihP would not be released - we'd end up with an ihandle
> leak.
> 
> Isn't there a
> 
> ihP->if_refcnt--;
> 
> missing just before the "assert" ?

I believe the patch is correct.   IH_REALLYCLOSE() will close the file
descriptors but not release the inode handle.  Wherease IH_RELEASE()
will close the file descriptors and release the inode handle.

Likewise, VCloseVolumeHandles_r() is closing the file descriptors but
intentionally leaving the inode handles alone.
VReleaseVolumeHandles_r() is the equivalent function that is used to
release the inode handles.

What the patch does is temporarily increment ih_refcnt so that it
cannot drop to zero while the lock is dropped.  Once the lock is
reasserted a check is performed.  If by dropping the reference that
ih_reallyclose() added the count will become zero, the inode handle is
really released.  Otherwise, the extra inode handle reference is simply
removed to restore the state to what it would have been if it had not
been added.

Jeffrey Altman