Skip to content

ODirect not working #30

Closed
Closed

Description

@mronstro

I installed Asahi Linux on an Apple M1 Pro laptop and it worked like a charm.
I installed the latest branch of RonDB. This branch is 22.05.
I managed to compile after installing a few extra packages.
I executed a number of test cases using MTR (MysqlTestRun).
Most test cases failed in a method called set_direct_io which sets up the file to
use O_DIRECT using fcntl calls. These calls fail. So I presume that O_DIRECT is
not yet supported by the NVMe driver.

Activity

  1. axboe commented on May 16, 2022

    @axboe

    The application is buggy and assumes 4k pages, and asahi runs 16k pages by default. O_DIRECT isn't a property of the storage driver, it's just as read/write as far as that is concerned.

  2. mronstro commented on May 16, 2022

    @mronstro
    Author

    Presume by application that you mean RonDB, RonDB actually always writes in 32 kB chunks, so a 16k page size shouldn't
    be an issue I presume. However the bug happens in that fcntl(fileDescriptor, , SETFL, flags | O_DIRECT) fails where flags
    is retrieved with a fcntl call using GETFL. This call is done after opening the file.

  3. mronstro commented on May 16, 2022

    @mronstro
    Author

    Actually looking at the function set_direct_io you might be right, will look another round to see what goes on
    in the RonDB code.

  4. mronstro commented on May 16, 2022

    @mronstro
    Author

    Yep, you were right. Seems like it depends on 4k page size. Interesting.

  5. mronstro commented on May 16, 2022

    @mronstro
    Author

    Debugged the code a bit more, it seems that fstat returns that block_size is 4k, but when one attempts to use this
    size in a pread call, the pread returns EINVAL indicating that O_DIRECT cannot be used with 4k alignment only.
    However should not the fstat return 16k if that is the minimum alignment for O_DIRECT?

  6. axboe commented on May 16, 2022

    @axboe

    No, stat correctly returns the file system block size, which is not the same thing as required memory alignment. They just happen to overlap on eg x86, because the page size is 4K as well. You can query the latter with sysconf(_SC_PAGESIZE);

  7. mronstro commented on May 16, 2022

    @mronstro
    Author

    Thx, read up a bit on O_DIRECT, seem to be common consensus that it is a bit hard to figure out the alignment size.
    But obviously the current code in RonDB needs to be extended to handle the requirements in Asahi Linux.

  8. mronstro commented on May 16, 2022

    @mronstro
    Author

    Thx for the assistance, will close this issue since it is an issue in RonDB rather.

  9. added a commit that references this issue on Feb 9, 2025
  10. added a commit that references this issue on Mar 1, 2025
  11. added a commit that references this issue on Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions