什么是pagecache/dentries/inodes?


=Start=

缘由:

最近因为新上了一个扫描功能导致大范围内的机器告警,新上的功能代码其实非常简单:

find / -type f -name "ffmpeg" -executable 2>/dev/null

因为ffmpeg安装路径的不确定性,所以使用了全盘扫描的办法,虽然之前有考虑过这样会对线上的部分机器产生影响,但是说实话,没想到影响这么大。。。

而且最诡异的地方在于,同一个命令对于不同的机器影响差别很大,有的基本没什么影响,有的服务器上面运行的服务可用性降低不少,而且更奇怪的地方在于——物理机的网络竟然也出现了问题。。。运气不好,这种事情让我撞上了,我只能这么安慰自己!

之前对pagecache/dentries/inodes这些知识有一定了解,但了解不深,趁着这次机会再好好学习一下,以后出现问题了也好快速定位。

正文:

参考解答:

It appears you are working with memory caching of directory structures. 当我们正在使用内存缓存目录结构时,

An inode in your context is a data structure that represents a file. A dentries is a data structure that represents a directory. 在这个上下文中的inode是表示文件的数据结构,而dentries是表示目录的数据结构

These structures could be used to build a memory cache that represents the file structure on a disk. To get a directly listing, the OS could go to the dentries–if the directory is there–list its contents (a series of inodes). If not there, go to the disk and read it into memory so that it can be used again. 这些结构可用于构建表示磁盘上的文件结构的内存高速缓存。为了直接获得列表,操作系统可以去dentries那里(如果目录在那里的话)列出其内容(一系列inode)。如果没有,则会去磁盘上将其读入内存,以便它可以再次使用。

The page cache could contain any memory mappings to blocks on disk. That could conceivably be buffered I/O, memory mapped files, paged areas of executables–anything that the OS could hold in memory from a file. 页面缓存(page cache)可以包含磁盘块的任何内存映射。这可以是缓冲I/O,内存映射文件,可执行文件的分页区域——操作系统可以从文件保存在内存中的任何内容。

==

如何释放pagecache/dentries/inodes
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
参考链接:

=END=

,

《“什么是pagecache/dentries/inodes?”》 有 1 条评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注