欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

FS-Cache和CacheFS 有什么不同吗?(转载)

程序员文章站 2022-04-29 13:55:01
FS-Cache and CacheFS. Are there any differences between these two? Initially, I thought both were same. But no, it’s not. CacheFS is the backend imple ......

fs-cache and cachefs. are there any differences between these two? initially, i thought both were same. but no, it’s not.

cachefs is the backend implementation which caches the data onto the disk and mainpulates it, while fs-cache is an interface which talks to cachefs.

so why do we need two levels here?

fs-cache was introduced as an api or front-end for cachefs, which can be used by any file system driver. the file system driver talks with the fs-cache api which inturn talks with cachefs in the back-end. hence, fs-cache acts as a common interface for the file system drivers without the need to understand the backend cachefs complexities, and how its implemented.

the only drawback is the additional code that needs to go into each file system driver which needs to use fs-cache. ie.. every file system driver that needs to talk with fs-cache, has to be patched with the support to do so. moreover, the cache structure differs slightly between file systems using it, and thus lacks a standard. this unfortunately, prevents fs-cache from being used by every network filesystem out there.

the data flow would be as:

vfs <-> file system driver (nfs/cifs etc..) <-> fs-cache <-> cachefs <-> cached data

cachefs need not cache every file in its entirety, it can also cache files partially. this partial caching mechanism is possible since fs-cache caches ‘pages’ rather than an entire file. pages are smaller fixed-size segments of data, and these are cached depending on how much the files are read initially.

fs-cache does not require an open file to be loaded in the cache, prior being accessed. this is a nice feature as far as i understand, and the reasons are:

a) not every open file in the remote file system can be loaded into cache, due to size limits. in such a case, only certain parts (pages) may be loaded. and the rest of the file should be accessed normally over the network.

b) the cache won’t necessarily be large enough to hold all the open files on the remote system.

c) even if the cache is not populated properly, the file should be accessible. ie.. the cache should be able to be bypassed totally.

this hopefully clears the differences between fs-cache and cachefs.

原文链接: 

保持更新,更多内容请关注 cnblogs.com/xuyaowen;