• 块设备驱动框架


    框架:

    app:      open,read,write "xxx.txt"
    	---------------------------------------------  文件的读写
    	文件系统: vfat, ext2, ext3, yaffs2, jffs2      (把文件的读写转换为扇区的读写)
    	-----------------ll_rw_block-----------------  扇区的读写
    	     1. 把"读写"放入队列
    	     2. 调用队列的处理函数(优化/调顺序/合并)
    	            (块设备驱动程序)     
    	---------------------------------------------
    硬件:        	硬盘,flash
    

    ll_rw_block 为主要的功能函数。

    分析 ll_rw_block
            for (i = 0; i < nr; i++)
                struct buffer_head *bh = bhs[i];
                submit_bh(rw, bh);
                    struct bio *bio; // 使用bh来构造bio (block input/output)
                    submit_bio(rw, bio);
                        
                        // 通用的构造请求: 使用bio来构造请求(request)
                        generic_make_request(bio);
                            __generic_make_request(bio);
                                request_queue_t *q = bdev_get_queue(bio->bi_bdev); // 找到队列                            
                                
                                // 调用队列的"构造请求函数"
                                ret = q->make_request_fn(q, bio);
                                        
                                        // 默认的函数是__make_request
                                        __make_request
                                            
                                            // 先尝试合并
                                            elv_merge(q, &req, bio);
                                            
                                            // 如果合并不成,使用bio构造请求
                                            init_request_from_bio(req, bio);
                                            
                                            // 把请求放入队列
                                            add_request(q, req);
                                            
                                            // 执行队列
                                            __generic_unplug_device(q);
                                                    
                                                    // 调用队列的"处理函数"
                                                    q->request_fn(q);
    
  • 相关阅读:
    Codeforces 1132D
    Codeforces 670F
    Codeforces 670E
    Codeforces 670E
    Codeforces 670E
    Codeforces 670
    Codeforces 1138
    Codeforces 1114E
    力扣21.合并两个有序链表
    力扣538.把二叉树转换为累加树
  • 原文地址:https://www.cnblogs.com/GyForever1004/p/8570106.html
Copyright © 2020-2023  润新知