cryptomator / dokany-nio-adapter

Dokany-based adapter to provide directory contents specified by a java.nio.file.Path (via dokan-java)
GNU Affero General Public License v3.0
14 stars 4 forks source link

Handling of `FILE_NO_INTERMEDIATE_BUFFERING` #35

Closed infeo closed 4 years ago

infeo commented 4 years ago

The zwCreateFileFunction() is the first function called for any file/directory operation. You can hand over several flags with the parameters, one of them is FILE_NO_INTERMEDIATE_BUFFERING part of the CreateOptions.

The windows documentation describes the purpose of this flag the following:

The file cannot be cached or buffered in a driver's internal buffers. [...]

Currently, when this flag is set, we handle write operations to the opened file as direct IO, leading to a very low write speed.

But this might be overcautiously. Taking this article about buffering from Microsoft into consideration, we do not pay any attention on buffer alignment, this is done by the JVM/System again.

Therefore we should thoroughly test ignoring this flag and then decide what to do.

infeo commented 4 years ago

There exists a dedicated file flag for synchronous writing:

FILE_WRITE_THROUGH | System services, file-system drivers, and drivers that write data to the file must actually transfer the data to the file before any requested write operation is considered complete.

Additionally the description provided by the documentation can be seen as that the Dokany driver cannot cache the file. This thought leads to the conclusion that the filesystem used by this adapter needs to decide to cache it or not.

The conclusion is that the file flag FILE_NO_INTERMEDIATE_BUFFERUNG will be ignored.