⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blk.h.txt

📁 linux内核学习笔记 希望想看的人可以很快下载到
💻 TXT
字号:
any question,send email to netxiong@263.net

相关文件:
	/linux/blkdev.h

************************基本数据结构************************
(1):#define CURRENT               blkdev_entry_next_request(&blk_dev[MAJOR_NR].request_queue.queue_head)	
	#得到当前的设备的request

结构示意图
blk_dev_struct
  #request_queue---->struct request_queue
			queue_head---------->struct request
						queue------->struct request		所以CURRENT就指向struct request


(2):#define QUEUE_EMPTY 		list_empty(&blk_dev[MAJOR_NR].request_queue.queue_head)
	#检验这个设备中的请求是否为空。


(2):#define INIT_REQUEST \	//检查request,
    if (QUEUE_EMPTY) {\		//如果没有request,返回
                CLEAR_INTR; \
                return; \
        } \
        if (MAJOR(CURRENT->rq_dev) != MAJOR_NR) \	//major不对,返回
                panic(DEVICE_NAME ": request list destroyed"); \
        if (CURRENT->bh) { \				
                if (!buffer_locked(CURRENT->bh)) \	//锁定buffer_head
                        panic(DEVICE_NAME ": block not locked"); \
        }	//这个宏的主要公用是用来对当前的request的buffer_head加锁
************************************************************


**********************基本函数*****************************
(1):static inline void end_request(int uptodate) {
        struct request *req = CURRENT;
        if (end_that_request_first(req, uptodate, DEVICE_NAME))
                return;
#ifndef DEVICE_NO_RANDOM
        add_blkdev_randomness(MAJOR(req->rq_dev));
#endif
        DEVICE_OFF(req->rq_dev);
        blkdev_dequeue_request(req);	//删除当前的请求
        end_that_request_last(req);
    }

(2):static inline void blkdev_dequeue_request(struct request * req)
   {
        list_del(&req->queue);	//从设备的请求列表中删除当前的请求
   }


***********************************************************






⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -