这篇文章讲解如何编译bcache-tools与编译bcache.ko。

编译bcache-tools

第一步 下载源码

此处提供一处下载地址:git clone http://evilpiepirate.org/git/bcache-tools.git

第二步 make

[root@mongodb bcache-tools]# make
cc -O2 -Wall -g `pkg-config --cflags uuid blkid`   -c -o bcache.o bcache.c
cc -O2 -Wall -g `pkg-config --cflags uuid blkid`    make-bcache.c bcache.o  `pkg-config --libs uuid blkid` -o make-bcache
cc -O2 -Wall -g `pkg-config --cflags uuid blkid`    probe-bcache.c  `pkg-config --libs uuid blkid` -o probe-bcache
cc -O2 -Wall -g -std=gnu99    bcache-super-show.c bcache.o  `pkg-config --libs uuid` -o bcache-super-show
cc -O2 -Wall -g   -c -o bcache-register.o bcache-register.c
cc   bcache-register.o   -o bcache-register
[root@mongodb bcache-tools]#

第三步 make install

[root@mongodb bcache-tools]# make install
install -m0755 make-bcache bcache-super-show    /usr/sbin/
install -m0755 probe-bcache bcache-register     /lib/udev/
install -m0644 69-bcache.rules  /lib/udev/rules.d/
install -m0644 -- *.8 /usr/share/man/man8/
install -D -m0755 initramfs/hook    /usr/share/initramfs-tools/hooks/bcache
install -D -m0755 initcpio/install  /usr/lib/initcpio/install/bcache
install -D -m0755 dracut/module-setup.sh /lib/dracut/modules.d/90bcache/module-setup.sh
[root@mongodb bcache-tools]#

最后生成了四个工具:
make-bcache
bcache-register
bcache-super-show
probe-bcache

编译bcache.ko(此处以centos为例)

第一步 下载bcache内核源码

自行上网下载(无法找到,私信我)

第二步 解压源码包

[root@AutoCloud bcache]# tar -xf src_bache.tar.gz
[root@AutoCloud bcache]#

第三步 拷贝文件到指定目录

[root@AutoCloud src_bcache]# cp include/uapi/linux/bcache.h /usr/src/kernels/3.10.0-1127.el7.x86_64/include/uapi/linux/
[root@AutoCloud src_bcache]#
[root@AutoCloud src_bcache]# cp include/trace/events/bcache.h /usr/src/kernels/3.10.0-1127.el7.x86_64/include/trace/events/
cp: overwrite ‘/usr/src/kernels/3.10.0-1127.el7.x86_64/include/trace/events/bcache.h’? y
[root@AutoCloud src_bcache]#

第四步 生成Makefile

[root@AutoCloud src_bcache]# vi Makefile KDIR:=/lib/modules/$(shell uname -r)/build
PWD:=$(shell pwd)/drivers/md/bcachedefault:$(MAKE) -e CONFIG_BCACHE=m -C $(KDIR) M=$(PWD) modules
clean:rm -rf .*.cmd *.o *.mod.c *.ko .tmp_versions *.order *symvers *Module.markers

第五步 make

