mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2025-02-17 01:19:53 +00:00
![Robin Hsu](/assets/img/avatar_default.png)
Implemented cache options in F2FS configuration 'c' (i.e. user options): * use c.cache_config.num_cache_entry to set the number of cache entries (in block), minimum 1024, or 0 to disable cache. * use c.cache_config.max_hash_collision to set maximum hash collision (max 16). * use c.cavhe_config.dbg_en to enable printing of debug messages. Cache properties: * Per block save based (block size = f2fs block size = 4K Bytes) * Device block indices are used to hash (simple modular hash function) to cache indices. * A hash collision (when a block is hashed to an already occupied cache block) will trigger offset-based relocation to max 16 other places, at first empty slot found policy. * A hash collision with all 17 possible relocating places occupied will evict the oldest used one (replaced by the new read block). A global 'use' tick is kept ticking-up per block read for this purpose. * On write cache hit, it will update the corresponding cached block. * On write cache miss, the data won't be cached. * Write-through policy only: never delayed write. * On read cache hit, it returns the cached block. * On read cache miss, it issues an I/O read to the kernel, and then caches and returns the block. * Currently read ahead is not implemented. Yet, the read ahead logic is kept as before, i.e. using kernel's read ahead mechanism. Signed-off-by: Robin Hsu <robinhsu@google.com> [Jaegeuk Kim: Fix one bug in dcache_update_rw()] Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>