2012-12-19 88 views
5

我需要找到一種方法來刷新客戶端的NFS屬性緩存。 stat()調用從屬性緩存中讀取ctime而不是實際值,最多需要3秒才能將實際值反映到緩存中。在安裝時使用'noac'選項,但會長期影響性能。如何刷新nfs屬性緩存?

我碰到過類似在文件的同一個所有者上執行chown等解決方案,但是在執行stat()之前是否有適當的方法來刷新屬性緩存?這個問題只發生在Redhat Linux而不是FreeBSD上。誰能解釋一下?

+0

您正在使用哪個版本的紅帽?也許這是一個錯誤,你最好報告它。你可以填寫[redhat的bugzilla](https://bugzilla.redhat.com/) –

回答

2

這不是特定於NFS,但可以讓內核刪除緩存。這通常在IO基準測試時完成,但也適用於NFS。

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.