This is the guts of the algorithm: I'm extending the file every time there is less than the specified chunk size into which to write.

I'm using the write that's crossing the extend boundary, and having that thread do the extension, that way only a single thread does the extension rather than a bunch of threads all extending the file.   I could also have the block allocation function return an extension flag to a single thread, which is a less complicated test, but splits the work over two chunks of code.