Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(OpenFlags): correct the O_DIRECT flag on aarch64 #2

Merged
merged 1 commit into from
Mar 17, 2024

Conversation

Chillax-0v0
Copy link
Contributor

No description provided.

@Chillax-0v0
Copy link
Contributor Author

@lexburner
你好,我尝试在一台 arm64 的机器上使用您开发的 kdio 库,发现在打开时会报错 "java.io.IOException: Error opening /dev/nvme1n1, got Invalid argument"。

使用 strace 对比在 amd64 和 arm64 上的系统调用,发现在 arm64 上的调用是

openat(AT_FDCWD, "/dev/nvme1n1", O_RDWR|O_CREAT|O_DIRECTORY, 0644 <unfinished ...>

可以注意到,用的是 O_DIRECTORY 而非 O_DIRECT。我检查了头文件 fcntl.h,发现在 arm64 上 O_DIRECTO_DIRECTORY 是与 amd64 上的值相反的。在别的地方也报告了类似的问题

我针对这个问题做了修改,请 review。值得说明的是,由于我没有找到在其他架构(比如 s390x, ppc64)上这些标记位的值,我只针对 arm64 (aarch64) 进行了修改.


hello, I tried using your developed kdio library on an arm64 machine and encountered an error when opening it: "java.io.IOException: Error opening /dev/nvme1n1, got Invalid argument".

By comparing the system calls on amd64 and arm64 using strace, I found that the call on arm64 is

openat(AT_FDCWD, "/dev/nvme1n1", O_RDWR|O_CREAT|O_DIRECTORY, 0644 <unfinished ...>

It's noticeable that O_DIRECTORY is used instead of O_DIRECT. I checked the fcntl.h header file and found that on arm64, the values of O_DIRECT and O_DIRECTORY are opposite to those on amd64. Similar issues have also been reported elsewhere.

I have made modifications regarding this issue, please review. It's worth mentioning that since I couldn't find the values of these flags on other architectures (such as s390x, ppc64), I only made changes for arm64 (aarch64).

@lexburner
Copy link
Owner

的确之前没有考虑 arm64 架构,看起来没啥问题,合并了

@lexburner lexburner merged commit a8a75f7 into lexburner:master Mar 17, 2024
@Chillax-0v0 Chillax-0v0 deleted the fix-direct-io-flag-on-arm64 branch March 19, 2024 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants