xfsでフォーマットした大容量HDD上のデータを32bitバイナリで読むと
"Value too large for defined data type"エラーになった
# yum install gcc
# yum install glibc-devel.i686
# gcc -m32 -Wall -o stat32 stat.c
# ./stat32 /data/dummy.dat
stat: Value too large for defined data type
# ll -i /data/dummy.dat
138236415364 -rw-r--r-- 1 nfsnobody nfsnobody 3 Dec 10 15:07 dummy.dat
↑ -i は inode
// man 2 statより
# include <sys/types.h>
# include <sys/stat.h>
# include <time.h>
# include <stdio.h>
# include <stdlib.h>
int
main(int argc, char *argv[])
{
struct stat sb;
if (argc != 2) {
fprintf(stderr, "Usage: %s <pathname>\n", argv[0]);
exit(EXIT_FAILURE);
}
if (stat(argv[1], &sb) == -1) {
perror("stat");
exit(EXIT_FAILURE);
}
printf("I-node number: %ld\n", (long) sb.st_ino);
exit(EXIT_SUCCESS);
}
原因
inodeが32bitを超えた値なのでオーバーフローしてエラーしているという訳。
- xfsでinode64オプションを使っていると起こる
- _FILE_OFFSET_BITS=64 を付けて再コンパイルする or
- nfsで公開している場合はkernelオプションにnfs.enable_ino64=0を入れる
以下のリンクが詳しい。
大容量XFSパーティションと64ビットiノード - ブログ - ワルブリックス株式会社
http://www.walbrix.com/jp/blog/2013-03-xfs-inode64.html
The 64 bit inode problem
http://www.tcm.phy.cam.ac.uk/sw/inodes64.html
Maximum Filesystem Size? (Page 1) — Software — chumbysphere forum
http://forum.chumby.com/viewtopic.php?id=9482
Inode numbers
For file systems above 1T with 256 byte inodes, or above 2T with 512 byte inodes, XFS inode
numbers may exceed 2^32. These large inode numbers will cause 32-bit stat calls to fail with
EOVERFLOW. In general, applications should properly handle these larger inode numbers but, if
necessary XFS may be mounted with -o inode32 to enforce inode nmbers below 2^32.
<
Red Hat Customer Portal
https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/6/html/Performance_Tuning_Guide/s-storage-xfs.html
ファイルシステムが NFS 経由でエクスポートされ、レガシーの 32 ビット NFS クライアントがそのファイルシステムへのアクセス
を必要としている場合を除いて、マルチテラバイトのファイルシステムには inode64 マウントオプションが強く推奨されます。
EKBO: XFS inode64 オプションの罠
http://ekbo.blogspot.jp/2012/01/xfs-inode64.html
32bit LinuxでXFSを使うとiノード絡みのバグに遭う可能性がある - 旧ID:itiriのブログ
http://ubuntu.hatenablog.jp/entry/20130605/1370438443