首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Flash >

linux内核源码翻阅之facebook硬盘加速flashcache之五

2013-09-18 
linux内核源码阅读之facebook硬盘加速flashcache之五正常流程到flashcache_map的1623行或1625行,按顺序先

linux内核源码阅读之facebook硬盘加速flashcache之五

正常流程到flashcache_map的1623行或1625行,按顺序先看读流程:

113void 114flashcache_io_callback(unsigned long error, void *context)115{116     struct kcached_job *job = (struct kcached_job *) context;117     struct cache_c *dmc = job->dmc;118     struct bio *bio;119     unsigned long flags;120     int index = job->index;121     struct cacheblock *cacheblk = &dmc->cache[index];122123     VERIFY(index != -1);          124     bio = job->bio;125     VERIFY(bio != NULL);126     if (error)127          DMERR("flashcache_io_callback: io error %ld block %lu action %d", 128                error, job->disk.sector, job->action);129     job->error = error;130     switch (job->action) {131     case READDISK:132          DPRINTK("flashcache_io_callback: READDISK  %d",133               index);134          spin_lock_irqsave(&dmc->cache_spin_lock, flags);135          if (unlikely(sysctl_flashcache_error_inject & READDISK_ERROR)) {136               job->error = error = -EIO;137               sysctl_flashcache_error_inject &= ~READDISK_ERROR;138          }139          VERIFY(cacheblk->cache_state & DISKREADINPROG);140          spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);141          if (likely(error == 0)) {142               /* Kick off the write to the cache */143               job->action = READFILL;144               flashcache_enqueue_readfill(dmc, job);145               return;146          } else {147               dmc->disk_read_errors++;               148               flashcache_bio_endio(bio, error);149          }150          break;          174     case READFILL:175          DPRINTK("flashcache_io_callback: READFILL %d",176               index);177          spin_lock_irqsave(&dmc->cache_spin_lock, flags);178          if (unlikely(sysctl_flashcache_error_inject & READFILL_ERROR)) {179               job->error = error = -EIO;180               sysctl_flashcache_error_inject &= ~READFILL_ERROR;181          }182          if (unlikely(error))183               dmc->ssd_write_errors++;184          VERIFY(cacheblk->cache_state & DISKREADINPROG);185          spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);186          flashcache_bio_endio(bio, error);187          break;

归纳一下读不命中的流程:1)创建一个kcached_job,直接下发到磁盘2)读磁盘返回到flashcache_io_callback,到131行下发READFILL,将读出来的数据写到缓存中3)写缓存成功并返回到flashcache_io_callback,到174行将数据返回给上层到这里已经将读流程简单过了一遍,下一个小节介绍写流程。

热点排行