首页 文章 精选 留言 我的

精选列表

搜索[ASIO支持],共10000篇文章
优秀的个人博客,低调大师

移植facebook flashcache模块支持 linux kernel 4.13以上

环境 准备在ubuntu 18.04 lts下搭建kvm+libvirt+glusterfs的虚拟化环境。 4台服务器是2块SSD,4块SATA(5400RPM)。 尝试了gluster tier,效果不好。 对于虚拟化环境下大文件的存储,tier的promote和demote的策略很难设置, 在大文件发生大量数据交换时会出现tier层"no space left"的错误,文件无法写入。 在没有更好的解决方案之前,facebook的flashcache(https://github.com/facebookarchive/flashcache )对于提速SATA盘的作用还是非常显著的。 但ubuntu18.04的apt源还没有。 https://launchpad.net/flashcache/+packages 错误 于是下载flashcache源码编译dkms模块的时候,报错: DKMS make.log for flashcache-3.1.3+git20150701 for kernel 4.15.0-36-generic (x86_64) Fri Oct 12 15:06:00 UTC 2018 make -C /lib/modules/4.15.0-36-generic/build M=/var/lib/dkms/flashcache/3.1.3+git20150701/build modules V=0 make[1]: Entering directory '/usr/src/linux-headers-4.15.0-36-generic' Makefile:975: "Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" CC [M] /var/lib/dkms/flashcache/3.1.3+git20150701/build/flashcache_conf.o CC [M] /var/lib/dkms/flashcache/3.1.3+git20150701/build/flashcache_main.o CC [M] /var/lib/dkms/flashcache/3.1.3+git20150701/build/flashcache_subr.o /var/lib/dkms/flashcache/3.1.3+git20150701/build/flashcache_subr.c: In function ‘flashcache_bio_endio’: /var/lib/dkms/flashcache/3.1.3+git20150701/build/flashcache_subr.c:742:7: error: ‘struct bio’ has no member named ‘bi_error’; did you mean ‘bi_iter’? bio->bi_error = error; ^~~~~~~~ bi_iter scripts/Makefile.build:332: recipe for target '/var/lib/dkms/flashcache/3.1.3+git20150701/build/flashcache_subr.o' failed make[2]: *** [/var/lib/dkms/flashcache/3.1.3+git20150701/build/flashcache_subr.o] Error 1 Makefile:1551: recipe for target '_module_/var/lib/dkms/flashcache/3.1.3+git20150701/build' failed make[1]: *** [_module_/var/lib/dkms/flashcache/3.1.3+git20150701/build] Error 2 make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-36-generic' Makefile:35: recipe for target 'modules' failed make: *** [modules] Error 2 OS内核的版本是4.15.0-36。 原因 根据错误提示:bio->bierror ‘struct bio’ has no member named ‘bierror’; 找了4.15的内核源码看看bio的struct的定义, bio是在include/linux/blktypes.h中定义。 https://elixir.bootlin.com/linux/v4.15/source/include/linux/blktypes.h struct bio { struct bio *bi_next; /* request queue link */ struct gendisk *bi_disk; unsigned int bi_opf; /* bottom bits req flags, * top bits REQ_OP. Use * accessors. */ unsigned short bi_flags; /* status, etc and bvec pool number */ unsigned short bi_ioprio; unsigned short bi_write_hint; blk_status_t bi_status; u8 bi_partno; /* Number of segments in this BIO after * physical address coalescing is performed. */ unsigned int bi_phys_segments; /* * To keep track of the max segment size, we account for the * sizes of the first and last mergeable segments in this bio. */ unsigned int bi_seg_front_size; unsigned int bi_seg_back_size; struct bvec_iter bi_iter; atomic_t __bi_remaining; bio_end_io_t *bi_end_io; void *bi_private; #ifdef CONFIG_BLK_CGROUP /* * Optional ioc and css associated with this bio. Put on bio * release. Read comment on top of bio_associate_current(). */ struct io_context *bi_ioc; struct cgroup_subsys_state *bi_css; #ifdef CONFIG_BLK_DEV_THROTTLING_LOW void *bi_cg_private; struct blk_issue_stat bi_issue_stat; #endif #endif union { #if defined(CONFIG_BLK_DEV_INTEGRITY) struct bio_integrity_payload *bi_integrity; /* data integrity */ #endif }; unsigned short bi_vcnt; /* how many bio_vec's */ /* * Everything starting with bi_max_vecs will be preserved by bio_reset() */ unsigned short bi_max_vecs; /* max bvl_vecs we can hold */ atomic_t __bi_cnt; /* pin count */ struct bio_vec *bi_io_vec; /* the actual vec list */ struct bio_set *bi_pool; /* * We can inline a number of vecs at the end of the bio, to avoid * double allocations for a small number of bio_vecs. This member * MUST obviously be kept at the very end of the bio. */ struct bio_vec bi_inline_vecs[0]; }; 里面根本没有bierror。 再翻翻以前版本的代码,在4.12的bio定义里发现了bierror: https://elixir.bootlin.com/linux/v4.12.14/source/include/linux/blk_types.h 应该是从4.13版本内核之后,bio的结构定义发生了变化。 struct bio { struct bio *bi_next; /* request queue link */ struct block_device *bi_bdev; int bi_error; unsigned int bi_opf; /* bottom bits req flags, * top bits REQ_OP. Use * accessors. */ unsigned short bi_flags; /* status, etc and bvec pool number */ unsigned short bi_ioprio; 解决 修改flashcache_subr.c,将 bi_error改成bi_status。 重新编译,ok。 更新: flashcache_subr.c按如下修改,可以兼容以前版本的内核。 void flashcache_bio_endio(struct bio *bio, int error, struct cache_c *dmc, struct timeval *start_time) { if (unlikely(dmc->sysctl_io_latency_hist && start_time != NULL && start_time->tv_sec != 0)) flashcache_record_latency(dmc, start_time); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) bio_endio(bio, bio->bi_size, error); #elif LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0) bio_endio(bio, error); #elif LINUX_VERSION_CODE < KERNEL_VERSION(4,13,0) bio->bi_error = error; bio_endio(bio); #else bio->bi_status = error; bio_endio(bio); #endif }

优秀的个人博客,低调大师

JavaScript实现的水果忍者游戏,支持鼠标操作

智能手机刚刚普及时,水果忍者这款小游戏可谓风靡一时。几年过去了,现在,让我们用纯JavaScript来实现这个水果忍者游戏,就算是为了锤炼我们的JavaScript开发技能吧。 大家可以通过这个链接在线玩一玩(该链接是我的github地址): http://i042416.github.io/FioriODataTestTool2014/WebContent/051_fruitninja.html 用鼠标在网页上划一条横线切正中的“New Game”的水果开始新的游戏: 然后按住鼠标左键不放,在屏幕上划一条线,即可去切您中意的水果了。 玩法和手机上一样简单。 如果大家想定制化水果忍者这个游戏,请从我的github上将水果忍者的源代码clone或者下载到本地,然后自行修改: https://github.com/i042416/FioriODataTestTool2014/ 如果大家想修改在游戏里登场的水果图标,直接把文件夹images/fruit下面的图片文件替换即可。以苹果为例,apple.png代表完整的苹果,apple-1.png和apple-2.png分别代表被切成两半的苹果左半部份和右半部份。 如果想修改游戏音效,请将您喜欢的音效的mp3文件放到sound文件夹下。 我们在玩这个游戏时,如果在JavaScript文件all.js的slice事件处理函数里设置断点,就能观察到JavaScript实现是如何检测水果刀(是否)切到了水果:collide.check: 如果大家觉得只有三次机会玩起来太不过瘾了,那很容易,直接把showLseAt这个函数里的number == 3的判断条件改成比如number == 999, 这样就可以几乎无限制得玩啦! 有的朋友想作弊得更彻底一点,想达到即使切到炸弹,游戏也不结束的效果。 那么只需要修改sliceAt函数,如下图if ( fruit.type != "boom")的红色分支就是切到水果的分支,执行加分和显示水果被切成两半的效果。else的蓝色分支是切到炸弹的分支,我们只需要将蓝色分支内的代码注释掉,游戏就永远不能结束了。不过这样挺无聊的,哈哈! 这个游戏的JavaScript版本的作者:https://github.com/ChineseDron/fruit-ninja 要获取更多Jerry的原创技术文章,请关注公众号"汪子熙"或者扫描下面二维码:

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册