The Linux Kernel's VFS Layer

本文介绍了 Linux 内核的虚拟文件系统 (VFS) 层及其提供的统一 I/O 数据缓存机制。Linux 维护四种缓存:页缓存、i-node 缓存、缓冲区缓存和目录缓存。通过这些缓存可以有效地管理文件系统的读写操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The Linux Kernel's VFS Layer

The Virtual File System (VFS) layer [1] providesa uniform interface for the kernel to deal with various I/O requestsand specifies a standard interface that each file system must support.Through this layer, one kernel can mount several different types offile systems (e.g. EXT2FS, ISO9660FS, NFS,...) into the same tree structure. We worked with version 2.2.12of the Linux kernel and confined our changes to the VFS layer. Bydoing all of our changes in the VFS layer we kept our predictiveprefetching totally independent of the underlying file system.

Arguably, the most important service the VFS layer provides is auniform I/O data cache. Linux maintains four caches of I/O data: page cache, i-node cache, buffer cache and directory cache. Figure 5 shows these caches andhow they interact with the kernel, each other and user level programs.The page cache combines virtual memory and file data. The i-node cache keeps recently accessed file i-nodes. The buffer cache interfaces with block devices, and caches recently usedmeta-data disk blocks. The Linux kernel reads file data through thebuffer cache, but keeps the data in the page cache for reuse on futurereads. The directory cache (d-cache) keeps in memory a tree thatrepresents a portion of the file system's directory structure. Thistree maps a file's path name to an i-node structure and speeds up filepath name look up. The basic element of the d-cache is a structurecalled the d-entry.

We implemented our methods of modeling file access patterns by addingone field to the d-entry structure. The various models wouldattach their modeling data structure to this pointer. For the lastsuccessor model this consisted of just a device and inode number. Forthe partitioned models this was a pointer to the partition that beganwith the file that the d-entry identified. After each fileaccess the model would update its predictions. The prefetch enginewas then called and would use these predictions to prefetch file data.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值