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

lxd/storage: Fix check for direct I/O write support #14157

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lxd/storage/backend_lxd.go
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,7 @@ func (b *lxdBackend) imageConversionFiller(imgPath string, imgFormat string, op
_ = from.Close()
}

to, err := os.OpenFile(diskPath, unix.O_DIRECT|unix.O_RDONLY, 0)
to, err := os.OpenFile(diskPath, unix.O_DIRECT|unix.O_WRONLY, 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this, we use O_RDONLY in ImageUnpack.

The aim is just to figure out if the underlying storage supports direct I/O, not to actually use the file handle.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question I don't know the answer for. Can direct I/O support be different for writing and reading?

If not, then why check both from and to?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVM re from and to, they can be on different FS :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mihalicyn do you know if O_DIRECT support can vary between read and write accesses? I'm well outside of my depth here but after reading the commit description of https://github.com/openzfs/zfs/pull/10018/commits, I believe it would be prudent to test for both type of operations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Simon,

do you know if O_DIRECT support can vary between read and write accesses?

from what I see all r/w filesystems which support O_DIRECT support both modes. At the same time, in theory, filesystem may reject O_DIRECT writes and support read. But I wasn't able to find any existing filesystem with such a behavior.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK thanks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be similarly adjusted on ImageUnpack?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah if its appropriate

if err == nil {
cmd = append(cmd, "-t", "none")
_ = to.Close()
Expand Down
Loading