thread can get the lock before the enqueueing thread updates the lock
value block. The correct fix is to do the granting inside of the
completion AST -- which can then be wrapped as appropriate to handle
the LVB mechanics -- but that's higher risk than I want right now.
Instead, I added a temporary LDLM_FL_CAN_MATCH flag, which gets set
only after the enqueueing thread is finished. Threads trying to match
will wait for this flag to be set after the lock is granted.
2. Fixes a fencepost error in the KMS calculation; a lock on [x, y]
actually protects a file of y + 1 bytes, not y bytes.
3. I spotted that ldlm_completion_ast might not call wake_up in
certain cases, but I think that's a theoretical concern. Fixed by
checking a different set of flags.
out:
if (oa)
obdo_free(oa);
+ if (rc && lvb != NULL) {
+ OBD_FREE(lvb, sizeof(*lvb));
+ res->lr_lvb_data = NULL;
+ res->lr_lvb_len = 0;
+ }
up(&res->lr_lvb_sem);
return rc;
}