fio icon indicating copy to clipboard operation
fio copied to clipboard

Add an option to disable COW when creating files

Open adam900710 opened this issue 6 months ago • 2 comments

Some projects like KDiskMark utilizes fio to evaluate performance upon a filesystem. And by default KDiskMark goes with direct IO to measure the real IO performance of the disk.

But for filesystems with checksum (like btrfs), direct IO with checksum exposed a risk that the direct IO buffer can be modified halfway, causing the resulted checksum doesn't match with the final content. There is a test case, generic/761 for that.

This is a problem of user space tools, but fs can not risk such checksum mismatch, thus has to fallback to buffered IO. This is done by upstream commit 968f19c5b1b7 ("btrfs: always fallback to buffered write if the inode requires checksum").

This will greatly degrade performance.

For now btrfs will only allow true direct IO if the inode has no data checksum support. And NOCOW also implies no data checksum. And I believe other filesystem would have a similar behavior for NOCOW flag.

If an option create_nocow=bool is added, this will allow fio to do real direct IO on fses with checksum.

adam900710 avatar Jun 10 '25 06:06 adam900710

@adam900710: Hmm... I think this would be solely for BtrFS as I haven't heard of any only other CoW FS that respects the attribute (bcachefs supports a nocow mode but it's unclear if it can also do so by attribute)...

However a quick search for "nocow bcachefs chattr" leads to a feature request for nocow in KDiskMark. That in turn leads to a KDiskMark commit that adds support for setting the nowcow attribute on the directory it uses. Thus my question is: if you are using KDiskMark isn't what you want already done by that tool?

sitsofe avatar Jun 10 '25 07:06 sitsofe

@sitsofe Thanks a lot for pointing out the KdiskMark feature request, in fact there is a report of KDiskMark performance drop caused by that btrfs commit which forces direct IO to go buffered if the inode has csum.

But I didn't look deep enough into KDiskMark to find out that the nocow directory feature.

I'll ask the reporter for clarification.

adam900710 avatar Jun 10 '25 08:06 adam900710