linux内核源码阅读之facebook硬盘加速flashcache之四
1581/*
1582 * Decide the mapping and perform necessary cache operations for a bio request.
1583 */
1584int
1585flashcache_map(struct dm_target *ti, struct bio *bio,
1586 union map_info *map_context)
1587{
1588 struct cache_c *dmc = (struct cache_c *) ti->private;
1589 int sectors = to_sector(bio->bi_size);
1590 int queued;
1591
1592 if (sectors <= 32)
1593 size_hist[sectors]++;
1594
1595 if (bio_barrier(bio))
1596 return -EOPNOTSUPP;
1597
1598 VERIFY(to_sector(bio->bi_size) <= dmc->block_size);
1599
1600 if (bio_data_dir(bio) == READ)
1601 dmc->reads++;
1602 else
1603 dmc->writes++;
1604
1605 spin_lock_irq(&dmc->cache_spin_lock);
1606 if (unlikely(sysctl_pid_do_expiry &&
1607 (dmc->whitelist_head || dmc->blacklist_head)))
1608 flashcache_pid_expiry_all_locked(dmc);
1609 if ((to_sector(bio->bi_size) != dmc->block_size) ||
1610 (bio_data_dir(bio) == WRITE && flashcache_uncacheable(dmc))) {
1611 queued = flashcache_inval_blocks(dmc, bio);
1612 spin_unlock_irq(&dmc->cache_spin_lock);
1613 if (queued) {
1614 if (unlikely(queued < 0))
1615 flashcache_bio_endio(bio, -EIO);
1616 } else {
1617 /* Start uncached IO */
1618 flashcache_start_uncached_io(dmc, bio);
1619 }
1620 } else {
1621 spin_unlock_irq(&dmc->cache_spin_lock);
1622 if (bio_data_dir(bio) == READ)
1623 flashcache_read(dmc, bio);
1624 else
1625 flashcache_write(dmc, bio);
1626 }
1627 return DM_MAPIO_SUBMITTED;
1628}
1350 ti->split_io = dmc->block_size;
1351 ti->private = dmc;
571int
572flashcache_dm_io_sync_vm(struct cache_c *dmc, struct dm_io_region *where, int rw, void *data)
573{
574 unsigned long error_bits = 0;
575 int error;
576 struct dm_io_request io_req = {
577 .bi_rw = rw,
578 .mem.type = DM_IO_VMA,
579 .mem.ptr.vma = data,
580 .mem.offset = 0,
581 .notify.fn = NULL,
582 .client = dmc->io_client,
583 };
584
585 error = dm_io(&io_req, 1, where, &error_bits);
586 if (error)
587 return error;
588 if (error_bits)
589 return error_bits;
590 return 0;
591}
720 header = (struct flash_superblock *)vmalloc(512);
721 if (!header) {
722 DMERR("flashcache_md_create: Unable to allocate sector");
723 return 1;
724 }
725 where.bdev = dmc->cache_dev->bdev;
726 where.sector = 0;
727 where.count = 1;
728#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
729 error = flashcache_dm_io_sync_vm(&where, READ, header);
730#else
731 error = flashcache_dm_io_sync_vm(dmc, &where, READ, header);
732#endif
unsigned num_dests, struct dm_io_region *dests,
unsigned flags, dm_kcopyd_notify_fn fn, void *context);
1208 r = dm_kcopyd_client_create(FLASHCACHE_COPY_PAGES, &dmc->kcp_client);
1209 if (r) {
1210 ti->error = "Failed to initialize kcopyd client\n";
1211 dm_io_client_destroy(dmc->io_client);
1212 goto bad3;
1213 }
struct block_device *bdev;
sector_t sector;
sector_t count; /* If this is zero the region is ignored. */
};
linux内核源码阅读之facebook硬盘加速flashcache之四的更多相关文章
- linux内核源码阅读之facebook硬盘加速flashcache之八
前面我们的分析中重点关注正常的数据流程,这一小节关注如果有异常,那么流程是怎么走完的呢? 1)创建新任务时kcached_job申请不到 2)读写命中时cache块为忙 3)系统关机时处理,系统开机时 ...
- linux内核源码阅读之facebook硬盘加速flashcache之三
上一节讲到在刷缓存的时候会调用new_kcahed_job创建kcached_job,由此我们也可以看到cache数据块与磁盘数据的对应关系.上一篇:http://blog.csdn.net/lium ...
- linux内核源码阅读之facebook硬盘加速flashcache之二
flashcache数据结构都在flashcache.h文件中,但在看数据结构之前,需要先过一遍flashcache是什么,要完成哪些功能?如果是自己设计这样一个系统的话,大概要怎么设计. 前面讲过, ...
- linux内核源码阅读之facebook硬盘加速flashcache之六
其实到目前为止,如果对读流程已经能轻松地看懂了,那么写流程不需要太多脑细胞.我觉得再写下去没有太大的必要了,后面想想为了保持flashcache完整性,还是写出来吧.接着到写流程: 1530stati ...
- linux内核源码阅读之facebook硬盘加速flashcache之五
正常流程到flashcache_map的1623行或1625行,按顺序先看读流程: 1221static void 1222flashcache_read(struct cache_c *dmc, s ...
- linux内核源码阅读之facebook硬盘加速利器flashcache
从来没有写过源码阅读,这种感觉越来越强烈,虽然劣于文笔,但还是下定决心认真写一回. 源代码下载请参见上一篇flashcache之我见 http://blog.csdn.net/liumangxiong ...
- ubuntu下linux内核源码阅读工具和调试方法总结
http://blog.chinaunix.net/uid-20940095-id-66148.html 一 linux内核源码阅读工具 windows下当然首选source insight, 但是l ...
- Linux内核源码阅读记录一之分析存储在不同段中的函数调用过程
在写驱动的过程中,对于入口函数与出口函数我们会用一句话来修饰他们:module_init与module_exit,那会什么经过修饰后,内核就能狗调用我们编写的入口函数与出口函数呢?下面就来分析内核调用 ...
- Linux内核源码分析
Linux源码下载: https://www.kernel.org/ https://git.kernel.org/ Linux内核源码阅读以及工具(转): https://blog.csdn.net ...
随机推荐
- IE兼容性bug汇总
1.IE6的双边距BUG. 发生条件:如果有元素是浮动元素,则该元素与它的父元素(一般是一个容器)直接相接触(中间不能隔着其他元素)的左或右的边距就会产生双倍边距,也意味着相邻的兄弟元素不可能会产生双 ...
- linux 开通ftp账号
1.更新yum源 首先需要更新系统的yum源,便捷工具下载地址:http://help.aliyun.com/manual?spm=0.0.0.0.zJ3dBU&helpId=1692 2.安 ...
- js判断终端是手机还是电脑
$(function(){ function browserRedirect() { var sUserAgent= navigator.userAgent.toLowerCase(); var bI ...
- dijkstra 优先队列最短路模板
;;*maxn];,):id(a),dist(b){} )); ;i<=n;i++)dist[i]=inf; dist[st]=; ;i= ...
- SPFile上传文件到文档库
, dataLen); SPSite sps = SPControl.GetContextSite(Context); sps.AllowUnsafeUpd ...
- Ajax或JS动态添加的元素,Jquery效果不起作用
问题: 最近在做一个Ajax分页的功能,遇到一个问题 一开始jquery效果是可用的,但是,ajax执行一次之后,jquery效果就无效了. 解决办法: 可以添加live事件来解决 W3C关于live ...
- android之PackageManager简介
PackageManager相关 本类API是对所有基于加载信息的数据结构的封装,包括以下功能: 安装,卸载应用查询permission相关信息 查询Application相关信息(applicati ...
- iOS 使用UILocalizedIndexedCollation实现区域索引标题(Section Indexed Title)即拼音排序
UITableView在行数相当多的时候,给人的感觉是非常笨重的.通常为了方便用户使用,采用的方法有:搜索框.按层级展示.区域索引标题. 前两种就不用介绍了,此文就介绍区域索引标题的实现. 区域索引标 ...
- [原创] 小而美 | Mac上鲜为人知,但极大提升效率的小工具
热爱收集实用又好用的软件,工具类软件不在多,发挥作用,提高效率最重要~推荐几个压箱底的藏货 一.Noizio -自然而然的白噪声,专注工作 Noizio是一款OS X 下的白噪音应用,可以让自己觉着是 ...
- Lc.exe已退出 代码为-1问题解决方法
对于用vs作为开发工具的同学来说,可能常常会碰到“Lc.exe已退出 代码为-1”的问题,造成这个结果的一般是因为加入了第三方的插件程序造成的,今天一一讲解如何解决. 工具/原料 vs各版本开发工具 ...