creator 发表于 2003-8-25 13:46:43

linux块设备缓冲机制,欢迎交流!!!

小弟最近在研究linux块设备缓冲机制,始终没有找齐相关的函数和数据结构,请大虾指导一下与块设备缓冲机制相关的源文件在哪里,具体有哪些文件,非常感谢!!!
我只找到两个相关的数据结构
//linux-kernel2.2.0
//include/linux/fs.h
struct buffer_head {
        /* First cache line: */
        struct buffer_head * b_next;        /* Hash queue list */
        unsigned long b_blocknr;        /* block number */
        unsigned long b_size;                /* block size */
        kdev_t b_dev;                        /* device (B_FREE = free) */
        kdev_t b_rdev;                        /* Real device */
        unsigned long b_rsector;        /* Real buffer location on disk */
        struct buffer_head * b_this_page;        /* circular list of buffers in one page */
        unsigned long b_state;                /* buffer state bitmap (see above) */
        struct buffer_head * b_next_free;
        unsigned int b_count;                /* users using this block */

        /* Non-performance-critical data follows. */
        char * b_data;                        /* pointer to data block (1024 bytes) */
        unsigned int b_list;                /* List that this buffer appears */
        unsigned long b_flushtime;      /* Time when this (dirty) buffer
                                       * should be written */
        struct wait_queue * b_wait;
        struct buffer_head ** b_pprev;                /* doubly linked list of hash-queue */
        struct buffer_head * b_prev_free;        /* doubly linked list of buffers */
        struct buffer_head * b_reqnext;                /* request queue */

        /*
       * I/O completion
       */
        void (*b_end_io)(struct buffer_head *bh, int uptodate);
        void *b_dev_id;
};
//blkdev.h
struct request {
        volatile int rq_status;        /* should split this into a few status bits */
#define RQ_INACTIVE                (-1)
#define RQ_ACTIVE                1
#define RQ_SCSI_BUSY                0xffff
#define RQ_SCSI_DONE                0xfffe
#define RQ_SCSI_DISCONNECTING        0xffe0

        kdev_t rq_dev;
        int cmd;                /* READ or WRITE */
        int errors;
        unsigned long sector;
        unsigned long nr_sectors;
        unsigned long current_nr_sectors;
        char * buffer;
        struct semaphore * sem;
        struct buffer_head * bh;
        struct buffer_head * bhtail;
        struct request * next;
};

Dragonfly 发表于 2003-8-25 21:00:11

ulk2 chapter 13, 14, 15
ldd2 block device driver chapter (i forget the number)
qjfx, chapter 5, 8


read them. and we can disuss here.
:-D:-D:-D

creator 发表于 2003-8-25 21:27:12

I got it , Thanks

Dragonfly 发表于 2003-8-26 00:26:36

welcome
good luck

creator 发表于 2003-8-30 12:40:35

struct buffer_head * b_next; /* Hash queue list */

根据源代码,buffer_head可以处于3个queue中:

unused queue
request queue
hash queue

hash queue指的是什么呢,有什么作用?

Dragonfly 发表于 2003-8-30 23:27:28

pls read ULK2 14.2.1.3 The hash table of cached buffer heads
:-D
页: [1]
查看完整版本: linux块设备缓冲机制,欢迎交流!!!