backend: warn before write to block devices with recognizable content - #2144
Open
WengRan wants to merge 1 commit into
Open
backend: warn before write to block devices with recognizable content#2144WengRan wants to merge 1 commit into
WengRan wants to merge 1 commit into
Conversation
fio currently overwrites unmounted block devices without warning, which can destroy partition tables, filesystems, LVM PVs, or LUKS headers due to a simple job file typo. The existing mount check only covers mounted devices, leaving all others unprotected. Use libblkid to probe target block devices for write jobs before opening any file. In interactive runs, prompt for confirmation and abort on rejection; in non-interactive runs, warn and continue to avoid breaking scripts and CI. The existing allow_mounted_write option is reused as an escape hatch to skip the check. Probing is read-only on a separate fd; all error paths fall back to "nothing detected", ensuring fio never fails or alters devices due to the check itself. The feature compiles out entirely without libblkid. Warnings are deduplicated per device across numjobs, and the periodic status line is suspended during input wait to avoid clobbering the prompt. Signed-off-by: wengjianing <1528193783@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
backend: warn before write to block devices with recognizable content
fio currently protects against writing to mounted devices, but a job
file pointing at the wrong raw block device silently destroys whatever
lives there: partition tables, unmounted file systems, LVM physical
volumes, LUKS headers, swap areas and RAID members are all overwritten
without warning. A single filename typo can be catastrophic and there
is no way to get the data back.
This PR adds a write safety check for block devices, built on libblkid:
job is probed (read-only, separate fd)
contains in human-readable form, e.g.
fio: /dev/sda contains a GPT partition table, writing may damage it.continue anyway? (y/N)and abort beforetouching any file unless the user confirms.
warn and continue, so existing automation is unaffected.
Signed-off-by: wengjianing 1528193783@qq.com