Description
On linux, it can be difficult to determine if a drive is in use by other parts of the system, since it can be mounted in a non-default namespace or directly opened by an application. (This page describes some of the many ways a drive can be in use that can be difficult to find.) However, opening a block device with the O_EXCL
flag causes the kernel to return EBUSY
if the drive is in use.
From open(2):
In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.
There should be an option to tell fio to use this flag, similar to the direct
option.