【发布时间】:2017-12-20 12:57:44
【问题描述】:
传统的文件系统创建一个 struct file_operations 结构来实现 VFS 功能。例如,在 ext4(Linux 4.0 及之前)中,struct file_operations ext4_file_operations 使读取指针指向 new_sync_read。
Linux 4.0 /fs/ext4/file.c
const struct file_operations ext4_dax_file_operations = {
.read = new_sync_read,
.read_iter = generic_file_read_iter,
....
}
但是在Linux 4.1及以后的版本中,read指针没有这样的赋值,而是增加了一个splice_read指针。
Linux 4.1 /fs/ext4/file.c
const struct file_operations ext4_file_operations = {
.read_iter = generic_file_read_iter,
.splice_read = generic_file_splice_read,
...
}
但是“/include/linux/fs.h”中定义的struct file_operations仍然有读指针。那么,现在 ext4 中的哪个函数负责常规的读取函数呢?
【问题讨论】:
-
我现在认为在新版本中常规读取是由read_iter直接实现的,而在旧版本中它是由read_iter间接实现的。如果是这样,那么新版本中 VFS 的 read pinter 的作用是什么?
标签: linux filesystems system-calls vfs ext4