gxqing 发表于 2003-7-4 16:07:21

end_that_request_first()读不明白

/usr/src/linux/drivers/block/ll_rw_blk.c中

int end_that_request_first (struct request *req, int uptodate, char *name)
{
        struct buffer_head * bh;
        int nsect;

        req->errors = 0;
        if (!uptodate)
                printk("end_request: I/O error, dev %s (%s), sector %lu\n",
                        kdevname(req->rq_dev), name, req->sector);

        if ((bh = req->bh) != NULL) {
                nsect = bh->b_size >> 9;
                blk_finished_io(nsect);
                req->bh = bh->b_reqnext;
                bh->b_reqnext = NULL;
                bh->b_end_io(bh, uptodate);
                if ((bh = req->bh) != NULL) {
                        req->hard_sector += nsect;
                        req->hard_nr_sectors -= nsect;
                        req->sector = req->hard_sector;
                        req->nr_sectors = req->hard_nr_sectors;

                        req->current_nr_sectors = bh->b_size >> 9;
                        req->hard_cur_sectors = req->current_nr_sectors;
                        if (req->nr_sectors < req->current_nr_sectors) {//??????
                                req->nr_sectors = req->current_nr_sectors;
                                printk("end_request: buffer-list destroyed\n");
                        }
                        req->buffer = bh->b_data;
                        return 1;
                }
        }
        return 0;
}
为什么在if (req->nr_sectors < req->current_nr_sectors) {//??????
                                req->nr_sectors = req->current_nr_sectors;
                                printk("end_request: buffer-list destroyed\n");
                        }就说破坏了缓冲区链呢?
request结构中的hard_sector ,hard_nr_sectors,hard_cur_sectors 是指什么呢? :?:

jjww 发表于 2003-7-4 18:33:47

你可以参考LDD2的第12章block driver里的request部分,上面对这个函数说明了,我没有时间仔细看,你自己看看就明白了。~
然后ulk2,13.4.5.1对request的每一个成员仔细描述了。
enjoy

Dragonfly 发表于 2003-7-4 20:39:09

jjww, u know so much now. u must work hard.:-D:-D

gxqing, follow the intruction from jjww, that book is very clear about that.

req->nr_sectors should always >= req->current_nr_sectors;

jjww 发表于 2003-7-4 21:06:04

还差的很远, 由于很多其它事,不能专注于linux kernel, 惭愧 :oops: ...

Dragonfly 发表于 2003-7-4 21:07:58

me too:oops::oops::oops:

gxqing 发表于 2003-7-5 15:23:07

谢谢两位版主的指点!
request->current_nr_sectors是指请求所包含的第一个bh中扇区数,
request->nr_sectors是指请求所包含的总扇区数,
这些我原来看到了,只是没有地方提到hard_sector ,hard_nr_sectors,hard_cur_sectors这几个域的含义

jjww 发表于 2003-7-5 16:03:30

ULK2 13.4.5.1, 你看了的话, 这几个成员的介绍都有
hard_sector: First sector number of the (real) block device
......

gxqing 发表于 2003-7-5 17:05:36

o,my god,我只有ULK1

xdwjack 发表于 2003-7-5 19:22:21

ULK2在公社里面可以下载.

Dragonfly 发表于 2003-7-5 21:50:27

ulk1 is for 2.2 kernel. differ from 2.4
use ulk2.
页: [1]
查看完整版本: end_that_request_first()读不明白