Documentation\device-mapper\dm-io

来源:互联网 发布:网络歌手夕阳醉了 编辑:程序博客网 时间:2024/05/22 15:48
Chinese translated version of Documentation\device-mapper\dm-io


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: biyu tang<tangbiyu17@qq.com>
---------------------------------------------------------------------
DocumentationDocumentation\device-mapper\dm-io的中文翻译


如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
译存在问题,请联系中文版维护者。


中文版维护者: 唐碧瑜  biyu tang<tangbiyu17@qq.com>
中文版翻译者: 唐碧瑜  biyu tang<tangbiyu17@qq.com>
中文版校译者: 唐碧瑜  biyu tang<tangbiyu17@qq.com>










以下为正文
---------------------------------------------------------------------

dm-io
=====

Dm-io provides synchronous and asynchronous I/O services. There are three
types of I/O services available, and each type has a sync and an async
version.

DM-IO提供同步和异步I / O服务。有三种类型的I / O服务可用,每种类型都有同步和异步
的版本。

The user must set up an io_region structure to describe the desired location
of the I/O. Each io_region indicates a block-device along with the starting
sector and size of the region.

用户必须设置一个io_region结构描述I / O所需的位置。每个io_region表示块设备起始
边界和该区域的大小。

   struct io_region {
      struct block_device *bdev;
      sector_t sector;
      sector_t count;
   };

Dm-io can read from one io_region or write to one or more io_regions. Writes
to multiple regions are specified by an array of io_region structures.

dm-io可以从一个io_region读取或写入到一个或多个io_region。通过一个io_region结
构组成的数组写入指定的多个区域。

The first I/O service type takes a list of memory pages as the data buffer for
the I/O, along with an offset into the first page.

第一种I / O服务需要一个内存页面列表作为I / O的数据缓冲区,以及第一页写入一个偏移量。

   struct page_list {
      struct page_list *next;
      struct page *page;
   };

   int dm_io_sync(unsigned int num_regions, struct io_region *where, int rw,
                  struct page_list *pl, unsigned int offset,
                  unsigned long *error_bits);
   int dm_io_async(unsigned int num_regions, struct io_region *where, int rw,
                   struct page_list *pl, unsigned int offset,
                   io_notify_fn fn, void *context);

The second I/O service type takes an array of bio vectors as the data buffer
for the I/O. This service can be handy if the caller has a pre-assembled bio,
but wants to direct different portions of the bio to different devices.

第二种I / O服务需要一个bio数组作为I / O的数据缓冲器。如果调用者有个预先装配好的bio,
那么这种服务是方便的,但要引导bio的不同部分到不同设备。

   int dm_io_sync_bvec(unsigned int num_regions, struct io_region *where,
                       int rw, struct bio_vec *bvec,
                       unsigned long *error_bits);
   int dm_io_async_bvec(unsigned int num_regions, struct io_region *where,
                        int rw, struct bio_vec *bvec,
                        io_notify_fn fn, void *context);

The third I/O service type takes a pointer to a vmalloc'd memory buffer as the
data buffer for the I/O. This service can be handy if the caller needs to do
I/O to a large region but doesn't want to allocate a large number of individual
memory pages.


第三种I / O服务需要一个指向vmalloc'd内存缓冲区的指针,作为I / O的数据缓冲区,
这种服务可以是方便,如果调用者需要一个很大的域实现I / O,但不希望分配了大量单独的
内存页。

   int dm_io_sync_vm(unsigned int num_regions, struct io_region *where, int rw,
                     void *data, unsigned long *error_bits);
   int dm_io_async_vm(unsigned int num_regions, struct io_region *where, int rw,
                      void *data, io_notify_fn fn, void *context);

Callers of the asynchronous I/O services must include the name of a completion
callback routine and a pointer to some context data for the I/O.


异步I / O服务的调用者必须包括一个完成回调函数的名称和一个指向在一定范围内数据
I / O的指针。

   typedef void (*io_notify_fn)(unsigned long error, void *context);

The "error" parameter in this callback, as well as the "*error" parameter in
all of the synchronous versions, is a bitset (instead of a simple error value).
In the case of an write-I/O to multiple regions, this bitset allows dm-io to
indicate success or failure on each individual region.

在这个回调函数中的“error”参数,以及所有的同步版本中的“*error”参数,是一个bitset
(而不是一个简单的错误值)。在写I / O到多个域的情况下,这个BitSet允许DM-IO在每个
单独的域指示成功或失败。

Before using any of the dm-io services, the user should call dm_io_get()
and specify the number of pages they expect to perform I/O on concurrently.
Dm-io will attempt to resize its mempool to make sure enough pages are
always available in order to avoid unnecessary waiting while performing I/O.

在使用任何DM-io服务之前,用户应该调用dm_io_get()同时指定他们希望执行I/ O的页数。
DM-IO将尝试调整其内存池,以确保有足够页面始终可用,以避免执行I/ O时不必要的等待。

When the user is finished using the dm-io services, they should call
dm_io_put() and specify the same number of pages that were given on the
dm_io_get() call.


当用户结束使用DM-io的服务时,他们应该调用dm_io_put(),并指定和dm_io_get()调用
相同数量的页。

原创粉丝点击