ZIL (ZFS intent log) zil.c

简介:
ZIL或称SLOG, 被用于提升ZFS系统的离散fsync性能.
类似数据库的redo log或wal.
注意
1. 每个dataset对应一个zil, 也就是说一个zpool有多个zfs的话, 如果有log设备, 那么在log设备中实际上包含了多个ZIL entry.
数据写入ZIL后(fsync), 即使服务器异常, 也可以用于恢复文件系统.
2. 并不是每一笔FSYNC都会用到ZIL, 只有小于2* zil_slog_limit  的commit操作才会用到. 如果你的zil 块设备够强的话, 可以调大伙调到UINT64_MAX,  那么就不检测了, 所有的commit都用上zil设备. 一般不需要调整
/*
 * The zfs intent log (ZIL) saves transaction records of system calls
 * that change the file system in memory with enough information
 * to be able to replay them. These are stored in memory until
 * either the DMU transaction group (txg) commits them to the stable pool
 * and they can be discarded, or they are flushed to the stable log
 * (also in the pool) due to a fsync, O_DSYNC or other synchronous
 * requirement. In the event of a panic or power fail then those log
 * records (transactions) are replayed.
 *
 * There is one ZIL per file system. Its on-disk (pool) format consists
 * of 3 parts:
 *
 *      - ZIL header
 *      - ZIL blocks
 *      - ZIL records
 *
 * A log record holds a system call transaction. Log blocks can
 * hold many log records and the blocks are chained together.
 * Each ZIL block contains a block pointer (blkptr_t) to the next
 * ZIL block in the chain. The ZIL header points to the first
 * block in the chain. Note there is not a fixed place in the pool
 * to hold blocks. They are dynamically allocated and freed as
 * needed from the blocks available. Figure X shows the ZIL structure:
 */

可调参数, 
/*
 * This global ZIL switch affects all pools
 */
int zil_replay_disable = 0;    /* disable intent logging replay */

/*
 * Tunable parameter for debugging or performance analysis.  Setting
 * zfs_nocacheflush will cause corruption on power loss if a volatile
 * out-of-order write cache is enabled.
 */
int zfs_nocacheflush = 0;


/*
 * Define a limited set of intent log block sizes.
 * These must be a multiple of 4KB. Note only the amount used (again
 * aligned to 4KB) actually gets written. However, we can't always just
 * allocate SPA_MAXBLOCKSIZE as the slog space could be exhausted.
 */
uint64_t zil_block_buckets[] = {
    4096,               /* non TX_WRITE */
    8192+4096,          /* data base */
    32*1024 + 4096,     /* NFS writes */
    UINT64_MAX
};

/*
 * Use the slog as long as the current commit size is less than the
 * limit or the total list size is less than 2X the limit.  Limit
 * checking is disabled by setting zil_slog_limit to UINT64_MAX.
 */
unsigned long zil_slog_limit = 1024 * 1024;
#define USE_SLOG(zilog) (((zilog)->zl_cur_used < zil_slog_limit) || \
        ((zilog)->zl_itx_list_sz < (zil_slog_limit << 1)))


#if defined(_KERNEL) && defined(HAVE_SPL)
module_param(zil_replay_disable, int, 0644);
MODULE_PARM_DESC(zil_replay_disable, "Disable intent logging replay");

module_param(zfs_nocacheflush, int, 0644);
MODULE_PARM_DESC(zfs_nocacheflush, "Disable cache flushes");

module_param(zil_slog_limit, ulong, 0644);
MODULE_PARM_DESC(zil_slog_limit, "Max commit bytes to separate log device");
#endif

相关实践学习
【涂鸦即艺术】基于云应用开发平台CAP部署AI实时生图绘板
【涂鸦即艺术】基于云应用开发平台CAP部署AI实时生图绘板
目录
相关文章
|
安全
选择最佳供应商:ERP系统的供应商选择与评估方法论
选择最佳供应商:ERP系统的供应商选择与评估方法论
1643 0
|
Linux 编译器 vr&ar
linux交叉编译一些常用依赖库util-linux,zlib,sqlite3,eudev ,openssl,libpng,glibc
linux交叉编译一些常用依赖库util-linux,zlib,sqlite3,eudev ,openssl,libpng,glibc
783 1
|
存储 Kubernetes Cloud Native
阿里巴巴开源容器镜像加速技术
近日阿里巴巴开源了其云原生容器镜像加速技术,其推出的overlaybd镜像格式,相比于传统的分层tar包文件格式,实现了基于网络的按需读取,从而使得容器可以快速启动。
|
自然语言处理 算法 搜索推荐
NLP中TF-IDF算法
TF-IDF(词频-逆文档频率)是一种用于信息检索与数据挖掘的加权技术,通过评估词语在文档中的重要性来过滤常见词语,保留关键信息。本文介绍了TF-IDF的基本概念、公式及其在Python、NLTK、Sklearn和jieba中的实现方法,并讨论了其优缺点。TF-IWF是TF-IDF的优化版本,通过改进权重计算提高精度。
1107 1
|
算法 Linux 开发者
深入探究Linux内核中的内存管理机制
本文旨在对Linux操作系统的内存管理机制进行深入分析,探讨其如何通过高效的内存分配和回收策略来优化系统性能。文章将详细介绍Linux内核中内存管理的关键技术点,包括物理内存与虚拟内存的映射、页面置换算法、以及内存碎片的处理方法等。通过对这些技术点的解析,本文旨在为读者提供一个清晰的Linux内存管理框架,帮助理解其在现代计算环境中的重要性和应用。
|
NoSQL 安全 Java
分布式锁实现原理与最佳实践
在单体的应用开发场景中涉及并发同步时,大家往往采用Synchronized(同步)或同一个JVM内Lock机制来解决多线程间的同步问题。而在分布式集群工作的开发场景中,就需要一种更加高级的锁机制来处理跨机器的进程之间的数据同步问题,这种跨机器的锁就是分布式锁。接下来本文将为大家分享分布式锁的最佳实践。
|
机器学习/深度学习 人工智能 自然语言处理
Tokenformer:基于参数标记化的高效可扩展Transformer架构
本文是对发表于arXiv的论文 "TOKENFORMER: RETHINKING TRANSFORMER SCALING WITH TOKENIZED MODEL PARAMETERS" 的深入解读与扩展分析。主要探讨了一种革新性的Transformer架构设计方案,该方案通过参数标记化实现了模型的高效扩展和计算优化。
608 0
|
消息中间件 NoSQL 安全
(转)Spring Boot加载 不同位置的 application.properties配置文件顺序规则
这篇文章介绍了Spring Boot加载配置文件的顺序规则,包括不同位置的application.properties文件的加载优先级,以及如何通过命令行参数或环境变量来指定配置文件的名称和位置。
743 0
RZ
|
存储 缓存 弹性计算
张弛有道,块存储极致的创盘弹性能力
前言“鸿蒙初判陶镕铁,大禹神人亲所设。湖海江河浅共深,曾将此棒知之切。开山治水太平时,流落东洋镇海阙。日久年深放彩霞,能消能长能光洁。老孙有分取将来,变化无方随口诀。要大弥于宇宙间,要小却似针儿节。棒名如意号金箍,天上人间称一绝。重该一万三千五百斤,或粗或细能生灭。也曾助我闹天宫,也曾随我攻地阙。伏虎降龙处处通,炼魔荡怪方方彻。举头一指太阳昏,天地鬼神皆胆怯。混沌仙传到至今,原来不是凡间铁。”  
RZ
1044 1