Created attachment 20181 [details] locking check cleanup Convert the file locking checks to a simple inline function.
Created attachment 20182 [details] lock-protect the file flushing operation Lock-protect the file flushing operation. Also, the lock is converted to nested type because internal callers may be already holding the lock.
Created attachment 20183 [details] lock-protect the writev call
Committed to trunk in r537393. Thanks for the patches Davi!