Linux RAID 读写 求助
各位,最近做实验,需要修改Linux RAID 读写相关代码, sources/drivers/md/raid1.c, 想实现对读、写的每个页的内容实现MD5,并记录MD5与页号的映射,以便下次使用,但是看了bio的结构体以及bio_vec的结构体,不知道从哪里获取页的内容以及页号的相关信息,以及将MD5加到什么地方,大家有什么思路及建议吗?
struct bio {
sector_t bi_sector; /* associated sector on disk */
struct bio *bi_next; /* list of requests */
struct block_device*bi_bdev; /* associated block device */
unsigned long bi_flags; /* status and command flags */
unsigned long bi_rw; /* read or write? */
unsigned short bi_vcnt; /* number of bio_vecs off */
unsigned short bi_idx; /* current index in bi_io_vec */
unsigned short bi_phys_segments;/* number of segments after coalescing */
unsigned short bi_hw_segments; /* number of segments after remapping */
unsigned int bi_size; /* I/O count */
unsigned int bi_hw_front_size;/* size of the first mergeable segment */
unsigned int bi_hw_back_size; /* size of the last mergeable segment */
unsigned int bi_max_vecs; /* maximum bio_vecs possible */
struct bio_vec *bi_io_vec; /* bio_vec list */
bio_end_io_t *bi_end_io; /* I/O completion method */
atomic_t bi_cnt; /* usage counter */
void *bi_private; /* owner-private method */
bio_destructor_t *bi_destructor; /* destructor method */
};
struct bio_vec {
/* pointer to the physical page on which this buffer resides */
struct page *bv_page;
/* the length in bytes of this buffer */
unsigned int bv_len;
/* the byte offset within the page where the buffer resides */
unsigned int bv_offset;
}
其中估计bio->bi_io_vec->bv_page 是要读写的内容。md.c中md_make_request()是读写的入口,其中会调用具体的RAID的make_request(),那么MD5应该在什么地方实现呢,以及如何截获bio的读写内容呢
页:
[1]