我对 XFS 文件系统中可以设置的最大元数据日志大小有点困惑。我到处都发现了相同的信息:最大大小为 64K 块或 128M,以较小者为准。使用标准 4K 块大小,则最大元数据日志大小 = 最小 (256M, 128M) = 128M。这还算合理,但当我尝试创建元数据日志大于 128M 的文件系统时,没有出现任何错误,xfs_info 命令的输出证实了这一点:
ingrid:/home/engineer # mkfs.xfs -f -l size=1024m /dev/md0
meta-data=/dev/md0 isize=256 agcount=16, agsize=2359280 blks
= sectsz=512 attr=2
data = bsize=4096 blocks=37748480, imaxpct=25
= sunit=16 swidth=64 blks
naming =version 2 bsize=4096 ascii-ci=0
log =internal log bsize=4096 blocks=262144, version=2
= sectsz=512 sunit=16 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
内部日志版本 2 中是否有任何新功能可以覆盖 128M 的限制?
ingrid:/home/engineer # uname -a
Linux sles11-064-VM-esocl00-i1r0-mysql 2.6.32.19-0.3-default #1 SMP 2010-09-17 20:28:21 +0200 x86_64 x86_64 x86_64 GNU/Linux
# rpm -qa | grep -i xfs
xfsprogs-3.1.1-0.1.36
xfsdump-3.0.4-0.1.35
非常感谢您能给我的任何建议。
答案1
解决了。我不得不查看 mkfs.xfs 的源代码。首先我安装了:
xfsprogs-3.1.1-0.1.36.src.rpm
让我们浏览一下 /usr/src/packages:
# ls -ltr | grep xfsprogs-3.1.1 -rw-r--r-- 1 根 根 1072077 2010-02-03 10:33 xfsprogs-3.1.1.tar.bz2
解压并列出:
# cd xfsprogs-3.1.1 # ls aclocal.m4 配置数据库估计 growfs io libxcmd logprint Makefile mkfs README rtcp config.guess configure.in debian fsck include libdisk libxfs ltmain.sh man po release.sh 版本 config.sub 复制 doc fsr install-sh libhandle libxlog m4 mdrestore 配额修复
因此,我们对 mkfs.xfs 感兴趣:
# vi mkfs/xfs_mkfs.c
void validate_log_size(__uint64_t logblocks, int blocklog, int min_logblocks)
{
if (logblocks < min_logblocks) {
fprintf(stderr,
_("log size %lld blocks too small, minimum size is %d blocks\n"),
(long long)logblocks, min_logblocks);
usage();
}
if (logblocks > XFS_MAX_LOG_BLOCKS) {
fprintf(stderr,
_("log size %lld blocks too large, maximum size is %lld blocks\n"),
(long long)logblocks, XFS_MAX_LOG_BLOCKS);
usage();
}
if ((logblocks << blocklog) > XFS_MAX_LOG_BYTES) {
fprintf(stderr,
_("log size %lld bytes too large, maximum size is %lld bytes\n"),
(long long)(logblocks << blocklog), XFS_MAX_LOG_BYTES);
usage();
}
}
元数据日志的限制由变量 XFS_MAX_LOG_BLOCKS 和 XFS_MAX_LOG_BYTES 设置。这些变量在 include/xfs_fs.h 中定义:
#define XFS_MIN_AG_BLOCKS 64
#define XFS_MIN_LOG_BLOCKS 512ULL
#define XFS_MAX_LOG_BLOCKS (1024 * 1024ULL)
#define XFS_MIN_LOG_BYTES (10 * 1024 * 1024ULL)
/* keep the maximum size under 2^31 by a small amount */
#define XFS_MAX_LOG_BYTES \
((2 * 1024 * 1024 * 1024ULL) - XFS_MIN_LOG_BYTES)
因此,对于此版本的 XFS,我们有:
XFS_MAX_LOG_BLOCKS = 1048576 <<<
XFS_MIN_LOG_BYTES = 10485760
XFS_MAX_LOG_BYTES = (2*1024*1024*1024)-(10485760) = 2136997888 = 2038M <<<<
使用 4 KB 的块大小(标准):
1048576 * 4096 = 4294967296 = 4096M
我认为日志的最大大小是 XFS_MAX_LOG_BYTES 和 XFS_MAX_LOG_BLOCKS * block_size 之间的最小值。事实上:
# mkfs.xfs -f -l size=2039m /dev/md0
log size 2138046464 bytes too large, maximum size is 2136997888 bytes
Usage: mkfs.xfs
/* blocksize */ [-b log=n|size=num]
/* data subvol */ [-d agcount=n,agsize=n,file,name=xxx,size=num,
(sunit=value,swidth=value|su=num,sw=num),
sectlog=n|sectsize=num
/* inode size */ [-i log=n|perblock=n|size=num,maxpct=n,attr=0|1|2]
/* log subvol */ [-l agnum=n,internal,size=num,logdev=xxx,version=n
sunit=value|su=num,sectlog=n|sectsize=num,
lazy-count=0|1]
/* label */ [-L label (maximum 12 characters)]
/* naming */ [-n log=n|size=num,version=2|ci]
/* prototype file */ [-p fname]
/* quiet */ [-q]
/* realtime subvol */ [-r extsize=num,size=num,rtdev=xxx]
/* sectorsize */ [-s log=n|size=num]
/* version */ [-V]
devicename
<devicename> is required unless -d name=xxx is given.
<num> is xxx (bytes), xxxs (sectors), xxxb (fs blocks), xxxk (xxx KiB),
xxxm (xxx MiB), xxxg (xxx GiB), xxxt (xxx TiB) or xxxp (xxx PiB).
<value> is xxx (512 byte blocks).
希望这可以帮助!