摘自 lessfs 没有写全:
#define MAX_FUSE_BLKSIZE
...
char * cache;
unsigned int cs = 0;
unsigned long calc;
...
cache = read_val("CACHESIZE");
if(cache)
cs = atoi(cache);
if(cs <= 0)
cs = 1;
cal = cs;
config->cachesize = (cal * 1024 * 1024) / MAX_FUSE_BLKSIZE;
...
TCTREE *workqtree; // Used to buffer incoming data (writes)
TCTREE *readcachetree; // Used to cache chunks of data that are likely to be read
...
if (tctreernum(workqtree) * 2 > config->cachesize ||
tctreernum(readcachetree) * 2 > config->cachesize) {
//workqtree 脏数据先写回
flush_wait(0);
//清除缓存处理
purge_read_cache(0, 1, (char *) __PRETTY_FUNCTION__);
}
...
中文部分注释是自己加的 想问的问题是:上面 tctreernum(workqtree) * 2 > config->cachesize || tctreernum(readcachetree) * 2 > config->cachesize 为什么在做判断的时候*2
1
lonelinsky 2016-05-10 10:29:39 +08:00
从贴出来的代码猜测应该是想在 workqtree 或者 readcachetree 占用 cache 超过一半的时候将数据写回并清理缓存吧。
|