root@ubuntu:/home/shevarey/ssdd/sbull# make
make -C /lib/modules/2.6.32.16/build M=/home/shevarey/ssdd/sbull
modules
make[1]: Entering directory `/usr/src/linux-2.6.32.16"
scripts/Makefile.build:49: *** CFLAGS was changed in
"/home/shevarey/ssdd/sbull/Makefile". Fix it to use EXTRA_CFLAGS.
Stop.
make[1]: *** [_module_/home/shevarey/ssdd/sbull] Error 2
make[1]: Leaving directory `/usr/src/linux-2.6.32.16"
make: *** [default] Error 2
告诉我们用EXTRA_CFLAGS替代CFLAGS,打开Makefile,修改。再次make:
root@ubuntu:/home/shevarey/ssdd/sbull# make
make -C /lib/modules/2.6.32.16/build M=/home/shevarey/ssdd/sbull
modules
make[1]: Entering directory `/usr/src/linux-2.6.32.16"
CC [M] /home/shevarey/ssdd/sbull/sbull.o
/home/shevarey/ssdd/sbull/sbull.c:5:26: error: linux/config.h: No
such file or directory
/home/shevarey/ssdd/sbull/sbull.c:104: error: expected ")"before
"*" token
/home/shevarey/ssdd/sbull/sbull.c: In function
sbull_xfer_bio
/home/shevarey/ssdd/sbull/sbull.c:138: error: implicit
declaration of function bio_cur_sectors鈥?/home/shevarey/ssdd/sbull/sbull.c: In
function sbull_xfer_request
/home/shevarey/ssdd/sbull/sbull.c:154: error: implicit declaration
of function rq_for_each_bio鈥?/home/shevarey/ssdd/sbull/sbull.c:154:
error: expected ")" before "*"token
/home/shevarey/ssdd/sbull/sbull.c:152: warning: unused variable
nrsect鈥?/home/shevarey/ssdd/sbull/sbull.c:159: warning: no return
statement in function returning non-void
/home/shevarey/ssdd/sbull/sbull.c: At top level:
/home/shevarey/ssdd/sbull/sbull.c:166: error: expected ")"before
"*" token
/home/shevarey/ssdd/sbull/sbull.c:191: error: expected ")"before
"*" token
/home/shevarey/ssdd/sbull/sbull.c:316: warning: initialization from
incompatible pointer type
/home/shevarey/ssdd/sbull/sbull.c:317: warning: initialization from
incompatible pointer type
/home/shevarey/ssdd/sbull/sbull.c:321: warning: initialization from
incompatible pointer type
/home/shevarey/ssdd/sbull/sbull.c: In function setup_device
/home/shevarey/ssdd/sbull/sbull.c:357: error: sbull_make_request
undeclared (first use in this function)
/home/shevarey/ssdd/sbull/sbull.c:357: error: (Each undeclared
identifier is reported only once
/home/shevarey/ssdd/sbull/sbull.c:357: error: for each function it
appears in.)
/home/shevarey/ssdd/sbull/sbull.c:361: error: sbull_full_request
undeclared (first use in this function)
/home/shevarey/ssdd/sbull/sbull.c:371: error: sbull_request
undeclared (first use in this function)
/home/shevarey/ssdd/sbull/sbull.c:376: error: implicit declaration
of function blk_queue_hardsect_size make[2]:
*** [/home/shevarey/ssdd/sbull/sbull.o] Error 1
make[1]: *** [_module_/home/shevarey/ssdd/sbull] Error 2
make[1]: Leaving directory `/usr/src/linux-2.6.32.16"
make: *** [default] Error 2
1.删除#include;
2.对于三处expected ")"before "*"
token这个貌似语法错误的报错困扰了我很久,观察这三处错误,这三个函数都使用了request_queue_t*这个参数,对照2.6.10和2.6.32的源码发现,在2.6.32中取消了typedef
struct request_queue
request_queue_t这个结构定义。那就自己在sbull.c源码中加入这一句。
3.bio_cur_sectors不存在,在2.6.10源码中发现这个宏的定义是#define
bio_cur_sectors(bio)
(bio_iovec(bio)->bv_len>>9),在2.6.32中已经删除该宏,函数bio_cur_bytes返回bio_iovec(bio)->bv_len,所以将其改为bio_cur_bytes(bio)>>9;
4.rq_for_each_bio未定义,发现改成了__rq_for_each_bio,修改之~;
此时这些错误已经修改完毕,重新make:
root@ubuntu:/home/shevarey/ssdd/sbull# make
make -C /lib/modules/2.6.32.16/build M=/home/shevarey/ssdd/sbull
modules
make[1]: Entering directory `/usr/src/linux-2.6.32.16"
CC [M] /home/shevarey/ssdd/sbull/sbull.o
/home/shevarey/ssdd/sbull/sbull.c: In function sbull_request
/home/shevarey/ssdd/sbull/sbull.c:109: error: implicit declaration
of function elv_next_request
/home/shevarey/ssdd/sbull/sbull.c:109: warning: assignment makes
pointer from integer without a cast
/home/shevarey/ssdd/sbull/sbull.c:113: error: implicit declaration
of function end_request
/home/shevarey/ssdd/sbull/sbull.c:120: error: struct request has
no member named sector
/home/shevarey/ssdd/sbull/sbull.c:120: error: struct request has
no member named current_nr_sectors
/home/shevarey/ssdd/sbull/sbull.c: In function
sbull_full_request
/home/shevarey/ssdd/sbull/sbull.c:173: warning: assignment makes
pointer from integer without a cast
/home/shevarey/ssdd/sbull/sbull.c:180: error: implicit declaration
of function end_that_request_first
?/home/shevarey/ssdd/sbull/sbull.c:181: error: implicit declaration
of function
blkdev_dequeue_request
/home/shevarey/ssdd/sbull/sbull.c:182: error: implicit
declaration of function
鈥榚nd_that_request_last鈥?/home/shevarey/ssdd/sbull/sbull.c: In
function sbull_make_request /home/shevarey/ssdd/sbull/sbull.c:198:
error: too many arguments to function io_endio
/home/shevarey/ssdd/sbull/sbull.c: At top level:
/home/shevarey/ssdd/sbull/sbull.c:317: warning: initialization from
incompatible pointer type
/home/shevarey/ssdd/sbull/sbull.c:318: warning: initialization from
incompatible pointer type
/home/shevarey/ssdd/sbull/sbull.c:322: warning: initialization from
incompatible pointer type
/home/shevarey/ssdd/sbull/sbull.c: In function setup_devices
/home/shevarey/ssdd/sbull/sbull.c:377: error: implicit
declaration of function blk_queue_hardsect_size
make[2]: *** [/home/shevarey/ssdd/sbull/sbull.o] Error 1
make[1]: *** [_module_/home/shevarey/ssdd/sbull] Error 2
make[1]: Leaving directory `/usr/src/linux-2.6.32.16"
make: *** [default] Error 2
1.elv_next_request不存在,改成了blk_fetch_request,有两处,改之~
2.end_request,改成了blk_end_request_all,改之~
3.现在不能直接获取request结构的sector和current_nr_sector;而是通过函数blk_rq_pos和blk_rq_cur_sectors获得,所以将对用两处改为:
sbull_transfer(dev,
blk_rq_pos(req), blk_rq_cur_sectors(req),
req->buffer, rq_data_dir(req));
4.end_that_request_first,end_that_request_last,blk_dequeque_request已经不存在,被blk_fetch_request,blk_end_request_cur,blk_start_request代替所以要做一下修改在sbull_full_request中:
if (!__blk_end_request_cur(req, 0)) {
blk_start_request(req);
blk_fetch_request(q);
5.bio_endio参数过多,发现6.32.16中少了中间那个参数,去掉~
6.blk_queue_hardsect_size未定义,在2.6.10中找到定义,直接修改如下:
blk_queue_logical_block_size(dev->queue,
hardsect_size);
make之后些许warning,执行insmod,出错了,显示blk_put_queue未定义,直接删掉。