最近在SuSE Linux Enterprise Server 11 SP3上编译flashcache模块时遇到如下的错误:
linux-qzdm:~/facebook-flashcache-9b26cb1 # make KERNEL_TREE=/usr/src/linux-3.0.76-0.11/
fatal: Not a git repository (or any of the parent directories): .git
make -C src KERNEL_TREE=/usr/src/linux-3.0.76-0.11/ PWD=/root/facebook-flashcache-9b26cb1/src all
make[1]: Entering directory `/root/facebook-flashcache-9b26cb1/src'
make -C /usr/src/linux-3.0.76-0.11/ M=/root/facebook-flashcache-9b26cb1/src modules V=0
make[2]: Entering directory `/usr/src/linux-3.0.76-0.11'
CC [M] /root/facebook-flashcache-9b26cb1/src/flashcache_conf.o
/root/facebook-flashcache-9b26cb1/src/flashcache_conf.c: In function ‘flashcache_ctr’:
/root/facebook-flashcache-9b26cb1/src/flashcache_conf.c:1181: error: ‘struct dm_target’ has no member named ‘split_io’
/root/facebook-flashcache-9b26cb1/src/flashcache_conf.c: At top level:
/root/facebook-flashcache-9b26cb1/src/flashcache_conf.c:1692: warning: initialization from incompatible pointer type
make[3]: *** [/root/facebook-flashcache-9b26cb1/src/flashcache_conf.o] Error 1
make[2]: *** [_module_/root/facebook-flashcache-9b26cb1/src] Error 2
make[2]: Leaving directory `/usr/src/linux-3.0.76-0.11'
make[1]: *** [modules] Error 2
make[1]: Leaving directory `/root/facebook-flashcache-9b26cb1/src'
make: *** [all] Error 2
flashcache_conf.c中的相关代码如下:
1180 #if LINUX_VERSION_CODE
1181 ti->split_io = dmc->block_size;
1182 #else
1183 ti->max_io_len = dmc->block_size;
1184 #endif
1185 ti->private = dmc;
初步判断是因为SuSE内核中对此处使用的结构体做了修改。
目前有两种解决办法:
(1)重新编译安装标准linux内核
编译安装内核:
linux-qzdm:~ # tar -xvf linux-3.0.76.tar.xz
linux-qzdm:~ # cd linux-3.0.76/
linux-qzdm:~/linux-3.0.76 # make config
linux-qzdm:~/linux-3.0.76 # make dep 生成内核功能间的依赖关系。一般会提示unecessary.
linux-qzdm:~/linux-3.0.76 # make
linux-qzdm:~/linux-3.0.76 # make modules_install
linux-qzdm:~/linux-3.0.76 # make install
linux-qzdm:~/linux-3.0.76 # reboot
重新编译安装flashcache:
linux-qzdm:~ # tar -zxvf flashcache.tar.gz
linux-qzdm:~ # cd facebook-flashcache-9b26cb1/
linux-qzdm:~/facebook-flashcache-9b26cb1 # make
linux-qzdm:~/facebook-flashcache-9b26cb1 # make install
加载flashcache模块:
linux-qzdm:~ # insmod /lib/modules/3.0.76-0.11-default/extra/flashcache/flashcache.ko
linux-qzdm:~ # lsmod | grep flash
flashcache 102320 1
dm_mod 77825 3 flashcache
(2)修改flashcache_conf.c文件
将
1180 #if LINUX_VERSION_CODE
1181 ti->split_io = dmc->block_size;
1182 #else
1183 ti->max_io_len = dmc->block_size;
1184 #endif
1185 ti->private = dmc;
修改为
1180 #if LINUX_VERSION_CODE
1181 ti->max_io_len = dmc->block_size;
1182 #else
1183 ti->max_io_len = dmc->block_size;
1184 #endif
1185 ti->private = dmc;
然后编译安装flashcache,方法同上