Chinese translated version of Documentation/filesystems/xip.txt
If you have any comment or update to the content, please contact the
original document maintainer directly. However, if you have a problem
communicating in English you can also ask the Chinese maintainer for
help. Contact the Chinese maintainer if this translation is outdated
or if there is a problem with the translation.
Chinese maintainer: 尹娇萍 1072986620@qq.com
---------------------------------------------------------------------
Documentation/filesystems/xip.txt 的中文翻译
如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
译存在问题,请联系中文版维护者。
中文版维护者: 尹娇萍 1072986620@qq.com
中文版翻译者: 尹娇萍 1072986620@qq.com
中文版校译者: 尹娇萍 1072986620@qq.com
以下为正文
---------------------------------------------------------------------
Execute-in-place for file mappings
----------------------------------
直接执行文件映射
----------------------------------
Motivation
----------
动机
----------
File mappings are performed by mapping page cache pages to userspace. In
addition, read&write type file operations also transfer data from/to the page
cache.
文件映射是将页面缓存页映射到用户空间来进行的。此外,读写类型的文件操作,也是
将数据从/到页面缓存。
For memory backed storage devices that use the block device interface, the page
cache pages are in fact copies of the original storage. Various approaches
exist to work around the need for an extra copy. The ramdisk driver for example
does read the data into the page cache, keeps a reference, and discards the
original data behind later on.
对于内存支持的存储设备使用块设备接口,页面高速缓存页事实上是原始存储的副本。
现在存在很多解决额外副本的需求的方法。ramdisk的驱动程序,例如确实将数据读入页
面缓存,作为一个参考,并稍后丢弃原始的数据。
Execute-in-place solves this issue the other way around: instead of keeping
data in the page cache, the need to have a page cache copy is eliminated
completely. With execute-in-place, read&write type operations are performed
directly from/to the memory backed storage device. For file mappings, the
storage device itself is mapped directly into userspace.
直接执行解决了这个问题,其他方式:在页面缓存中保存数据,而不是完全消除,需要
有一个页面缓存副本。直接执行,读与写直接从/到内存支持的存储设备类型进行操作。
对于文件映射,存储装置本身被直接映射到用户空间。
This implementation was initially written for shared memory segments between
different virtual machines on s390 hardware to allow multiple machines to
share the same binaries and libraries.
这种实现最初被写入不同的虚拟机S390硬件上的共享内存段之间,允许多台机器共享相同
的二进制代码和库。
Implementation
--------------
实现
--------------
Execute-in-place is implemented in three steps: block device operation,
address space operation, and file operations.
在执行中实现三个步骤:块设备操作,地址空间操作,文件操作。
A block device operation named direct_access is used to retrieve a
reference (pointer) to a block on-disk. The reference is supposed to be
cpu-addressable, physical address and remain valid until the release operation
is performed. A struct block_device reference is used to address the device,
and a sector_t argument is used to identify the individual block. As an
alternative, memory technology devices can be used for this.
块设备操作名为direct_access是磁盘上的块用于检索参考(指针)。该引用应该是CPU寻址,
物理地址,并保持有效,直到执行释放操作。一个struct block_device引用使用,是用来标
识该设备,而一个sector_t参数是用来识别私有块。作为一种替代方法,记忆体技术的设备可
以用于此目的。
The block device operation is optional, these block devices support it as of
today:
- dcssblk: s390 dcss block device driver
块设备的操作是可选的,这些块设备支持它的今天:
- DCSS BLK:S390 DCSS块设备驱动程序
An address space operation named get_xip_mem is used to retrieve references
to a page frame number and a kernel address. To obtain these values a reference
to an address_space is provided. This function assigns values to the kmem and
pfn parameters. The third argument indicates whether the function should allocate
blocks if needed.
一个地址空间操作名为get_xip_mem是用于检索引用一个页框的数量和内核地址。要获得这些
值地址空间要提供一个参考。这个函数分配的的KMEM和PFN参数的值。第三个参数表示功能是
否分配块,如果需要的话。
This address space operation is mutually exclusive with readpage&writepage that
do page cache read/write operations.
The following filesystems support it as of today:
- ext2: the second extended filesystem, see Documentation/filesystems/ext2.txt
这个地址空间操作是相互排斥的,与readpage writepage做页面缓存的读/写操作。
下列文件系统支持它的今天:
- ext2: the second extended filesystem, see Documentation/filesystems/ext2.txt
A set of file operations that do utilize get_xip_page can be found in
mm/filemap_xip.c . The following file operation implementations are provided:
- aio_read/aio_write
- readv/writev
- sendfile
在mm/filemap_xip.c中可以找到利用get_xip_page对一组文件的操作。提供以下文件操作实现:
- aio_read/aio_write
- readv/writev
- sendfile
The generic file operations do_sync_read/do_sync_write can be used to implement
classic synchronous IO calls.
通用的文件操作do_sync_read,/ do_sync_write可以用来实现经典的同步IO调用。
Shortcomings
------------
缺点
------------
This implementation is limited to storage devices that are cpu addressable at
all times (no highmem or such). It works well on rom/ram, but enhancements are
needed to make it work with flash in read+write mode.
Putting the Linux kernel and/or its modules on a xip filesystem does not mean
they are not copied.
这种实现经常受限于cpu寻址的存储设备(no highmem or such)。
它的工作原理以及ROM / RAM,但需要改进,使其工作用闪读+写模式。
把Linux内核和/或模块放在一个zip文件系统并不意味着它们不会被复制。