FS-Cache 調研


最近需要使用到 FSCache,今天調研一下FS-Cache,主要記錄一些索引,方便以后查閱:

RedHat 文檔:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/ch-fscache (此文檔講解較為詳細)

內核社區文檔:https://www.kernel.org/doc/Documentation/filesystems/caching/fscache.txt 

FS-Cache: A Network Filesystem Caching Facility:https://people.redhat.com/dhowells/fscache/FS-Cache.pdf 

NFS 相關,請閱讀:https://www.cnblogs.com/xuyaowen/p/NFS_install.html (之前寫的關於nfs安裝相關的內容)

使用NFS緩存減少IO https://blog.csdn.net/luckytanggu/article/details/78476634 (此篇文章較為實踐,我也進行了相同的測試,顯示fscache起作用,大家可以參考) 

關於linux內核中對文件系統的cache大家可以參考此鏈接:https://www.kernel.org/doc/Documentation/filesystems/caching/ (內核文件系統cache詳細文檔)

FS-Cache 配置文件解析:

###############################################################################
#
# Copyright (C) 2006,2010 Red Hat, Inc. All Rights Reserved.
# Written by David Howells (dhowells@redhat.com)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version
# 2 of the License, or (at your option) any later version.
#
###############################################################################

dir /var/cache/fscache  # 自定義緩存目錄
tag mycache             # 標簽,用於區分多個緩存
brun 10%                # 剩余空間大於這個設置值時,自動進行緩存
bcull 7%                # 剩余空間大於這個設置值時,開始自動刪除使用頻率最低的緩存
bstop 3%                # 剩余空間小於這個設置值時,緩存功能關閉

# 開頭的參數則是按照文件數來計算%, 其原理與根據block數(剩余空間)計算是一樣的。
frun 10%
fcull 7%
fstop 3%

# Assuming you're using SELinux with the default security policy included in
# this package
secctx system_u:system_r:cachefiles_kernel_t:s0
brun N% (percentage of blocks) , frun N% (percentage of files)
If the amount of free space and the number of available files in the cache rises above both these limits, then culling is turned off.
bcull N% (percentage of blocks), fcull N% (percentage of files)
If the amount of available space or the number of files in the cache falls below either of these limits, then culling is started.
bstop N% (percentage of blocks), fstop N% (percentage of files)
If the amount of available space or the number of available files in the cache falls below either of these limits, then no further allocation of disk space or files is permitted until culling has raised things above these limits again.
cachefiles參數說明

三對參數應該滿足的關系:

0 ≤ bstop < bcull < brun < 100
0 ≤ fstop < fcull < frun < 100 

注意:Culling depends on both bxxx and fxxx pairs simultaneously; they can not be treated separately.

其他參考地址:/usr/share/doc/kernel-doc-version/Documentation/filesystems/caching/fscache.txt 

關於nfs fsc 選項的說明(fsc選項):

閱讀摘要:

  • yum install cachefilesd; 
  • 掛載命令:直接mount服務端共享的目錄到本地的/mnt目錄,必須使用-o fsc參數選項;
  • All access to files under /mount/point will go through the cache, unless the file is opened for direct I/O or writing; 
  • Opening a file from a shared file system for direct I/O automatically bypasses the cache. This is because this type of access must be direct to the server.
  • To avoid coherency management problems between superblocks, all NFS superblocks that wish to cache data have unique Level 2 keys. Normally, two NFS mounts with same source volume and options share a superblock, and thus share the caching, even if they mount different directories within that volume.

  • Opening a file from a shared file system for writing will not work on NFS version 2 and 3.  因為沒有足夠的維持並發寫的一致性信息;
  • Furthermore, this release of FS-Cache only caches regular NFS files. FS-Cache will not cache directories, symlinks, device files, FIFOs and sockets. 其只對文件數據進行cache的操作。

保持更新,資源來源自網絡,此文章主要是用來索引,如果您有相關問題,請關注cnblogs.com/xuyaowen; 

# 更新 12.3.2019 

  • cachefiles 為 fscache的后端;cachefs也是 fscache的后端;
  • cachefiles 和 fscache都集成到了linux 內核中;作為單獨的模塊;好像 cachefs沒有繼承到內核之中,說明cachefiles較為常用,已經合並到內核之中,說明該功能模塊,較為穩定。
  • 對應的linux內核模塊為 cachefiles.ko 和 fscache.ko,在 /lib/modules/內核版本/kernel/fs/之中;
  • 同理,我們在相應的內核模塊目錄中,可以查看fuse的內核模塊:cuse.ko; 使用modprobe -v 可以加載;rmmod和inmod 可以卸載和安裝內核模塊;具體其他操作,可以查找相應的手冊;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM