手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux I/O Block--递交I/O请求

[日期:2012-12-10] 来源:Linux社区  作者:vanbreaker [字体:大 中 小]

bi_sector:该I/O操作的起始扇区号

bi_rw:指明了读写方向

bi_vcnt:该I/O操作中涉及到了多少个缓存向量,每个缓存向量由[page,offset,len]来描述

bi_idx:指示当前的缓存向量

bi_io_vec:缓存向量数组

缓存向量的定义:

struct bio_vec { 
    struct page *bv_page; 
    unsigned int    bv_len; 
    unsigned int    bv_offset; 
}; 

struct request用于描述提交给块设备的I/O请求,bio会动态地添加进request,因此一个request往往会包含若干相邻的bio。

struct request { 
    struct list_head queuelist; 
    struct call_single_data csd; 
    int cpu; 
 
    struct request_queue *q; 
 
    unsigned int cmd_flags; 
    enum rq_cmd_type_bits cmd_type; 
    unsigned long atomic_flags; 
 
    /* the following two fields are internal, NEVER access directly */ 
    sector_t __sector;      /* sector cursor */ 
    unsigned int __data_len;    /* total data len */ 
 
    struct bio *bio; 
    struct bio *biotail; 
 
    struct hlist_node hash; /* merge hash */ 
    /*
    * The rb_node is only used inside the io scheduler, requests
    * are pruned when moved to the dispatch queue. So let the
    * completion_data share space with the rb_node.
    */ 
    union { 
        struct rb_node rb_node; /* sort/lookup */ 
        void *completion_data; 
    }; 
 
    /*
    * two pointers are available for the IO schedulers, if they need
    * more they have to dynamically allocate it.
    */ 
    void *elevator_private; 
    void *elevator_private2; 
 
    struct gendisk *rq_disk; 
    unsigned long start_time; 
 
    /* Number of scatter-gather DMA addr+len pairs after
    * physical address coalescing is performed.
    */ 
    unsigned short nr_phys_segments; 
 
    unsigned short ioprio; 
 
    void *special;      /* opaque pointer available for LLD use */ 
    char *buffer;      /* kaddr of the current segment if available */ 
 
    int tag; 
    int errors; 
 
    int ref_count; 
 
    /*
    * when request is used as a packet command carrier
    */ 
    unsigned short cmd_len; 
    unsigned char __cmd[BLK_MAX_CDB]; 
    unsigned char *cmd; 
 
    unsigned int extra_len; /* length of alignment and padding */ 
    unsigned int sense_len; 
    unsigned int resid_len; /* residual count */ 
    void *sense; 
 
    unsigned long deadline; 
    struct list_head timeout_list; 
    unsigned int timeout; 
    int retries; 
 
    /*
    * completion callback.
    */ 
    rq_end_io_fn *end_io; 
    void *end_io_data; 
 
    /* for bidi */ 
    struct request *next_rq; 
}; 

queuelist:用于将request链入请求队列的链表元素

q:指向所属的请求队列

__sector:下一个要传输的bio的起始扇区号

__data_len:request要传输的数据字节数

bio,biotail:用于维护request中的bio链表

在之前介绍的gendisk结构中,可以看到每个块设备(或分区)都对应了一个request_queue的结构,该结构用来容纳request,并且包含了相应的递交request以及I/O调度的方法 http://www.linuxidc.com/Linux/2012-12/75629.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款