[Galaxy S II Android Development] Lanchon:
hi arnab,

pure log-structured file systems store everything in a single circular log buffer.

when the FS runs out of space at the tail, it starts to advance the head to make room for new changes to the FS (that always have to be appended to the tail).

to make space and advance the head:

1) reads an entry from the head of the log

2) if entry is obsolete and has been superseded by newer data on the log, then discard the entry (freeing some space)

3) otherwise copy the entry to the tail of the log (causing a delay but without freeing any space)

4) advance the head pointer over the processed entry

5) repeat process if more space is needed

this is called garbage collection. it becomes very expensive if say 80% of the FS has files that never change. because the GC has to rewrite all of those files on EVERY GC cycle around the buffer, only to free max 20% of the buffer.

if the FS is filled to 95%, then it needs move all that data just to reclaim max 5% of space. it becomes prohibitively expensive.

(to keep in mind: F2FS will be behave much better if FS usage is below 50%. those who like to keep their FS nearly full SHOULD STAY THE HELL AWAY FROM F2FS.)

F2FS does two things to counter this phenomenon:

A) it switches to a non-log structure when the log space is getting full (starts to write in-place (scattered) instead of in-log).

B) it keeps several independent logs (this is akin to generational garbage collectors). data that changes a lot is kept in one log, while mostly constant data is kept in another. this way, F2FS does not have to move EVERYTHING around on every GC cycle: most data will be constant and in the 'slow' log, which most of the time won't need new space, and thus won't need a GC (and won't need being moved around).

from https://www.kernel.org/doc/Documentation/filesystems/f2fs.txt :

At runtime, F2FS manages six active logs inside "Main" area: Hot/Warm/Cold node

and Hot/Warm/Cold data.

- Hot node	contains direct node blocks of directories.

- Warm node	contains direct node blocks except hot node blocks.

- Cold node	contains indirect node blocks

- Hot data	contains dentry blocks

- Warm data	contains data blocks except hot and cold data blocks

- Cold data	contains multimedia data or migrated data blocks​

it is VERY BAD to disable the 6 logs and use -say- only 2, because you are disabling this needed optimization.

but that option is there because (from what i understand) fewer logs mean less overhead. this MIGHT be useful for very small FS partitions, you know what i'm getting at...

F2FS shouldn't be used on very small partition like /cache. but if people insist on using it (who knows why), it might be better to limit to 2 logs on that partition. (that might or might not fix the formatting on 100mb issue.) and in fact, because all data in /cache is short lived, loosing the generational optimization is not a big deal. (only on /cache; it is a BIG DEAL on /data.)

so this note is to let you know there might be another option to handle those F2FS format /cache errors:

-my preferred option: tell people to format cache in /ext4.

-the other option: try formatting using 2 logs (for cache only!)

(not a full solution: /cache useful capacity will be lowered drastically compared to /ext4, but at least the pesky error might be gone :) )

sorry if this note is too long. i just wanted to let you know given that we were both involved in the gerrit change of mount options. (anyway, mount options shouldn't influence the format in TWRP, AFAIK.)