我需要找到一种方法来刷新客户端的NFS属性缓存. stat()调用从属性缓存中读取ctime而不是实际值,实际值最多需要3秒才能在缓存中反映出来.在安装工作时使用’noac’选项,但从长远来看会影响性能.
我遇到了解决方案,比如在文件的同一所有者上做了一个chown,但在执行stat()之前是否有适当的方法来刷新属性缓存?这个问题只发生在Redhat Linux而不是FreeBSD上.谁能解释一下?
最佳答案
这不是特定于NFS,但您可以使用内核删除缓存.这通常在IO基准测试时完成,但也适用于NFS.
原文链接:https://www.f2er.com/linux/440861.htmlhttps://www.kernel.org/doc/Documentation/sysctl/vm.txt:
Writing to this will cause the kernel to drop clean caches,dentries and
inodes from memory,causing that memory to become free.
To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
echo 2 > /proc/sys/vm/drop_caches
To free pagecache,dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches
As this is a non-destructive operation and dirty objects are not freeable,the
user should run `sync' first.