samueldlightfoot commented on code in PR #4178:
URL: https://github.com/apache/cassandra/pull/4178#discussion_r2758160436
##########
src/java/org/apache/cassandra/io/util/FileUtils.java:
##########
@@ -740,14 +741,54 @@ public static void deleteDirectoryIfEmpty(Path path)
throws IOException
}
}
+ public static boolean isDirectIOSupported(File file)
+ {
+ File testFile = null;
+ try
+ {
+ File dir = file.isDirectory() ? file : file.parent();
+ testFile = createTempFile("direct-io-test", ".tmp", dir);
+
+ // Direct IO requires knowing the block size for buffer alignment
+ if (blockSize(testFile) <= 0)
+ return false;
+
+ try (FileChannel channel = FileChannel.open(testFile.toPath(),
Review Comment:
The try-with resources pattern used here will close the channel immediately
after opening.
https://manpages.ubuntu.com/manpages/xenial//man2/open.2.html
> O_DIRECT support was added under Linux in kernel version 2.4.10.
Older Linux kernels simply ignore this
> flag. Some filesystems may not implement the flag and open() will
fail with EINVAL if it is used.
The blockSize check is not wrong, but it alone does not guarantee Direct I/O
is supported by the underlying filesystem.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]