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

linux: use O_EXCL when opening a file for write #1822

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

keithr-mext
Copy link

On linux systems, opening a device with O_EXCL will fail with EBUSY if the drive is in use. For example, if a partition is mounted on /dev/nvme1n1p1, the current mounted filesystem check will allow running write workloads on /dev/nvme1n1 even if allow_mounted_write is zero. Opening /dev/nvme1n1 with O_EXCL will fail with EBUSY in that case. Add O_EXCL when opening a file with O_WRONLY or O_RDWR on linux systems.

Fixes: #1820
Signed-of-by: Keith Reynolds keith.reynolds@mext.ai

On linux systems, opening a device with O_EXCL will fail with
EBUSY if the drive is in use.  For example, if a partition is
mounted on /dev/nvme1n1p1, the current mounted filesystem check
will allow running write workloads on /dev/nvme1n1 even if
allow_mounted_write is zero.  Opening /dev/nvme1n1 with O_EXCL
will fail with EBUSY in that case.  Add O_EXCL when opening a
file with O_WRONLY or O_RDWR on linux systems.

Fixes: axboe#1820
Signed-of-by: Keith Reynolds <keith.reynolds@mext.ai>
@keithr-mext
Copy link
Author

The changes to xnvme will require a similar change to use O_EXCL in that library; I'm planning to submit one to them. Regardless of that, passing the correct access bits for the type of I/O fio will be doing seems better to me.

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.

Add an option to open with O_EXCL
1 participant