[root@AutoCloud src_bcache]# make
make -e CONFIG_BCACHE=m -C /lib/modules/3.10.0-1127.el7.x86_64/build M=/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache modules
make[1]: Entering directory `/usr/src/kernels/3.10.0-1127.el7.x86_64'
make[2]: Entering directory `/usr/src/kernels/3.10.0-1127.el7.x86_64'CC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/alloc.oCC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/bset.oCC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/btree.oCC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/closure.oCC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/debug.oCC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/extents.oCC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/io.oCC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/journal.oCC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/movinggc.oCC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.o
In file included from /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/bset.h:8:0,from /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/bcache.h:190,from /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.c:9:
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.c: In function ‘add_sequential’:
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.c:357:12: error: ‘struct task_struct’ has no member named ‘sequential_io_avg’ewma_add(t->sequential_io_avg,^
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/util.h:440:3: note: in definition of macro ‘ewma_add’(ewma) *= (weight) - 1;      \^
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.c:357:12: error: ‘struct task_struct’ has no member named ‘sequential_io_avg’ewma_add(t->sequential_io_avg,^
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/util.h:441:3: note: in definition of macro ‘ewma_add’(ewma) += (val) << factor;     \^
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.c:358:5: error: ‘struct task_struct’ has no member named ‘sequential_io’t->sequential_io, 8, 0);^
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/util.h:441:13: note: in definition of macro ‘ewma_add’(ewma) += (val) << factor;     \^
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.c:357:12: error: ‘struct task_struct’ has no member named ‘sequential_io_avg’ewma_add(t->sequential_io_avg,^
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/util.h:442:3: note: in definition of macro ‘ewma_add’(ewma) /= (weight);      \^
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.c:357:12: error: ‘struct task_struct’ has no member named ‘sequential_io_avg’ewma_add(t->sequential_io_avg,^
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/util.h:443:3: note: in definition of macro ‘ewma_add’(ewma) >> factor;      \^
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.c:360:3: error: ‘struct task_struct’ has no member named ‘sequential_io’t->sequential_io = 0;^
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.c: In function ‘check_should_bypass’:
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.c:425:6: error: ‘struct task_struct’ has no member named ‘sequential_io’task->sequential_io  = i->sequential;^
In file included from include/asm-generic/bug.h:15:0,from ./arch/x86/include/asm/bug.h:38,from include/linux/bug.h:4,from include/linux/thread_info.h:11,from include/linux/preempt.h:9,from include/linux/spinlock.h:50,from include/linux/wait.h:7,from include/linux/fs.h:6,from include/linux/highmem.h:4,from include/linux/bio.h:23,from /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/bcache.h:181,from /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.c:9:
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.c:433:20: error: ‘struct task_struct’ has no member named ‘sequential_i’sectors = max(task->sequential_io,^
include/linux/kernel.h:793:9: note: in definition of macro ‘max’typeof(x) _max1 = (x);   \^
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.c:433:20: error: ‘struct task_struct’ has no member named ‘sequential_i’sectors = max(task->sequential_io,^
include/linux/kernel.h:793:21: note: in definition of macro ‘max’typeof(x) _max1 = (x);   \^
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.c:434:13: error: ‘struct task_struct’ has no member named ‘sequential_io_avg’task->sequential_io_avg) >> 9;^
include/linux/kernel.h:794:9: note: in definition of macro ‘max’typeof(y) _max2 = (y);   \^
/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.c:434:13: error: ‘struct task_struct’ has no member named ‘sequential_io_avg’task->sequential_io_avg) >> 9;^
include/linux/kernel.h:794:21: note: in definition of macro ‘max’typeof(y) _max2 = (y);   \^
make[2]: *** [/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.o] Error 1
make[2]: Leaving directory `/usr/src/kernels/3.10.0-1127.el7.x86_64'
make[1]: *** [_module_/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache] Error 2
make[1]: Leaving directory `/usr/src/kernels/3.10.0-1127.el7.x86_64'
make: *** [default] Error 2
[root@AutoCloud src_bcache]#

直接编译发现错误,没有发现sequential_io_avg。如何解决呢?
编辑drivers/md/bcache/Makefile文件

[root@AutoCloud src_bcache]# vi drivers/md/bcache/Makefile obj-$(CONFIG_BCACHE)    += bcache.obcache-y                := alloc.o bset.o btree.o closure.o debug.o extents.o\io.o journal.o movinggc.o request.o stats.o super.o sysfs.o trace.o\util.o writeback.oCFLAGS_request.o        += -Iblock -DCONFIG_BCACHE

加上-DCONFIG_BCACHE。
再进行编译

[root@AutoCloud src_bcache]# make
make -e CONFIG_BCACHE=m -C /lib/modules/3.10.0-1127.el7.x86_64/build M=/opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache modules
make[1]: Entering directory `/usr/src/kernels/3.10.0-1127.el7.x86_64'
make[2]: Entering directory `/usr/src/kernels/3.10.0-1127.el7.x86_64'CC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/request.oCC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/stats.oCC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/super.oCC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/sysfs.oCC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/trace.oCC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/util.oCC [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/writeback.oLD [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/bcache.o
make[2]: Leaving directory `/usr/src/kernels/3.10.0-1127.el7.x86_64'Building modules, stage 2.
make[2]: Entering directory `/usr/src/kernels/3.10.0-1127.el7.x86_64'MODPOST 1 modulesCC      /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/bcache.mod.oLD [M]  /opt/zone/sdc1/bcache/src_bcache/drivers/md/bcache/bcache.ko
make[2]: Leaving directory `/usr/src/kernels/3.10.0-1127.el7.x86_64'
make[1]: Leaving directory `/usr/src/kernels/3.10.0-1127.el7.x86_64'
[root@AutoCloud src_bcache]#

发现编译成功了,让我们查看一下:

[root@AutoCloud src_bcache]# ls drivers/md/bcache/bcache.ko
drivers/md/bcache/bcache.ko
[root@AutoCloud src_bcache]#

总结

至此,此篇文章结束,希望大家有所收获。
注意:低版本bcache有挺多bug,可能导致系统崩溃,使用时注意。

初涉Bcache(3)相关推荐

  1. bcache状态和配置文件详细介绍(翻译自官网)

    参考文献 http://www.cnblogs.com/zimufeng/p/6640439.html 有参考价值 https://www.kernel.org/doc/Documentation/b ...

  2. linux cache控制 内核,linux内核之bcache简介 [转]

    bcache是按照SSD特性来设计的,只按擦除桶大小进行分配,使用btree和日志混合方法来跟踪缓存数据,缓存数据可以是桶上的任意一个扇区.bcache最大程度上减少了随机写的代价,它按顺序填充一个桶 ...

  3. 初涉SQL Server性能问题(3/4):列出阻塞的会话

    原文:初涉SQL Server性能问题(3/4):列出阻塞的会话 在 初涉SQL Server性能问题(2/4)里,我们讨论了列出等待资源或正运行的会话脚本.这篇文章我们会看看如何列出包含具体信息的话 ...

  4. 初涉SQL Server性能问题(1/4):服务器概况

    原文:初涉SQL Server性能问题(1/4):服务器概况 当你作为DBA时,很多人会向你抱怨:"这个程序数据加载和蜗牛一样,你看看是不是服务器出问题了?"造成这个问题的原因有很 ...

  5. 关于bcache的一些事情

    最近因为工作的原因接触到bcache缓存技术的一些皮毛,做个笔记备忘. bcache是自3.10开始集成到Linux Kernel中去,后面更新了几个版本增加了一些功能. 另一个备用技术选项为face ...

  6. 初涉c#设计模式-proxy pattern-从中国足球黑哨开始

    好吧,这次的设计模式,我从最爱的足球谈起. 嗯,球员不是演员,想要行贿球员好比门将放球进去,这样演起来真的挺难,但作为裁判,对于一些争议性的问题,往往可以通过一些手段让他"看清"到 ...

  7. 走向.NET架构设计—第三章—分层设计,初涉架构

    走向.NET架构设计-分层设计,初涉架构(前篇) 前言:本篇不打算接着上一篇来,这没有关系,以为内他们之间的联系不大,以后我再补上.因为之前一直在谈论设计,也谈了一些TDD的东西,大家反应觉得讲述的还 ...

  8. 程序员初涉江湖 宜步步为赢(转-1) 作者:IT168 职业发展顾问Leo

    [IT168 专稿] 何时算初涉江湖呢?其实大学没毕业,我们就已身在其中了,实习是让我们了解这个江湖的绝好机会.那么作为开发人员,我们又如何日进入角色?下面IT168的职场顾问Leo与你分享过来人的观 ...

  9. bcache使用教程

    原文:https://leshared.com/148.html 文章内容可能更新,阅读原文可获得最新内容 混合存储中flashcache和bcache是比较知名的两个开源项目,之前文章详述了flas ...

最新文章

  1. [引]ASP.NET 中 事务处理(SqlTransaction)示例
  2. 如果不当程序员,你会在做什么? | 每日趣闻
  3. 7.Nginx_Keepalived高可用配置
  4. Asp.net 序列化应用实例(转载)
  5. 使用Atomikos Transactions Essentials实现多数据源JTA分布式事务--转载
  6. 曙光中学2021年高考成绩查询,上海市部分高中2020高考录取喜报,成绩喜人!
  7. 新增方法java_Java8_map新增方法
  8. Jeesite信息化快速开发平台
  9. 达拉斯大学计算机硕士专业排名,美国大学研究生专业排名:人机交互
  10. [蛋蛋四格漫画]蛋蛋式按摩……(中日台词对照)
  11. shell 脚本 简易for循环 脚本
  12. 10个精妙的Java编码最佳实践
  13. ajax+对号,操作成功动画效果(圆圈变成勾号)
  14. 基4fft matlab,快速傅里叶变换基4时间抽取FFT算法
  15. Cesium的坐标拾取
  16. 5.0以上机器XPOSED框架安装流程
  17. 计算机按键截图,截图按什么键,电脑按哪个键是截屏
  18. H5 canvas 画圆 画圆角
  19. 分布式计算模式:MapReduce
  20. Python3 网络爬虫入门与实战

热门文章

  1. html网页制作图案,HTML+CSS实现画出一个太极八卦图案
  2. 梨山王:2021粤港澳大湾区企业家联盟四周年庆典暨中法企业家峰会
  3. 越来越多的人认为边缘计算是大势所趋
  4. requests爬虫遇到404怎么办_Python网络爬虫2 – 请求中遇到的几个问题
  5. 六 c# 字符与字符串
  6. matlab guide 打不开,matlab 图形用户界面不GUIDE不能用~求指导
  7. 怎么这虚拟服务器中加内存,如何增大主机的虚拟内存?
  8. linux shell编程输入输出,Linux shell编程 13标准输入、输出及文件重定向-dps文件怎么打开...
  9. 【python】office操作,doc转docx、ppt,pptx转pdf,pdf转txt
  10. 关于苹果销量的一些看法