如何刷新nfs属性缓存? [英] How to flush nfs attribute cache?

查看:212
本文介绍了如何刷新nfs属性缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到一种在客户端刷新NFS属性缓存的方法. stat()调用从属性缓存中读取ctime而不是实际值,要花费3秒的时间才能将实际值反映到缓存中.安装时使用'noac'选项,但从长远来看会影响性能.

I need to find a way to flush the NFS attribute cache on the client side. stat() call reads ctime from attribute cache and not the actual value, takes upto 3 second for the actual value to be reflected in cache. using 'noac' option when mounting works but will affect performance in the long run.

我遇到了类似的解决方案,例如在文件的同一所有者上执行chown等操作,但是在执行stat()之前是否有适当的方法来刷新属性缓存?而且这个问题仅发生在Redhat Linux而不是FreeBSD.谁能解释?

I came across solutions like doing a chown on the same owner of the file etc. but is there a proper method to flush the attribute cache before doing a stat()? and this prob happens only on Redhat Linux and not FreeBSD. Can anyone explain?

推荐答案

这不是特定于NFS的,但是您可以拥有内核放置缓存.通常在IO基准测试时完成此操作,但也适用于NFS.

This isn't specific to NFS, but you can have the kernel drop caches. This is usually done when IO benchmarking, but works for NFS too.

https://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.

这篇关于如何刷新nfs属性缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