F2FS DIO Cache Bug

Author Avatar
Love4Taylor Jun 26, 2017
  • Read this article on other devices

以下内容转载自 XDA论坛

A few “enthusiast” users who might read benchmarks before purchasing phones,

might have noticed something with OnePlus 3T’s random write benchmark performance.

Here’s a TL;DR.

- f2fs phones are not “drastically” faster than the ones with ext4, in terms of random writes

- OEMs might be (inadvertently) cheating with f2fs random writes benchmarks

Many testers and reviewers use AndroBench to test storage performance. It uses DIO(Direct-IO) when testing random reads and writes to avoid cache hits as Linux is smart enough to cache upcoming random r/w requests. I guess the intention of the AndroBench developers is to avoid cache hits and test pure storage performance.

https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-stable.git/commit/?h=linux-3.18.y&id=39a58e05f7eb52bcc2130ed6340ebb546a7d75a8

However, there’s a bug on earlier versions of f2fs, which caches DIO requests. This bug drastically improves DIO performance at the cost of data consistency. More importantly, this is not an expected behavior of a filesystem. More popular, extensively tested filesystems such as ext4 and xfs never had this kind of issues.
The link above is the fix to this issue.

Since OEMs like to play safe and tend to use older versions of f2fs, they can inadvertently have this issue as well, along side with much improved benchmark performance.

“So why not follow OEMs and cache DIO?”
As I said, this is not an expected behavior of a filesystem, and should be considered as a bug. Most importantly, almost nothing on your phone uses DIO for anything, except for benchmarks.

“Then, who are (inadvertently) cheating?”
OnePlus and Motorola are the ones I confirmed. And I guess many more as the DIO fix is only a year old.

“My f2fs performance is so much worse after installing a custom ROM. Am I ok?”
Absolutely yes. Your device’s daily performance will not be worse(if not better) than OEM ones.

OEMs who decide to switch to f2fs will suddenly get praises from the benchmark lovers that they are miles better than other phones with ext4.
This is not true at all and I hope AndroBench and other storage testing benchmarks can workaround with this.

Tell your family and friends that DIO cache bug thinggy got their hypes over 9000.

Licensed under CC BY-NC-SA 4.0
Link to this article: https://love4taylor.me/f2fs-dio-cache-bug.html