From Jeff Layton <jlayton@redhat.com>: Jeff Layton has uploaded this change for review. ( https://review.gerrithub.io/428016 Change subject: SAL: sticky grace periods ...................................................................... SAL: sticky grace periods Some operations require a grace period, or that we not be in one. Ganesha will generally check this prior to doing the operation, but those checks are racy. We could end up flipping the state of grace after checking but during or before the actual operation. This is particularly a problem for clustered servers that may end up going back into grace to satisfy the needs of another node, as they could end up reporting that they are enforcing the grace period while there are still ops in flight. This patch adds some new grace period handling infrastructure to address this. When ganesha needs to do an operation that requires a particular state of grace, take a reference to that state to ensure that it can't change until we are done. If we go to start or lift the grace period, check first to see whether there might be ops in flight. If there are, then set a flag indicating that a change has been requested and don't do it. If that flag is set, then we will no longer hand out grace period references. Once the refcount goes to zero, we can allow the change to occur and clear the flag so that new references can be acquired again. We start by changing the usage of current_grace. It still contains when the most recent grace period expires, but we don't use the value of 0 to denote anything special now. The other values are now tracked in a single uint32_t, which contains two bitflags and a counter. By doing it this way, we can handle the most common usage (getting/putting references) locklessly. Starting or lifting the grace period still requires the grace_mutex however. Change-Id: I7089cb468baaa64e98cc9c6220c009fc61c85840 Signed-off-by: Jeff Layton <jlayton@redhat.com> --- M src/SAL/nfs4_recovery.c M src/include/sal_functions.h 2 files changed, 151 insertions(+), 14 deletions(-) git pull ssh://review.gerrithub.io:29418/ffilz/nfs-ganesha refs/changes/16/428016/1 -- To view, visit https://review.gerrithub.io/428016 To unsubscribe, or for help writing mail filters, visit https://review.gerrithub.io/settings Gerrit-Project: ffilz/nfs-ganesha Gerrit-Branch: next Gerrit-MessageType: newchange Gerrit-Change-Id: I7089cb468baaa64e98cc9c6220c009fc61c85840 Gerrit-Change-Number: 428016 Gerrit-PatchSet: 1 Gerrit-Owner: Jeff Layton <jlayton@redhat.com>