Xfs文件系统磁盘布局

目录

一,CentOS下Xfs文件系统的安装

二,准备工作

三,AG结构

四,AG超级块

五,AG空闲磁盘空间管理

六,ABTB的B+tree

七,ABTB/ABTC的节点块管理

八,inode节点管理

九,inode节点结构

十,普通文件数据结构(extents)

十一,目录文件数据结构

十二,总结


一,CentOS下Xfs文件系统的安装

Xfs早已经合到了Linux内核主线,所以在Linux下对Xfs的使用比较简单,但是CentOS默认并没有安装Xfs的相关用户层工具,所以这里记录一下,后续将对Xfs做更深层次的研究。
在VM虚拟机里先添加了一块128G的硬盘,然后创建了一个分区:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

[root@localhost ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 16709.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-16709, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-16709, default 16709):

Using default value 16709

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

安装Xfs的用户层工具,然后试试:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

[root@localhost ~]# yum install xfsprogs kmod-xfs

[root@localhost ~]# mkfs.xfs -f /dev/sdb1

meta-data=/dev/sdb1              isize=256    agcount=16, agsize=2097109 blks

         =                       sectsz=512   attr=0

data     =                       bsize=4096   blocks=33553744, imaxpct=25

         =                       sunit=0      swidth=0 blks, unwritten=1

naming   =version 2              bsize=4096 

log      =internal log           bsize=4096   blocks=16383, version=1

         =                       sectsz=512   sunit=0 blks, lazy-count=0

realtime =none                   extsz=4096   blocks=0, rtextents=0

[root@localhost ~]# mkdir /root/xfs/

[root@localhost ~]# mount /dev/sdb1 /root/xfs/

[root@localhost xfs]# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                     129125916   9418916 113041992   8% /

/dev/sda1               101086     32735     63132  35% /boot

tmpfs                   510824         0    510824   0% /dev/shm

/dev/sdb1            134149444     33312 134116132   1% /root/xfs

[root@localhost ~]# umount xfs

[root@localhost ~]# time mkfs.xfs -f /dev/sdb1

meta-data=/dev/sdb1              isize=256    agcount=16, agsize=2097109 blks

         =                       sectsz=512   attr=0

data     =                       bsize=4096   blocks=33553744, imaxpct=25

         =                       sunit=0      swidth=0 blks, unwritten=1

naming   =version 2              bsize=4096 

log      =internal log           bsize=4096   blocks=16383, version=1

         =                       sectsz=512   sunit=0 blks, lazy-count=0

realtime =none                   extsz=4096   blocks=0, rtextents=0

real    0m0.145s

user    0m0.008s

sys 0m0.103s

二,准备工作

对于Xfs文件系统的磁盘布局分析内容会比较多,所以这将是一系列的文章,争取在元旦三天内写完,由于对于Xfs系统的接触刚刚开始,看其代码和文档也就是前几天的事情,所以由于这些文章都只是我目前的理解,如果有错,后续会进行修正。这是本系列第一篇文章,主要介绍准备工作。
首先是Linux系统,要确保内核的XFS选项是打开的:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

[root@localhost ~]# uname -a

Linux localhost.localdomain 2.6.36.1 #1 SMP Fri Dec 30 05:00:57 EST 2011 i686 i686 i386 GNU/Linux

[root@localhost ~]# file /bin/ls

/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped

[root@localhost ~]# cat /etc/issue

CentOS Linux release 6.0 (Final)

Kernel \r on an \m

[root@localhost ~]# cat /usr/src/linux-2.6.36.1/.config | grep XFS

CONFIG_XFS_FS=m

CONFIG_XFS_QUOTA=y

CONFIG_XFS_POSIX_ACL=y

CONFIG_XFS_RT=y

CONFIG_XFS_DEBUG=y

# CONFIG_VXFS_FS is not set

其次是Xfs应用层工具:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

[root@localhost ~]# mkdir -p /home/lenky/xfs

[root@localhost ~]# cd !$

cd /home/lenky/xfs

[root@localhost xfs]# git clone git://oss.sgi.com/xfs/cmds/xfsprogs

Initialized empty Git repository in /home/lenky/xfs/xfsprogs/.git/

...

Resolving deltas: 100% (8803/8803), done.

[root@localhost xfs]# ls

xfsprogs

[root@localhost xfs]# cd xfsprogs

[root@localhost xfsprogs]# cat VERSION

#

# This file is used by configure to get version information

#

PKG_MAJOR=3

PKG_MINOR=1

PKG_REVISION=7

PKG_BUILD=1

[root@localhost xfsprogs]# make

./configure $LOCAL_CONFIGURE_OPTIONS

checking build system type... i686-pc-linux-gnu

...

Building debian

[root@localhost xfsprogs]# ls

aclocal.m4      config.sub    debian    growfs      libhandle  logprint   mdrestore  release.sh

autom4te.cache  configure     doc       include     libtool    ltmain.sh  mkfs       repair

config.guess    configure.in  estimate  install-sh  libxcmd    m4         po         rtcp

config.log      copy          fsck      io          libxfs     Makefile   quota      VERSION

config.status   db            fsr       libdisk     libxlog    man        README

[root@localhost xfsprogs]# make install

...

接着是磁盘,在虚拟机上再挂一个4G的磁盘,然后建立一个分区,并挂载到系统上:

Xfs文件系统磁盘布局_第1张图片

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

[root@localhost xfsprogs]# fdisk -l

Disk /dev/sda: 68.7 GB, 68719476736 bytes

255 heads, 63 sectors/track, 8354 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0002de08

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          64      512000   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              64        8355    66595840   8e  Linux LVM

Disk /dev/sdb: 4294 MB, 4294967296 bytes

255 heads, 63 sectors/track, 522 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

...

[root@localhost xfsprogs]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0xaab0b8ba.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

         switch off the mode (command 'c') and change display units to

         sectors (command 'u').

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-522, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522):

Using default value 522

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@localhost xfsprogs]# fdisk -l

Disk /dev/sda: 68.7 GB, 68719476736 bytes

255 heads, 63 sectors/track, 8354 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0002de08

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          64      512000   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              64        8355    66595840   8e  Linux LVM

Disk /dev/sdb: 4294 MB, 4294967296 bytes

255 heads, 63 sectors/track, 522 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xaab0b8ba

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         522     4192933+  83  Linux

Disk /dev/mapper/VolGroup-lv_root: 32.8 GB, 32753319936 bytes

255 heads, 63 sectors/track, 3982 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

...

[root@localhost xfsprogs]# mkdir -p /home/lenky/xfs/sdb1

[root@localhost xfsprogs]# mount -t xfs /dev/sdb1 !$

mount -t xfs /dev/sdb1 /home/lenky/xfs/sdb1

[root@localhost xfsprogs]# cp -r /usr/src/linux-2.6.36.1 !$

cp -fr /usr/src/linux-2.6.36.1 /home/lenky/xfs/sdb1

^C

需要说明的是Xfs文件系统磁盘布局受很多mount参数的影响,而这里全部采用默认值,也就是最主要的两个参数sector为512字节,block为4096字节,当然,磁盘大小为4G。先简单测试一下,OK,一切搞定,只等开始分析:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

[root@localhost ~]# hexdump -C -s 0 -n 512 /dev/sdb1

00000000  58 46 53 42 00 00 10 00  00 00 00 00 00 0f fe a9  |XFSB............|

00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00000020  d0 08 f5 d2 7b 96 4a e0  b6 b5 3b 3e cd 76 53 6b  |....{.J...;>.vSk|

00000030  00 00 00 00 00 08 00 04  00 00 00 00 00 00 00 80  |................|

00000040  00 00 00 00 00 00 00 81  00 00 00 00 00 00 00 82  |................|

00000050  00 00 00 01 00 03 ff ab  00 00 00 04 00 00 00 00  |................|

00000060  00 00 0a 00 b4 a4 02 00  01 00 00 10 00 00 00 00  |................|

00000070  00 00 00 00 00 00 00 00  0c 09 08 04 12 00 00 19  |................|

00000080  00 00 00 00 00 00 00 40  00 00 00 00 00 00 00 3d  |.......@.......=|

00000090  00 00 00 00 00 0f f4 95  00 00 00 00 00 00 00 00  |................|

000000a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

000000b0  00 00 00 00 00 00 00 02  00 00 00 00 00 00 00 00  |................|

000000c0  00 00 00 00 00 00 00 01  00 00 00 0a 00 00 00 0a  |................|

000000d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00000200

[root@localhost ~]#

参考资料:
源码下载:Getting the latest source code - xfs.org
Xfs文件系统结构(本系列文章参考的最主要资料,但该文档有些陈旧,部分内容已经与Xfs现状不符):http://xfs.org/docs/xfsdocs-xml-dev/XFS_Filesystem_Structure//tmp/en-US/html/index.html

三,AG结构

Xfs文件系统会把磁盘分成多个同等大小的块组(Allocation Groups,简称AG)来进行管理,而对于一块容量在128MB到4TB之间的磁盘,其将被分为4个AG(见函数:calc_default_ag_geometry;注意:文章里所有提到的函数、结构体以及代码片段等,除非有特殊说明,否则都是应用程序xfsprogs里的代码)。每一个AG的磁盘布局结构完全一致,它们各自管理着自己的磁盘空间,但是第0块AG被称为主AG(primary AG),有一些全局统计信息的使用主要是从该AG内获取,而其它AG保存的信息仅做备份。

一块AG的布局结构如下图所示:

Xfs文件系统磁盘布局_第2张图片
1,AG的第0块block存放着xfs_sb、xfs_agf、xfs_agi、xfs_agfl这四个信息块,而每一个信息块占去一个sector,所以剩余2048空闲;
2,接下来的3块block都是存放的btree,但是设定的类型各不一样,分别为ABTB、ABTC、IABT(见宏block_to_bt与全局静态变量btrees);
3,再接下来的4块block保留使用,不能用来存放任何普通用户数据。保留起来做什么呢?总不能白白浪费吧?是用来存放前面第2点中所提到的ABTB和ABTC的,因为随着磁盘的使用,不可能1块ABTB或ABTC就足够用了,而这4块block在一开始就为此目的而保留下来了。
4,再接下来就是inode节点的存放了,Xfs下inode节点的分配总是以64个为单位来进行,64个inode形成chunk再被前面的IABT btree管理起来。
5,最后接下来的磁盘空间就没有固定格式了,可以用来存放任何类型的数据。
实践验证:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

[root@localhost xfsprogs]# hexdump -C -s 0 -n 512 /dev/sdb1

00000000  58 46 53 42 00 00 10 00  00 00 00 00 00 0f fe a9  |XFSB............|

00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00000020  d0 08 f5 d2 7b 96 4a e0  b6 b5 3b 3e cd 76 53 6b  |....{.J...;>.vSk|

00000030  00 00 00 00 00 08 00 04  00 00 00 00 00 00 00 80  |................|

00000040  00 00 00 00 00 00 00 81  00 00 00 00 00 00 00 82  |................|

00000050  00 00 00 01 00 03 ff ab  00 00 00 04 00 00 00 00  |................|

00000060  00 00 0a 00 b4 b4 02 00  01 00 00 10 00 00 00 00  |................|

00000070  00 00 00 00 00 00 00 00  0c 09 08 04 12 00 00 19  |................|

00000080  00 00 00 00 00 00 1c 80  00 00 00 00 00 00 00 52  |...............R|

00000090  00 00 00 00 00 0d 91 11  00 00 00 00 00 00 00 00  |................|

000000a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

000000b0  00 00 00 00 00 00 00 02  00 00 00 00 00 00 00 00  |................|

000000c0  00 00 00 00 00 00 00 01  00 00 00 0a 00 00 00 0a  |................|

000000d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00000200

[root@localhost xfsprogs]# hexdump -C -s 512 -n 512 /dev/sdb1

00000200  58 41 47 46 00 00 00 01  00 00 00 00 00 03 ff ab  |XAGF............|

00000210  00 00 00 01 00 00 00 02  00 00 00 00 00 00 00 01  |................|

00000220  00 00 00 01 00 00 00 00  00 00 00 00 00 00 00 03  |................|

00000230  00 00 00 04 00 02 ee 3d  00 02 ee 3d 00 00 00 00  |.......=...=....|

00000240  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00000400

[root@localhost xfsprogs]# hexdump -C -s 1024 -n 512 /dev/sdb1

00000400  58 41 47 49 00 00 00 01  00 00 00 00 00 03 ff ab  |XAGI............|

00000410  00 00 08 c0 00 00 00 03  00 00 00 01 00 00 00 26  |...............&|

00000420  00 10 a4 40 ff ff ff ff  ff ff ff ff ff ff ff ff  |...@............|

00000430  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

*

00000520  ff ff ff ff ff ff ff ff  00 00 00 00 00 00 00 00  |................|

00000530  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00000600

[root@localhost xfsprogs]# hexdump -C -s 1536 -n 512 /dev/sdb1

00000600  00 00 00 04 00 00 00 05  00 00 00 06 00 00 00 07  |................|

00000610  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00000800

[root@localhost xfsprogs]# hexdump -C -s 2048 -n 2048 /dev/sdb1

00000800  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00001000

[root@localhost xfsprogs]# hexdump -C -s 4096 -n 512 /dev/sdb1

00001000  41 42 54 42 00 00 00 01  ff ff ff ff ff ff ff ff  |ABTB............|

00001010  00 01 11 6e 00 02 ee 3d  00 00 dd 58 00 03 22 53  |...n...=...X.."S|

00001020  00 00 dc e0 00 03 22 cb  00 00 00 00 00 00 00 00  |......".........|

00001030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00001200

[root@localhost xfsprogs]# hexdump -C -s 8192 -n 512 /dev/sdb1

00002000  41 42 54 43 00 00 00 01  ff ff ff ff ff ff ff ff  |ABTC............|

00002010  00 01 11 6e 00 02 ee 3d  00 00 dd 58 00 03 22 53  |...n...=...X.."S|

00002020  00 00 dc e0 00 03 22 cb  00 00 00 00 00 00 00 00  |......".........|

00002030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00002200

[root@localhost xfsprogs]# hexdump -C -s 12288 -n 512 /dev/sdb1

00003000  49 41 42 54 00 00 00 23  ff ff ff ff ff ff ff ff  |IABT...#........|

00003010  00 00 00 80 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00003020  00 00 00 e0 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00003030  00 00 01 40 00 00 00 00  00 00 00 00 00 00 00 00  |...@............|

00003040  00 00 01 c0 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00003050  00 00 02 40 00 00 00 00  00 00 00 00 00 00 00 00  |...@............|

00003060  00 00 02 c0 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00003070  00 00 03 60 00 00 00 00  00 00 00 00 00 00 00 00  |...`............|

00003080  00 00 03 c0 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00003090  00 00 04 40 00 00 00 00  00 00 00 00 00 00 00 00  |...@............|

000030a0  00 00 04 80 00 00 00 00  00 00 00 00 00 00 00 00  |................|

000030b0  00 00 04 c0 00 00 00 00  00 00 00 00 00 00 00 00  |................|

000030c0  00 00 05 20 00 00 00 00  00 00 00 00 00 00 00 00  |... ............|

000030d0  00 00 05 60 00 00 00 00  00 00 00 00 00 00 00 00  |...`............|

000030e0  00 00 05 a0 00 00 00 00  00 00 00 00 00 00 00 00  |................|

000030f0  00 00 05 e0 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00003100  00 00 06 40 00 00 00 00  00 00 00 00 00 00 00 00  |...@............|

00003110  00 02 43 e0 00 00 00 00  00 00 00 00 00 00 00 00  |..C.............|

00003120  00 02 44 40 00 00 00 00  00 00 00 00 00 00 00 00  |..D@............|

00003130  00 0b 57 40 00 00 00 00  00 00 00 00 00 00 00 00  |..W@............|

00003140  00 0b 57 a0 00 00 00 00  00 00 00 00 00 00 00 00  |..W.............|

00003150  00 0b a9 c0 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00003160  00 0b aa 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00003170  00 0c 2d c0 00 00 00 00  00 00 00 00 00 00 00 00  |..-.............|

00003180  00 0d c8 40 00 00 00 00  00 00 00 00 00 00 00 00  |...@............|

00003190  00 0d c8 80 00 00 00 00  00 00 00 00 00 00 00 00  |................|

000031a0  00 0d c8 e0 00 00 00 00  00 00 00 00 00 00 00 00  |................|

000031b0  00 0d c9 20 00 00 00 00  00 00 00 00 00 00 00 00  |... ............|

000031c0  00 0d c9 80 00 00 00 00  00 00 00 00 00 00 00 00  |................|

000031d0  00 0d c9 c0 00 00 00 00  00 00 00 00 00 00 00 00  |................|

000031e0  00 0d ca 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

000031f0  00 0d ca 40 00 00 00 00  00 00 00 00 00 00 00 00  |...@............|

00003200

[root@localhost xfsprogs]# hexdump -C -s 16384 -n 16384 /dev/sdb1

00004000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00008000

[root@localhost xfsprogs]# hexdump -C -s 32768 -n 512 /dev/sdb1

00008000  49 4e 41 ed 02 01 00 00  00 00 00 00 00 00 00 00  |INA.............|

00008010  00 00 00 03 00 00 00 00  00 00 00 00 00 00 00 02  |................|

00008020  4e fd d5 72 23 0e 94 21  4e fd d4 1f 31 7b 35 1f  |N..r#..!N...1{5.|

00008030  4e fd d4 1f 31 8a 77 4f  00 00 00 00 00 00 00 1b  |N...1.wO........|

00008040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00008050  00 00 00 02 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00008060  ff ff ff ff 01 00 00 00  00 80 0e 00 30 6c 69 6e  |............0lin|

00008070  75 78 2d 32 2e 36 2e 33  36 2e 31 00 00 00 83 00  |ux-2.6.36.1.....|

00008080  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00008100  49 4e 80 00 02 02 00 00  00 00 00 00 00 00 00 00  |IN..............|

00008110  00 00 00 01 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00008120  00 00 00 00 00 00 00 00  4e fd 64 87 32 f0 f0 78  |........N.d.2..x|

00008130  4e fd 64 87 32 f0 f0 78  00 00 00 00 00 00 00 00  |N.d.2..x........|

00008140  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00008150  00 00 00 02 00 00 00 00  00 00 00 04 00 00 00 00  |................|

00008160  ff ff ff ff 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00008170  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00008200

四,AG超级块

AG超级块内保存着很多非常重要的信息,想要了解一个被格式化为Xfs的磁盘分区就要从AG超级块着手,其对应的结构体为xfs_sb_t,下面就来分析并验证这其中的一些重要相关字段。
查看AG超级块内的数据,我们仍然可以利用hexdump命令来查看,不过为了方便,这里使用xfsprogs提供的xfs_db工具:
[root@localhost xfsprogs]# ./db/xfs_db /dev/sdb1
xfs_db> sb 0
xfs_db> p
magicnum = 0x58465342
魔术数,即是‘XFSB’。
blocksize = 4096
逻辑块大小4096,单位字节。
dblocks = 1048233
磁盘总逻辑块数,1048233*4096/1024/1024/1024 = 3.998691558837890625,即约为4G,正好是我挂载的磁盘大小。
rblocks = 0
rextents = 0
uuid = d008f5d2-7b96-4ae0-b6b5-3b3ecd76536b
logstart = 524292
rootino = 128
根节点inode号,我这里把磁盘挂载在/home/lenky/xfs/sdb1文件夹下,所以这个rootino就是这个sdb1的inode节点号:

1

2

3

4

5

[root@localhost sdb1]# ls -ila

total 8

   128 drwxr-xr-x. 3 root root   27 Dec 30 10:09 .

523274 drwxr-xr-x. 4 root root 4096 Dec 30 02:13 ..

   131 drwxr-xr-x. 6 root root 4096 Dec 30 10:14 linux-2.6.36.1

rbmino = 129
rsumino = 130
rextsize = 1
agblocks = 262059
每一个AG的块数目,agblocks = dblocks/agcount,即262059 = 1048233/4;向上取整。
agcount = 4
磁盘的总AG数目。
rbmblocks = 0
logblocks = 2560
versionnum = 0xb4b4
所以超级块有多种类型,用该字段来区分。
sectsize = 512
一个sector的大小,默认512。
inodesize = 256
一个inode的大小,之前提到inode都是以64个为单位进行分配和管理,所以一次需要4个block,即是256*64/4096 = 4。
inopblock = 16
每一个block可以存储的inode数目,16 = 4096/256。
fname = “\000\000\000\000\000\000\000\000\000\000\000\000″
文件系统的名称,可以在格式化时指定,但不要超过12个字节:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

[root@localhost xfsprogs]# mkdir /home/lenky/loop

[root@localhost xfsprogs]# cd !$

cd /home/lenky/loop

[root@localhost loop]# dd if=/dev/zero of=xfs.img bs=512 count=1048576

1048576+0 records in

1048576+0 records out

536870912 bytes (537 MB) copied, 144.81 s, 3.7 MB/s

[root@localhost loop]# losetup /dev/loop0 xfs.img

[root@localhost loop]# mkfs.xfs -L lenky.xfs  /dev/loop0

meta-data=/dev/loop0             isize=256    agcount=4, agsize=32768 blks

         =                       sectsz=512   attr=2, projid32bit=0

data     =                       bsize=4096   blocks=131072, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0

log      =internal log           bsize=4096   blocks=1200, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

[root@localhost loop]# cd /home/lenky/xfs/xfsprogs/db

[root@localhost db]# ./xfs_db /dev/loop0

xfs_db> sb

xfs_db> p fname

fname = "lenky.xfs\000\000\000"

xfs_db>

blocklog = 12
块block大小的log2数值,即是log2(4096) = 12。
sectlog = 9
sector大小的log2数值,即是log2(512) = 9。
inodelog = 8
inode大小的log2数值,即是log2(256) = 8。
inopblog = 4
每一个block可以存储的inode数目的log2数值,即是log2(16) = 4。
agblklog = 18
每一个AG的块数目的log2数值,即是log2(262059) = 18,向上取整。
rextslog = 0
inprogress = 0
imax_pct = 25
icount = 7296
ifree = 82
fdblocks = 889105
frextents = 0
uquotino = 0
gquotino = 0
qflags = 0
flags = 0
shared_vn = 0
inoalignmt = 2
unit = 0
width = 0
dirblklog = 0
logsectlog = 0
logsectsize = 0
logsunit = 1
features2 = 0xa
bad_features2 = 0xa
xfs_db>
其它未说明的字段是我目前为关心到的字段,后续看到对应的部分后再补上。

五,AG空闲磁盘空间管理

Xfs文件系统的AG空闲磁盘空间管理信息保存的位置紧接在AG超级块后面,其对应的数据结构体为xfs_agf_t,如下所示:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

typedef struct xfs_agf {

    /*

     * Common allocation group header information

     */

    __be32      agf_magicnum;   /* magic number == XFS_AGF_MAGIC */

    __be32      agf_versionnum; /* header version == XFS_AGF_VERSION */

    __be32      agf_seqno;  /* sequence # starting from 0 */

    __be32      agf_length; /* size in blocks of a.g. */

    /*

     * Freespace information

     */

    __be32      agf_roots[XFS_BTNUM_AGF];   /* root blocks */

    __be32      agf_spare0; /* spare field */

    __be32      agf_levels[XFS_BTNUM_AGF];  /* btree levels */

    __be32      agf_spare1; /* spare field */

    __be32      agf_flfirst;    /* first freelist block's index */

    __be32      agf_fllast; /* last freelist block's index */

    __be32      agf_flcount;    /* count of blocks in freelist */

    __be32      agf_freeblks;   /* total free blocks */

    __be32      agf_longest;    /* longest free space */

    __be32      agf_btreeblks;  /* # of blocks held in AGF btrees */

} xfs_agf_t;

Xfs文件系统使用两个B+tree来对空闲磁盘空间进行管理,而这两个B+tree又分别根据空闲block块号和空闲block块数(如果空闲block块数相等,则再按空闲block块号,都是升序)来对空闲磁盘进行跟踪,因此,结构体xfs_agf_t中最重要的两个字段也就分别是agf_roots和agf_levels,这两个字段都是数组,数组元素个数都为2,分别表示ABTB(对应0号元素)和ABTC(对应1号元素)的根节点(agf_roots)和树深度(agf_levels):

1

2

3

4

5

6

7

8

9

typedef enum {

    XFS_BTNUM_BNOi, XFS_BTNUM_CNTi, XFS_BTNUM_BMAPi, XFS_BTNUM_INOi,

    XFS_BTNUM_MAX

} xfs_btnum_t;

#define XFS_BTNUM_AGF   ((int)XFS_BTNUM_CNTi + 1)

agf_roots[XFS_BTNUM_AGF];

agf_levels[XFS_BTNUM_AGF];

我们仍然先来看实例数据,这样便于理解和记忆:
[root@localhost xfsprogs]# ./db/xfs_db /dev/sdb1
xfs_db> agf 0
xfs_db> p
magicnum = 0x58414746
魔术数,即是‘XAGF’。
versionnum = 1
版本号,这里由宏XFS_AGF_VERSION定义,数值为1。
seqno = 0
agf的序号,第一块AG的agf序号为0,第二块AG的agf序号为1,……

1

2

3

4

5

6

7

xfs_db> agf 1

xfs_db> p seqno

seqno = 1

xfs_db> agf 2

xfs_db> p seqno

seqno = 2

xfs_db>

length = 262059
本AG内的block块数,前面提到过Xfs会把磁盘等分为多块AG,但不能保证完全的等分(比如不能整除),所以最末一块AG的block块数不一定和前面的AG的block块数完全相等,但也不会差太多。

1

2

3

4

5

6

7

8

9

10

xfs_db> agf 1

xfs_db> p length

length = 262059

xfs_db> agf 2

xfs_db> p length

length = 262059

xfs_db> agf 3

xfs_db> p length

length = 262056

xfs_db>

bnoroot = 1
类型为ABTB的B+tree的根节点所在的块号,前面提到AG的第0块block存放着xfs_sb、xfs_agf、xfs_agi、xfs_agfl这四个信息块,并且还剩余了2048空闲,而第1块block存放的就是ABTB,其对应的块号由这个字段指明。
cntroot = 2
和上一个字段类似,指示类型为ABTC的B+tree的根节点所在的块号。
bnolevel = 1
类型为ABTB的B+tree的树深度为1。
cntlevel = 1
类型为ABTC的B+tree的树深度为1。
flfirst = 0
该字段后面再提。
fllast = 3
该字段后面再提。
flcount = 4
该字段后面再提。
freeblks = 192061
本AG内空闲块数目。一块新建立的AG,其块数目可以做下试验,/dev/loop0是一块新的磁盘(见前面的操作),格式成Xfs文件系统,但没有任何文件数据:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

[root@localhost xfsprogs]# ./db/xfs_db /dev/loop0

xfs_db> sb 0

xfs_db> p agblocks

agblocks = 32768

xfs_db> agf 0

xfs_db> p freeblks

freeblks = 32756

xfs_db> agf 1

xfs_db> p freeblks

freeblks = 32760

xfs_db> agf 2

xfs_db> p freeblks

freeblks = 31560

xfs_db>

可以看到,一块新格式化的Xfs文件系统,其primary AG的freeblks = agblocks-12,而其它AG的freeblks = agblocks-8,这根据前面文章《Xfs文件系统磁盘布局之二:AG结构》中的图和说明不难理解,另外可以看出除了primary AG的其它AG并没有一开始就分配inode chunk。
longest = 192061
B+tree树内节点最长的块数目,当前只有一个根节点,并且根节点包含了所有的空闲块,所以longest就等于freeblks。
btreeblks = 0
被用来存放ABTB和ABTC这两种类型B+tree的树节点的block块数,但不包括根节点所占的块,即不包括第1块和第2块。因为当前B+tree的树深度为1,即是没有其它节点占用block,所以btreeblks的值当然为0。
xfs_db>

六,ABTB的B+tree

关于B+tree数据结构不是本系列文章讨论的内容,其基本概念可以参考:http://en.wikipedia.org/wiki/B%2Btree。我们仍然先直接把实例数据给弄出来,这样便于分析和理解。新建一块磁盘并格式化,然后弄些数据上去:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

[root@localhost xfsprogs]# cd /home/lenky/loop/

[root@localhost loop]# dd if=/dev/zero of=xfs.img.256 bs=512 count=524288

524288+0 records in

524288+0 records out

268435456 bytes (268 MB) copied, 10.1262 s, 26.5 MB/s

[root@localhost loop]# losetup /dev/loop1 xfs.img.256

[root@localhost loop]# mkfs.xfs /dev/loop1

meta-data=/dev/loop1             isize=256    agcount=4, agsize=16384 blks

         =                       sectsz=512   attr=2, projid32bit=0

data     =                       bsize=4096   blocks=65536, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0

log      =internal log           bsize=4096   blocks=1200, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

[root@localhost loop]# mkdir xfs.256

[root@localhost loop]# mount /dev/loop1 xfs.256/

[root@localhost loop]# cp -r /usr/src/linux-2.6.36.1 xfs.256/

cp: cannot create regular file `xfs.256/linux-2.6.36.1/net/core/dev_addr_lists.o': No space left on device

cp: cannot create regular file `xfs.256/linux-2.6.36.1/net/core/.skbuff.o.cmd': No space left on device

...

[root@localhost loop]# cd xfs.256/

[root@localhost xfs.256]# du -sh

238M    .

[root@localhost xfs.256]# find . -name "*a*" | xargs rm

rm: cannot remove `./linux-2.6.36.1/Documentation': Is a directory

rm: cannot remove `./linux-2.6.36.1/Documentation/pcmcia': Is a directory

...

[root@localhost xfs.256]# find . -name "*b*" | xargs rm

...

[root@localhost xfs.256]# find . -name "*c*" | xargs rm

...

[root@localhost xfs.256]# find . -name "*d*" | xargs rm

...

[root@localhost xfs.256]# find . -name "*e*" | xargs rm

...

[root@localhost xfs.256]# find . -name "*f*" | xargs rm

...

[root@localhost xfs.256]# du -sh

139M    .

[root@localhost xfs.256]# cd ..

[root@localhost loop]# umount xfs.256/

[root@localhost loop]# cd /home/lenky/xfs/xfsprogs

[root@localhost xfsprogs]# ./db/xfs_db /dev/loop1

xfs_db> agf 0

xfs_db> p

magicnum = 0x58414746

versionnum = 1

seqno = 0

length = 16384

bnoroot = 1

cntroot = 2

bnolevel = 1

cntlevel = 1

flfirst = 0

fllast = 3

flcount = 4

freeblks = 15653

longest = 4006

btreeblks = 0

xfs_db> fsblock 1

xfs_db> type bnobt

xfs_db> p

magic = 0x41425442

level = 0

numrecs = 49

leftsib = null

rightsib = null

recs[1-49] = [startblock,blockcount] 1:[12,2] 2:[18,1] 3:[25,3] 4:[32,4] 5:[40,4] 6:[48,6] 7:[58,2] 8:[64,2] 9:[68,4] 10:[76,4] 11:[83,3] 12:[98,2] 13:[104,77] 14:[189,40] 15:[233,36] 16:[270,9] 17:[565,63] 18:[637,62] 19:[701,2] 20:[705,32] 21:[740,40] 22:[782,100] 23:[886,13] 24:[900,8] 25:[910,4] 26:[915,3] 27:[919,2] 28:[922,4] 29:[928,132] 30:[1063,1080] 31:[2163,1528] 32:[3711,1722] 33:[5457,570] 34:[6061,74] 35:[6185,1] 36:[6194,8] 37:[6206,4006] 38:[10266,61] 39:[10369,3938] 40:[14322,304] 41:[14634,2] 42:[14640,36] 43:[14677,1] 44:[14680,21] 45:[14702,80] 46:[14784,75] 47:[14888,59] 48:[14960,57] 49:[15018,1366]

xfs_db>

这是一个树深度为1的B+tree,就先分析它吧。ABTB类型的B+tree对应的结构体为xfs_btree_block,而ABTB其中的union是使用的“short form pointers”,这从全局静态变量btrees可以看出,另一侧面也说明了块号都是相对本AG而言的:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

struct xfs_btree_block {

    __be32      bb_magic;   /* magic number for block type */

    __be16      bb_level;   /* 0 is a leaf */

    __be16      bb_numrecs; /* current # of data records */

    union {

        struct {

            __be32      bb_leftsib;

            __be32      bb_rightsib;

        } s;            /* short form pointers */

        struct  {

            __be64      bb_leftsib;

            __be64      bb_rightsib;

        } l;            /* long form pointers */

    } bb_u;             /* rest */

};

#define XFS_BTREE_SBLOCK_LEN    16  /* size of a short form block */

#define XFS_BTREE_LBLOCK_LEN    24  /* size of a long form block */

/*

 * Definition of the possible btree block layouts.

 */

struct xfs_db_btree {

    size_t          block_len;

    size_t          key_len;

    size_t          rec_len;

    size_t          ptr_len;

} btrees[] = {

    [/*0x424d415*/0] = { /* BMAP */

        XFS_BTREE_LBLOCK_LEN,

        sizeof(xfs_bmbt_key_t),

        sizeof(xfs_bmbt_rec_t),

        sizeof(__be64),

    },

    [/*0x4142544*/2] = { /* ABTB */

        XFS_BTREE_SBLOCK_LEN,

        sizeof(xfs_alloc_key_t),

        sizeof(xfs_alloc_rec_t),

        sizeof(__be32),

    },

    [/*0x4142544*/3] = { /* ABTC */

        XFS_BTREE_SBLOCK_LEN,

        sizeof(xfs_alloc_key_t),

        sizeof(xfs_alloc_rec_t),

        sizeof(__be32),

    },

    [/*0x4941425*/4] = { /* IABT */

        XFS_BTREE_SBLOCK_LEN,

        sizeof(xfs_inobt_key_t),

        sizeof(xfs_inobt_rec_t),

        sizeof(__be32),

    },

};

分析对应的字段数据:
xfs_db> fsblock 1
xfs_db> type bnobt
xfs_db> p
magic = 0x41425442
魔术数,即是‘ABTB’。
level = 0
0表示这是一个叶子节点,1表示为中间节点。
numrecs = 49
本叶子节点实际所跟踪的“空闲block块”,这些跟踪数据通过一个数组的形式链接起来,所以这个字段指定该数组的实际大小。
leftsib = null
叶子节点会以双向链表的形式链接起来,这里左节点为空。
rightsib = null
叶子节点会以双向链表的形式链接起来,这里右节点也为空。
recs[1-49] = [startblock,blockcount] 1:[12,2] 2:[18,1] 3:[25,3] 4:[32,4] 5:[40,4] 6:[48,6] 7:[58,2] 8:[64,2] 9:[68,4] 10:[76,4] 11:[83,3] 12:[98,2] 13:[104,77] 14:[189,40] 15:[233,36] 16:[270,9] 17:[565,63] 18:[637,62] 19:[701,2] 20:[705,32] 21:[740,40] 22:[782,100] 23:[886,13] 24:[900,8] 25:[910,4] 26:[915,3] 27:[919,2] 28:[922,4] 29:[928,132] 30:[1063,1080] 31:[2163,1528] 32:[3711,1722] 33:[5457,570] 34:[6061,74] 35:[6185,1] 36:[6194,8] 37:[6206,4006] 38:[10266,61] 39:[10369,3938] 40:[14322,304] 41:[14634,2] 42:[14640,36] 43:[14677,1] 44:[14680,21] 45:[14702,80] 46:[14784,75] 47:[14888,59] 48:[14960,57] 49:[15018,1366]
本叶子节点实际所跟踪的“空闲block块”,这些跟踪数据通过一个数组的形式链接起来,这个字段指定该数组的实际值。
xfs_db>
布局图示如下:

Xfs文件系统磁盘布局_第3张图片
可以直接hexdump磁盘对比一下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

[root@localhost xfsprogs]# hexdump -C -s 4096 -n 512 /dev/loop1

00001000  41 42 54 42 00 00 00 31  ff ff ff ff ff ff ff ff  |ABTB...1........|

00001010  00 00 00 0c 00 00 00 02  00 00 00 12 00 00 00 01  |................|

00001020  00 00 00 19 00 00 00 03  00 00 00 20 00 00 00 04  |........... ....|

00001030  00 00 00 28 00 00 00 04  00 00 00 30 00 00 00 06  |...(.......0....|

00001040  00 00 00 3a 00 00 00 02  00 00 00 40 00 00 00 02  |...:.......@....|

00001050  00 00 00 44 00 00 00 04  00 00 00 4c 00 00 00 04  |...D.......L....|

00001060  00 00 00 53 00 00 00 03  00 00 00 62 00 00 00 02  |...S.......b....|

00001070  00 00 00 68 00 00 00 4d  00 00 00 bd 00 00 00 28  |...h...M.......(|

00001080  00 00 00 e9 00 00 00 24  00 00 01 0e 00 00 00 09  |.......$........|

00001090  00 00 02 35 00 00 00 3f  00 00 02 7d 00 00 00 3e  |...5...?...}...>|

000010a0  00 00 02 bd 00 00 00 02  00 00 02 c1 00 00 00 20  |............... |

000010b0  00 00 02 e4 00 00 00 28  00 00 03 0e 00 00 00 64  |.......(.......d|

000010c0  00 00 03 76 00 00 00 0d  00 00 03 84 00 00 00 08  |...v............|

000010d0  00 00 03 8e 00 00 00 04  00 00 03 93 00 00 00 03  |................|

000010e0  00 00 03 97 00 00 00 02  00 00 03 9a 00 00 00 04  |................|

000010f0  00 00 03 a0 00 00 00 84  00 00 04 27 00 00 04 38  |...........'...8|

00001100  00 00 08 73 00 00 05 f8  00 00 0e 7f 00 00 06 ba  |...s............|

00001110  00 00 15 51 00 00 02 3a  00 00 17 ad 00 00 00 4a  |...Q...:.......J|

00001120  00 00 18 29 00 00 00 01  00 00 18 32 00 00 00 08  |...).......2....|

00001130  00 00 18 3e 00 00 0f a6  00 00 28 1a 00 00 00 3d  |...>......(....=|

00001140  00 00 28 81 00 00 0f 62  00 00 37 f2 00 00 01 30  |..(....b..7....0|

00001150  00 00 39 2a 00 00 00 02  00 00 39 30 00 00 00 24  |..9*......90...$|

00001160  00 00 39 55 00 00 00 01  00 00 39 58 00 00 00 15  |..9U......9X....|

00001170  00 00 39 6e 00 00 00 50  00 00 39 c0 00 00 00 4b  |..9n...P..9....K|

00001180  00 00 3a 28 00 00 00 3b  00 00 3a 70 00 00 00 39  |..:(...;..:p...9|

00001190  00 00 3a aa 00 00 05 56  00 00 3a aa 00 00 05 56  |..:....V..:....V|

*

00001200

[root@localhost xfsprogs]#

继续验证空闲块的管理,这里我们先拷贝个新的磁盘(关联到loop2),便于对比,先挂载这个loop2磁盘,并写入一个文件,然后再卸载(保证数据已经写到磁盘上),具体操作如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

[root@localhost xfsprogs]# cd /home/lenky/loop/

[root@localhost loop]# cp xfs.img.256 xfs.img.256.new

[root@localhost loop]# losetup /dev/loop2 xfs.img.256

[root@localhost loop]# mkdir xfs.256.new

[root@localhost loop]# mount /dev/loop2 xfs.256.new/

[root@localhost loop]# cd !$

cd xfs.256.new/

[root@localhost xfs.256.new]# ls

linux-2.6.36.1

[root@localhost xfs.256.new]# cat > lenky.xfs

1111111111111111111111111111111111111

2222222222222222222222222222222222222

3333333333333333333333333333333333333

^C

[root@localhost xfs.256.new]# cat lenky.xfs

1111111111111111111111111111111111111

2222222222222222222222222222222222222

3333333333333333333333333333333333333

[root@localhost xfs.256.new]# cd ..

[root@localhost loop]# umount xfs.256.new/

[root@localhost loop]#

再来看一下ABTB:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

[root@localhost loop]# /home/lenky/xfs/xfsprogs/db/xfs_db /dev/loop2

xfs_db> agf 0

xfs_db> p

magicnum = 0x58414746

versionnum = 1

seqno = 0

length = 16384

bnoroot = 1

cntroot = 2

bnolevel = 1

cntlevel = 1

flfirst = 0

fllast = 3

flcount = 4

freeblks = 15652

longest = 4006

btreeblks = 0

xfs_db> fsblock 1

xfs_db> type bnobt

xfs_db> p

magic = 0x41425442

level = 0

numrecs = 49

leftsib = null

rightsib = null

recs[1-49] = [startblock,blockcount] 1:[13,1] 2:[18,1] 3:[25,3] 4:[32,4] 5:[40,4] 6:[48,6] 7:[58,2] 8:[64,2] 9:[68,4] 10:[76,4] 11:[83,3] 12:[98,2] 13:[104,77] 14:[189,40] 15:[233,36] 16:[270,9] 17:[565,63] 18:[637,62] 19:[701,2] 20:[705,32] 21:[740,40] 22:[782,100] 23:[886,13] 24:[900,8] 25:[910,4] 26:[915,3] 27:[919,2] 28:[922,4] 29:[928,132] 30:[1063,1080] 31:[2163,1528] 32:[3711,1722] 33:[5457,570] 34:[6061,74] 35:[6185,1] 36:[6194,8] 37:[6206,4006] 38:[10266,61] 39:[10369,3938] 40:[14322,304] 41:[14634,2] 42:[14640,36] 43:[14677,1] 44:[14680,21] 45:[14702,80] 46:[14784,75] 47:[14888,59] 48:[14960,57] 49:[15018,1366]

xfs_db>

对比上一篇的ABTB数据,只有两处不同:
freeblks = 15653
freeblks = 15652

recs[1-49] = [startblock,blockcount] 1:[12,2] …
recs[1-49] = [startblock,blockcount] 1:[13,1] …
即第12(编号从0开始)块block被占用了,所以总空闲块数(freeblks)少了一块,并且空闲块链里的[12,2]变成了[13,1],看一下第12块block的具体数据是什么:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

xfs_db> fsblock 12

xfs_db> type text

xfs_db> p

000:  31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31  1111111111111111

010:  31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31  1111111111111111

020:  31 31 31 31 31 0a 32 32 32 32 32 32 32 32 32 32  11111.2222222222

030:  32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32  2222222222222222

040:  32 32 32 32 32 32 32 32 32 32 32 0a 33 33 33 33  22222222222.3333

050:  33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33  3333333333333333

060:  33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33  3333333333333333

070:  33 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00  3...............

080:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

090:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

*

ff0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

xfs_db>

刚好是文件lenky.xfs里的内容,这说明这块原本的空闲block被用来存放文件lenky.xfs了。一个文件还有inode信息,为什么没有看到lenky.xfs的inode占去空闲块呢?因为之前提到过inode总是以64为chunk进行分配和释放,所以lenky.xfs的inode正好利用到了之前申请的但尚未使用的inode空间。
有了上面的这些基础认识,再来看多层(即树深度不为1)的情况。要找一个多层的实例,如果有现成的使用了很久的Xfs文件系统分区就最好了,没有的话就可以这样尝试自己弄一个,我这里是先尽量把4G的磁盘写满,然后再随机的删一大部分,这样让它的Btree打乱,以形成多层结构:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

[root@localhost sdb1]# cp /usr/

bin/     etc/     games/   include/ lib/     libexec/ local/   sbin/    share/   src/     tmp/    

[root@localhost sdb1]# cp -r /usr/* ./

...

[root@localhost sdb1]# find . -name "*a*" | xargs rm

...

[root@localhost sdb1]# find . -name "*b*" | xargs rm

...

[root@localhost sdb1]# du -sh

1.7G    .

[root@localhost sdb1]# cd ..

[root@localhost xfs]# umount sdb1/

[root@localhost xfs]# /home/lenky/xfs/xfsprogs/db/xfs_db /dev/sdb1

xfs_db> agf 0

xfs_db> p

magicnum = 0x58414746

versionnum = 1

seqno = 0

length = 262059

bnoroot = 5

cntroot = 472

bnolevel = 2

cntlevel = 2

flfirst = 21

fllast = 26

flcount = 6

freeblks = 165395

longest = 86535

btreeblks = 16

xfs_db>

从上面的数据可以看出,ABTB类型的B+tree深度为2,而根节点所在的block块号为5:
bnoroot = 5
bnolevel = 2

1

2

3

4

5

6

7

8

9

10

11

xfs_db> fsblock 5

xfs_db> type bnobt

xfs_db> p

magic = 0x41425442

level = 1

numrecs = 8

leftsib = null

rightsib = null

keys[1-8] = [startblock,blockcount] 1:[32,3] 2:[47931,66] 3:[70425,1] 4:[75668,2] 5:[99725,12] 6:[139125,51] 7:[151459,3] 8:[153765,1]

ptrs[1-8] = 1:1 2:324 3:4 4:473 5:6 6:138 7:139 8:110

xfs_db>

根节点的level为1,表示这是一个中间节点,前面提到过叶子节点里数据的布局,而对于中间节点,多了“指针”字段,如下,图中xfs_alloc_rec即为xfs_alloc_rec_t,xfs_alloc_key即为xfs_alloc_key_t,xfs_alloc_ptr即为xfs_alloc_ptr_t,后面说明类此:

Xfs文件系统磁盘布局_第4张图片
对于中间节点,存放“指针”字段xfs_alloc_ptr的开始地址并不是紧接在xfs_alloc_key[bb_numrecs – 1]之后,如果紧接着xfs_alloc_key[bb_numrecs – 1],一旦数目增加或减少(即bb_numrecs发生改变),那么岂不是要向前或者向后移动xfs_alloc_ptr的数据?对于xfs_alloc_ptr[0]的起始地址,通过函数btblock_ptr_offset可以看出端倪。通过计算出最大可能的bb_numrecs值,即xfs_alloc_ptr前面最大可能有多少个xfs_alloc_key,预留出需要的最大的空闲地址之后,就是xfs_alloc_ptr的开始地址,具体计算是这样:
一个节点占用一个block,这里默认的block大小为4096。
减去前面xfs_btree_block所占的空间,由于ABTB为“short form block”,即是XFS_BTREE_SBLOCK_LEN=16,那么,4096-16=4080。
最大可能的bb_numrecs值为:4080/(sizeof(xfs_alloc_key)+sizeof(xfs_alloc_ptr))=4080/(8+4)=340。
xfs_alloc_ptr的开始地址(相对本block偏移)xfs_alloc_ptr[0]=16+340*8=2736=0xAB0。
看实际数据验证我们的分析:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

xfs_db> type text

xfs_db> p

000:  41 42 54 42 00 01 00 08 ff ff ff ff ff ff ff ff  ABTB............

010:  00 00 00 20 00 00 00 03 00 00 bb 3b 00 00 00 42  ...............B

020:  00 01 13 19 00 00 00 01 00 01 27 94 00 00 00 02  ................

030:  00 01 85 8d 00 00 00 0c 00 02 1f 75 00 00 00 33  ...........u...3

040:  00 02 4f a3 00 00 00 03 00 02 58 a5 00 00 00 01  ..O.......X.....

050:  73 e1 75 00 01 01 00 00 77 e1 75 00 01 01 00 00  s.u.....w.u.....

060:  80 e1 75 00 01 01 00 00 84 e1 75 00 01 01 00 00  ..u.......u.....

*

ab0:  00 00 00 01 00 00 01 44 00 00 00 04 00 00 01 d9  .......D........

ac0:  00 00 00 06 00 00 00 8a 00 00 00 8b 00 00 00 6e  ...............n

ad0:  73 ec 75 00 01 01 00 00 77 ec 75 00 01 01 00 00  s.u.....w.u.....

ae0:  87 ec 75 00 01 01 00 00 8b ec 75 00 01 01 00 00  ..u.......u.....

af0:  92 ec 75 00 01 01 00 00 96 ec 75 00 01 01 00 00  ..u.......u.....

b00:  a5 ec 75 00 01 01 00 00 a9 ec 75 00 01 01 00 00  ..u.......u.....

*

xfs_db>

单独看了叶子节点,也单独看了中间节点,现在再整体来看,也就是这两行数据:
keys[1-8] = [startblock,blockcount] 1:[32,3] 2:[47931,66] 3:[70425,1] 4:[75668,2] 5:[99725,12] 6:[139125,51] 7:[151459,3] 8:[153765,1]
ptrs[1-8] = 1:1 2:324 3:4 4:473 5:6 6:138 7:139 8:110
还是很好理解的,要注意的是key是由两个值组成的,另外同级节点还会以双向链表的形式组织起来(图中未画出):

Xfs文件系统磁盘布局_第5张图片
ABTC的B+tree于此类似,所以就不讲了。最后,看一下ABTB的实例数据:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

xfs_db> fsblock 5

xfs_db> type bnobt

xfs_db> p

magic = 0x41425442

level = 1

numrecs = 8

leftsib = null

rightsib = null

keys[1-8] = [startblock,blockcount] 1:[32,3] 2:[47931,66] 3:[70425,1] 4:[75668,2] 5:[99725,12] 6:[139125,51] 7:[151459,3] 8:[153765,1]

ptrs[1-8] = 1:1 2:324 3:4 4:473 5:6 6:138 7:139 8:110

xfs_db> fsblock 1

xfs_db> type bnobt

xfs_db> p

magic = 0x41425442

level = 0

numrecs = 265

leftsib = null

rightsib = 324

recs[1-265] = [startblock,blockcount] 1:[32,3] 2:[41,3] 3:[49,4] 4:[107,1] 5:[111,11] 6:[124,1] 7:[126,7] 8:[135,3] 9:[140,1] 10:[160,1] 11:[163,9] 12:[176,13] 13:[193,4] 14:[199,30] 15:[239,12] 16:[255,8] 17:[264,51] 18:[329,14] 19:[360,13] 20:[378,10] 21:[423,1] 22:[440,2] 23:[453,13] 24:[470,1] 25:[482,14] 26:[500,4] 27:[505,6] 28:[519,2] 29:[522,3] 30:[528,5] 31:[536,9] 32:[547,42] 33:[592,9] 34:[605,1] 35:[607,3] 36:[612,1] 37:[619,2] 38:[623,2] 39:[627,5] 40:[639,2] 41:[644,3] 42:[658,1] 43:[661,11] 44:[674,7] 45:[684,4] 46:[696,6] 47:[708,9] 48:[726,8] 49:[735,6] 50:[742,10] 51:[767,1] 52:[770,1] 53:[773,9] 54:[792,1] 55:[808,19] 56:[831,10] 57:[850,5] 58:[856,302] 59:[1159,299] 60:[1460,1] 61:[1462,2] 62:[1475,1] 63:[1478,1] 64:[1480,5] 65:[1488,1] 66:[1490,2] 67:[1495,2] 68:[1498,4] 69:[1510,3] 70:[1514,1] 71:[1525,1] 72:[1527,4] 73:[1534,1] 74:[1537,2] 75:[1544,1] 76:[1548,2] 77:[1552,4] 78:[1557,1] 79:[1562,1] 80:[1566,1] 81:[1573,7] 82:[1592,18] 83:[1673,4] 84:[1687,1] 85:[1704,27] 86:[1778,30] 87:[1809,23] 88:[1882,2] 89:[1981,1] 90:[2007,8] 91:[2022,22] 92:[2091,34] 93:[2145,38] 94:[2214,99] 95:[2324,28] 96:[2363,10] 97:[2405,70] 98:[2488,55] 99:[2587,46] 100:[2644,41] 101:[2717,34] 102:[2768,5] 103:[2812,56] 104:[2888,9] 105:[2903,21] 106:[2981,10] 107:[2997,41] 108:[3066,7] 109:[3142,1] 110:[3255,6] 111:[3268,2] 112:[3297,5] 113:[3335,6] 114:[3374,35] 115:[3450,25] 116:[3492,17] 117:[3587,36] 118:[3646,29] 119:[3682,4] 120:[3706,23] 121:[3761,27] 122:[3809,38] 123:[3855,1] 124:[3857,25] 125:[3889,22] 126:[3912,8] 127:[3949,8] 128:[3996,54] 129:[4059,35] 130:[4105,37] 131:[4149,3] 132:[4205,42] 133:[4248,1] 134:[4252,1] 135:[4260,29] 136:[4293,37] 137:[4338,6] 138:[4353,6] 139:[4384,6] 140:[4391,6] 141:[4599,39] 142:[4685,38] 143:[4729,15] 144:[4752,2] 145:[4756,633] 146:[5393,32] 147:[5454,20] 148:[5475,6] 149:[5506,6] 150:[5518,41] 151:[5565,80] 152:[5650,8] 153:[5674,6] 154:[5681,19] 155:[5709,3] 156:[5757,7] 157:[5765,20] 158:[5786,1] 159:[5791,5] 160:[5814,33] 161:[5857,47] 162:[5932,29] 163:[5977,44] 164:[6027,17] 165:[6106,44] 166:[6151,7] 167:[6212,10] 168:[6223,24] 169:[6251,36] 170:[6311,27] 171:[6341,1] 172:[6407,73] 173:[6490,54] 174:[6545,7] 175:[6623,1] 176:[6642,30] 177:[6696,12] 178:[6815,4] 179:[6824,7] 180:[6832,12] 181:[6851,20] 182:[6920,6] 183:[6934,1] 184:[6947,10] 185:[7000,8] 186:[7015,1] 187:[7018,9] 188:[7028,30] 189:[7065,1] 190:[7076,10] 191:[7087,45] 192:[7142,170] 193:[7364,24] 194:[7423,10] 195:[7483,13] 196:[7497,2] 197:[7505,28] 198:[7574,5] 199:[7580,11] 200:[7685,2] 201:[7715,15] 202:[7741,1] 203:[7755,35] 204:[7805,29] 205:[7896,1232] 206:[9276,1] 207:[9290,9] 208:[9305,2] 209:[9308,3] 210:[9312,2] 211:[9315,1] 212:[9319,3] 213:[29802,1] 214:[43415,79] 215:[43495,66] 216:[43564,1] 217:[43571,47] 218:[43673,3] 219:[43718,1] 220:[43720,68] 221:[43789,1] 222:[43849,10] 223:[43888,73] 224:[44138,7] 225:[44171,56] 226:[44402,68] 227:[44549,1] 228:[44552,1] 229:[45055,1] 230:[45057,1] 231:[45313,1] 232:[45345,14] 233:[45370,15] 234:[45386,31] 235:[45596,188] 236:[45785,6] 237:[45838,11] 238:[46017,149] 239:[46167,45] 240:[46219,2] 241:[46222,1] 242:[46235,51] 243:[46297,94] 244:[46423,4] 245:[46449,1] 246:[46451,1] 247:[46457,1] 248:[46462,77] 249:[46540,75] 250:[46702,53] 251:[46757,6] 252:[46830,2] 253:[46837,1] 254:[46844,46] 255:[46969,10] 256:[47041,10] 257:[47239,41] 258:[47291,10] 259:[47303,68] 260:[47381,11] 261:[47410,72] 262:[47584,3] 263:[47780,1] 264:[47808,10] 265:[47850,10]

xfs_db> fsblock 324

xfs_db> type bnobt

xfs_db> p

magic = 0x41425442

level = 0

numrecs = 291

leftsib = 1

rightsib = 4

recs[1-291] = [startblock,blockcount] 1:[47931,66] 2:[48257,9] 3:[48312,47] 4:[48422,45] 5:[48580,5] 6:[48649,10] 7:[48763,55] 8:[48973,10] 9:[48990,1] 10:[48993,135] 11:[49177,114] 12:[49302,109] 13:[49421,1] 14:[49469,3] 15:[49485,6] 16:[49542,1] 17:[49599,1] 18:[49699,10] 19:[49719,47] 20:[49827,1] 21:[49888,67] 22:[50000,8] 23:[50011,5] 24:[50150,82] 25:[52137,1] 26:[52147,11] 27:[52260,8] 28:[52336,57] 29:[54277,138] 30:[54429,1] 31:[54514,20] 32:[54544,5] 33:[54614,10] 34:[54705,122] 35:[54837,10] 36:[54848,11] 37:[54861,37] 38:[54899,7] 39:[54908,119] 40:[55028,2] 41:[55039,9] 42:[55171,1] 43:[55182,321] 44:[55538,78] 45:[55619,9] 46:[55631,50] 47:[55683,9] 48:[55701,18] 49:[55720,327] 50:[56085,138] 51:[56224,23] 52:[56251,122] 53:[56382,69] 54:[56488,3] 55:[56492,1] 56:[56502,1] 57:[56606,58] 58:[56677,1] 59:[56693,22] 60:[56872,3] 61:[56876,68] 62:[56956,10] 63:[57030,4] 64:[57105,36] 65:[57196,65] 66:[57262,11] 67:[57338,21] 68:[57375,48] 69:[57440,1] 70:[57442,1] 71:[57487,1] 72:[57499,13] 73:[57525,1] 74:[57598,41] 75:[57674,6] 76:[57682,2] 77:[57696,13] 78:[57720,36] 79:[57825,9] 80:[57889,9] 81:[57904,168] 82:[58108,10] 83:[58234,112] 84:[58396,14] 85:[58419,18] 86:[58440,71] 87:[58559,6] 88:[58585,46] 89:[58685,141] 90:[58879,35] 91:[58969,6] 92:[58985,55] 93:[59043,6] 94:[59192,18] 95:[59253,58] 96:[59331,10] 97:[59342,88] 98:[59491,112] 99:[59613,114] 100:[59737,1] 101:[59739,6] 102:[59747,1] 103:[59805,83] 104:[59890,3] 105:[59894,56] 106:[59960,1] 107:[60016,7] 108:[60034,44] 109:[60081,528] 110:[60629,92] 111:[60826,19] 112:[60883,1] 113:[60894,58] 114:[61099,7] 115:[61116,65] 116:[61182,110] 117:[61397,9] 118:[61531,1] 119:[61539,53] 120:[61647,6] 121:[61711,1] 122:[61714,20] 123:[61751,1] 124:[61828,285] 125:[62115,37] 126:[62153,46] 127:[62242,46] 128:[62343,49] 129:[62434,57] 130:[62492,59] 131:[62567,100] 132:[62668,6] 133:[62675,19] 134:[62704,13] 135:[62772,2] 136:[62775,11] 137:[62792,56] 138:[62854,1] 139:[62867,1] 140:[62901,1] 141:[62963,5] 142:[63105,10] 143:[63203,64] 144:[63268,1] 145:[63281,11] 146:[63301,47] 147:[63410,90] 148:[63555,10] 149:[63581,1] 150:[63649,36] 151:[63686,10] 152:[63750,20] 153:[63790,6] 154:[63802,35] 155:[64061,3] 156:[64108,47] 157:[64165,10] 158:[64276,9] 159:[64301,11] 160:[64366,10] 161:[64388,9] 162:[64398,68] 163:[64475,10] 164:[64487,1] 165:[64500,94] 166:[64597,2] 167:[64646,5] 168:[64652,42] 169:[64770,1] 170:[64858,11] 171:[64922,45] 172:[64968,43] 173:[65013,53] 174:[65072,57] 175:[65135,536] 176:[65681,16] 177:[65707,20] 178:[65788,1] 179:[65828,19] 180:[66003,9] 181:[66018,7] 182:[66044,58] 183:[66142,48] 184:[66193,1] 185:[66263,1] 186:[66302,124] 187:[66472,12] 188:[66528,85] 189:[66614,45] 190:[66687,36] 191:[66759,10] 192:[66902,6] 193:[66957,9] 194:[66986,16] 195:[67071,75] 196:[67151,9] 197:[67225,56] 198:[67358,9] 199:[67424,10] 200:[67501,1] 201:[67545,2] 202:[67550,1] 203:[67553,28] 204:[67588,110] 205:[67709,1] 206:[67778,33] 207:[67859,32] 208:[67982,8] 209:[68000,35] 210:[68044,6] 211:[68052,1] 212:[68063,9] 213:[68073,15] 214:[68098,64] 215:[68168,5] 216:[68211,45] 217:[68257,60] 218:[68326,14] 219:[68348,1] 220:[68390,190] 221:[68591,2] 222:[68608,18] 223:[68715,1] 224:[68717,63] 225:[68788,8] 226:[68803,58] 227:[68868,73] 228:[68944,512] 229:[69503,26] 230:[69628,22] 231:[69652,83] 232:[69766,7] 233:[69790,12] 234:[69822,176] 235:[69999,1] 236:[70004,1] 237:[70016,2] 238:[70021,3] 239:[70028,1] 240:[70030,5] 241:[70045,3] 242:[70049,25] 243:[70081,13] 244:[70097,3] 245:[70103,5] 246:[70112,2] 247:[70119,4] 248:[70131,3] 249:[70136,1] 250:[70140,1] 251:[70145,2] 252:[70149,1] 253:[70152,3] 254:[70164,2] 255:[70167,4] 256:[70173,2] 257:[70176,2] 258:[70179,1] 259:[70181,1] 260:[70184,4] 261:[70190,3] 262:[70196,2] 263:[70199,1] 264:[70201,1] 265:[70206,4] 266:[70211,1] 267:[70213,2] 268:[70216,4] 269:[70221,1] 270:[70224,2] 271:[70227,6] 272:[70238,1] 273:[70240,2] 274:[70245,2] 275:[70268,1] 276:[70285,1] 277:[70292,1] 278:[70298,1] 279:[70305,1] 280:[70310,2] 281:[70319,1] 282:[70324,2] 283:[70339,1] 284:[70352,2] 285:[70355,1] 286:[70361,1] 287:[70367,7] 288:[70378,2] 289:[70386,3] 290:[70405,1] 291:[70412,1]

xfs_db> fsblock 4

xfs_db> type bnobt

xfs_db> p

magic = 0x41425442

level = 0

numrecs = 499

leftsib = 324

rightsib = 473

recs[1-499] = [startblock,blockcount] 1:[70425,1] 2:[70432,1] 3:[70446,1] 4:[70449,1] 5:[70454,5] 6:[70468,3] 7:[70472,8] 8:[70482,3] 9:[70486,2] 10:[70490,6] 11:[70497,4] 12:[70504,1] 13:[70507,1] 14:[70509,1] 15:[70515,4] 16:[70521,2] 17:[70524,2] 18:[70528,1] 19:[70536,1] 20:[70547,4] 21:[70561,8] 22:[70570,5] 23:[70576,5] 24:[70595,4] 25:[70603,2] 26:[70608,2] 27:[70611,2] 28:[70619,5] 29:[70627,8] 30:[70637,2] 31:[70640,4] 32:[70648,3] 33:[70655,21] 34:[70678,1] 35:[70685,1] 36:[70687,11] 37:[70702,2] 38:[70708,2] 39:[70712,1] 40:[70715,7] 41:[70723,8] 42:[70739,4] 43:[70746,4] 44:[70751,4] 45:[70756,9] 46:[70774,3] 47:[70780,5] 48:[70790,2] 49:[70801,3] 50:[70806,1] 51:[70809,2] 52:[70812,3] 53:[70819,1] 54:[70822,3] 55:[70830,1] 56:[70834,3] 57:[70838,2] 58:[70841,4] 59:[70850,3] 60:[70855,1] 61:[70862,4] 62:[70871,2] 63:[70878,1] 64:[70886,3] 65:[70890,2] 66:[70893,1] 67:[70896,3] 68:[70901,2] 69:[70909,7] 70:[70917,9] 71:[70931,7] 72:[70954,1] 73:[70961,38] 74:[71030,1] 75:[71036,27] 76:[71084,1] 77:[71240,3] 78:[71244,1] 79:[71246,1] 80:[71270,7] 81:[71278,2] 82:[71281,2] 83:[71295,4] 84:[71316,1] 85:[71325,1] 86:[71328,1] 87:[71330,4] 88:[71338,1] 89:[71340,3] 90:[71345,1] 91:[71350,1] 92:[71360,5] 93:[71368,1] 94:[71371,1] 95:[71373,1] 96:[71378,3] 97:[71387,4] 98:[71398,1] 99:[71401,1] 100:[71406,1] 101:[71408,1] 102:[71420,2] 103:[71426,1] 104:[71432,1] 105:[71434,5] 106:[71441,3] 107:[71468,5] 108:[71476,2] 109:[71509,2] 110:[71515,2] 111:[71518,2] 112:[71521,1] 113:[71523,2] 114:[71529,2] 115:[71533,1] 116:[71536,1] 117:[71538,2] 118:[71543,1] 119:[71545,15] 120:[71577,9] 121:[71587,2] 122:[71590,1] 123:[71594,1] 124:[71598,2] 125:[71601,3] 126:[71610,1] 127:[71618,7] 128:[71626,1] 129:[71628,4] 130:[71647,1] 131:[71649,3] 132:[71653,2] 133:[71656,3] 134:[71665,2] 135:[71676,3] 136:[71681,1] 137:[71683,2] 138:[71686,1] 139:[71690,2] 140:[71693,1] 141:[71700,2] 142:[71708,4] 143:[71713,1] 144:[71716,11] 145:[71728,1] 146:[71730,4] 147:[71735,4] 148:[71740,1] 149:[71748,1] 150:[71759,2] 151:[71764,1] 152:[71766,1] 153:[71768,5] 154:[71775,24] 155:[71801,22] 156:[71825,1] 157:[71827,2] 158:[71833,1] 159:[71836,2] 160:[71942,3] 161:[71947,4] 162:[71952,8] 163:[71962,3] 164:[71980,1] 165:[71982,1] 166:[71984,4] 167:[71995,135] 168:[72132,21] 169:[72154,15] 170:[72170,10] 171:[72182,1] 172:[72184,2] 173:[72188,1] 174:[72190,3] 175:[72197,12] 176:[72216,6] 177:[72223,2] 178:[72227,10] 179:[72243,7] 180:[72251,4] 181:[72261,16] 182:[72282,2] 183:[72288,6] 184:[72295,14] 185:[72310,2] 186:[72322,3] 187:[72326,1] 188:[72330,11] 189:[72345,4] 190:[72350,10] 191:[72361,14] 192:[72376,2] 193:[72379,98] 194:[72478,23] 195:[72504,5] 196:[72510,7] 197:[72518,3] 198:[72522,2] 199:[72525,1] 200:[72550,6] 201:[72563,2] 202:[72569,3] 203:[72575,3] 204:[72582,1] 205:[72584,1] 206:[72586,3] 207:[72590,3] 208:[72595,3] 209:[72609,1] 210:[72611,7] 211:[72622,1] 212:[72626,5] 213:[72640,2] 214:[72646,4] 215:[72654,3] 216:[72662,1] 217:[72664,1] 218:[72666,3] 219:[72670,4] 220:[72677,3] 221:[72694,1] 222:[72696,8] 223:[72709,1] 224:[72713,5] 225:[72725,2] 226:[72731,4] 227:[72738,3] 228:[72745,1] 229:[72747,1] 230:[72749,3] 231:[72753,3] 232:[72758,3] 233:[72772,1] 234:[72774,7] 235:[72785,1] 236:[72789,3] 237:[72793,7] 238:[72801,3] 239:[72805,5] 240:[72814,2] 241:[72817,11] 242:[72829,10] 243:[72843,2] 244:[72847,2] 245:[72850,3] 246:[72854,1] 247:[72858,1] 248:[72862,1] 249:[72864,5] 250:[72870,1] 251:[72890,4] 252:[72895,6] 253:[72903,11] 254:[72915,2] 255:[72918,1] 256:[72924,10] 257:[72936,2] 258:[72945,1] 259:[72958,1] 260:[72976,14] 261:[72991,2] 262:[72999,12] 263:[73012,5] 264:[73021,2] 265:[73025,1] 266:[73032,1] 267:[73035,3] 268:[73044,8] 269:[73053,6] 270:[73064,4] 271:[73069,1] 272:[73072,5] 273:[73078,1] 274:[73080,1] 275:[73082,1] 276:[73088,2] 277:[73091,10] 278:[73105,1] 279:[73111,4] 280:[73116,1] 281:[73121,3] 282:[73126,1] 283:[73133,10] 284:[73145,7] 285:[73157,254] 286:[73412,14] 287:[73429,3] 288:[73433,2] 289:[73437,3] 290:[73441,2] 291:[73444,2] 292:[73447,6] 293:[73455,1] 294:[73458,3] 295:[73462,4] 296:[73471,10] 297:[73483,16] 298:[73500,8] 299:[73520,3] 300:[73530,22] 301:[73553,65] 302:[73623,7] 303:[73632,28] 304:[73665,24] 305:[73692,22] 306:[73722,5] 307:[73733,29] 308:[73765,3] 309:[73769,7] 310:[73779,19] 311:[73800,1] 312:[73802,5] 313:[73811,45] 314:[73857,4] 315:[73865,15] 316:[73886,21] 317:[73910,55] 318:[73966,14] 319:[73984,2] 320:[73997,8] 321:[74006,9] 322:[74020,28] 323:[74050,24] 324:[74076,12] 325:[74089,1] 326:[74100,6] 327:[74109,1] 328:[74111,4] 329:[74119,1] 330:[74121,27] 331:[74149,8] 332:[74158,5] 333:[74165,10] 334:[74176,1] 335:[74180,6] 336:[74192,11] 337:[74205,5] 338:[74213,4] 339:[74219,6] 340:[74227,1] 341:[74230,2] 342:[74236,1] 343:[74238,2] 344:[74242,7] 345:[74250,9] 346:[74263,1] 347:[74267,5] 348:[74273,1] 349:[74276,2] 350:[74279,2] 351:[74282,2] 352:[74285,3] 353:[74290,4] 354:[74297,18] 355:[74322,5] 356:[74356,6] 357:[74365,5] 358:[74374,4] 359:[74379,2] 360:[74382,2] 361:[74385,1] 362:[74391,10] 363:[74407,14] 364:[74422,7] 365:[74430,2] 366:[74439,9] 367:[74452,4] 368:[74459,1] 369:[74461,1] 370:[74463,7] 371:[74471,3] 372:[74475,4] 373:[74481,1] 374:[74483,9] 375:[74493,1] 376:[74495,1] 377:[74497,1] 378:[74499,2] 379:[74513,6] 380:[74524,1] 381:[74526,2] 382:[74530,3] 383:[74538,9] 384:[74548,13] 385:[74562,3] 386:[74572,1] 387:[74574,7] 388:[74593,4] 389:[74601,2] 390:[74607,1] 391:[74614,1] 392:[74620,19] 393:[74640,8] 394:[74658,3] 395:[74662,11] 396:[74677,2] 397:[74680,2] 398:[74683,3] 399:[74694,8] 400:[74704,1] 401:[74706,7] 402:[74717,25] 403:[74751,3] 404:[74761,5] 405:[74767,2] 406:[74772,4] 407:[74777,3] 408:[74792,14] 409:[74808,7] 410:[74816,14] 411:[74834,12] 412:[74848,23] 413:[74872,12] 414:[74887,1] 415:[74889,1] 416:[74891,1] 417:[74893,4] 418:[74898,1] 419:[74901,1] 420:[74904,1] 421:[74906,1] 422:[74908,2] 423:[74911,3] 424:[74915,1] 425:[74919,3] 426:[74923,1] 427:[74926,25] 428:[74952,19] 429:[74973,3] 430:[74984,1] 431:[74986,5] 432:[74992,2] 433:[74995,1] 434:[74997,1] 435:[74999,7] 436:[75007,6] 437:[75041,7] 438:[75060,3] 439:[75064,7] 440:[75075,9] 441:[75088,4] 442:[75095,14] 443:[75129,12] 444:[75143,57] 445:[75207,4] 446:[75214,5] 447:[75225,4] 448:[75231,7] 449:[75241,17] 450:[75260,4] 451:[75265,1] 452:[75270,7] 453:[75292,1] 454:[75294,3] 455:[75299,2] 456:[75302,3] 457:[75306,16] 458:[75323,9] 459:[75333,8] 460:[75342,1] 461:[75344,2] 462:[75347,1] 463:[75349,2] 464:[75353,1] 465:[75388,8] 466:[75400,5] 467:[75406,1] 468:[75503,5] 469:[75509,2] 470:[75512,2] 471:[75518,3] 472:[75528,5] 473:[75535,1] 474:[75538,3] 475:[75546,6] 476:[75555,4] 477:[75562,8] 478:[75572,2] 479:[75580,2] 480:[75583,1] 481:[75586,4] 482:[75593,1] 483:[75596,1] 484:[75598,1] 485:[75601,1] 486:[75609,1] 487:[75613,1] 488:[75624,2] 489:[75628,1] 490:[75630,1] 491:[75634,4] 492:[75640,1] 493:[75643,5] 494:[75649,1] 495:[75652,3] 496:[75656,2] 497:[75661,1] 498:[75663,1] 499:[75665,2]

xfs_db> fsblock 473

xfs_db> type bnobt

xfs_db> p

magic = 0x41425442

level = 0

numrecs = 504

leftsib = 4

rightsib = 6

recs[1-504] = [startblock,blockcount] 1:[75668,2] 2:[75671,1] 3:[75673,3] 4:[75679,3] 5:[75684,3] 6:[75688,1] 7:[75690,2] 8:[75695,2] 9:[75703,1] 10:[75705,1] 11:[75709,1] 12:[75711,3] 13:[75717,2] 14:[75720,2] 15:[75727,2] 16:[75732,1] 17:[75734,1] 18:[75736,3] 19:[75740,1] 20:[75742,1] 21:[75744,1] 22:[75746,1] 23:[75749,3] 24:[75753,2] 25:[75756,3] 26:[75760,3] 27:[75766,1] 28:[75768,2] 29:[75775,2] 30:[75778,11] 31:[75790,1] 32:[75793,1] 33:[75795,14] 34:[75810,1] 35:[75812,4] 36:[75820,21] 37:[75848,11] 38:[75861,2] 39:[75868,5] 40:[75874,2] 41:[75880,9] 42:[75891,12] 43:[75922,1] 44:[75925,2] 45:[75939,3] 46:[75944,3] 47:[75965,2] 48:[75979,1] 49:[76012,1] 50:[76018,3] 51:[76023,3] 52:[76027,4] 53:[76032,3] 54:[76036,6] 55:[76044,6] 56:[76051,1] 57:[76053,5] 58:[76059,1] 59:[76061,3] 60:[76065,34] 61:[76151,244] 62:[76396,5] 63:[76402,12] 64:[76415,10] 65:[76427,2] 66:[76431,1] 67:[76433,10] 68:[76445,1] 69:[76451,1] 70:[76454,5] 71:[76460,10] 72:[76479,1] 73:[76481,7] 74:[76495,2] 75:[76500,2] 76:[76506,1] 77:[76508,2] 78:[76518,1] 79:[76521,5] 80:[76529,3] 81:[76534,4] 82:[76539,2] 83:[76545,5] 84:[76555,2] 85:[76559,14] 86:[76574,1] 87:[76576,13] 88:[76592,4] 89:[76597,8] 90:[76606,6] 91:[76619,1] 92:[76621,1] 93:[76633,2] 94:[76636,1] 95:[76638,2] 96:[76652,7] 97:[76662,2] 98:[76667,1] 99:[76669,1] 100:[76672,5] 101:[76683,4] 102:[76688,1] 103:[76690,2] 104:[76696,3] 105:[76701,3] 106:[76705,1] 107:[76707,1] 108:[76710,13] 109:[76725,4] 110:[76730,4] 111:[76735,1] 112:[76740,2] 113:[76743,14] 114:[76758,11] 115:[76770,7] 116:[76778,1] 117:[76780,4] 118:[76785,1] 119:[76797,1] 120:[76799,5] 121:[76813,3] 122:[76819,2] 123:[76825,7] 124:[76833,6] 125:[76855,1] 126:[76860,2] 127:[76864,3] 128:[76869,2] 129:[76872,3] 130:[76877,3] 131:[76884,4] 132:[76890,4] 133:[76899,3] 134:[76903,2] 135:[76912,4] 136:[76921,1] 137:[76928,4] 138:[76936,3] 139:[76940,1] 140:[76945,1] 141:[76947,1] 142:[76949,3] 143:[76955,11] 144:[76969,2] 145:[76989,4] 146:[76996,11] 147:[77010,4] 148:[77016,3] 149:[77030,3] 150:[77037,6] 151:[77046,18] 152:[77070,2] 153:[77076,5] 154:[77082,7] 155:[77090,17] 156:[77108,4] 157:[77124,3] 158:[77134,13] 159:[77157,2] 160:[77161,8] 161:[77224,2] 162:[77229,3] 163:[77233,3] 164:[77237,2] 165:[77240,4] 166:[77245,3] 167:[77250,5] 168:[77256,4] 169:[77262,3] 170:[77273,4] 171:[77279,2] 172:[77284,1] 173:[77286,1] 174:[77290,2] 175:[77297,4] 176:[77311,64] 177:[77376,1] 178:[77379,5] 179:[77385,5] 180:[77391,6] 181:[77398,1] 182:[77404,1] 183:[77406,73] 184:[77500,2] 185:[77508,5] 186:[77559,14] 187:[77575,48] 188:[77637,60] 189:[77746,193] 190:[77966,5] 191:[77976,77] 192:[78102,30] 193:[78184,39] 194:[78227,3] 195:[78244,39] 196:[78288,54] 197:[78356,5] 198:[78364,62] 199:[78427,108] 200:[78540,116] 201:[78674,39] 202:[78730,27] 203:[78759,48] 204:[78811,16] 205:[78866,3] 206:[78908,36] 207:[78951,150] 208:[81355,4] 209:[81420,235] 210:[81740,36] 211:[81814,58] 212:[81885,249] 213:[82135,37] 214:[88936,18] 215:[88958,2] 216:[88965,3] 217:[88972,2] 218:[88978,2] 219:[88984,4] 220:[88992,3] 221:[89000,2] 222:[89006,24] 223:[89032,17] 224:[89051,11] 225:[89064,22] 226:[89088,1] 227:[89098,12] 228:[89113,18] 229:[89132,35] 230:[89188,2] 231:[89215,345] 232:[89561,23] 233:[89592,10] 234:[89622,6] 235:[89633,49] 236:[89693,15] 237:[89714,41] 238:[89756,49] 239:[89813,23] 240:[89845,755] 241:[90602,4] 242:[90619,56] 243:[90682,4] 244:[90688,9] 245:[90698,2] 246:[90707,32] 247:[90744,1] 248:[90751,1] 249:[90756,2] 250:[90760,10] 251:[90772,58] 252:[90833,12] 253:[90852,13] 254:[90868,5] 255:[90883,2] 256:[90888,12] 257:[90916,45] 258:[90964,47] 259:[91026,30] 260:[91058,4] 261:[91063,5] 262:[91071,1] 263:[91074,3] 264:[91078,2] 265:[91102,2] 266:[91105,2] 267:[91109,3] 268:[91113,2] 269:[91118,4] 270:[91128,1] 271:[91132,1] 272:[91134,2] 273:[91139,5] 274:[91151,102] 275:[91254,93] 276:[91352,2] 277:[91359,1] 278:[91364,2] 279:[91386,48] 280:[91436,10] 281:[91448,1] 282:[91450,2] 283:[91453,18] 284:[91472,41] 285:[91514,400] 286:[91920,2166] 287:[94089,5] 288:[94101,3] 289:[94108,2] 290:[94114,5] 291:[94120,2] 292:[94126,6] 293:[94136,19] 294:[94156,2] 295:[94159,7] 296:[94167,13] 297:[94182,4] 298:[94190,1] 299:[94193,8] 300:[94206,2] 301:[94211,1] 302:[94214,2] 303:[94221,2] 304:[94226,1] 305:[94229,2] 306:[94236,1283] 307:[95521,8] 308:[95534,1] 309:[95537,8] 310:[95550,1] 311:[95553,8] 312:[95566,4] 313:[95575,1] 314:[95579,8] 315:[95592,1] 316:[95595,8] 317:[95608,1] 318:[95610,2] 319:[95613,2] 320:[95619,1] 321:[95621,11] 322:[95644,1] 323:[95652,2] 324:[95656,8] 325:[95669,7] 326:[95677,21] 327:[95699,2] 328:[95703,5] 329:[95709,1] 330:[95711,3] 331:[95717,2] 332:[95720,7] 333:[95728,3] 334:[95734,9] 335:[95753,3] 336:[95757,15] 337:[95782,43] 338:[95827,3] 339:[95834,2] 340:[95837,1] 341:[95843,2] 342:[95850,1] 343:[95867,2] 344:[95870,2] 345:[95874,3] 346:[95879,5] 347:[95885,7] 348:[95893,67] 349:[95961,44] 350:[96007,56] 351:[96086,19] 352:[96258,5] 353:[96294,2] 354:[96301,1] 355:[96305,28] 356:[96346,10] 357:[96393,10] 358:[96405,1] 359:[96407,2] 360:[96412,1] 361:[96414,2] 362:[96422,2] 363:[96428,1] 364:[96450,6] 365:[96457,5] 366:[96468,5] 367:[96476,1] 368:[96484,9] 369:[96495,1] 370:[96498,2] 371:[96505,3] 372:[96509,1] 373:[96513,1] 374:[96516,1] 375:[96520,4] 376:[96527,1] 377:[96531,4] 378:[96536,1] 379:[96540,2] 380:[96544,3] 381:[96550,2] 382:[96554,2] 383:[96557,3] 384:[96569,22] 385:[96604,1] 386:[96614,9] 387:[96625,2] 388:[96638,2] 389:[97218,1] 390:[97221,1] 391:[97236,1] 392:[97247,2] 393:[97250,2] 394:[97271,1] 395:[97273,1] 396:[97283,2] 397:[97286,1] 398:[97292,1] 399:[97340,2] 400:[97377,1] 401:[97382,1] 402:[97391,3] 403:[97399,8] 404:[97413,3] 405:[97420,2] 406:[97423,2] 407:[97433,17] 408:[97455,3] 409:[97465,1] 410:[97471,1] 411:[97475,15] 412:[97494,6] 413:[97507,37] 414:[97584,1] 415:[97619,25] 416:[97666,10] 417:[97686,26] 418:[97753,14] 419:[97778,11] 420:[97798,3] 421:[97810,15] 422:[97827,4] 423:[97835,2] 424:[97846,2] 425:[97857,2] 426:[97905,7] 427:[97914,2] 428:[97925,19] 429:[97946,2] 430:[97966,4] 431:[97974,5] 432:[97995,24] 433:[98057,1] 434:[98067,34] 435:[98113,18] 436:[98136,19] 437:[98163,4] 438:[98186,2] 439:[98193,2] 440:[98198,4] 441:[98203,37] 442:[98244,22] 443:[98279,4] 444:[98284,2] 445:[98289,6] 446:[98330,4] 447:[98338,6] 448:[98349,11] 449:[98365,3] 450:[98383,1] 451:[98396,1] 452:[98405,22] 453:[98432,3] 454:[98454,2] 455:[98458,12] 456:[98479,2] 457:[98493,7] 458:[98504,2] 459:[98512,5] 460:[98531,1] 461:[98536,5] 462:[98609,2] 463:[98619,10] 464:[98631,10] 465:[98644,9] 466:[98657,13] 467:[98684,4] 468:[98692,2] 469:[98696,3] 470:[98715,6] 471:[98736,8] 472:[98794,2] 473:[98798,15] 474:[98863,2] 475:[98869,4] 476:[98920,2] 477:[98926,5] 478:[98986,10] 479:[98997,18] 480:[99039,2] 481:[99042,74] 482:[99133,6] 483:[99147,130] 484:[99282,6] 485:[99299,4] 486:[99306,20] 487:[99327,3] 488:[99338,18] 489:[99357,1] 490:[99359,2] 491:[99364,5] 492:[99375,4] 493:[99380,6] 494:[99393,47] 495:[99451,5] 496:[99457,3] 497:[99520,5] 498:[99539,11] 499:[99572,14] 500:[99590,3] 501:[99594,25] 502:[99623,40] 503:[99665,13] 504:[99686,28]

xfs_db> fsblock 6

xfs_db> type bnobt

xfs_db> p

magic = 0x41425442

level = 0

numrecs = 510

leftsib = 473

rightsib = 138

recs[1-510] = [startblock,blockcount] 1:[99725,12] 2:[99749,4] 3:[99771,12] 4:[99784,11] 5:[99797,5] 6:[99806,11] 7:[99819,2] 8:[99824,2] 9:[99829,8] 10:[99840,2] 11:[99844,23] 12:[99869,1] 13:[99873,2] 14:[99882,2] 15:[99889,3] 16:[99893,11] 17:[99918,10] 18:[99929,8] 19:[100069,8] 20:[100079,21] 21:[100107,14] 22:[100220,99] 23:[100555,25] 24:[101020,13] 25:[101060,58] 26:[101215,4] 27:[101220,1] 28:[101222,7] 29:[101233,10] 30:[101245,13] 31:[101261,22] 32:[101286,4] 33:[101292,2] 34:[101305,4] 35:[101314,2] 36:[101317,1] 37:[101321,50] 38:[101402,13] 39:[101430,8] 40:[101440,18] 41:[101465,2] 42:[101474,1] 43:[101481,1] 44:[101510,1] 45:[101527,1] 46:[101552,9] 47:[101576,8] 48:[101585,1] 49:[101610,1] 50:[101613,8] 51:[101647,5] 52:[101655,2] 53:[101702,2] 54:[101718,2] 55:[101733,2] 56:[101754,4] 57:[101767,2] 58:[101785,1] 59:[101824,2] 60:[101832,4] 61:[101839,2] 62:[101854,2] 63:[101870,2] 64:[101886,1] 65:[101889,2] 66:[101902,6] 67:[101917,19] 68:[101992,3] 69:[101999,12] 70:[102025,9] 71:[102046,3] 72:[102053,3] 73:[102057,1] 74:[102097,1] 75:[102099,1] 76:[102101,1] 77:[102109,3] 78:[102118,3] 79:[102128,1] 80:[102141,3] 81:[102184,3] 82:[102215,1] 83:[102221,2] 84:[102267,7] 85:[102277,42] 86:[102340,5] 87:[102356,53] 88:[102449,13] 89:[102471,9] 90:[102484,2] 91:[102491,1] 92:[102496,25] 93:[102522,48] 94:[102571,2111] 95:[104686,149] 96:[104836,6] 97:[104846,2] 98:[104852,83] 99:[104936,3] 100:[104940,1] 101:[104944,2] 102:[104947,3] 103:[104951,7] 104:[104959,2] 105:[104962,19] 106:[104982,3] 107:[104986,3] 108:[104990,15] 109:[105006,1] 110:[105008,5] 111:[105014,2] 112:[105017,1] 113:[105022,1] 114:[105024,9] 115:[105034,3] 116:[105038,1] 117:[105041,3] 118:[105046,1] 119:[105049,5] 120:[105074,7] 121:[105100,29] 122:[105132,2] 123:[105136,21] 124:[105165,1] 125:[105167,4] 126:[105172,1] 127:[105176,25] 128:[105276,1] 129:[105280,9] 130:[105292,4] 131:[105298,11] 132:[105367,9] 133:[105381,3] 134:[105388,2] 135:[105402,115] 136:[105543,37] 137:[105651,1] 138:[105685,29] 139:[105715,1] 140:[105722,1] 141:[105729,1] 142:[105739,37] 143:[105777,1] 144:[105783,1] 145:[106053,17] 146:[106076,48] 147:[106130,9] 148:[106146,6] 149:[106174,6] 150:[106185,19] 151:[106213,3] 152:[106221,22] 153:[106247,60] 154:[106310,18] 155:[106334,4] 156:[106344,8] 157:[106429,4] 158:[106450,476] 159:[106927,139] 160:[107067,19] 161:[107087,5486] 162:[112581,20] 163:[112608,29] 164:[112639,1] 165:[112647,1] 166:[112652,1] 167:[112659,1] 168:[112665,1] 169:[112667,1] 170:[112673,1] 171:[112684,1] 172:[112696,2] 173:[112707,1] 174:[112716,2051] 175:[114783,2] 176:[114788,1] 177:[114791,1] 178:[114817,2] 179:[114843,13] 180:[114860,2] 181:[114865,15] 182:[114889,2] 183:[114892,8] 184:[114910,3] 185:[114919,2] 186:[114937,1] 187:[114940,3] 188:[114966,1] 189:[114970,1] 190:[114973,2] 191:[114976,1] 192:[114978,7] 193:[114990,2] 194:[114997,1] 195:[114999,2] 196:[115004,1] 197:[115010,5] 198:[115019,2] 199:[115022,3] 200:[115039,3] 201:[115043,4] 202:[115058,2] 203:[115074,1] 204:[115076,3] 205:[115081,29] 206:[115113,14] 207:[115133,2] 208:[115136,12] 209:[115150,4] 210:[115164,1] 211:[115167,4] 212:[115184,2] 213:[115187,3] 214:[115203,9] 215:[115215,1] 216:[115218,1] 217:[115225,2] 218:[115229,1] 219:[115232,1] 220:[115241,8] 221:[115256,9] 222:[115271,11] 223:[115288,1] 224:[115293,3] 225:[115297,1] 226:[115299,1] 227:[115302,1] 228:[115307,3] 229:[115311,3] 230:[115315,5] 231:[115324,4] 232:[115332,2] 233:[115338,3] 234:[115344,6] 235:[115352,1] 236:[115356,3] 237:[115367,2] 238:[115370,1] 239:[115372,2] 240:[115377,4] 241:[115383,1] 242:[115386,1] 243:[115393,4] 244:[115400,1] 245:[115402,5] 246:[115411,2] 247:[115415,13] 248:[115437,5] 249:[115448,2] 250:[115457,3] 251:[115462,1] 252:[115482,2] 253:[115487,1] 254:[115492,2] 255:[115496,1] 256:[115498,4] 257:[115504,4] 258:[115514,1] 259:[115516,5] 260:[115522,2] 261:[115530,3] 262:[115537,1] 263:[115546,2] 264:[115550,1] 265:[115563,1] 266:[115567,2] 267:[115582,1] 268:[115589,1] 269:[115595,5] 270:[115603,1] 271:[115609,2] 272:[115620,12] 273:[115637,1] 274:[115639,1] 275:[115643,1] 276:[115650,1] 277:[115663,1] 278:[115665,1] 279:[115668,3] 280:[115676,1] 281:[115683,2] 282:[115688,1] 283:[115699,5] 284:[115706,2] 285:[115715,1] 286:[115718,3] 287:[115723,8] 288:[115732,15] 289:[115752,1] 290:[115758,1] 291:[115760,5] 292:[115769,2] 293:[115773,3] 294:[115783,1] 295:[115785,1] 296:[115797,2] 297:[115801,5] 298:[115828,4] 299:[115835,4] 300:[115840,2] 301:[115850,1] 302:[115853,2] 303:[115863,1] 304:[115867,3] 305:[115876,1] 306:[115879,1] 307:[115883,1] 308:[115885,1] 309:[115889,1] 310:[115893,1] 311:[115895,1] 312:[115899,1] 313:[115902,1] 314:[115904,2] 315:[115908,3] 316:[115913,1] 317:[115920,2] 318:[115925,1] 319:[115928,3] 320:[115951,1] 321:[115953,3] 322:[115958,2] 323:[115962,3] 324:[115979,3] 325:[115987,5] 326:[115996,2] 327:[116001,3] 328:[116012,4] 329:[116026,1] 330:[116028,2] 331:[116032,1] 332:[116035,1] 333:[116038,1] 334:[116042,1] 335:[116045,1] 336:[116063,4] 337:[116068,3] 338:[116073,3] 339:[116081,6] 340:[116088,2] 341:[116092,10] 342:[116115,49] 343:[116165,2] 344:[116176,8] 345:[116240,54] 346:[116295,54] 347:[116359,107] 348:[116472,10] 349:[116486,3] 350:[116549,3] 351:[116846,6] 352:[116862,33] 353:[117056,14] 354:[117838,7] 355:[117848,921] 356:[118789,59] 357:[118969,996] 358:[119966,57] 359:[120327,10] 360:[120381,1] 361:[120387,1] 362:[120404,69] 363:[120514,75] 364:[120596,133] 365:[120833,17] 366:[120927,42] 367:[121025,2] 368:[121149,45] 369:[121244,102] 370:[122151,117] 371:[122287,10] 372:[122317,13] 373:[122469,10] 374:[122505,79] 375:[122654,173] 376:[122894,5] 377:[122909,56] 378:[123009,25] 379:[123188,19] 380:[123265,20] 381:[123475,54] 382:[123598,3] 383:[123683,10] 384:[123754,87] 385:[123888,1] 386:[123908,98] 387:[124122,1460] 388:[125585,53] 389:[125744,10] 390:[125756,44] 391:[125852,54] 392:[125995,57] 393:[126055,20] 394:[126154,73] 395:[126280,3] 396:[126335,54] 397:[126395,46] 398:[126442,5] 399:[126475,1] 400:[126514,1] 401:[126516,1] 402:[126868,1] 403:[126994,1] 404:[126996,1] 405:[127156,1] 406:[127158,1] 407:[127177,3] 408:[127203,1] 409:[127235,3] 410:[127245,1] 411:[127251,11] 412:[127263,12] 413:[127281,5] 414:[127287,4] 415:[127301,7] 416:[127414,6] 417:[127447,89] 418:[127563,11] 419:[127741,10] 420:[127761,2] 421:[127764,520] 422:[128332,11] 423:[128421,4] 424:[128595,63] 425:[128710,6] 426:[128717,8] 427:[129006,1] 428:[129008,1] 429:[129010,2] 430:[129019,9] 431:[129114,3] 432:[129119,1] 433:[129135,8] 434:[129145,55] 435:[129207,40] 436:[129276,9] 437:[129346,9] 438:[129358,12] 439:[129411,9] 440:[129423,10] 441:[129449,44] 442:[129496,1] 443:[129506,9] 444:[129519,50] 445:[129662,2] 446:[129676,9] 447:[129695,86] 448:[129808,4] 449:[129860,57] 450:[129954,19] 451:[130067,92] 452:[130209,1] 453:[130249,4] 454:[130258,48] 455:[130307,1] 456:[130310,1] 457:[130312,1] 458:[130340,2988] 459:[133329,67] 460:[133484,3] 461:[133524,9] 462:[133535,43] 463:[133604,18] 464:[133666,9] 465:[133684,11] 466:[133757,9] 467:[133833,10] 468:[133863,49] 469:[133914,5] 470:[133986,7] 471:[134037,15] 472:[134110,1] 473:[134112,1] 474:[134122,4] 475:[134130,7] 476:[134138,3] 477:[134154,1] 478:[134158,1] 479:[134185,1] 480:[134187,40] 481:[134249,1] 482:[134298,1] 483:[134449,9] 484:[134467,11] 485:[134486,4] 486:[134506,9] 487:[134521,4] 488:[134530,17] 489:[134548,7] 490:[134570,259] 491:[134830,594] 492:[135462,2] 493:[136678,109] 494:[136863,109] 495:[136973,6] 496:[136991,2] 497:[137003,3] 498:[137041,56] 499:[137098,45] 500:[137207,78] 501:[137337,69] 502:[137526,26] 503:[137588,10] 504:[137621,1] 505:[137708,13] 506:[137732,10] 507:[137755,7] 508:[137763,8] 509:[139034,2] 510:[139046,10]

xfs_db> fsblock 138

xfs_db> type bnobt

xfs_db> p

magic = 0x41425442

level = 0

numrecs = 510

leftsib = 6

rightsib = 139

recs[1-510] = [startblock,blockcount] 1:[139125,51] 2:[139252,66] 3:[139389,14] 4:[139429,55] 5:[139495,8] 6:[139510,8] 7:[139529,11] 8:[139612,121] 9:[139768,40] 10:[139817,21] 11:[139839,90] 12:[140021,19] 13:[140076,56] 14:[140154,1] 15:[140191,71] 16:[140263,49] 17:[140313,6] 18:[140326,38] 19:[140377,9] 20:[140435,1] 21:[140529,62] 22:[140594,10] 23:[140729,12] 24:[140807,15] 25:[140886,1] 26:[140942,47] 27:[141185,1] 28:[141216,65] 29:[141282,207] 30:[141535,46] 31:[141635,3] 32:[141639,10] 33:[141663,7] 34:[141679,2] 35:[141682,11] 36:[141694,9] 37:[141773,34] 38:[141813,7] 39:[141946,1] 40:[141948,12] 41:[141971,1] 42:[141982,16] 43:[142019,11] 44:[142033,428] 45:[142462,6] 46:[142479,1] 47:[142526,76] 48:[142608,10] 49:[142679,6] 50:[142760,49] 51:[142844,50] 52:[142899,4] 53:[142906,93] 54:[143014,1] 55:[143041,6] 56:[143058,11] 57:[143075,56] 58:[143177,10] 59:[143193,50] 60:[143292,45] 61:[143563,2] 62:[143566,6] 63:[143573,38] 64:[143791,89] 65:[143935,6] 66:[144005,76] 67:[144177,2] 68:[144188,65] 69:[144306,39] 70:[144352,12] 71:[144376,1] 72:[144433,3] 73:[144512,63] 74:[144577,5] 75:[144592,153] 76:[144746,11] 77:[144761,6] 78:[144777,56] 79:[144852,24] 80:[144884,1] 81:[144907,13] 82:[144922,62] 83:[144987,6] 84:[145013,38] 85:[145137,4] 86:[145154,1] 87:[145195,74] 88:[145313,2] 89:[145316,2] 90:[145319,13] 91:[145334,1] 92:[145340,7] 93:[145350,2] 94:[145353,5] 95:[145359,1] 96:[145361,19] 97:[145386,17] 98:[145411,13] 99:[145426,5] 100:[145434,2] 101:[145439,9] 102:[145454,6] 103:[145462,2] 104:[145465,5] 105:[145471,1] 106:[145473,3] 107:[145479,1] 108:[145481,6] 109:[145488,5] 110:[145495,2] 111:[145499,10] 112:[145511,5] 113:[145518,10] 114:[145529,9] 115:[145550,2] 116:[145554,10] 117:[145568,44] 118:[145613,27] 119:[145649,3] 120:[145683,37] 121:[145722,1635] 122:[147362,1] 123:[147369,1] 124:[147377,1] 125:[147393,1] 126:[147423,1] 127:[147450,1] 128:[147456,1] 129:[147465,1] 130:[147478,1] 131:[147498,1] 132:[147504,2] 133:[147512,1] 134:[147520,1] 135:[147528,1] 136:[147540,1] 137:[147548,1] 138:[147572,1] 139:[147598,1] 140:[147607,1] 141:[147618,1] 142:[147638,2] 143:[147641,1] 144:[147643,1] 145:[147653,11] 146:[147675,65] 147:[147829,2] 148:[147881,1] 149:[148067,281] 150:[148388,7] 151:[148403,2] 152:[148462,20] 153:[148520,17] 154:[148545,43] 155:[148595,1] 156:[148597,1] 157:[148602,2] 158:[148614,1] 159:[148624,3] 160:[148633,1] 161:[148635,1] 162:[148650,1] 163:[148655,6] 164:[148662,3] 165:[148667,1] 166:[148669,7] 167:[148680,1] 168:[148685,3] 169:[148689,2] 170:[148695,7] 171:[148703,5] 172:[148709,7] 173:[148717,19] 174:[148739,2] 175:[148742,1] 176:[148749,1] 177:[148752,21] 178:[148776,1] 179:[148779,1] 180:[148782,5] 181:[148803,19] 182:[148825,4] 183:[148835,3] 184:[148842,2] 185:[148845,4] 186:[148854,1] 187:[148856,1] 188:[148865,1] 189:[148868,2] 190:[148871,2] 191:[148884,3] 192:[148896,1] 193:[148902,1] 194:[148906,3] 195:[148920,4] 196:[148932,2] 197:[148945,1] 198:[148969,1] 199:[148974,2] 200:[148978,1] 201:[148981,4] 202:[148989,3] 203:[148993,1] 204:[148999,2] 205:[149015,1] 206:[149019,3] 207:[149036,4] 208:[149044,5] 209:[149057,2] 210:[149086,1] 211:[149096,1] 212:[149101,1] 213:[149111,5] 214:[149117,2] 215:[149125,7] 216:[149133,1] 217:[149135,1] 218:[149138,6] 219:[149161,2] 220:[149165,1] 221:[149169,1] 222:[149180,4] 223:[149207,1] 224:[149210,13] 225:[149227,6] 226:[149236,1] 227:[149246,1] 228:[149248,6] 229:[149257,2] 230:[149261,3] 231:[149266,5] 232:[149273,2] 233:[149276,1] 234:[149278,2] 235:[149281,5] 236:[149288,2] 237:[149291,2] 238:[149294,3] 239:[149300,5] 240:[149307,26] 241:[149349,30] 242:[149394,1] 243:[149401,4] 244:[149407,1] 245:[149412,2] 246:[149415,1] 247:[149418,1] 248:[149432,5] 249:[149438,4] 250:[149443,3] 251:[149448,1] 252:[149450,1] 253:[149456,3] 254:[149461,6] 255:[149470,6] 256:[149478,9] 257:[149497,2] 258:[149506,2] 259:[149526,2] 260:[149529,1] 261:[149533,3] 262:[149543,5] 263:[149550,1] 264:[149560,1] 265:[149562,8] 266:[149572,4] 267:[149579,1] 268:[149583,1] 269:[149589,5] 270:[149596,7] 271:[149611,1] 272:[149614,2] 273:[149618,1] 274:[149620,1] 275:[149622,3] 276:[149626,1] 277:[149630,2] 278:[149637,3] 279:[149641,1] 280:[149645,2] 281:[149656,11] 282:[149677,2] 283:[149681,1] 284:[149684,4] 285:[149689,2] 286:[149707,1] 287:[149710,2] 288:[149713,3] 289:[149721,2] 290:[149724,2] 291:[149728,1] 292:[149730,2] 293:[149734,1] 294:[149736,1] 295:[149739,1] 296:[149743,1] 297:[149746,2] 298:[149752,1] 299:[149758,2] 300:[149769,1] 301:[149780,4] 302:[149785,3] 303:[149791,4] 304:[149801,33] 305:[149838,1] 306:[149842,3] 307:[149846,1] 308:[149848,1] 309:[149852,3] 310:[149856,2] 311:[149860,2] 312:[149863,2] 313:[149867,3] 314:[149871,4] 315:[149880,3] 316:[149884,11] 317:[149896,1] 318:[149900,1] 319:[149904,1] 320:[149906,2] 321:[149912,2] 322:[149915,1] 323:[149917,1] 324:[149927,5] 325:[149934,2] 326:[149939,2] 327:[149950,1] 328:[149957,2] 329:[149961,3] 330:[149967,1] 331:[149969,4] 332:[149974,3] 333:[149980,1] 334:[149985,1] 335:[149987,1] 336:[149989,4] 337:[149997,2] 338:[150000,3] 339:[150004,2] 340:[150008,1] 341:[150013,2] 342:[150017,1] 343:[150020,1] 344:[150022,3] 345:[150030,2] 346:[150038,1] 347:[150044,3] 348:[150051,1] 349:[150053,2] 350:[150060,6] 351:[150069,6] 352:[150077,7] 353:[150087,2] 354:[150091,1] 355:[150093,1] 356:[150096,18] 357:[150116,25] 358:[150144,9] 359:[150159,4] 360:[150164,4] 361:[150173,14] 362:[150193,13] 363:[150208,18] 364:[150227,9] 365:[150237,4] 366:[150242,3] 367:[150246,10] 368:[150264,1] 369:[150271,7] 370:[150284,1] 371:[150296,1] 372:[150303,3] 373:[150308,5] 374:[150347,1] 375:[150352,1] 376:[150359,1] 377:[150364,2] 378:[150380,1] 379:[150385,2] 380:[150410,1] 381:[150413,1] 382:[150420,2] 383:[150424,3] 384:[150432,5] 385:[150439,1] 386:[150482,1] 387:[150484,1] 388:[150489,2] 389:[150492,1] 390:[150494,5] 391:[150502,2] 392:[150506,1] 393:[150508,1] 394:[150525,2] 395:[150529,7] 396:[150537,1] 397:[150540,1] 398:[150546,1] 399:[150548,1] 400:[150553,3] 401:[150557,2] 402:[150560,6] 403:[150592,1] 404:[150601,1] 405:[150604,13] 406:[150621,4] 407:[150631,21] 408:[150653,7] 409:[150662,1] 410:[150667,1] 411:[150699,1] 412:[150701,2] 413:[150704,4] 414:[150711,3] 415:[150724,2] 416:[150727,10] 417:[150742,2] 418:[150745,1] 419:[150748,1] 420:[150750,3] 421:[150754,6] 422:[150761,1] 423:[150763,2] 424:[150768,1] 425:[150770,2] 426:[150773,6] 427:[150780,8] 428:[150798,1] 429:[150800,2] 430:[150803,1] 431:[150808,3] 432:[150814,1] 433:[150816,1] 434:[150820,1] 435:[150824,4] 436:[150838,2] 437:[150845,2] 438:[150848,6] 439:[150858,3] 440:[150864,3] 441:[150873,1] 442:[150876,2] 443:[150879,7] 444:[150893,3] 445:[150898,2] 446:[150903,1] 447:[150905,2] 448:[150911,1] 449:[150913,1] 450:[150920,2] 451:[150927,9] 452:[150955,1] 453:[150960,4] 454:[150967,1] 455:[150970,19] 456:[150994,10] 457:[151007,1] 458:[151010,1] 459:[151014,3] 460:[151021,2] 461:[151024,3] 462:[151034,2] 463:[151043,2] 464:[151050,4] 465:[151055,1] 466:[151059,1] 467:[151062,11] 468:[151074,6] 469:[151087,9] 470:[151102,5] 471:[151113,25] 472:[151142,3] 473:[151154,15] 474:[151183,14] 475:[151198,7] 476:[151208,5] 477:[151221,9] 478:[151233,2] 479:[151238,35] 480:[151274,7] 481:[151284,6] 482:[151291,1] 483:[151297,11] 484:[151318,7] 485:[151328,1] 486:[151331,16] 487:[151348,2] 488:[151357,5] 489:[151363,3] 490:[151369,1] 491:[151373,3] 492:[151378,2] 493:[151384,1] 494:[151386,1] 495:[151388,1] 496:[151390,1] 497:[151395,2] 498:[151398,1] 499:[151409,4] 500:[151414,1] 501:[151417,3] 502:[151421,1] 503:[151425,1] 504:[151427,2] 505:[151430,1] 506:[151433,1] 507:[151435,2] 508:[151443,4] 509:[151449,7] 510:[151457,1]

xfs_db> fsblock 139

xfs_db> type bnobt

xfs_db> p

magic = 0x41425442

level = 0

numrecs = 315

leftsib = 138

rightsib = 110

recs[1-315] = [startblock,blockcount] 1:[151459,3] 2:[151466,3] 3:[151471,1] 4:[151474,1] 5:[151480,9] 6:[151490,2] 7:[151498,1] 8:[151502,5] 9:[151512,2] 10:[151516,1] 11:[151519,3] 12:[151523,1] 13:[151525,2] 14:[151528,7] 15:[151536,1] 16:[151540,4] 17:[151547,2] 18:[151550,1] 19:[151577,6] 20:[151584,3] 21:[151589,9] 22:[151601,6] 23:[151608,1] 24:[151610,1] 25:[151614,2] 26:[151621,1] 27:[151624,6] 28:[151635,1] 29:[151641,2] 30:[151644,2] 31:[151649,1] 32:[151655,1] 33:[151657,1] 34:[151660,2] 35:[151666,1] 36:[151670,2] 37:[151673,1] 38:[151675,1] 39:[151677,1] 40:[151684,3] 41:[151688,1] 42:[151691,2] 43:[151695,1] 44:[151700,1] 45:[151705,2] 46:[151708,6] 47:[151716,1] 48:[151720,7] 49:[151729,4] 50:[151740,10] 51:[151753,4] 52:[151762,1] 53:[151765,4] 54:[151772,4] 55:[151779,3] 56:[151785,1] 57:[151790,6] 58:[151797,1] 59:[151800,3] 60:[151810,1] 61:[151813,12] 62:[151828,1] 63:[151835,2] 64:[151840,3] 65:[151849,3] 66:[151853,4] 67:[151867,1] 68:[151869,8] 69:[151881,1] 70:[151885,1] 71:[151887,1] 72:[151893,1] 73:[151895,1] 74:[151899,1] 75:[151901,2] 76:[151904,1] 77:[151906,1] 78:[151909,1] 79:[151911,1] 80:[151914,1] 81:[151917,1] 82:[151919,4] 83:[151926,2] 84:[151930,1] 85:[151932,4] 86:[151938,1] 87:[151943,1] 88:[151947,1] 89:[151951,1] 90:[151953,2] 91:[151960,3] 92:[151965,1] 93:[151968,24] 94:[152002,13] 95:[152018,8] 96:[152028,1] 97:[152030,3] 98:[152036,1] 99:[152041,5] 100:[152051,1] 101:[152055,4] 102:[152060,1] 103:[152063,1] 104:[152065,2] 105:[152068,1] 106:[152072,1] 107:[152074,1] 108:[152076,1] 109:[152078,3] 110:[152082,3] 111:[152087,1] 112:[152089,3] 113:[152094,1] 114:[152096,2] 115:[152100,3] 116:[152104,1] 117:[152106,1] 118:[152109,4] 119:[152117,6] 120:[152124,4] 121:[152141,1] 122:[152147,5] 123:[152154,4] 124:[152161,5] 125:[152176,1] 126:[152178,8] 127:[152189,1] 128:[152195,1] 129:[152199,1] 130:[152208,4] 131:[152214,1] 132:[152216,6] 133:[152224,2] 134:[152230,1] 135:[152234,4] 136:[152240,1] 137:[152242,3] 138:[152246,1] 139:[152249,1] 140:[152251,2] 141:[152255,13] 142:[152269,3] 143:[152273,2] 144:[152276,1] 145:[152278,1] 146:[152280,1] 147:[152284,2] 148:[152288,5] 149:[152295,1] 150:[152298,1] 151:[152305,2] 152:[152309,1] 153:[152317,3] 154:[152324,10] 155:[152339,1] 156:[152344,1] 157:[152351,1] 158:[152356,1] 159:[152358,3] 160:[152363,1] 161:[152366,6] 162:[152373,1] 163:[152378,2] 164:[152386,2] 165:[152389,157] 166:[152547,4] 167:[152552,3] 168:[152557,1] 169:[152560,74] 170:[152635,6] 171:[152642,1] 172:[152647,2] 173:[152653,10] 174:[152667,1] 175:[152673,2] 176:[152680,2] 177:[152685,1] 178:[152690,1] 179:[152694,1] 180:[152700,1] 181:[152704,2] 182:[152709,1] 183:[152714,1] 184:[152716,2] 185:[152726,4] 186:[152732,4] 187:[152739,3] 188:[152751,6] 189:[152760,1] 190:[152764,2] 191:[152768,7] 192:[152776,4] 193:[152782,2] 194:[152787,1] 195:[152791,3] 196:[152795,1] 197:[152797,3] 198:[152801,1] 199:[152803,1] 200:[152805,10] 201:[152816,2] 202:[152820,1] 203:[152822,1] 204:[152827,1] 205:[152829,2] 206:[152834,2] 207:[152840,2] 208:[152845,2] 209:[152862,14] 210:[152878,1] 211:[152881,6] 212:[152889,1] 213:[152891,4] 214:[152903,2] 215:[152906,3] 216:[152922,1] 217:[152926,5] 218:[152936,1] 219:[152946,2] 220:[152951,7] 221:[152959,1] 222:[152966,1] 223:[152970,6] 224:[152979,14] 225:[152995,1] 226:[152998,8] 227:[153015,4] 228:[153020,11] 229:[153032,2] 230:[153038,13] 231:[153056,2] 232:[153059,4] 233:[153065,14] 234:[153089,1] 235:[153095,6] 236:[153109,1] 237:[153111,1] 238:[153115,3] 239:[153120,3] 240:[153139,3] 241:[153147,1] 242:[153149,5] 243:[153157,2] 244:[153161,1] 245:[153164,2] 246:[153179,2] 247:[153187,1] 248:[153203,3] 249:[153207,1] 250:[153216,4] 251:[153221,5] 252:[153227,8] 253:[153236,19] 254:[153256,10] 255:[153268,11] 256:[153282,16] 257:[153300,5] 258:[153306,6] 259:[153314,3] 260:[153318,3] 261:[153324,6] 262:[153331,1] 263:[153333,5] 264:[153340,4] 265:[153349,7] 266:[153359,1] 267:[153363,2] 268:[153366,2] 269:[153369,2] 270:[153372,2] 271:[153375,3] 272:[153379,2] 273:[153383,2] 274:[153387,1] 275:[153395,5] 276:[153402,2] 277:[153407,4] 278:[153416,1] 279:[153418,1] 280:[153420,5] 281:[153426,2] 282:[153430,2] 283:[153433,1] 284:[153438,1] 285:[153446,7] 286:[153459,3] 287:[153468,3] 288:[153482,1] 289:[153486,1] 290:[153489,1] 291:[153501,1] 292:[153505,3] 293:[153520,1] 294:[153527,1] 295:[153532,2] 296:[153539,3] 297:[153546,1] 298:[153548,1] 299:[153552,1] 300:[153554,8] 301:[153565,20] 302:[153586,1] 303:[153588,3] 304:[153602,8] 305:[153616,6] 306:[153633,12] 307:[153654,9] 308:[153684,1] 309:[153689,5] 310:[153703,7] 311:[153722,2] 312:[153725,4] 313:[153742,9] 314:[153753,2] 315:[153759,3]

xfs_db> fsblock 110

xfs_db> type bnobt

xfs_db> p

magic = 0x41425442

level = 0

numrecs = 366

leftsib = 139

rightsib = null

recs[1-366] = [startblock,blockcount] 1:[153765,1] 2:[153769,7] 3:[153778,10] 4:[153801,1] 5:[153806,2] 6:[153813,31] 7:[153845,2] 8:[153850,1] 9:[153855,4] 10:[153862,3] 11:[153871,3] 12:[153883,6] 13:[153899,1] 14:[153930,1] 15:[153936,1] 16:[153969,1] 17:[153975,1] 18:[153986,5] 19:[153993,1] 20:[154000,2] 21:[154006,1] 22:[154008,3] 23:[154012,1] 24:[154016,5] 25:[154022,2] 26:[154025,1] 27:[154027,2] 28:[154035,1] 29:[154037,7] 30:[154045,5] 31:[154053,1] 32:[154063,1] 33:[154073,1] 34:[154079,4] 35:[154090,4] 36:[154113,2] 37:[154126,12] 38:[154141,1] 39:[154154,9] 40:[154248,2] 41:[154253,3] 42:[154261,1] 43:[154280,1] 44:[154283,1] 45:[154286,5] 46:[154298,5] 47:[154309,1] 48:[154311,1] 49:[154314,2] 50:[154317,1] 51:[154319,3] 52:[154325,5] 53:[154331,2] 54:[154337,1] 55:[154345,1] 56:[154348,3] 57:[154357,1] 58:[154362,3] 59:[154371,1] 60:[154374,1] 61:[154382,1] 62:[154386,1] 63:[154390,1] 64:[154392,1] 65:[154398,8] 66:[154409,2] 67:[154412,1] 68:[154415,1] 69:[154426,2] 70:[154434,1] 71:[154439,2] 72:[154444,1] 73:[154457,1] 74:[154459,1] 75:[154473,2] 76:[154477,2] 77:[154481,4] 78:[154486,1] 79:[154494,3] 80:[154500,6] 81:[154509,6] 82:[154519,3] 83:[154525,2] 84:[154529,1] 85:[154534,7] 86:[154546,11] 87:[154565,1] 88:[154567,13] 89:[154588,4] 90:[154593,2] 91:[154600,1] 92:[154602,1] 93:[154604,1] 94:[154609,1] 95:[154613,2] 96:[154621,1] 97:[154628,9] 98:[154638,11] 99:[154653,3] 100:[154658,19] 101:[154678,12] 102:[154698,1] 103:[154710,4] 104:[154800,1] 105:[154805,1] 106:[154869,1] 107:[154880,1] 108:[154884,3] 109:[154888,1] 110:[154891,1] 111:[154894,2] 112:[154903,3] 113:[154908,2] 114:[154922,2] 115:[154929,1] 116:[154934,1] 117:[154938,1] 118:[154941,1] 119:[154947,1] 120:[154952,3] 121:[154956,1] 122:[154960,1] 123:[154963,1] 124:[154969,1] 125:[154983,1] 126:[154986,1] 127:[155005,3613] 128:[158619,2] 129:[158629,1] 130:[158631,3] 131:[158635,1] 132:[158638,1] 133:[158641,1] 134:[158644,2] 135:[158648,1] 136:[158658,3] 137:[158662,3] 138:[158669,1] 139:[158672,1] 140:[158674,3] 141:[158678,2] 142:[158681,5] 143:[158697,2] 144:[158710,2] 145:[158716,5] 146:[158722,5] 147:[158728,2] 148:[158738,2] 149:[158741,10] 150:[158754,8] 151:[158768,1] 152:[158773,1] 153:[158779,3] 154:[158784,4] 155:[158790,2] 156:[158795,9] 157:[158806,1] 158:[158810,3] 159:[158814,6] 160:[158824,1] 161:[158829,4] 162:[158834,4] 163:[158850,2] 164:[158854,1] 165:[158858,9] 166:[158868,5] 167:[158892,1] 168:[158894,1] 169:[158896,2] 170:[158901,1] 171:[158911,1] 172:[158915,1] 173:[158919,4] 174:[158926,2] 175:[158930,2] 176:[158933,1] 177:[158935,2] 178:[158938,14] 179:[158958,2] 180:[158962,9] 181:[158973,1] 182:[158977,6] 183:[158986,3] 184:[158994,3] 185:[159002,3] 186:[159006,5] 187:[159012,6] 188:[159019,1] 189:[159021,1] 190:[159025,1] 191:[159028,1] 192:[159033,2] 193:[159042,1] 194:[159044,5] 195:[159053,1] 196:[159056,1] 197:[159060,1] 198:[159062,18] 199:[159179,2] 200:[159197,1] 201:[159212,2] 202:[159235,17] 203:[159340,1] 204:[159348,268] 205:[159617,29] 206:[159648,13] 207:[159664,8] 208:[159693,1] 209:[159719,19] 210:[159742,1] 211:[159749,3] 212:[159753,52] 213:[159826,7] 214:[159841,1] 215:[159878,217] 216:[160128,20] 217:[160150,4] 218:[160155,3] 219:[160159,23] 220:[160184,3] 221:[160189,2] 222:[160200,16] 223:[160232,1] 224:[160234,1] 225:[160240,1] 226:[160247,1672] 227:[161920,1] 228:[162806,873] 229:[164551,4] 230:[164562,1] 231:[164763,1] 232:[164768,1] 233:[164773,2] 234:[164776,3] 235:[164785,3] 236:[164792,2] 237:[164796,1] 238:[164801,4] 239:[164806,1] 240:[164808,3] 241:[164812,3] 242:[164818,3] 243:[164830,8] 244:[164841,1] 245:[164846,2] 246:[164852,6] 247:[164859,1] 248:[164865,4] 249:[164871,1] 250:[164878,1] 251:[164882,6] 252:[164890,1] 253:[164892,1] 254:[164897,1] 255:[164899,1] 256:[164901,11] 257:[164916,2] 258:[164920,2] 259:[164923,1] 260:[164925,1] 261:[164928,1] 262:[164930,1] 263:[164933,15] 264:[164950,7] 265:[164958,3] 266:[164965,1] 267:[164967,1] 268:[164969,4] 269:[164977,2] 270:[164983,1] 271:[164985,5] 272:[165029,3] 273:[165034,2] 274:[165074,4] 275:[165098,1] 276:[165106,5] 277:[165115,1] 278:[165117,2] 279:[165149,4] 280:[165189,4] 281:[165216,1] 282:[165230,42] 283:[165277,1] 284:[165310,50] 285:[165406,65] 286:[165480,2] 287:[165501,47] 288:[165549,5] 289:[165618,4] 290:[165660,2] 291:[165663,23] 292:[165759,9] 293:[165802,250] 294:[166064,28] 295:[166106,11] 296:[166131,3] 297:[166136,6] 298:[166150,9] 299:[166208,186] 300:[166415,1] 301:[166417,1] 302:[166419,1] 303:[166421,12] 304:[166456,10] 305:[166469,10] 306:[166481,33] 307:[166520,11] 308:[166628,1] 309:[166679,2] 310:[166712,31] 311:[166816,8] 312:[166845,11] 313:[166908,2] 314:[166911,1] 315:[166922,58] 316:[166990,13] 317:[167075,53] 318:[167177,2337] 319:[169573,11] 320:[169632,64] 321:[169697,52] 322:[169752,11] 323:[169796,11] 324:[169897,7] 325:[169920,188] 326:[170109,176] 327:[170334,1] 328:[170337,84] 329:[170431,11] 330:[170454,80] 331:[170536,3] 332:[170644,150] 333:[170846,42] 334:[170893,131] 335:[171095,3] 336:[171105,40] 337:[171169,37] 338:[171335,90] 339:[171445,3] 340:[171463,30] 341:[171495,59] 342:[171672,59] 343:[171741,70] 344:[171813,10] 345:[171890,9] 346:[171909,2324] 347:[174285,46] 348:[174341,19] 349:[174420,43] 350:[174464,154] 351:[174645,4] 352:[174768,8] 353:[174835,7] 354:[174852,17] 355:[174879,7] 356:[174891,10] 357:[175046,58] 358:[175105,1] 359:[175115,39] 360:[175212,6] 361:[175220,77] 362:[175347,32] 363:[175383,89] 364:[175492,8] 365:[175510,1] 366:[175524,86535]

xfs_db>

七,ABTB/ABTC的节点块管理

前面几篇文章都是描述的如何利用ABTB/ABTC类型的B+tree来对AG空闲磁盘空间块进行管理,而这篇文章主要讲对ABTB/ABTC类型的B+tree各个节点本身所占去的磁盘block块的管理。
前面提到过,一块刚建立的Xfs文件系统,AG(仍然是以primary AG为例)的第1块block和第2块block分别被用来作为了ABTB和ABTC类型的B+tree的根节点,并且保留了第4、5、6、7这4块block作为B+tree增长所需。再来看一下:
[root@localhost ~]# /home/lenky/xfs/xfsprogs/db/xfs_db /dev/loop0
xfs_db> agf
xfs_db> p
magicnum = 0x58414746
versionnum = 1
seqno = 0
length = 32768
bnoroot = 1
被ABTB类型的B+tree根节点占去的第1块block。
cntroot = 2
被ABTC类型的B+tree根节点占去的第2块block。
bnolevel = 1
cntlevel = 1
flfirst = 0
fllast = 3
flcount = 4
freeblks = 32756
longest = 32756
btreeblks = 0
xfs_db> agfl
xfs_db> p
bno[0-127] = 0:4 1:5 2:6 3:7
为ABTB/ABTC类型的B+tree增长所需而保留下来的第4、5、6、7这4块block。
xfs_db>
保留下来的block的块号被记录在agfl里,前面文章的图示中给出过agfl的位置,即是在第0块block的第3个sector内:

1

2

3

4

5

6

[root@localhost loop]# hexdump -C -s 1536 -n 512 /dev/loop0

00000600  00 00 00 04 00 00 00 05  00 00 00 06 00 00 00 07  |................|

00000610  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00000800

[root@localhost loop]#

一个sector大小为512,而指示一个block号需要4个字节,所以agfl总共可以保存128块block的块号,也即是上面的bno[0-127]被显示为一个具有128个元素的数组。agfl内指定的block并不全是有效的,有一些block可能已经被当作BTB/ABTC类型的B+tree节点使用,也可能已经释放或做它用,只有一部分有效,哪些有效呢?agf里的三个字段(flfirst、fllast和flcount)指明了这一点,即是bno[flfirst]到bno[fllast],这flcount个元素指定的block块才是有效的,值得注意的是,bno被组成了一个环状,也就是说如果flfirst=126,fllast=1,flcount=4,那么有效block的块号分别为bno[126]、bno[127]、bno[0]、bno[1]。这些保留下来的有效的block块不能用来保存任何其它数据,只能用来作为当ABTB/ABTC类型的B+tree增长需要新的中间节点或叶子节点的存储空间。保留block块的申请释放在函数xfs_alloc_fix_freelist内,被释放出保留队列的block块当然就可以用来存放其它数据了。
看实际数据验证我们的分析:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

[root@localhost xfsprogs]# ./db/xfs_db /dev/sdb1

xfs_db> agf 0

xfs_db> p

magicnum = 0x58414746

versionnum = 1

seqno = 0

length = 262059

bnoroot = 5

cntroot = 472

bnolevel = 2

cntlevel = 2

flfirst = 21

fllast = 26

flcount = 6

freeblks = 165395

longest = 86535

btreeblks = 16

xfs_db> agfl

xfs_db> p

bno[0-127] = 0:4 1:5 2:6 3:7 4:470 5:471 6:472 7:473 8:474 9:475 10:6 11:7 12:58 13:138 14:139 15:106 16:108 17:110 18:134 19:160 20:324 21:407 22:419 23:421 24:64 25:134 26:99

xfs_db> fsblock 5

xfs_db> type bnobt

xfs_db> p

magic = 0x41425442

level = 1

numrecs = 8

leftsib = null

rightsib = null

keys[1-8] = [startblock,blockcount] 1:[32,3] 2:[47931,66] 3:[70425,1] 4:[75668,2] 5:[99725,12] 6:[139125,51] 7:[151459,3] 8:[153765,1]

ptrs[1-8] = 1:1 2:324 3:4 4:473 5:6 6:138 7:139 8:110

xfs_db> fsblock 472

xfs_db> type cntbt

xfs_db> p

magic = 0x41425443

level = 1

numrecs = 8

leftsib = null

rightsib = null

keys[1-8] = [blockcount,startblock] 1:[1,107] 2:[1,115863] 3:[1,152036] 4:[2,115332] 5:[3,76899] 6:[4,77297] 7:[8,77161] 8:[24,73665]

ptrs[1-8] = 1:2 2:474 3:106 4:471 5:108 6:58 7:475 8:7

xfs_db>

ABTB占用的块:
1、4、5、6、110、138、139、324、473
ABTC占用的块:
2、7、58、106、108、471、472、474、475
保留队列:
0:4 1:5 2:6 3:7 4:470 5:471 6:472 7:473 8:474 9:475 10:6 11:7 12:58 13:138 14:139 15:106 16:108 17:110 18:134 19:160 20:324 21:407 22:419 23:421 24:64 25:134 26:99
红色字体block块是当前做为ABTB/ABTC类型的B+tree节点在使用的,一共有16块,符合上面btreeblks的值(这个字段记录ABTB和ABTC这两种类型B+tree的树节点所占的block块数,但不包括最开始根节点所占的那两块,即是第1块和第2块),蓝色字体block当前是处于保留状态,而绿色字体block是之前做过保留、被当作B+tree节点使用之后,现在已被释放,但释放的134这块block现在又处于了保留状态。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

xfs_db> fsblock 470

xfs_db> type text

xfs_db> p

000:  52 43 55 20 61 6e 64 20 55 6e 6c 6f 61 64 61 62  RCU.and.Unloadab

010:  6c 65 20 4d 6f 64 75 6c 65 73 0a 0a 5b 4f 72 69  le.Modules...Ori

020:  67 69 6e 61 6c 6c 79 20 70 75 62 6c 69 73 68 65  ginally.publishe

030:  64 20 69 6e 20 4c 57 4e 20 4a 61 6e 2e 20 31 34  d.in.LWN.Jan..14

040:  2c 20 32 30 30 37 3a 20 68 74 74 70 3a 2f 2f 6c  ..2007..http...l

*

ff0:  20 20 20 20 20 20 20 22 53 74 6f 70 70 69 6e 67  ........Stopping

xfs_db> fsblock 160

xfs_db> type text

xfs_db> p

000:  0a 50 6f 77 65 72 4e 6f 77 21 20 61 6e 64 20 43  .PowerNow..and.C

010:  6f 6f 6c 27 6e 27 51 75 69 65 74 20 61 72 65 20  ool.n.Quiet.are.

020:  41 4d 44 20 6e 61 6d 65 73 20 66 6f 72 20 66 72  AMD.names.for.fr

030:  65 71 75 65 6e 63 79 0a 6d 61 6e 61 67 65 6d 65  equency.manageme

040:  6e 74 20 63 61 70 61 62 69 6c 69 74 69 65 73 20  nt.capabilities.

*

ff0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

xfs_db> fsblock 134

xfs_db> type text

xfs_db> p

000:  41 42 54 42 00 00 00 ff 00 00 00 01 00 00 00 04  ABTB............

010:  00 00 bb 3b 00 00 00 42 00 00 bd 26 00 00 00 2d  .......B........

020:  00 00 bd c4 00 00 00 05 00 00 be 09 00 00 00 0a  ................

030:  00 00 be 7b 00 00 00 37 00 00 bf 61 00 00 00 02  .......7...a....

040:  00 00 c0 19 00 00 00 72 00 00 c0 96 00 00 00 6d  .......r.......m

*

ff0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

xfs_db>

一定程度上可以看到470和160这两块block已经放了数据(不能确定这些数据当前是否有效,但可以确定其一定没有作为B+tree节点在使用),而134这块block被保留下来了(可以确定其当前一定没有存放其它有效数据)。

八,inode节点管理

作为标记一个文件的inode号,对于它的管理当然也是十分重要的。inode的分配与释放总是以64为单位组成chunk块来进行,那么一个AG对于inode整体的管理也就是对这些chunk块的管理,AG仍然还是使用B+tree这个数据结构来管理这些chunk块的分配与释放。这个B+tree的类型(指人为的对其所占用的block块进行magic标记和区分)为IABT,和ABTB/ABTC类似。
IABT类型的B+tree的根节点所在block块号由xfs_agi指定,xfs_agi存储在第0块block的第2块sector内,一块新建立的Xfs文件系统的AG的agi如下:
[root@localhost xfsprogs]# ./db/xfs_db /dev/loop0
xfs_db> agi 0
xfs_db> p
magicnum = 0x58414749
魔术数,即是‘XAGI’。
versionnum = 1
版本号,由XFS_AGI_VERSION定义,值为1。
seqno = 0
agi的序号,第0块AG内的agi序号为0,第1块AG内的agi序号为2,类此。
length = 32768
本AG内的block块数,其值=磁盘总大小/block块大小/AG数目,这里loop0磁盘大小为512M,即是:512*1024*1024/4096/4=32768。
count = 64
已分配的inode数目,这是一块新建立的primary AG,所以其一开始就分配了一个inode chunk,即是64个inode。如果是其它AG,一开始是没有分配inode chunk的:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

xfs_db> agi 1

xfs_db> p

magicnum = 0x58414749

versionnum = 1

seqno = 1

length = 32768

count = 0

root = 3

level = 1

freecount = 0

newino = null

dirino = null

unlinked[0-63] =

xfs_db>

root = 3
指定IABT类型的B+tree的根节点所在block块号,一开始就是第3块,后续随着分区的使用,inode的分配与释放,B+tree发生变化,随之根节点也会变到其它block块上。
level = 1
指定IABT类型的B+tree的树深度。
freecount = 61
当前可用的inode数,即是已经分配但尚未被使用的inode。新分区为什么只剩下了61个空闲inode?不是64个么?事实上,是因为1个(inode号为128)被用来作为了根节点,另外两个(inode号分别为129和130)被用来作为实时设备空间(real-time device’s space)的管理节点,即是位图节点和综述节点(the Bitmap Inode and the Summary Inode),关于这两个节点后续再讨论。这三个inode节点在代码路径(main(xfs_mkfs.c:2631)-> parse_proto(proto.c:592) -> parseproto(proto.c:564) -> rtinit(proto.c:645) -> …)里被使用掉,可以ls命令看一下根节点:

1

2

3

4

5

6

7

[root@localhost loop]# mount /dev/loop0 xfs

[root@localhost loop]# cd xfs

[root@localhost xfs]# ls -lia

total 4

   128 drwxr-xr-x. 2 root root    6 Dec 31 06:22 .

524142 drwxr-xr-x. 5 root root 4096 Dec 31 02:32 ..

[root@localhost xfs]#

newino = 128
新分配的inode chunk块内的起始inode号。
dirino = null
最后一个目录inode chunk块号。
unlinked[0-63] =
该字段后续会讲到。
xfs_db>
前面已经详细讲解了ABTB/ABTC类型B+tree的组织与结构,与此类似的IABT类型B+tree也差不多,只是B+tree里具体的数据字段以及含义有点变化而已。先来看深度为1的IABT类型B+tree,在此之前先弄点数据上去:

1

2

3

4

5

6

7

8

9

10

[root@localhost loop]# mount /dev/loop0 xfs

[root@localhost loop]# cd xfs

[root@localhost xfs]# for((i=1;i<=897;i++)); do touch "$i"; done

[root@localhost xfs]# ls | wc -w

897

[root@localhost xfs]# rm -f 234  271  308  345  382  419  456  493  53   567  603  640  678

[root@localhost xfs]# ls | wc -w

884

[root@localhost xfs]# cd ..

[root@localhost loop]# umount xfs

再看agi和IABT:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

[root@localhost xfsprogs]# ./db/xfs_db /dev/loop0

xfs_db> agi

xfs_db> p

magicnum = 0x58414749

versionnum = 1

seqno = 0

length = 32768

count = 960

root = 3

level = 1

freecount = 73

newino = 1184

dirino = null

unlinked[0-63] =

xfs_db> fsblock 3

xfs_db> type inobt

xfs_db> p

magic = 0x49414254

level = 0

numrecs = 15

leftsib = null

rightsib = null

recs[1-15] = [startino,freecount,free] 1:[128,1,0x80000000000000] 2:[224,0,0] 3:[288,0,0] 4:[352,1,0x100000000000] 5:[416,2,0x40000000020000] 6:[512,1,0x8000000] 7:[576,2,0x2000000001] 8:[640,2,0x800000000400] 9:[768,1,0x200000000000000] 10:[832,1,0x20000000] 11:[896,2,0x10000000004] 12:[960,0,0] 13:[1056,0,0] 14:[1120,0,0] 15:[1184,60,0xfffffffffffffff0]

xfs_db>

上面的agi信息给出:IABT的根节点在第3块block,树深度为1,当前空闲的inode数为73,最新分配的inode chunk块内的起始inode号为1184;而从第3块block里的信息可以看出一些inode的分布,比如从[128,1,0×80000000000000]可以看出第8(起始inode号是128,那么推算出该inode chunk所在的block号为128/16=8,其中16是指1块block可以存放16个inode,当然是指默认配置下)块block被用来作为inode chunk,并且还有一个inode处于空闲状态,该空闲inode通过0x80000000000000掩码来标识出。

Xfs文件系统磁盘布局_第6张图片
看实际数据验证我们的分析,注意inode的魔术数,即‘IN’:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

xfs_db> fsblock 14

xfs_db> type text

xfs_db> p

000:  49 4e 81 a4 02 02 00 00 00 00 00 00 00 00 00 00  IN..............

010:  00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01  ................

020:  4e ff 06 27 26 df 24 32 4e ff 06 27 26 df 24 32  N......2N......2

030:  4e ff 06 27 26 df 24 32 00 00 00 00 00 00 00 00  N......2........

040:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

050:  00 00 0d 01 00 00 00 00 00 00 00 00 c9 8b c4 a0  ................

060:  ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00  ................

070:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

080:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

090:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

0a0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

0b0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

0c0:  00 00 00 00 00 00 00 00 00 00 00 00 00 2e 01 00  ................

0d0:  07 20 04 73 65 6c 69 6e 75 78 75 6e 63 6f 6e 66  ...selinuxunconf

0e0:  69 6e 65 64 5f 75 3a 6f 62 6a 65 63 74 5f 72 3a  ined.u.object.r.

0f0:  66 69 6c 65 5f 74 3a 73 30 00 00 00 00 00 00 00  file.t.s0.......

100:  49 4e 81 a4 02 02 00 00 00 00 00 00 00 00 00 00  IN..............

110:  00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01  ................

120:  4e ff 06 27 27 e2 8a 71 4e ff 06 27 27 e2 8a 71  N......qN......q

再来看深度为2的IABT类型B+tree,这意味着该B+tree有中间节点:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

[root@localhost xfsprogs]# ./db/xfs_db /dev/sdb1

xfs_db> agi

xfs_db> p

magicnum = 0x58414749

versionnum = 1

seqno = 0

length = 262059

count = 17216

root = 153945

level = 2

freecount = 8337

newino = 2712224

dirino = null

unlinked[0-63] =

xfs_db> fsblock 153945

xfs_db> type inobt

xfs_db> p

magic = 0x49414254

level = 1

numrecs = 2

leftsib = null

rightsib = null

keys[1-2] = [startino] 1:[128] 2:[1557376]

ptrs[1-2] = 1:3 2:153893

xfs_db> fsblock 3

xfs_db> type inobt

xfs_db> p

magic = 0x49414254

level = 0

numrecs = 127

leftsib = null

rightsib = 153893

recs[1-127] = [startino,freecount,free] 1:[128,37,0x7df4ffbb16ec1e0] 2:[224,25,0x137551fd67500] 3:[320,17,0xa07611981000a804] 4:[448,42,0xd52a8fefffff366] 5:[576,25,0xa7d5811171a40198] 6:[704,32,0x657c8fd13f0107f0] 7:[864,27,0x7a00b8e69874a506] 8:[960,29,0xece2a1702427cd32] 9:[1088,29,0x792d3126ba0e6831] 10:[1152,24,0x4c86309169106876] 11:[1216,33,0xae133c71367ac387] 12:[1312,33,0xb7a5cbd5c3805566] 13:[1376,37,0x859df31fde65a8f4] 14:[1440,28,0xa6ed30e21ac05836] 15:[1504,30,0xb0d0da190fd74aa4] 16:[1600,36,0x29bffbfef0122e9] 17:[148448,18,0x80a0024b2388b50] 18:[148544,34,0xf11be655e967ae10] 19:[743232,20,0x2008e2a40095252e] 20:[743328,20,0x7cb5061004250184] 21:[764352,23,0x43d08c842b251509] 22:[764416,35,0xaebffdde9ac1058] 23:[798144,48,0x3bf7bfbffdabd7d2] 24:[903232,22,0x8ce531826c01c108] 25:[903296,28,0xc38203d4fa5608ea] 26:[903392,33,0xb0fa7782527c893d] 27:[903456,27,0xb019303c66656895] 28:[903552,27,0x5495808f44f9203d] 29:[903616,31,0x24668b2252db36be] 30:[903680,24,0xa88974490a86996] 31:[903744,26,0x59341846dea7482] 32:[903904,23,0x1110bb2201106f69] 33:[903968,35,0xebb95b71e084f3a5] 34:[904064,40,0xffefbf6f5c960115] 35:[1090624,30,0x7a606d0822798d7b] 36:[1120000,30,0x352260c6399cbfe] 37:[1120096,36,0xd2f6b0ace3cad9ec] 38:[1120192,33,0xc45b654ded9e86d0] 39:[1124064,38,0x7ff33b3b8a4c3778] 40:[1124160,39,0x837b1ddcc7ba9bf5] 41:[1124224,30,0xe050e4b0c75cb5a9] 42:[1124320,19,0x2061500a402a196a] 43:[1124416,26,0x7867870a9410b452] 44:[1124480,26,0xb4b306a931968c02] 45:[1124608,27,0x60b1560bae862e11] 46:[1124704,38,0x3cffe6a3212f4fea] 47:[1124800,35,0xfffdc0794035992d] 48:[1124896,46,0x9aee755373cfffff] 49:[1125024,41,0xffdabbb716c9768d] 50:[1125120,34,0x7b00005bb5f0ffe7] 51:[1125248,31,0x474c7a4e83ad474c] 52:[1125344,32,0x83ad474c7a4e83ad] 53:[1125440,39,0x30f7ef9878efda4e] 54:[1125536,31,0x237a6bcd00bd113b] 55:[1125696,34,0x5c0f519128fbfd2e] 56:[1125792,34,0xff8ede09958452ae] 57:[1125984,54,0xaa6cbdffffffffff] 58:[1126112,42,0xfdfeb99675e63dd1] 59:[1126240,47,0xaf6d7fe23beffa7f] 60:[1126336,55,0xfef7effffbfb77f9] 61:[1126400,46,0xdef5fd1e9657dffd] 62:[1126528,40,0xefe6993f1e33f38b] 63:[1126624,33,0xb00c0ffc776d9711] 64:[1126720,34,0xe0e805bf1856f3e7] 65:[1126848,34,0xd4782a5a93dcfb51] 66:[1126976,30,0x4dee910cb83d0a3c] 67:[1127072,36,0xc0cff3a5a0db36dd] 68:[1127200,42,0xffdffa0df73c1995] 69:[1127360,36,0xea8b8bb525ea8baf] 70:[1127424,32,0x4101db756fa017eb] 71:[1133728,41,0x1bb229c3bfef75ef] 72:[1133856,37,0x4d2bd7afdad43d7] 73:[1133984,21,0x7a1c36c00005e140] 74:[1134112,29,0x921e580a75610fb9] 75:[1142432,23,0x1b97c9e298008404] 76:[1142560,31,0x1b1d140c6b9c75b5] 77:[1142624,37,0xfdec1a3bb72aba8c] 78:[1142752,34,0xb0b970fe095db749] 79:[1142848,32,0xf3f77b8c82414943] 80:[1156448,52,0x9dffffbf3ff6ebeb] 81:[1156544,57,0x5df4fffffffffffb] 82:[1167040,27,0xca719322228d217a] 83:[1167136,35,0xc35336aa757ebf20] 84:[1167232,40,0xb7fd91679ff2ba94] 85:[1167360,35,0x76769abef4de802a] 86:[1167424,32,0x1db9d16925dc4396] 87:[1183680,40,0x3578bbef333fe798] 88:[1183776,30,0x7be77b7718003300] 89:[1183872,39,0xfffffe0e18a33a0e] 90:[1194368,50,0xf7fbfaffd57b7c9f] 91:[1194464,45,0xf5fabb87f5ff6a97] 92:[1239872,47,0xf5ffdd9dade7f17e] 93:[1239936,53,0x83befffffcf7fdff] 94:[1240032,26,0x84fb6fee00e00081] 95:[1423264,27,0x7effff856] 96:[1423360,29,0xff6fdeedc0000001] 97:[1423488,60,0xbdbffffffbffffff] 98:[1423584,49,0xfbffbb7fef155f3b] 99:[1423680,59,0xaffdfffeffefffff] 100:[1423808,55,0x7f5afffffbbfffd7] 101:[1423936,40,0x310bf2b7fb5fe93b] 102:[1424032,32,0xb9ebd5a318958a89] 103:[1451840,40,0xdb6ddb19dfd370d5] 104:[1451936,38,0x9e6db0b27796db6e] 105:[1452032,40,0xdb67f07593fde1da] 106:[1461568,43,0xb75eddb34f8dbddb] 107:[1461664,39,0x79b8ddb6db6db6d] 108:[1461760,49,0xffff7ffeb7899e1f] 109:[1461856,44,0x55555554fffe3fff] 110:[1470656,31,0xd523195555555555] 111:[1505664,38,0xfffffaa12a05948f] 112:[1505760,31,0xe5c288b2c2d65967] 113:[1505952,34,0xccffff0f420b280e] 114:[1506112,35,0xeed806dd21dec3ab] 115:[1533280,57,0xbf3f7ffffdffffbe] 116:[1533408,30,0x2434415aa234e3ff] 117:[1533536,23,0x9d22e093e1054024] 118:[1533632,25,0x36f90800d3390bc] 119:[1533760,18,0x72932000aaa20900] 120:[1556608,30,0x530ece40df0cd0ad] 121:[1556736,32,0x404cf3e9c5ad694b] 122:[1556832,22,0x2100d32001ac33d9] 123:[1556896,13,0x400002418b25011] 124:[1556992,18,0x83806cc00311e4] 125:[1557088,20,0x88b268d442123200] 126:[1557216,33,0xa6ee1b050ed26b97] 127:[1557312,30,0xd88cc1dd5d5503a8]

xfs_db> fsblock 153893

xfs_db> type inobt

xfs_db> p

magic = 0x49414254

level = 0

numrecs = 142

leftsib = 3

rightsib = null

recs[1-142] = [startino,freecount,free] 1:[1557376,35,0x8fd81b18aff5d4d8] 2:[1557472,25,0xefcd60900040f826] 3:[1557568,32,0x800003ff59e37be7] 4:[1557664,15,0x1428c01101261900] 5:[1557760,10,0x2200208408440090] 6:[1557824,18,0x81e0d000061c5211] 7:[1557920,20,0x21e800129128aa83] 8:[1558048,51,0xbaffdfffffd7789e] 9:[1639680,52,0xfffbbbffffb5fb98] 10:[1639776,39,0xe63593977fd0b7cb] 11:[1639872,23,0x11e0680215a1fb4] 12:[1674912,44,0xfffffffff8808e05] 13:[1677472,55,0xaa87ffffffffdfff] 14:[1677568,29,0xf7a76137b809a080] 15:[1692448,41,0xe7b75b6db238b5df] 16:[1692544,33,0x260851855fffbbb] 17:[1802240,26,0xac44022483ec0fce] 18:[1802368,25,0x8bd92018a4209f94] 19:[1802464,26,0xc68063ab51298ea0] 20:[1802560,29,0x42f06844dfa07ed] 21:[1802688,29,0x1f6e15420f0bba12] 22:[1802816,29,0xca714b5038b38c2b] 23:[1802880,27,0xde8ce91300cd0d06] 24:[1802976,20,0x287044c918816098] 25:[1803072,27,0xef76437044435102] 26:[1803168,33,0xf187b0a064742f7f] 27:[1803232,19,0xa314451207100c82] 28:[1803328,27,0x87660c6ce864a09c] 29:[1803392,24,0x36a61ce00924cd1] 30:[1857664,33,0xaf84d380f74aea65] 31:[1857760,34,0xf8f1c2c0c01fbede] 32:[1926112,26,0x603471c8bf208391] 33:[1926208,28,0x5b2707594e99204c] 34:[1926272,12,0x1821120500405004] 35:[1926400,25,0x46da084831d1f62] 36:[2036960,21,0xa44f19402a80141c] 37:[2065952,34,0xab6be38a3a495c6b] 38:[2066016,35,0x956963b6ecda1bf0] 39:[2066080,26,0xf6e694990008b416] 40:[2146560,45,0xf3851ab8f3ffefff] 41:[2166784,29,0xe59598e394526458] 42:[2166880,29,0x662c1465ba1b03da] 43:[2166944,27,0x81a0ad96bfb84048] 44:[2167008,31,0xab489e3296d54396] 45:[2167104,28,0xb828e4d990f07a81] 46:[2167168,32,0xf58644129c8f35be] 47:[2167264,38,0xf67cfcf1a558f827] 48:[2167328,37,0xf911ebc99ee95f32] 49:[2167424,27,0x70010219d65eb41f] 50:[2357728,24,0x4fa76102241b8850] 51:[2357824,32,0x8424e92f42b7b9e5] 52:[2357952,23,0x6703108c1b20506d] 53:[2358048,24,0x8b11041679918532] 54:[2358144,23,0xa026f900184b0395] 55:[2358208,30,0x24400b3b4ed6734f] 56:[2358336,22,0x8a04e3b420858aa] 57:[2358432,20,0xd224039129900452] 58:[2358528,19,0x205413092854c224] 59:[2358624,20,0xa14a4918940d805] 60:[2358688,20,0xea15a200140f000e] 61:[2358784,14,0x24046e180200809] 62:[2358848,11,0x480240244002800a] 63:[2358912,15,0x464111012080ca8] 64:[2358976,12,0x3000043d40050200] 65:[2359072,14,0x1240a1048aa0410] 66:[2359136,19,0x20a860825c029116] 67:[2359232,24,0xc1c4d18011591963] 68:[2359328,24,0x5141301929c5cd11] 69:[2359456,27,0xd2b44d401ba80fa2] 70:[2359584,24,0x54f0a144fc000bb] 71:[2359680,13,0x101040c800182a41] 72:[2359744,15,0x342b0010d4c00001] 73:[2359840,30,0x527f3967c01b881a] 74:[2359904,23,0xbb2032c605104b28] 75:[2360000,26,0xd3ac536c5442981] 76:[2360096,25,0xa989b22b23949009] 77:[2360256,24,0x475807bc08b0c43] 78:[2360384,19,0x3040c84aa6c14900] 79:[2360480,26,0x453711625c38bc04] 80:[2360576,26,0x20ccf00561a20beb] 81:[2360704,29,0x584dd8f5086e8e60] 82:[2360800,27,0x94c43efc6860440d] 83:[2360928,54,0xdfeffbcd9f7ffeff] 84:[2360992,28,0x21400fb8841e5ddb] 85:[2361088,20,0x2940238398093203] 86:[2361184,24,0x94869c280aec0a62] 87:[2361312,31,0x583fcc71ea1011be] 88:[2361408,32,0x51846807f7d46bba] 89:[2361504,27,0x34618fd428d885c4] 90:[2361632,24,0x83b089703aa4250a] 91:[2361728,33,0x5e5bbe1b96a41631] 92:[2361824,41,0xdf5fc8e0ffc2e9db] 93:[2361920,28,0x9c35697502caa489] 94:[2361984,34,0x17b54c1d378a63af] 95:[2362080,37,0xd09f9115f8fdde53] 96:[2362144,27,0x3c8f3109a8ab12a4] 97:[2377760,30,0x46812f4c8f46bf06] 98:[2377856,26,0xa54ad29443a3a188] 99:[2377920,30,0x3ee49a4a1a224e9b] 100:[2378048,27,0x4c96b452aaa188d4] 101:[2378176,32,0x3dcf881d78194973] 102:[2378272,27,0x569e433d3c2211a0] 103:[2378336,31,0x6182412698aaeffb] 104:[2382816,36,0xffff983165d11117] 105:[2382944,38,0x82fe18b575d7f7f] 106:[2383040,23,0x3b9e1508c484446] 107:[2383168,38,0x4dffabae4677cc46] 108:[2383232,24,0x203b1a762804c469] 109:[2383328,41,0xa7cbfafafdd12e93] 110:[2383424,28,0x414aa26281c42ffd] 111:[2383520,42,0x773f376fbfdd7142] 112:[2390080,37,0x9f26b6b49f839ebc] 113:[2390144,26,0xc4228420f116ba9e] 114:[2390240,21,0x2270964d4a264200] 115:[2390336,27,0x2de11831e0b1688e] 116:[2392832,27,0xd272539312a15d20] 117:[2416576,22,0xe210f0808233b448] 118:[2462304,18,0xb0e920081a800382] 119:[2462400,23,0x824c21a09371aca0] 120:[2462528,18,0x80284888022de122] 121:[2462624,34,0x207fbf0b677985a4] 122:[2462720,25,0xe004325203701b77] 123:[2462816,35,0xa01903fdffbbfd] 124:[2462912,16,0x840c198192610400] 125:[2463008,17,0xa1aa4001110b2110] 126:[2463136,26,0x6900203eda4d0b55] 127:[2463200,33,0x3a4fc667111bfb03] 128:[2463296,30,0xcf484d46f9200f72] 129:[2463360,41,0xbeee1b1f93f37dac] 130:[2463424,28,0xc871265ba51e8452] 131:[2463520,38,0x60ff25e7e748b73e] 132:[2469856,33,0x4b0a1f19bbbbf7] 133:[2563488,26,0x3118076d78888ea4] 134:[2563584,34,0x4a98ffd54f209cbc] 135:[2563648,30,0xc68e010c3ca37be9] 136:[2563776,18,0x7c2d21ca8100001] 137:[2646432,33,0xc05100f6daf89f6f] 138:[2648864,34,0x1aa23beffe435154] 139:[2662304,34,0xf5e55ab1c61a17c9] 140:[2662400,36,0x18835fcbcbebb935] 141:[2662464,37,0x977db55ec1bcc707] 142:[2712224,38,0xffe2edda7f2804da]

xfs_db>

IABT类型B+tree的叶子节点和中间节点内存布局如下所示:

Xfs文件系统磁盘布局_第7张图片
和前面所讲过的ABTB/ABTC类型的B+tree的中间节点一样,对于xfs_inobt_ptr[0]的起始地址为:16+510*4=2056=0x808,其中510=(4096-16)/(4+4)。
看实际数据验证我们的分析:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

xfs_db> fsblock 153945

xfs_db> type text

xfs_db> p

000:  49 41 42 54 00 01 00 02 ff ff ff ff ff ff ff ff  IABT............

010:  00 00 00 80 00 17 c3 80 01 00 7e 85 7f 00 00 00  ................

020:  14 00 10 0c c9 00 00 18 7f 12 e9 b5 00 00 0f bb  ................

030:  3b 01 00 7f 13 26 30 00 00 00 0f fb ef 00 00 7f  ......0.........

040:  14 ea 00 00 00 04 0f 18 c2 00 00 7f 16 7d 03 00  ................

*

800:  00 a4 01 00 06 ae af 00 00 00 00 03 00 02 59 25  ..............Y.

810:  00 00 01 00 06 2f b9 00 00 ae bd 00 00 07 8a 00  ................

820:  00 00 01 00 06 18 bd 00 00 be bd 00 00 07 8a 00  ................

830:  00 00 01 00 08 04 c4 bd 00 00 09 ef 58 00 00 29  ............X...

840:  04 41 31 02 eb bd 00 00 34 62 75 66 00 41 32 02  .A1.....4buf.A2.

*

xfs_db>

其它的关于这个B+tree的整体组织,前面已经描述过ABTB/ABTC类型的B+tree,所以不再多讲,下一篇开始inode本身结构的分析。

九,inode节点结构

Linux下一切皆文件,所以文件的类型有很多,比如普通文件、目录文件、软链接文件、设备文件等等,ls -l命令显示的文件列表的第一个字符表示该文件的类型:b:块设备、c:字符设备、d:目录、p:命名管道、f:普通文件、l:软连接、s:socket,可以利用find的命令查找系统上指定类型的文件:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

[root@localhost xfsprogs]# ls -l

total 1736

-rw-r--r-- 1 root root 231387 Jan  5 14:09 aclocal.m4

drwxr-xr-x 2 root root   4096 Jan  5 14:09 autom4te.cache

-rwxr-xr-x 1 root root  42037 Jan  5 14:09 config.guess

...

[root@localhost xfsprogs]# ls -l /dev/ttyS0

crw-rw---- 1 root uucp 4, 64 Jan  5 10:10 /dev/ttyS0

[root@localhost xfsprogs]# ls -l /dev/sda1

brw-r----- 1 root disk 8, 1 Jan  5 10:11 /dev/sda1

[root@localhost xfsprogs]# ls -l /dev/ramdisk

lrwxrwxrwx 1 root root 4 Jan  5 10:11 /dev/ramdisk -> ram0

[root@localhost xfsprogs]# ls /dev/initctl  -l

prw------- 1 root root 0 Jan  5 10:11 /dev/initctl

[root@localhost xfsprogs]# find / -type s

/tmp/.font-unix/fs7100

/dev/gpmctl

/dev/log

^C

[root@localhost xfsprogs]# ls /dev/log -l

srw-rw-rw- 1 root root 0 Jan  5 10:12 /dev/log

Linux任何一个文件,除了本身的固定属性(比如文件类型、访问权限、所有者、最后访问时间、最后修改时间等),还有文件数据(后面特称之为文件内容)与其它扩展属性(比如用户自定义的属性),与此一一对应,inode结构也就被分成了三部分,即inode核心数据、文件内容、扩展属性(文件内容和扩展属性之间为什么是虚线后面会讲到,另外为了后续文章的叙述清楚,下图中的inode核心数据、文件内容和扩展属性分别所占的磁盘空间就分别以inode core、data fork、attribute fork代称,即一说到inode core,那就是指图中斜网格填充的这一块磁盘空间区域,其它类此。):

Xfs文件系统磁盘布局_第8张图片
其中inode核心数据由结构体xfs_dinode描述,有几个字段比较重要,它们决定了后面数据的安放。第一个重要字段是di_mode,这个字段记录该文件的类型和权限,而不同类型的文件存放的据内容和格式很明显是不一样的,比如目录文件和普通文件。第二个重要字段是di_format,这个字段决定了文件内容的存放方式。这个字段的取值定义在枚举体xfs_dinode_fmt内,其中“uuid”目前尚未用到,“dev”表示本inode关联的是一个字符或块设备,“local”表示文件内容直接存放在本inode所在的这个block块内,“extents”表示文件内容存放在其他block块内,而这些block的块号被以数组的形式组织起来存放在本inode所在的block块内,“btree”表示文件内容存放在其他block块内,而这些block的块号被以B+tree的形式组织,并且该B+tree的根节点存放在本inode所在的block块内。可以看到“local”->“extents”->“btree”的形式可以存放由少到多的文件内容。
文件内容(根据前面几句话的描述,文件内容不一定就是文件的实际数据,也可能是其他存放实际文件内容的block块号或B+tree根节点等,这里统一认为是文件内容,当然,标准说法为Data Fork)存放的起始地址紧跟在inode核心数据之后,由于结构体xfs_dinode占100个字节,所以文件内容存放的起始地址也就是100。
看实际数据验证我们的分析:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

[root@localhost loop]# ls

xfs  xfs.256  xfs.256.new  xfs.img  xfs.img.256  xfs.img.256.new

[root@localhost loop]# dd if=/dev/zero of=inode.256.img bs=512 count=524288

524288+0 records in

524288+0 records out

268435456 bytes (268 MB) copied, 9.77917 s, 27.4 MB/s

[root@localhost loop]# losetup -d /dev/loop0

[root@localhost loop]# losetup /dev/loop0 inode.256.img

[root@localhost loop]# mkfs.xfs /dev/loop0

meta-data=/dev/loop0             isize=256    agcount=4, agsize=16384 blks

         =                       sectsz=512   attr=2, projid32bit=0

data     =                       bsize=4096   blocks=65536, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0

log      =internal log           bsize=4096   blocks=1200, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

[root@localhost loop]# ls

inode.256.img  xfs  xfs.256  xfs.256.new  xfs.img  xfs.img.256  xfs.img.256.new

[root@localhost loop]# mkdir inode.256

[root@localhost loop]# mount /dev/loop0 inode.256

[root@localhost loop]# cd !$

cd inode.256

[root@localhost inode.256]# echo "123456789" > lenky.xfs

[root@localhost inode.256]# cat lenky.xfs

123456789

[root@localhost inode.256]# ls -lai

total 8

   128 drwxr-xr-x. 2 root root   22 Dec 31 09:18 .

524142 drwxr-xr-x. 6 root root 4096 Dec 31 09:17 ..

   131 -rw-r--r--. 1 root root   10 Dec 31 09:18 lenky.xfs

[root@localhost inode.256]# cd ..

[root@localhost loop]# umount inode.256

[root@localhost loop]# /home/lenky/xfs/xfsprogs/db/xfs_db /dev/loop0

xfs_db> inode 128

xfs_db> p

core.magic = 0x494e

core.mode = 040755

core.version = 2

core.format = 1 (local)

core.nlinkv2 = 2

core.onlink = 0

core.projid_lo = 0

core.projid_hi = 0

core.uid = 0

core.gid = 0

core.flushiter = 1

core.atime.sec = Sat Dec 31 09:18:03 2011

core.atime.nsec = 812159818

core.mtime.sec = Sat Dec 31 09:18:01 2011

core.mtime.nsec = 473154327

core.ctime.sec = Sat Dec 31 09:18:01 2011

core.ctime.nsec = 473154327

core.size = 22

core.nblocks = 0

core.extsize = 0

core.nextents = 0

core.naextents = 0

core.forkoff = 0

core.aformat = 2 (extents)

core.dmevmask = 0

core.dmstate = 0

core.newrtbm = 0

core.prealloc = 0

core.realtime = 0

core.immutable = 0

core.append = 0

core.sync = 0

core.noatime = 0

core.nodump = 0

core.rtinherit = 0

core.projinherit = 0

core.nosymlinks = 0

core.extsz = 0

core.extszinherit = 0

core.nodefrag = 0

core.filestream = 0

core.gen = 0

next_unlinked = null

u.sfdir2.hdr.count = 1

u.sfdir2.hdr.i8count = 0

u.sfdir2.hdr.parent.i4 = 128

u.sfdir2.list[0].namelen = 9

u.sfdir2.list[0].offset = 0x30

u.sfdir2.list[0].name = "lenky.xfs"

u.sfdir2.list[0].inumber.i4 = 131

xfs_db> inode 131

xfs_db> p

core.magic = 0x494e

core.mode = 0100644

core.version = 2

core.format = 2 (extents)

core.nlinkv2 = 1

core.onlink = 0

core.projid_lo = 0

core.projid_hi = 0

core.uid = 0

core.gid = 0

core.flushiter = 2

core.atime.sec = Sat Dec 31 09:18:04 2011

core.atime.nsec = 300159942

core.mtime.sec = Sat Dec 31 09:18:01 2011

core.mtime.nsec = 474154430

core.ctime.sec = Sat Dec 31 09:18:01 2011

core.ctime.nsec = 474154430

core.size = 10

core.nblocks = 1

core.extsize = 0

core.nextents = 1

core.naextents = 0

core.forkoff = 13

core.aformat = 1 (local)

core.dmevmask = 0

core.dmstate = 0

core.newrtbm = 0

core.prealloc = 0

core.realtime = 0

core.immutable = 0

core.append = 0

core.sync = 0

core.noatime = 0

core.nodump = 0

core.rtinherit = 0

core.projinherit = 0

core.nosymlinks = 0

core.extsz = 0

core.extszinherit = 0

core.nodefrag = 0

core.filestream = 0

core.gen = 0

next_unlinked = null

u.bmx[0] = [startoff,startblock,blockcount,extentflag] 0:[0,12,1,0]

a.sfattr.hdr.totsize = 46

a.sfattr.hdr.count = 1

a.sfattr.list[0].namelen = 7

a.sfattr.list[0].valuelen = 32

a.sfattr.list[0].root = 0

a.sfattr.list[0].secure = 1

a.sfattr.list[0].name = "selinux"

a.sfattr.list[0].value = "unconfined_u:object_r:file_t:s0\000"

xfs_db>

从命令“ls -lai”里可以看到目录文件“.”对应的inode是128,普通文件lenky.xfs对应的inode是131,128的di_format字段为1(local),表示该文件的内容(因为这是一个目录文件,所以文件内容就是该目录的子文件、子目录等信息)存放在本inode所在的这个block块内,即是100字节的起始位置;另一方面,可以看出131的di_format字段为 2(extents),它的数据存放在其它block内,block号为12;先hexdump验证一下,由于128的inode在第8块block(不清楚的话看前面的文章),所以偏移为32768:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

[root@localhost loop]# hexdump -C -s 32768 -n 256 /dev/loop0

00008000  49 4e 41 ed 02 01 00 00  00 00 00 00 00 00 00 00  |INA.............|

00008010  00 00 00 02 00 00 00 00  00 00 00 00 00 00 00 01  |................|

00008020  4e ff 19 9b 30 68 93 4a  4e ff 19 99 1c 33 c3 17  |N...0h.JN....3..|

00008030  4e ff 19 99 1c 33 c3 17  00 00 00 00 00 00 00 16  |N....3..........|

00008040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00008050  00 00 00 02 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00008060  ff ff ff ff 01 00 00 00  00 80 09 00 30 6c 65 6e  |............0len|

00008070  6b 79 2e 78 66 73 00 00  00 83 00 00 00 00 00 00  |ky.xfs..........|

00008080  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00008100

[root@localhost loop]# hexdump -C -s 49152 -n 256 /dev/loop0

0000c000  31 32 33 34 35 36 37 38  39 0a 00 00 00 00 00 00  |123456789.......|

0000c010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

0000c100

[root@localhost loop]#

再看继续看一下,可以看到随着子文件的增多,信息已经无法在当前inode所在的block块存放了(一个inode一共才256字节的空间),所以由“local”变成了“extents”的。另一方面,对于普通文件,就算只有2个字节,其存放方式也是“extents”(实验结论):

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

[root@localhost loop]# mount /dev/loop0 inode.256

[root@localhost loop]# cd !$

cd inode.256

[root@localhost inode.256]# for((i=1;i<=100;i++)); do touch "lenky.$i"; done

[root@localhost inode.256]# ls

lenky.1    lenky.14  lenky.2   lenky.25  lenky.30  lenky.36  lenky.41  lenky.47  lenky.52  lenky.58  lenky.63  lenky.69  lenky.74  lenky.8   lenky.85  lenky.90  lenky.96

lenky.10   lenky.15  lenky.20  lenky.26  lenky.31  lenky.37  lenky.42  lenky.48  lenky.53  lenky.59  lenky.64  lenky.7   lenky.75  lenky.80  lenky.86  lenky.91  lenky.97

lenky.100  lenky.16  lenky.21  lenky.27  lenky.32  lenky.38  lenky.43  lenky.49  lenky.54  lenky.6   lenky.65  lenky.70  lenky.76  lenky.81  lenky.87  lenky.92  lenky.98

lenky.11   lenky.17  lenky.22  lenky.28  lenky.33  lenky.39  lenky.44  lenky.5   lenky.55  lenky.60  lenky.66  lenky.71  lenky.77  lenky.82  lenky.88  lenky.93  lenky.99

lenky.12   lenky.18  lenky.23  lenky.29  lenky.34  lenky.4   lenky.45  lenky.50  lenky.56  lenky.61  lenky.67  lenky.72  lenky.78  lenky.83  lenky.89  lenky.94  lenky.xfs

lenky.13   lenky.19  lenky.24  lenky.3   lenky.35  lenky.40  lenky.46  lenky.51  lenky.57  lenky.62  lenky.68  lenky.73  lenky.79  lenky.84  lenky.9   lenky.95

[root@localhost inode.256]# cd ..

[root@localhost loop]# umount inode.256

[root@localhost loop]# /home/lenky/xfs/xfsprogs/db/xfs_db /dev/loop0

xfs_db> inode 128

xfs_db> p

core.magic = 0x494e

core.mode = 040755

core.version = 2

core.format = 2 (extents)

core.nlinkv2 = 2

core.onlink = 0

core.projid_lo = 0

core.projid_hi = 0

core.uid = 0

core.gid = 0

core.flushiter = 2

core.atime.sec = Sat Dec 31 09:41:33 2011

core.atime.nsec = 324158002

core.mtime.sec = Sat Dec 31 09:41:31 2011

core.mtime.nsec = 340158002

core.ctime.sec = Sat Dec 31 09:41:31 2011

core.ctime.nsec = 340158002

core.size = 4096

core.nblocks = 1

core.extsize = 0

core.nextents = 1

core.naextents = 0

core.forkoff = 0

core.aformat = 2 (extents)

core.dmevmask = 0

core.dmstate = 0

core.newrtbm = 0

core.prealloc = 0

core.realtime = 0

core.immutable = 0

core.append = 0

core.sync = 0

core.noatime = 0

core.nodump = 0

core.rtinherit = 0

core.projinherit = 0

core.nosymlinks = 0

core.extsz = 0

core.extszinherit = 0

core.nodefrag = 0

core.filestream = 0

core.gen = 0

next_unlinked = null

u.bmx[0] = [startoff,startblock,blockcount,extentflag] 0:[0,13,1,0]

xfs_db> inode

current inode number is 128

xfs_db> fsblock 3^H

bad fsblock 3

xfs_db> fsblock 13

xfs_db> type text

xfs_db> p

000:  58 44 32 42 09 a8 03 18 00 00 00 00 00 00 00 00  XD2B............

010:  00 00 00 00 00 00 00 80 01 2e 00 00 00 00 00 10  ................

020:  00 00 00 00 00 00 00 80 02 2e 2e 00 00 00 00 20  ................

030:  00 00 00 00 00 00 00 83 09 6c 65 6e 6b 79 2e 78  .........lenky.x

040:  66 73 00 00 00 00 00 30 00 00 00 00 00 00 00 84  fs.....0........

050:  07 6c 65 6e 6b 79 2e 31 00 00 00 00 00 00 00 48  .lenky.1.......H

060:  00 00 00 00 00 00 00 85 07 6c 65 6e 6b 79 2e 32  .........lenky.2

070:  00 00 00 00 00 00 00 60 00 00 00 00 00 00 00 86  ................

080:  07 6c 65 6e 6b 79 2e 33 00 00 00 00 00 00 00 78  .lenky.3.......x

090:  00 00 00 00 00 00 00 87 07 6c 65 6e 6b 79 2e 34  .........lenky.4

0a0:  00 00 00 00 00 00 00 90 00 00 00 00 00 00 00 88  ................

0b0:  07 6c 65 6e 6b 79 2e 35 00 00 00 00 00 00 00 a8  .lenky.5........

0c0:  00 00 00 00 00 00 00 89 07 6c 65 6e 6b 79 2e 36  .........lenky.6

0d0:  00 00 00 00 00 00 00 c0 00 00 00 00 00 00 00 8a  ................

0e0:  07 6c 65 6e 6b 79 2e 37 00 00 00 00 00 00 00 d8  .lenky.7........

*

xfs_db> q

[root@localhost loop]# mount /dev/loop0 inode.256

[root@localhost loop]# cd inode.256

[root@localhost inode.256]# vi lenky.xfs

[root@localhost inode.256]# hexdump lenky.xfs -C

00000000  31 0a                                             |1.|

00000002

[root@localhost inode.256]# cd ..

[root@localhost loop]# umount inode.256

[root@localhost loop]# /home/lenky/xfs/xfsprogs/db/xfs_db /dev/loop0

xfs_db> inode 131

xfs_db> p

core.magic = 0x494e

core.mode = 0

core.version = 2

core.format = 2 (extents)

core.nlinkv2 = 0

core.onlink = 0

core.projid_lo = 0

core.projid_hi = 0

core.uid = 0

core.gid = 0

core.flushiter = 3

core.atime.sec = Sat Dec 31 09:18:04 2011

core.atime.nsec = 300159942

core.mtime.sec = Sat Dec 31 09:18:01 2011

core.mtime.nsec = 474154430

core.ctime.sec = Sat Dec 31 09:52:11 2011

core.ctime.nsec = 498158007

core.size = 0

core.nblocks = 0

core.extsize = 0

core.nextents = 0

core.naextents = 0

core.forkoff = 0

core.aformat = 2 (extents)

core.dmevmask = 0

core.dmstate = 0

core.newrtbm = 0

core.prealloc = 0

core.realtime = 0

core.immutable = 0

core.append = 0

core.sync = 0

core.noatime = 0

core.nodump = 0

core.rtinherit = 0

core.projinherit = 0

core.nosymlinks = 0

core.extsz = 0

core.extszinherit = 0

core.nodefrag = 0

core.filestream = 0

core.gen = 1

next_unlinked = null

u = (empty)

xfs_db> q

[root@localhost loop]#

下篇分析各种不同类型文件的文件内容的具体结构与组织,附带相关数据结构体的定义:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

/*

 * On-disk inode structure.

 *

 * This is just the header or "dinode core", the inode is expanded to fill a

 * variable size the leftover area split into a data and an attribute fork.

 * The format of the data and attribute fork depends on the format of the

 * inode as indicated by di_format and di_aformat.  To access the data and

 * attribute use the XFS_DFORK_PTR, XFS_DFORK_DPTR, and XFS_DFORK_PTR macros

 * below.

 *

 * There is a very similar struct icdinode in xfs_inode which matches the

 * layout of the first 96 bytes of this structure, but is kept in native

 * format instead of big endian.

 */

typedef struct xfs_dinode {

    __be16      di_magic;   /* inode magic # = XFS_DINODE_MAGIC */

    __be16      di_mode;    /* mode and type of file */

    __u8        di_version; /* inode version */

    __u8        di_format;  /* format of di_c data */

    __be16      di_onlink;  /* old number of links to file */

    __be32      di_uid;     /* owner's user id */

    __be32      di_gid;     /* owner's group id */

    __be32      di_nlink;   /* number of links to file */

    __be16      di_projid_lo;   /* lower part of owner's project id */

    __be16      di_projid_hi;   /* higher part owner's project id */

    __u8        di_pad[6];  /* unused, zeroed space */

    __be16      di_flushiter;   /* incremented on flush */

    xfs_timestamp_t di_atime;   /* time last accessed */

    xfs_timestamp_t di_mtime;   /* time last modified */

    xfs_timestamp_t di_ctime;   /* time created/inode modified */

    __be64      di_size;    /* number of bytes in file */

    __be64      di_nblocks; /* # of direct & btree blocks used */

    __be32      di_extsize; /* basic/minimum extent size for file */

    __be32      di_nextents;    /* number of extents in data fork */

    __be16      di_anextents;   /* number of extents in attribute fork*/

    __u8        di_forkoff; /* attr fork offs, <<3 for 64b align */

    __s8        di_aformat; /* format of attr fork's data */

    __be32      di_dmevmask;    /* DMIG event mask */

    __be16      di_dmstate; /* DMIG state info */

    __be16      di_flags;   /* random flags, XFS_DIFLAG_... */

    __be32      di_gen;     /* generation number */

    /* di_next_unlinked is the only non-core field in the old dinode */

    __be32      di_next_unlinked;/* agi unlinked list ptr */

} __attribute__((packed)) xfs_dinode_t;

/*

 * Values for di_format

 */

typedef enum xfs_dinode_fmt {

    XFS_DINODE_FMT_DEV,     /* xfs_dev_t */

    XFS_DINODE_FMT_LOCAL,       /* bulk data */

    XFS_DINODE_FMT_EXTENTS,     /* struct xfs_bmbt_rec */

    XFS_DINODE_FMT_BTREE,       /* struct xfs_bmdr_block */

    XFS_DINODE_FMT_UUID     /* uuid_t */

} xfs_dinode_fmt_t;

十,普通文件数据结构(extents)

对于普通文件来说,文件内容可以以“extents”或者“btree”两种方式存放,前一篇已经讲过这两种方式所存放数据的大致格式,下面详细描述;
先看“extents”,“extents”是将存放文件实际数据的block块号以数组的形式存放在inode核心数据之后,当然,不仅仅只是块号那么简单,假设称其中的每一个数组元素为一个“extent”,那么,一个“extent”具体就是如下四个信息:
1,这一部分文件内容对应到文件整体内容中的逻辑起始地址(也以block块为单位)。
2,存放这一部分文件内容的起始block块号。
3,有多少块block用来存放这一部分文件内容。
4,该“extent”的状态标记。
一个文件可能由多个“extent”组成,于是此时就由多个“extent”形成“extents”数组,有多少“extent”记录在inode核心数据对应的结构体xfs_dinode的di_nextents字段内。一个“extent”对应的数据结构是xfs_bmbt_rec,它看上去很简单:

1

2

3

typedef struct xfs_bmbt_rec {

    __be64          l0, l1;

} xfs_bmbt_rec_t;

这是在磁盘上对应的数据结构,占128bit,大端字节序,而在实际Xfs操作代码里,为了更方便的获取上面提到的四个信息,所以其对应的数据结构是xfs_bmbt_irec:

1

2

3

4

5

6

7

8

9

10

/*

 * Incore version of above.

 */

typedef struct xfs_bmbt_irec

{

    xfs_fileoff_t   br_startoff;    /* starting file offset */

    xfs_fsblock_t   br_startblock;  /* starting block number */

    xfs_filblks_t   br_blockcount;  /* number of blocks */

    xfs_exntst_t    br_state;   /* extent state */

} xfs_bmbt_irec_t;

很明显,xfs_bmbt_irec是xfs_bmbt_rec的扩展形式,那么这个结构体如何对应呢?在文件include/xfs_bmp_btree.h头文件里已有详细说明:

1

2

3

4

5

6

7

8

9

10

11

/*

 * Bmap btree record and extent descriptor.

 *  l0:63 is an extent flag (value 1 indicates non-normal).

 *  l0:9-62 are startoff.

 *  l0:0-8 and l1:21-63 are startblock.

 *  l1:0-20 are blockcount.

 */

#define BMBT_EXNTFLAG_BITLEN    1

#define BMBT_STARTOFF_BITLEN    54

#define BMBT_STARTBLOCK_BITLEN  52

#define BMBT_BLOCKCOUNT_BITLEN  21

看一个实例,根据实例数据来分析:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

[root@localhost loop]# /home/lenky/xfs/xfsprogs/db/xfs_db /dev/loop0

xfs_db> inode 132

xfs_db> p

core.magic = 0x494e

core.mode = 0100644

core.version = 1

core.format = 2 (extents)

...

core.size = 21465

core.nblocks = 6

core.extsize = 0

core.nextents = 2

...

next_unlinked = null

u.bmx[0-1] = [startoff,startblock,blockcount,extentflag] 0:[0,12,1,0] 1:[1,25,5,0]

xfs_db> q

[root@localhost loop]# hexdump -C -s 33792 -n 256 /dev/loop0

00008400  49 4e 81 a4 01 02 00 01  00 00 00 00 00 00 00 00  |IN..............|

00008410  00 00 00 01 00 00 00 00  00 00 00 00 00 00 00 07  |................|

00008420  4f 06 f3 9e 09 b7 2f 49  4f 06 f4 5e 08 0b ef 70  |O...../IO..^...p|

00008430  4f 06 f4 5e 08 0b ef 70  00 00 00 00 00 00 53 d9  |O..^...p......S.|

00008440  00 00 00 00 00 00 00 06  00 00 00 00 00 00 00 02  |................|

00008450  00 00 00 02 00 00 00 00  00 00 00 00 00 00 00 02  |................|

00008460  ff ff ff ff 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00008470  01 80 00 01 00 00 00 00  00 00 02 00 00 00 00 00  |................|

00008480  03 20 00 05 00 00 00 00  00 00 00 00 00 00 00 00  |. ..............|

00008490  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00008500

[root@localhost loop]#

磁盘extents数据为:
00008460 ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 |…………….|
00008470 01 80 00 01 00 00 00 00 00 00 02 00 00 00 00 00 |…………….|
00008480 03 20 00 05
即是:
(la.0):00 00 00 00 00 00 00 00 (la.1): 00 00 00 00 01 80 00 01
(lb.0):00 00 00 00 00 00 02 00 (lb.1): 00 00 00 00 03 20 00 05
解压缩后的数据:
u.bmx[0-1] = [startoff,startblock,blockcount,extentflag] 0:[0,12,1,0] 1:[1,25,5,0]
1,la.0:63和lb.0:63都为0。
2,la.0:9-62为0,而lb.0:9-62为1(看最末的2,二进制即为0010,注意这个蓝色的0要排除,因为它是lb.0:8,所以lb.0:9-62的结果为1)。
3,la.0:0-8和la.1:21-63组合为:0 00 00 00 00 00 01 8,最后的18的二进制表示为0001 1000,同样注意这个蓝色的0要排除,因为它是la.0:20,所以最后有效位值为1100,即12。与此类似,lb.0:0-8和lb.1:21-63组合为:2 00 00 00 00 00 03 2,第一位16进制数2属于lb.0:0-8的第8bit为0,最后的32的二进制表示为0011 0010,同样排除蓝色的0,因为它是lb.0:20,所以最后有效位值为11001,即25。
4,la.1:0-20为1,而lb.1:0-20为5。
也许全部展开可以一目了然(以lb,[1,25,5,0]为例,其中颜色显示:startoff、startblock、blockcount、extentflag):
127-96: 00000000 00000000 00000000 00000000
  95-64: 00000000 00000000 00000010 00000000
  63-32: 00000000 00000000 00000000 00000000
    31-0: 00000011 00100000 00000000 00000101
另外,0:[0,12,1,0] 1:[1,25,5,0]的具体含义表示这个文件由两个extent存放实际数据,第一个extent的起始block块号为12,长度为1;而第二个extent的起始block块号为25,长度为5,即占用25、26、27、28、29这五块block,它对应的文件的逻辑起始地址为4096(因为startoff=1),对比看看:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

xfs_db> fsblock 25

xfs_db> type text

xfs_db> p

000:  70 74 6f 72 20 2a 2f 0a 09 69 6e 74 20 20 20 20  ptor.....int....

010:  20 20 20 20 20 20 20 20 20 72 74 66 64 3b 20 20  .........rtfd...

020:  20 20 20 20 20 20 20 20 20 2f 2a 20 72 65 61 6c  ............real

030:  74 69 6d 65 20 73 75 62 76 6f 6c 75 6d 65 20 66  time.subvolume.f

040:  69 6c 65 20 64 65 73 63 72 69 70 74 6f 72 20 2a  ile.descriptor..

050:  2f 0a 7d 20 6c 69 62 78 66 73 5f 69 6e 69 74 5f  ....libxfs.init.

060:  74 3b 0a 0a 23 64 65 66 69 6e 65 20 4c 49 42 58  t....define.LIBX

070:  46 53 5f 45 58 49 54 5f 4f 4e 5f 46 41 49 4c 55  FS.EXIT.ON.FAILU

080:  52 45 09 30 78 30 30 30 31 09 2f 2a 20 65 78 69  RE.0x0001....exi

090:  74 20 74 68 65 20 70 72 6f 67 72 61 6d 20 69 66  t.the.program.if

0a0:  20 61 20 63 61 6c 6c 20 66 61 69 6c 73 20 2a 2f  .a.call.fails...

0b0:  0a 23 64 65 66 69 6e 65 20 4c 49 42 58 46 53 5f  ..define.LIBXFS.

0c0:  49 53 52 45 41 44 4f 4e 4c 59 09 30 78 30 30 30  ISREADONLY.0x000

0d0:  32 09 2f 2a 20 64 69 73 61 6c 6c 6f 77 20 61 6c  2....disallow.al

0e0:  6c 20 6d 6f 75 6e 74 65 64 20 66 69 6c 65 73 79  l.mounted.filesy

0f0:  73 74 65 6d 73 20 2a 2f 0a 23 64 65 66 69 6e 65  stems.....define

100:  20 4c 49 42 58 46 53 5f 49 53 49 4e 41 43 54 49  .LIBXFS.ISINACTI

110:  56 45 09 30 78 30 30 30 34 09 2f 2a 20 61 6c 6c  VE.0x0004....all

120:  6f 77 20 6d 6f 75 6e 74 65 64 20 6f 6e 6c 79 20  ow.mounted.only.

130:  69 66 20 6d 6f 75 6e 74 65 64 20 72 6f 20 2a 2f  if.mounted.ro...

140:  0a 23 64 65 66 69 6e 65 20 4c 49 42 58 46 53 5f  ..define.LIBXFS.

150:  44 41 4e 47 45 52 4f 55 53 4c 59 09 30 78 30 30  DANGEROUSLY.0x00

160:  30 38 09 2f 2a 20 72 65 70 61 69 72 69 6e 67 20  08....repairing.

170:  61 20 64 65 76 69 63 65 20 6d 6f 75 6e 74 65 64  a.device.mounted

180:  20 72 6f 20 20 20 20 2a 2f 0a 23 64 65 66 69 6e  .ro........defin

190:  65 20 4c 49 42 58 46 53 5f 45 58 43 4c 55 53 49  e.LIBXFS.EXCLUSI

1a0:  56 45 4c 59 09 30 78 30 30 31 30 09 2f 2a 20 64  VELY.0x0010....d

1b0:  69 73 61 6c 6c 6f 77 20 6f 74 68 65 72 20 61 63  isallow.other.ac

1c0:  63 65 73 73 65 73 20 28 4f 5f 45 58 43 4c 29 20  cesses..O.EXCL..

...

[root@localhost loop]# mount /dev/loop0 inode.256

[root@localhost loop]# cd inode.256

[root@localhost inode.256]# ls -lai

total 76

     128 drwxr-xr-x 2 root root    56 Jan  6 08:14 .

32800854 drwxr-xr-x 4 root root  4096 Jan  6 07:11 ..

     133 -rw-r--r-- 1 root root 21465 Jan  6 08:17 lenky.xfs

     132 -rw-r--r-- 1 root root 21465 Jan  6 08:17 lenky.xfs.bk

     131 -rw-r--r-- 1 root root 21416 Jan  6 07:15 libxfs.h

[root@localhost inode.256]# hexdump -C -s 4096 -n 256 lenky.xfs.bk

00001000  70 74 6f 72 20 2a 2f 0a  09 69 6e 74 20 20 20 20  |ptor */..int    |

00001010  20 20 20 20 20 20 20 20  20 72 74 66 64 3b 20 20  |         rtfd;  |

00001020  20 20 20 20 20 20 20 20  20 2f 2a 20 72 65 61 6c  |         /* real|

00001030  74 69 6d 65 20 73 75 62  76 6f 6c 75 6d 65 20 66  |time subvolume f|

00001040  69 6c 65 20 64 65 73 63  72 69 70 74 6f 72 20 2a  |ile descriptor *|

00001050  2f 0a 7d 20 6c 69 62 78  66 73 5f 69 6e 69 74 5f  |/.} libxfs_init_|

00001060  74 3b 0a 0a 23 64 65 66  69 6e 65 20 4c 49 42 58  |t;..#define LIBX|

00001070  46 53 5f 45 58 49 54 5f  4f 4e 5f 46 41 49 4c 55  |FS_EXIT_ON_FAILU|

00001080  52 45 09 30 78 30 30 30  31 09 2f 2a 20 65 78 69  |RE.0x0001./* exi|

00001090  74 20 74 68 65 20 70 72  6f 67 72 61 6d 20 69 66  |t the program if|

000010a0  20 61 20 63 61 6c 6c 20  66 61 69 6c 73 20 2a 2f  | a call fails */|

000010b0  0a 23 64 65 66 69 6e 65  20 4c 49 42 58 46 53 5f  |.#define LIBXFS_|

000010c0  49 53 52 45 41 44 4f 4e  4c 59 09 30 78 30 30 30  |ISREADONLY.0x000|

000010d0  32 09 2f 2a 20 64 69 73  61 6c 6c 6f 77 20 61 6c  |2./* disallow al|

000010e0  6c 20 6d 6f 75 6e 74 65  64 20 66 69 6c 65 73 79  |l mounted filesy|

000010f0  73 74 65 6d 73 20 2a 2f  0a 23 64 65 66 69 6e 65  |stems */.#define|

00001100

[root@localhost inode.256]#

一个inode最大大小为256个字节,除去inode核心数据100个字节,假设该文件没有扩展属性,那么最多可以有(256-100)*8/128=9.75个“extent”,即数组“extents”最多只能有9个元素,当文件增大到一定程度,这些“extent”无法以数组的形式存放时,就会以B+tree的形式组织起来,这将是下一篇文章的内容。最后,看一个图:

Xfs文件系统磁盘布局_第9张图片

仍然按照我的习惯,先弄出一B+tree的“extents”,采用的方法就先把磁盘给填满,然后随机删除一些文件,然后再写一个超大文件,由于前面两步操作使得磁盘上的free block很碎并且不连续,所以这个大文件占用的磁盘空间也都不连续,所以需要更多的“extent”来标记这些block块,上一篇提到当“extent”数目大于9时,Xfs文件系统就只能使用B+tree来对它们进行管理了:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

[root@localhost loop]# mount /dev/loop0 inode.256

[root@localhost loop]# cp -fr /usr/src/linux-2.6.36/ inode.256

...

[root@localhost loop]# cd inode.256

[root@localhost inode.256]# find . -name "*a*" | xargs rm

...

[root@localhost inode.256]# find . -name "*c*" | xargs rm

...

[root@localhost inode.256]# find . -name "*e*" | xargs rm

...

[root@localhost inode.256]# dd if=/dev/zero of=bigfile

[root@localhost inode.256]# ls -lai

total 79008

     128 drwxr-xr-x  4 root root       51 Jan  7 05:46 .

32800854 drwxr-xr-x  4 root root     4096 Jan  6 07:11 ..

     137 -rw-r--r--  1 root root 80859136 Jan  7 05:46 bigfile

 1045632 drwxr-xr-x 51 root root    20480 Jan  7 05:46 lib64

     134 drwxr-xr-x  6 root root       81 Jan  7 05:43 linux-2.6.36

[root@localhost inode.256]# cd ..

[root@localhost loop]# umount inode.256

[root@localhost loop]# /home/lenky/xfs/xfsprogs/db/xfs_db /dev/loop0

xfs_db> inode 137

xfs_db> p

core.magic = 0x494e

core.mode = 0100644

core.version = 1

core.format = 3 (btree)

...

core.size = 80859136

core.nblocks = 19742

core.extsize = 0

core.nextents = 63

core.naextents = 0

...

core.gen = 4

next_unlinked = null

u.bmbt.level = 1

u.bmbt.numrecs = 1

u.bmbt.keys[1] = [startoff] 1:[0]

u.bmbt.ptrs[1] = 1:4147

xfs_db> q

[root@localhost loop]#

core.format = 3 (btree),达到了我们想要的结果。这颗B+tree的根节点存放在data fork内,所以根节点最大只能占有156字节,正因为如此,所以这棵树的节点布局要把根节点单独出来,所以就有三种。
根节点:

Xfs文件系统磁盘布局_第10张图片
xfs_bmdr_block_t的起始位置偏移inode节点的100字节处,xfs_bmbt_key_t紧跟在xfs_bmdr_block_t之后,而xfs_bmbt_ptr_t的起始位置如前面介绍的B+tree类似,并不会紧接在xfs_dfiloff_t br_startoff[n-1]元素之后,而是会预留出足够的空闲空间用以存放xfs_bmbt_key_t元素可能的增长,具体的值当然可以计算出来:(256-100-4)/(8+8)*8+100+4=176=0xB0(注意其中的整型计算),即相对当前inode节点起始地址偏移的176字节处,可以验证(其中的35072是inode 137的起始地址,即是137*256=35072):

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

[root@localhost loop]# hexdump -C -s 35072 -n 256 /dev/loop0

00008900  49 4e 81 a4 01 03 00 01  00 00 00 00 00 00 00 00  |IN..............|

00008910  00 00 00 01 00 00 00 00  00 00 00 00 00 00 00 0c  |................|

00008920  4f 08 22 8e 25 ca 11 ec  4f 08 22 90 32 6c ee ec  |O.".%...O.".2l..|

00008930  4f 08 22 90 32 6c ee ec  00 00 00 00 04 d1 d0 00  |O.".2l..........|

00008940  00 00 00 00 00 00 4d 1e  00 00 00 00 00 00 00 3f  |......M........?|

00008950  00 00 00 02 00 00 00 00  00 00 00 00 00 00 00 04  |................|

00008960  ff ff ff ff 00 01 00 01  00 00 00 00 00 00 00 00  |................|

00008970  10 00 00 20 00 00 00 00  00 00 00 00 00 00 00 00  |... ............|

00008980  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

000089b0  00 00 00 00 00 00 10 33  00 00 00 00 00 00 00 00  |.......3........|

000089c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00008a00

[root@localhost loop]#

00008960 ff ff ff ff 00 01 00 01 00 00 00 00 00 00 00 00 |…………….|
00008970 10 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 |… …………|
00008980 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |…………….|
*
000089b0 00 00 00 00 00 00 10 33 00 00 00 00 00 00 00 00 |…….3……..|
000089c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |…………….|
*
00008a00
叶子节点占用一整的block块,其布局图示如下:

Xfs文件系统磁盘布局_第11张图片
实例,具体就不一个个字段对比了,数据如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

[root@localhost loop]# /home/lenky/xfs/xfsprogs/db/xfs_db /dev/loop0

xfs_db> fsblock 4147

xfs_db> type inobt

xfs_db> p

magic = 0x424d4150

level = 0

numrecs = 63

leftsib = null

rightsib = null

recs[1-63] = [startino,freecount,free] 1:[0,0,0xd66400c00] 2:[0,1572864,0x1abc600a1d] 3:[0,2898432,0x12f3400866] 4:[0,3999232,0x656e00417] 5:[0,4535296,0x179da00313] 6:[0,4938240,0x1195c002f1] 7:[0,5323776,0xa6d6002a0] 8:[0,5667840,0xcd400025a] 9:[0,5976064,0xb1c600259] 10:[0,6283776,0x162e00235] 11:[0,6573056,0x1d1a0001cf] 12:[0,6810112,0x12226001c1] 13:[0,7040000,0x1dcf4001b6] 14:[0,7264256,0x1ec88001ac] 15:[0,7483392,0xf1fa00176] 16:[0,7674880,0x756c00123] 17:[0,7823872,0x1c7960011b] 18:[0,7968768,0x8aa400112] 19:[0,8109056,0x8ee0000dc] 20:[0,8221696,0x94ac000ca] 21:[0,8325120,0xad58000bc] 22:[0,8421376,0xaf54000ba] 23:[0,8516608,0xc14a000a6] 24:[0,8601600,0xa58c000a0] 25:[0,8683520,0xf5660009f] 26:[0,8764928,0x1418a00099] 27:[0,8843264,0x1430200095] 28:[0,8919552,0x18b3c00092] 29:[0,8994304,0xc6fe00073] 30:[0,9053184,0xf09000071] 31:[0,9111040,0x1f63800065] 32:[0,9162752,0x7cda00064] 33:[0,9213952,0x85d000063] 34:[0,9264640,0xb68e00061] 35:[0,9314304,0x1da3c0005d] 36:[0,9361920,0x1447e0005c] 37:[0,9409024,0x1c5c200056] 38:[0,9453056,0xc30e0004e] 39:[0,9492992,0x1e9040004d] 40:[0,9532416,0xa1a200046] 41:[0,9568256,0x1f0a80003c] 42:[0,9598976,0x23140003c] 43:[0,9629696,0x436a0003c] 44:[0,9660416,0xc0bc00039] 45:[0,9689600,0x1f91a00038] 46:[0,9718272,0x886200038] 47:[0,9746944,0x18fc800037] 48:[0,9775104,0x3ea800036] 49:[0,9802752,0xc29a00036] 50:[0,9830400,0xfea400033] 51:[0,9856512,0x1f1f600031] 52:[0,9881600,0xff8a0002f] 53:[0,9905664,0x12a9a0002f] 54:[0,9929728,0x20680002e] 55:[0,9953280,0x3e140002d] 56:[0,9976320,0x114100002d] 57:[0,9999360,0x127fe0002a] 58:[0,10020864,0x1e8840002a] 59:[0,10042368,0x7ec60002a] 60:[0,10063872,0x7fb000004] 61:[0,10065920,0x935a0002a] 62:[0,10087424,0xa07000026] 63:[0,10106880,0xa0f600001]

xfs_db> q

[root@localhost loop]# hexdump -C -s 16986112 -n 4096 /dev/loop0

01033000  42 4d 41 50 00 00 00 3f  ff ff ff ff ff ff ff ff  |BMAP...?........|

01033010  ff ff ff ff ff ff ff ff  00 00 00 00 00 00 00 00  |................|

01033020  00 00 00 0d 66 40 0c 00  00 00 00 00 00 18 00 00  |....f@..........|

01033030  00 00 00 1a bc 60 0a 1d  00 00 00 00 00 2c 3a 00  |.....`.......,:.|

01033040  00 00 00 12 f3 40 08 66  00 00 00 00 00 3d 06 00  |[email protected].....=..|

01033050  00 00 00 06 56 e0 04 17  00 00 00 00 00 45 34 00  |....V........E4.|

01033060  00 00 00 17 9d a0 03 13  00 00 00 00 00 4b 5a 00  |.............KZ.|

01033070  00 00 00 11 95 c0 02 f1  00 00 00 00 00 51 3c 00  |.............Q<.|

01033080  00 00 00 0a 6d 60 02 a0  00 00 00 00 00 56 7c 00  |....m`.......V|.|

01033090  00 00 00 0c d4 00 02 5a  00 00 00 00 00 5b 30 00  |.......Z.....[0.|

010330a0  00 00 00 0b 1c 60 02 59  00 00 00 00 00 5f e2 00  |.....`.Y....._..|

010330b0  00 00 00 01 62 e0 02 35  00 00 00 00 00 64 4c 00  |....b..5.....dL.|

010330c0  00 00 00 1d 1a 00 01 cf  00 00 00 00 00 67 ea 00  |.............g..|

010330d0  00 00 00 12 22 60 01 c1  00 00 00 00 00 6b 6c 00  |...."`.......kl.|

010330e0  00 00 00 1d cf 40 01 b6  00 00 00 00 00 6e d8 00  |[email protected]..|

010330f0  00 00 00 1e c8 80 01 ac  00 00 00 00 00 72 30 00  |.............r0.|

01033100  00 00 00 0f 1f a0 01 76  00 00 00 00 00 75 1c 00  |.......v.....u..|

01033110  00 00 00 07 56 c0 01 23  00 00 00 00 00 77 62 00  |....V..#.....wb.|

01033120  00 00 00 1c 79 60 01 1b  00 00 00 00 00 79 98 00  |....y`.......y..|

01033130  00 00 00 08 aa 40 01 12  00 00 00 00 00 7b bc 00  |.....@.......{..|

...

其它中间节点也是占用一整的block块,所以其内部布局虽然和根节点有点类似,但开始的一部分有点不同,得换成xfs_btree_block结构体,另外xfs_bmbt_ptr_t的起始地址当然也不是176了,不过也可以计算出来,这里都不累述。最后,看它的图示如下:

Xfs文件系统磁盘布局_第12张图片

十一,目录文件数据结构

对于目录类型的文件来说,其文件内容就是该目录下管理的所有文件(也即是子目录、普通文件等等)的信息(比如文件名、inode号等),随着目录文件内容的多少不同,存放的方式也不同,本篇就先介绍最简单的存放方式,称为简短方式(Shortform Directories)。前面说过,目录文件对应inode的data fork最大可有156个字节,利用这些磁盘空间也是可以存放一些信息的,简短方式就是直接把目录文件下的子文件相关信息存放在该目录文件对应inode的这156个字节空间内。

Xfs文件系统磁盘布局_第13张图片

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

typedef struct xfs_dir2_sf_hdr {

    __uint8_t       count;      /* count of entries */

    __uint8_t       i8count;    /* count of 8-byte inode #s */

    xfs_dir2_inou_t     parent;     /* parent dir inode number */

} __arch_pack xfs_dir2_sf_hdr_t;

typedef union {

    xfs_dir2_ino8_t i8;

    xfs_dir2_ino4_t i4;

} xfs_dir2_inou_t;

typedef struct { __uint8_t i[8]; } xfs_dir2_ino8_t;

typedef struct { __uint8_t i[4]; } xfs_dir2_ino4_t;

typedef struct xfs_dir2_sf_entry {

    __uint8_t       namelen;    /* actual name length */

    xfs_dir2_sf_off_t   offset;     /* saved offset */

    __uint8_t       name[1];    /* name, variable size */

    xfs_dir2_inou_t     inumber;    /* inode number, var. offset */

} __arch_pack xfs_dir2_sf_entry_t;

typedef struct { __uint8_t i[2]; } __arch_pack xfs_dir2_sf_off_t;

Xfs在使用简短方式存储子文件信息时会采用尽可能的方法压缩这些子文件信息,以便在156字节空间里存储最大容量的项目:
1,只存储子文件的文件名(包括文件名长度以及文件名字符串)、inode号、offset偏移(为了迭代调用readdir函数而设定的字段,但其具体含义以及怎么被readdir函数使用,目前尚未搞清楚)。
2,代表当前目录的“.”没有存储,因为就是当前inode本身;代表父目录的“..”直接存放在头结构体xfs_dir2_sf_hdr_t的parent字段内。
3,为了尽量节省每个项目占用的字节数,代表inode号的项目字段inumber为union类型,既可以是8字节,又可以是4字节。当所有子文件的inode号都可以用4字节完整表示时,项目的字段inumber就用4字节字段足以,此时整个项目数记录在头结构体xfs_dir2_sf_hdr_t的count字段内,与此相对的i8count字段值为0;只要有一个子文件的inode号需要用8字节才能完整表示,此时每个项目的字段inumber就要都占用8字节(因为无法知道具体哪个项目的inumber字段需要8字节,所以此时想节省空间也没有办法,只能全部占用8字节),整个项目数记录在头结构体xfs_dir2_sf_hdr_t的i8count字段内,与此相对的count字段值为0;
简短方式比较简单,看一个实例:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

[root@localhost loop]# ls

inode.256  inode.256.img  xfs  xfs.img

[root@localhost loop]# mount /dev/loop0 inode.256

[root@localhost loop]# cd !$

cd inode.256

[root@localhost inode.256]# ls

bigfile  lib64  linux-2.6.36  shortform  t1

[root@localhost inode.256]# cd shortform/

[root@localhost shortform]# ls -lai

total 32

   149 drwxr-xr-x 5 root root    82 Jan  9 09:54 .

   128 drwxr-xr-x 5 root root    76 Jan  9 09:52 ..

   157 -rw-r--r-- 1 root root     0 Jan  9 09:53 empty

338976 drwxr-xr-x 2 root root     6 Jan  9 09:53 gdb

   160 -rw-r--r-- 1 root root 27596 Jan  9 09:54 history

132448 drwxr-xr-x 2 root root     6 Jan  9 09:52 linux-2.6.30

393347 drwxr-xr-x 2 root root     6 Jan  9 09:54 study

   155 -rw-r--r-- 1 root root     5 Jan  9 09:53 t1

[root@localhost shortform]# cd ../../

[root@localhost loop]# umount inode.256

[root@localhost loop]# /home/lenky/xfs/xfsprogs/db/xfs_db /dev/loop0

xfs_db> inode 149

xfs_db> p

core.magic = 0x494e

core.mode = 040755

core.version = 1

core.format = 1 (local)

core.nlinkv1 = 5

core.uid = 0

core.gid = 0

core.flushiter = 11

core.atime.sec = Mon Jan  9 09:54:30 2012

core.atime.nsec = 536999855

core.mtime.sec = Mon Jan  9 09:54:27 2012

core.mtime.nsec = 823999851

core.ctime.sec = Mon Jan  9 09:54:27 2012

core.ctime.nsec = 823999851

core.size = 82

core.nblocks = 0

core.extsize = 0

core.nextents = 0

core.naextents = 0

core.forkoff = 0

core.aformat = 2 (extents)

core.dmevmask = 0

core.dmstate = 0

core.newrtbm = 0

core.prealloc = 0

core.realtime = 0

core.immutable = 0

core.append = 0

core.sync = 0

core.noatime = 0

core.nodump = 0

core.rtinherit = 0

core.projinherit = 0

core.nosymlinks = 0

core.extsz = 0

core.extszinherit = 0

core.nodefrag = 0

core.filestream = 0

core.gen = 5

next_unlinked = null

u.sfdir2.hdr.count = 6

u.sfdir2.hdr.i8count = 0

u.sfdir2.hdr.parent.i4 = 128

u.sfdir2.list[0].namelen = 12

u.sfdir2.list[0].offset = 0x30

u.sfdir2.list[0].name = "linux-2.6.30"

u.sfdir2.list[0].inumber.i4 = 132448

u.sfdir2.list[1].namelen = 3

u.sfdir2.list[1].offset = 0x48

u.sfdir2.list[1].name = "gdb"

u.sfdir2.list[1].inumber.i4 = 338976

u.sfdir2.list[2].namelen = 2

u.sfdir2.list[2].offset = 0x58

u.sfdir2.list[2].name = "t1"

u.sfdir2.list[2].inumber.i4 = 155

u.sfdir2.list[3].namelen = 5

u.sfdir2.list[3].offset = 0x68

u.sfdir2.list[3].name = "empty"

u.sfdir2.list[3].inumber.i4 = 157

u.sfdir2.list[4].namelen = 7

u.sfdir2.list[4].offset = 0x78

u.sfdir2.list[4].name = "history"

u.sfdir2.list[4].inumber.i4 = 160

u.sfdir2.list[5].namelen = 5

u.sfdir2.list[5].offset = 0x90

u.sfdir2.list[5].name = "study"

u.sfdir2.list[5].inumber.i4 = 393347

xfs_db> q

[root@localhost loop]#  hexdump -C -s 38144 -n 256 /dev/loop0

00009500  49 4e 41 ed 01 01 00 05  00 00 00 00 00 00 00 00  |INA.............|

00009510  00 00 00 05 00 00 00 00  00 00 00 00 00 00 00 0b  |................|

00009520  4f 0a ff a6 20 01 f7 af  4f 0a ff a3 31 1d 3d 6b  |O... ...O...1.=k|

00009530  4f 0a ff a3 31 1d 3d 6b  00 00 00 00 00 00 00 52  |O...1.=k.......R|

00009540  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00009550  00 00 00 02 00 00 00 00  00 00 00 00 00 00 00 05  |................|

00009560  ff ff ff ff 06 00 00 00  00 80 0c 00 30 6c 69 6e  |............0lin|

00009570  75 78 2d 32 2e 36 2e 33  30 00 02 05 60 03 00 48  |ux-2.6.30...`..H|

00009580  67 64 62 00 05 2c 20 02  00 58 74 31 00 00 00 9b  |gdb.., ..Xt1....|

00009590  05 00 68 65 6d 70 74 79  00 00 00 9d 07 00 78 68  |..hempty......xh|

000095a0  69 73 74 6f 72 79 00 00  00 a0 05 00 90 73 74 75  |istory.......stu|

000095b0  64 79 00 06 00 83 00 00  00 00 00 00 00 00 00 00  |dy..............|

000095c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00009600

[root@localhost loop]#

当我们删除一个子文件时,如果这个子文件对应的项目不是最后一个,那么接在后面的项目必须要前移,这些都是很容易想到的事情,因为如果不前移,那么按照头结构体里的count或i8count字段而遍历后续“数组”找到的项目就不对了。

当一个目录文件下的子文件比较多,其子文件的相关信息以简短方式无法在inode的data fork内存放时,就要被转移到一个新的单独的“directory block”块内。“directory block”块是存放目录子文件相关信息所需磁盘的基本申请和释放单位,一块“directory block”的大小不一定和一块逻辑block大小一致,因为一块“directory block”可以由多个连续逻辑block组成,具体大小bytes = sb_blocksize * 2sb_dirblklog,但在默认情况下sb_dirblklog = 0,也即是一块“directory block”就由一块逻辑block组成,默认大小同为为4096。另外,一块“directory block”的大小最大值为35536(bytes)。

利用新的单独的“directory block”块来更多存放子文件的相关信息,对这些“directory block”的组织又有多种方式,如前面所说,包括数组“extents”、“Btree”等。先来看看“extents”方式,此时目录文件inode核心数据的di_format字段值将由XFS_DINODE_FMT_LOCAL(数值1,简短方式时的值)变成XFS_DINODE_FMT_EXTENTS(数值2),各个“directory block”块号等信息以数组的形式存放在data fork空间内,数组元素的个数由inode核心数据的di_nextents标记,数组元素内记录的一个“directory block”的信息包括startoff、startblock、blockcount、extentflag,这和前面介绍的普通文件的extents数据结构是一样的。
先看数组元素只有一个的情况,这是一种特例情况,此时di_nextents = 1,di_nblocks = “directory block”/“logic block” (我这里,“directory block”和“logic block” 大小一样,所以di_nblocks = 1),数组第0个元素内记录的“directory block”的信息:startoff恒等于0、startblock指向对应的起始block块好、blockcount等于“directory block”/“logic block”、extentflag记录flag标记。

Xfs文件系统磁盘布局_第14张图片
实例:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

[root@localhost block]# ls -lai

total 616

 137 drwxr-xr-x 2 root root  4096 Jan 10 04:59 .

 128 drwxr-xr-x 6 root root    81 Jan 10 04:49 ..

 143 -rw-r--r-- 1 root root  1244 Jan 10 04:59 atomic.h

 166 -rw-r--r-- 1 root root   664 Jan 10 04:59 bitops.h

 168 -rw-r--r-- 1 root root  8381 Jan 10 04:59 builddefs

 170 -rw-r--r-- 1 root root  3838 Jan 10 04:59 builddefs.in

...

[root@localhost block]# cd ../../

[root@localhost loop]# umount inode.256

[root@localhost loop]# /home/lenky/xfs/xfsprogs/db/xfs_db /dev/loop0

xfs_db> inode 137

xfs_db> p

core.magic = 0x494e

core.mode = 040755

core.version = 1

core.format = 2 (extents)

...

core.nblocks = 1

core.extsize = 0

core.nextents = 1

core.naextents = 0

...

core.gen = 5

next_unlinked = null

u.bmx[0] = [startoff,startblock,blockcount,extentflag] 0:[0,36,1,0]

xfs_db> q

[root@localhost loop]# hexdump -C -s 35072 -n 256 /dev/loop0

00008900  49 4e 41 ed 01 02 00 02  00 00 00 00 00 00 00 00  |INA.............|

00008910  00 00 00 02 00 00 00 00  00 00 00 00 00 00 00 17  |................|

00008920  4f 0c 0c 01 16 3b 86 ac  4f 0c 0c 00 17 a9 bc ac  |O....;..O.......|

00008930  4f 0c 0c 00 17 a9 bc ac  00 00 00 00 00 00 10 00  |O...............|

00008940  00 00 00 00 00 00 00 01  00 00 00 00 00 00 00 01  |................|

00008950  00 00 00 02 00 00 00 00  00 00 00 00 00 00 00 05  |................|

00008960  ff ff ff ff 00 00 00 00  00 00 00 00 00 00 00 00  |................|

00008970  04 80 00 01 00 00 00 00  00 00 02 00 00 00 00 00  |................|

00008980  21 80 00 01 00 00 00 01  00 00 00 00 00 00 00 01  |!...............|

00008990  9b c0 00 01 00 00 00 00  00 00 00 00 00 00 00 00  |................|

000089a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

000089b0  00 00 00 00 00 00 10 33  00 00 00 00 00 00 00 00  |.......3........|

000089c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00008a00

[root@localhost loop]#

00008960 ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 |…………….|
00008970 04 80 00 01 00 00 00 00 00 00 02 00 00 00 00 00 |…………….|
非0的数据“04 80 00 01”拆成2进制为“00000100 10000000 00000000 00000001”,即startblock的二进制值为100100(十进制为36),blockcount的二进制值为001(十进制为1),对比前面是符合数据一致的。

上一篇实例里讲到“directory block”块存放在startblock指向的逻辑block块内,块号为36(注意我这里“directory block”和“逻辑block”大小一致),先看看其内容:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749

750

[root@localhost loop]# /home/lenky/xfs/xfsprogs/db/xfs_db /dev/loop0

xfs_db> fsblock 36

xfs_db> type dir2

xfs_db> p

bhdr.magic = 0x58443242

bhdr.bestfree[0].offset = 0x7e8

bhdr.bestfree[0].length = 0x598

bhdr.bestfree[1].offset = 0

bhdr.bestfree[1].length = 0

bhdr.bestfree[2].offset = 0

bhdr.bestfree[2].length = 0

bu[0].inumber = 137

bu[0].namelen = 1

bu[0].name = "."

bu[0].tag = 0x10

bu[1].inumber = 128

bu[1].namelen = 2

bu[1].name = ".."

bu[1].tag = 0x20

bu[2].inumber = 143

bu[2].namelen = 8

bu[2].name = "atomic.h"

bu[2].tag = 0x30

bu[3].inumber = 166

bu[3].namelen = 8

bu[3].name = "bitops.h"

bu[3].tag = 0x48

bu[4].inumber = 168

bu[4].namelen = 9

bu[4].name = "builddefs"

bu[4].tag = 0x60

bu[5].inumber = 170

bu[5].namelen = 12

bu[5].name = "builddefs.in"

bu[5].tag = 0x78

bu[6].inumber = 173

bu[6].namelen = 11

bu[6].name = "buildmacros"

bu[6].tag = 0x90

bu[7].inumber = 174

bu[7].namelen = 10

bu[7].name = "buildrules"

bu[7].tag = 0xa8

bu[8].inumber = 175

bu[8].namelen = 7

bu[8].name = "cache.h"

bu[8].tag = 0xc0

bu[9].inumber = 178

bu[9].namelen = 9

bu[9].name = "command.h"

bu[9].tag = 0xd8

bu[10].inumber = 185

bu[10].namelen = 8

bu[10].name = "darwin.h"

bu[10].tag = 0xf0

bu[11].inumber = 187

bu[11].namelen = 5

bu[11].name = "dvh.h"

bu[11].tag = 0x108

bu[12].inumber = 191

bu[12].namelen = 9

bu[12].name = "freebsd.h"

bu[12].tag = 0x118

bu[13].inumber = 225

bu[13].namelen = 7

bu[13].name = "fstyp.h"

bu[13].tag = 0x130

bu[14].inumber = 232

bu[14].namelen = 13

bu[14].name = "gnukfreebsd.h"

bu[14].tag = 0x148

bu[15].inumber = 234

bu[15].namelen = 8

bu[15].name = "handle.h"

bu[15].tag = 0x160

bu[16].inumber = 239

bu[16].namelen = 7

bu[16].name = "hlist.h"

bu[16].tag = 0x178

bu[17].inumber = 241

bu[17].namelen = 7

bu[17].name = "input.h"

bu[17].tag = 0x190

bu[18].inumber = 242

bu[18].namelen = 10

bu[18].name = "install-sh"

bu[18].tag = 0x1a8

bu[19].inumber = 244

bu[19].namelen = 6

bu[19].name = "irix.h"

bu[19].tag = 0x1c0

bu[20].inumber = 250

bu[20].namelen = 5

bu[20].name = "jdm.h"

bu[20].tag = 0x1d8

bu[21].inumber = 251

bu[21].namelen = 6

bu[21].name = "kmem.h"

bu[21].tag = 0x1e8

bu[22].inumber = 253

bu[22].namelen = 8

bu[22].name = "libxfs.h"

bu[22].tag = 0x200

bu[23].inumber = 255

bu[23].namelen = 9

bu[23].name = "libxlog.h"

bu[23].tag = 0x218

bu[24].inumber = 256

bu[24].namelen = 7

bu[24].name = "linux.h"

bu[24].tag = 0x230

bu[25].inumber = 259

bu[25].namelen = 6

bu[25].name = "list.h"

bu[25].tag = 0x248

bu[26].inumber = 260

bu[26].namelen = 8

bu[26].name = "Makefile"

bu[26].tag = 0x260

bu[27].inumber = 262

bu[27].namelen = 8

bu[27].name = "parent.h"

bu[27].tag = 0x278

bu[28].inumber = 263

bu[28].namelen = 6

bu[28].name = "path.h"

bu[28].tag = 0x290

bu[29].inumber = 269

bu[29].namelen = 15

bu[29].name = "platform_defs.h"

bu[29].tag = 0x2a8

bu[30].inumber = 272

bu[30].namelen = 18

bu[30].name = "platform_defs.h.in"

bu[30].tag = 0x2c8

bu[31].inumber = 273

bu[31].namelen = 9

bu[31].name = "project.h"

bu[31].tag = 0x2e8

bu[32].inumber = 280

bu[32].namelen = 12

bu[32].name = "radix-tree.h"

bu[32].tag = 0x300

bu[33].inumber = 287

bu[33].namelen = 6

bu[33].name = "swab.h"

bu[33].tag = 0x318

bu[34].inumber = 291

bu[34].namelen = 8

bu[34].name = "volume.h"

bu[34].tag = 0x330

bu[35].inumber = 292

bu[35].namelen = 8

bu[35].name = "xfs_ag.h"

bu[35].tag = 0x348

bu[36].inumber = 295

bu[36].namelen = 17

bu[36].name = "xfs_alloc_btree.h"

bu[36].tag = 0x360

bu[37].inumber = 300

bu[37].namelen = 11

bu[37].name = "xfs_alloc.h"

bu[37].tag = 0x380

bu[38].inumber = 301

bu[38].namelen = 10

bu[38].name = "xfs_arch.h"

bu[38].tag = 0x398

bu[39].inumber = 303

bu[39].namelen = 15

bu[39].name = "xfs_attr_leaf.h"

bu[39].tag = 0x3b0

bu[40].inumber = 306

bu[40].namelen = 13

bu[40].name = "xfs_attr_sf.h"

bu[40].tag = 0x3d0

bu[41].inumber = 310

bu[41].namelen = 9

bu[41].name = "xfs_bit.h"

bu[41].tag = 0x3e8

bu[42].inumber = 313

bu[42].namelen = 16

bu[42].name = "xfs_bmap_btree.h"

bu[42].tag = 0x400

bu[43].inumber = 319

bu[43].namelen = 10

bu[43].name = "xfs_bmap.h"

bu[43].tag = 0x420

bu[44].inumber = 320

bu[44].namelen = 11

bu[44].name = "xfs_btree.h"

bu[44].tag = 0x438

bu[45].inumber = 324

bu[45].namelen = 17

bu[45].name = "xfs_btree_trace.h"

bu[45].tag = 0x450

bu[46].inumber = 329

bu[46].namelen = 14

bu[46].name = "xfs_buf_item.h"

bu[46].tag = 0x470

bu[47].inumber = 331

bu[47].namelen = 14

bu[47].name = "xfs_da_btree.h"

bu[47].tag = 0x490

bu[48].inumber = 336

bu[48].namelen = 11

bu[48].name = "xfs_dfrag.h"

bu[48].tag = 0x4b0

bu[49].inumber = 337

bu[49].namelen = 12

bu[49].name = "xfs_dinode.h"

bu[49].tag = 0x4c8

bu[50].inumber = 341

bu[50].namelen = 16

bu[50].name = "xfs_dir2_block.h"

bu[50].tag = 0x4e0

bu[51].inumber = 346

bu[51].namelen = 15

bu[51].name = "xfs_dir2_data.h"

bu[51].tag = 0x500

bu[52].inumber = 2400

bu[52].namelen = 10

bu[52].name = "xfs_dir2.h"

bu[52].tag = 0x520

bu[53].inumber = 2401

bu[53].namelen = 15

bu[53].name = "xfs_dir2_leaf.h"

bu[53].tag = 0x538

bu[54].inumber = 2402

bu[54].namelen = 15

bu[54].name = "xfs_dir2_node.h"

bu[54].tag = 0x558

bu[55].inumber = 2403

bu[55].namelen = 13

bu[55].name = "xfs_dir2_sf.h"

bu[55].tag = 0x578

bu[56].inumber = 2405

bu[56].namelen = 14

bu[56].name = "xfs_dir_leaf.h"

bu[56].tag = 0x590

bu[57].inumber = 2406

bu[57].namelen = 12

bu[57].name = "xfs_dir_sf.h"

bu[57].tag = 0x5b0

bu[58].inumber = 2407

bu[58].namelen = 18

bu[58].name = "xfs_extfree_item.h"

bu[58].tag = 0x5c8

bu[59].inumber = 2408

bu[59].namelen = 8

bu[59].name = "xfs_fs.h"

bu[59].tag = 0x5e8

bu[60].inumber = 2409

bu[60].namelen = 5

bu[60].name = "xfs.h"

bu[60].tag = 0x600

bu[61].inumber = 2410

bu[61].namelen = 18

bu[61].name = "xfs_ialloc_btree.h"

bu[61].tag = 0x610

bu[62].inumber = 2411

bu[62].namelen = 12

bu[62].name = "xfs_ialloc.h"

bu[62].tag = 0x630

bu[63].inumber = 2412

bu[63].namelen = 11

bu[63].name = "xfs_inode.h"

bu[63].tag = 0x648

bu[64].inumber = 2413

bu[64].namelen = 16

bu[64].name = "xfs_inode_item.h"

bu[64].tag = 0x660

bu[65].inumber = 2414

bu[65].namelen = 10

bu[65].name = "xfs_inum.h"

bu[65].tag = 0x680

bu[66].inumber = 2415

bu[66].namelen = 9

bu[66].name = "xfs_log.h"

bu[66].tag = 0x698

bu[67].inumber = 2416

bu[67].namelen = 14

bu[67].name = "xfs_log_priv.h"

bu[67].tag = 0x6b0

bu[68].inumber = 2417

bu[68].namelen = 17

bu[68].name = "xfs_log_recover.h"

bu[68].tag = 0x6d0

bu[69].inumber = 2418

bu[69].namelen = 14

bu[69].name = "xfs_metadump.h"

bu[69].tag = 0x6f0

bu[70].inumber = 2419

bu[70].namelen = 11

bu[70].name = "xfs_mount.h"

bu[70].tag = 0x710

bu[71].inumber = 2420

bu[71].namelen = 11

bu[71].name = "xfs_quota.h"

bu[71].tag = 0x728

bu[72].inumber = 2421

bu[72].namelen = 13

bu[72].name = "xfs_rtalloc.h"

bu[72].tag = 0x740

bu[73].inumber = 2422

bu[73].namelen = 8

bu[73].name = "xfs_sb.h"

bu[73].tag = 0x758

bu[74].inumber = 2423

bu[74].namelen = 11

bu[74].name = "xfs_trace.h"

bu[74].tag = 0x770

bu[75].inumber = 2424

bu[75].namelen = 11

bu[75].name = "xfs_trans.h"

bu[75].tag = 0x788

bu[76].inumber = 2425

bu[76].namelen = 17

bu[76].name = "xfs_trans_space.h"

bu[76].tag = 0x7a0

bu[77].inumber = 2426

bu[77].namelen = 11

bu[77].name = "xfs_types.h"

bu[77].tag = 0x7c0

bu[78].inumber = 2427

bu[78].namelen = 5

bu[78].name = "xqm.h"

bu[78].tag = 0x7d8

bu[79].freetag = 0xffff

bu[79].length = 0x598

bu[79].tag = 0x7e8

bleaf[0].hashval = 0x2e

bleaf[0].address = 0x2

bleaf[1].hashval = 0x172e

bleaf[1].address = 0x4

bleaf[2].hashval = 0x752b7c8

bleaf[2].address = 0x59

bleaf[3].hashval = 0x790d582

bleaf[3].address = 0x8a

bleaf[4].hashval = 0xebcb01f

bleaf[4].address = 0x32

bleaf[5].hashval = 0x122449b7

bleaf[5].address = 0xc6

bleaf[6].hashval = 0x181c9812

bleaf[6].address = 0x7a

bleaf[7].hashval = 0x1d268212

bleaf[7].address = 0xaf

bleaf[8].hashval = 0x1e9a14ee

bleaf[8].address = 0x52

bleaf[9].hashval = 0x1fe71197

bleaf[9].address = 0x76

bleaf[10].hashval = 0x21bf2944

bleaf[10].address = 0xb6

bleaf[11].hashval = 0x235fe9a7

bleaf[11].address = 0x99

bleaf[12].hashval = 0x236caad2

bleaf[12].address = 0x35

bleaf[13].hashval = 0x2c98a83e

bleaf[13].address = 0x5d

bleaf[14].hashval = 0x2d3e1427

bleaf[14].address = 0x38

bleaf[15].hashval = 0x2e62be24

bleaf[15].address = 0xe2

bleaf[16].hashval = 0x2e72d415

bleaf[16].address = 0xc

bleaf[17].hashval = 0x31638a36

bleaf[17].address = 0x6c

bleaf[18].hashval = 0x358de20b

bleaf[18].address = 0xcc

bleaf[19].hashval = 0x389d8ce1

bleaf[19].address = 0xe8

bleaf[20].hashval = 0x39c7d0c9

bleaf[20].address = 0xab

bleaf[21].hashval = 0x3a9856e1

bleaf[21].address = 0xb9

bleaf[22].hashval = 0x3d18d866

bleaf[22].address = 0x18

bleaf[23].hashval = 0x41fa7624

bleaf[23].address = 0x80

bleaf[24].hashval = 0x4547b8bd

bleaf[24].address = 0x60

bleaf[25].hashval = 0x489c8046

bleaf[25].address = 0x23

bleaf[26].hashval = 0x4a9d685b

bleaf[26].address = 0x73

bleaf[27].hashval = 0x4d48d01e

bleaf[27].address = 0x2c

bleaf[28].hashval = 0x4eda176e

bleaf[28].address = 0x21

bleaf[29].hashval = 0x4f3d8cf7

bleaf[29].address = 0x26

bleaf[30].hashval = 0x533937ec

bleaf[30].address = 0x9c

bleaf[31].hashval = 0x55f0d996

bleaf[31].address = 0x7d

bleaf[32].hashval = 0x5b6881e5

bleaf[32].address = 0x15

bleaf[33].hashval = 0x5c41f13b

bleaf[33].address = 0x4c

bleaf[34].hashval = 0x5d3c90fe

bleaf[34].address = 0x4f

bleaf[35].hashval = 0x5d54e80f

bleaf[35].address = 0x66

bleaf[36].hashval = 0x5f06c2fc

bleaf[36].address = 0x87

bleaf[37].hashval = 0x5f865a6c

bleaf[37].address = 0x96

bleaf[38].hashval = 0x60c22c36

bleaf[38].address = 0xda

bleaf[39].hashval = 0x6e631acd

bleaf[39].address = 0xf1

bleaf[40].hashval = 0x6fc69acd

bleaf[40].address = 0xee

bleaf[41].hashval = 0x7c3894f7

bleaf[41].address = 0x63

bleaf[42].hashval = 0x7df210ff

bleaf[42].address = 0x1e

bleaf[43].hashval = 0x7e06a006

bleaf[43].address = 0x1b

bleaf[44].hashval = 0x7e3be7ba

bleaf[44].address = 0xde

bleaf[45].hashval = 0x7f031a94

bleaf[45].address = 0xf8

bleaf[46].hashval = 0x82ae7ab4

bleaf[46].address = 0xf

bleaf[47].hashval = 0x849c9f1a

bleaf[47].address = 0xd6

bleaf[48].hashval = 0x885c281a

bleaf[48].address = 0xd0

bleaf[49].hashval = 0x8b68ab3e

bleaf[49].address = 0x92

bleaf[50].hashval = 0x8c05707f

bleaf[50].address = 0x40

bleaf[51].hashval = 0x8cdcd76f

bleaf[51].address = 0xc0

bleaf[52].hashval = 0x8d278ef5

bleaf[52].address = 0xe5

bleaf[53].hashval = 0x8e3b576f

bleaf[53].address = 0xfb

bleaf[54].hashval = 0x8f26ee2d

bleaf[54].address = 0xc9

bleaf[55].hashval = 0x90f00d57

bleaf[55].address = 0xf4

bleaf[56].hashval = 0x996710d9

bleaf[56].address = 0xa7

bleaf[57].hashval = 0x9e7cb40e

bleaf[57].address = 0x2f

bleaf[58].hashval = 0x9e7d140e

bleaf[58].address = 0x49

bleaf[59].hashval = 0xa12a5cae

bleaf[59].address = 0x43

bleaf[60].hashval = 0xac9b576e

bleaf[60].address = 0x3b

bleaf[61].hashval = 0xb5341996

bleaf[61].address = 0xd3

bleaf[62].hashval = 0xbadb6842

bleaf[62].address = 0x84

bleaf[63].hashval = 0xbd7da087

bleaf[63].address = 0xc2

bleaf[64].hashval = 0xbe474e3d

bleaf[64].address = 0x70

bleaf[65].hashval = 0xc819303a

bleaf[65].address = 0x55

bleaf[66].hashval = 0xcee15d33

bleaf[66].address = 0x29

bleaf[67].hashval = 0xdbc6d099

bleaf[67].address = 0xa0

bleaf[68].hashval = 0xdcbb5436

bleaf[68].address = 0x3d

bleaf[69].hashval = 0xddfb0416

bleaf[69].address = 0x6

bleaf[70].hashval = 0xeebfa426

bleaf[70].address = 0x46

bleaf[71].hashval = 0xf3b29fff

bleaf[71].address = 0xb2

bleaf[72].hashval = 0xf5a53c27

bleaf[72].address = 0x12

bleaf[73].hashval = 0xf8abe872

bleaf[73].address = 0xa4

bleaf[74].hashval = 0xfc2d4cf5

bleaf[74].address = 0xbd

bleaf[75].hashval = 0xfcc84cf5

bleaf[75].address = 0x69

bleaf[76].hashval = 0xfe890cf5

bleaf[76].address = 0xeb

bleaf[77].hashval = 0xfed970ce

bleaf[77].address = 0x9

bleaf[78].hashval = 0xff185fd5

bleaf[78].address = 0x8e

btail.count = 79

btail.stale = 0

xfs_db> q

[root@localhost loop]# hexdump -C -s 147456 -n 4096 /dev/loop0

00024000  58 44 32 42 07 e8 05 98  00 00 00 00 00 00 00 00  |XD2B............|

00024010  00 00 00 00 00 00 00 89  01 2e 00 00 00 00 00 10  |................|

00024020  00 00 00 00 00 00 00 80  02 2e 2e 00 00 00 00 20  |............... |

00024030  00 00 00 00 00 00 00 8f  08 61 74 6f 6d 69 63 2e  |.........atomic.|

00024040  68 00 00 00 00 00 00 30  00 00 00 00 00 00 00 a6  |h......0........|

00024050  08 62 69 74 6f 70 73 2e  68 00 00 00 00 00 00 48  |.bitops.h......H|

00024060  00 00 00 00 00 00 00 a8  09 62 75 69 6c 64 64 65  |.........buildde|

00024070  66 73 00 00 00 00 00 60  00 00 00 00 00 00 00 aa  |fs.....`........|

00024080  0c 62 75 69 6c 64 64 65  66 73 2e 69 6e 00 00 78  |.builddefs.in..x|

00024090  00 00 00 00 00 00 00 ad  0b 62 75 69 6c 64 6d 61  |.........buildma|

000240a0  63 72 6f 73 00 00 00 90  00 00 00 00 00 00 00 ae  |cros............|

000240b0  0a 62 75 69 6c 64 72 75  6c 65 73 00 00 00 00 a8  |.buildrules.....|

000240c0  00 00 00 00 00 00 00 af  07 63 61 63 68 65 2e 68  |.........cache.h|

000240d0  00 00 00 00 00 00 00 c0  00 00 00 00 00 00 00 b2  |................|

000240e0  09 63 6f 6d 6d 61 6e 64  2e 68 00 00 00 00 00 d8  |.command.h......|

000240f0  00 00 00 00 00 00 00 b9  08 64 61 72 77 69 6e 2e  |.........darwin.|

00024100  68 00 00 00 00 00 00 f0  00 00 00 00 00 00 00 bb  |h...............|

00024110  05 64 76 68 2e 68 01 08  00 00 00 00 00 00 00 bf  |.dvh.h..........|

00024120  09 66 72 65 65 62 73 64  2e 68 6d 65 6d 2e 01 18  |.freebsd.hmem...|

00024130  00 00 00 00 00 00 00 e1  07 66 73 74 79 70 2e 68  |.........fstyp.h|

00024140  07 6b 6d 65 6d 2e 01 30  00 00 00 00 00 00 00 e8  |.kmem..0........|

00024150  0d 67 6e 75 6b 66 72 65  65 62 73 64 2e 68 01 48  |.gnukfreebsd.h.H|

00024160  00 00 00 00 00 00 00 ea  08 68 61 6e 64 6c 65 2e  |.........handle.|

00024170  68 6c 69 62 78 66 01 60  00 00 00 00 00 00 00 ef  |hlibxf.`........|

00024180  07 68 6c 69 73 74 2e 68  07 6c 69 6e 75 78 01 78  |.hlist.h.linux.x|

00024190  00 00 00 00 00 00 00 f1  07 69 6e 70 75 74 2e 68  |.........input.h|

000241a0  08 6c 69 6e 75 78 01 90  00 00 00 00 00 00 00 f2  |.linux..........|

000241b0  0a 69 6e 73 74 61 6c 6c  2d 73 68 6e 75 78 01 a8  |.install-shnux..|

000241c0  00 00 00 00 00 00 00 f4  06 69 72 69 78 2e 68 f4  |.........irix.h.|

000241d0  09 6c 6f 67 69 74 01 c0  00 00 00 00 00 00 00 fa  |.logit..........|

000241e0  05 6a 64 6d 2e 68 01 d8  00 00 00 00 00 00 00 fb  |.jdm.h..........|

000241f0  06 6b 6d 65 6d 2e 68 e0  ff ff 00 18 00 00 01 e8  |.kmem.h.........|

00024200  00 00 00 00 00 00 00 fd  08 6c 69 62 78 66 73 2e  |.........libxfs.|

00024210  68 00 00 00 00 00 02 00  00 00 00 00 00 00 00 ff  |h...............|

00024220  09 6c 69 62 78 6c 6f 67  2e 68 00 00 00 00 02 18  |.libxlog.h......|

00024230  00 00 00 00 00 00 01 00  07 6c 69 6e 75 78 2e 68  |.........linux.h|

00024240  ff ff 00 30 00 00 02 30  00 00 00 00 00 00 01 03  |...0...0........|

00024250  06 6c 69 73 74 2e 68 40  ff ff 00 18 00 00 02 48  |[email protected]|

00024260  00 00 00 00 00 00 01 04  08 4d 61 6b 65 66 69 6c  |.........Makefil|

00024270  65 00 00 00 00 00 02 60  00 00 00 00 00 00 01 06  |e......`........|

00024280  08 70 61 72 65 6e 74 2e  68 ff 00 30 00 00 02 78  |.parent.h..0...x|

00024290  00 00 00 00 00 00 01 07  06 70 61 74 68 2e 68 88  |.........path.h.|

000242a0  ff ff 00 18 00 00 02 90  00 00 00 00 00 00 01 0d  |................|

000242b0  0f 70 6c 61 74 66 6f 72  6d 5f 64 65 66 73 2e 68  |.platform_defs.h|

000242c0  07 74 72 61 6e 73 02 a8  00 00 00 00 00 00 01 10  |.trans..........|

000242d0  12 70 6c 61 74 66 6f 72  6d 5f 64 65 66 73 2e 68  |.platform_defs.h|

000242e0  2e 69 6e 00 00 00 02 c8  00 00 00 00 00 00 01 11  |.in.............|

000242f0  09 70 72 6f 6a 65 63 74  2e 68 00 00 00 00 02 e8  |.project.h......|

00024300  00 00 00 00 00 00 01 18  0c 72 61 64 69 78 2d 74  |.........radix-t|

00024310  72 65 65 2e 68 00 03 00  00 00 00 00 00 00 01 1f  |ree.h...........|

00024320  06 73 77 61 62 2e 68 6f  00 00 00 00 00 00 03 18  |.swab.ho........|

00024330  00 00 00 00 00 00 01 23  08 76 6f 6c 75 6d 65 2e  |.......#.volume.|

00024340  68 00 00 00 00 00 03 30  00 00 00 00 00 00 01 24  |h......0.......$|

00024350  08 78 66 73 5f 61 67 2e  68 63 5f 62 74 72 03 48  |.xfs_ag.hc_btr.H|

00024360  00 00 00 00 00 00 01 27  11 78 66 73 5f 61 6c 6c  |.......'.xfs_all|

00024370  6f 63 5f 62 74 72 65 65  2e 68 5f 62 74 72 03 60  |oc_btree.h_btr.`|

00024380  00 00 00 00 00 00 01 2c  0b 78 66 73 5f 61 6c 6c  |.......,.xfs_all|

00024390  6f 63 2e 68 5f 61 03 80  00 00 00 00 00 00 01 2d  |oc.h_a.........-|

000243a0  0a 78 66 73 5f 61 72 63  68 2e 68 00 00 00 03 98  |.xfs_arch.h.....|

000243b0  00 00 00 00 00 00 01 2f  0f 78 66 73 5f 61 74 74  |......./.xfs_att|

000243c0  72 5f 6c 65 61 66 2e 68  0c 78 66 73 5f 61 03 b0  |r_leaf.h.xfs_a..|

000243d0  00 00 00 00 00 00 01 32  0d 78 66 73 5f 61 74 74  |.......2.xfs_att|

000243e0  72 5f 73 66 2e 68 03 d0  00 00 00 00 00 00 01 36  |r_sf.h.........6|

000243f0  09 78 66 73 5f 62 69 74  2e 68 66 73 5f 61 03 e8  |.xfs_bit.hfs_a..|

00024400  00 00 00 00 00 00 01 39  10 78 66 73 5f 62 6d 61  |.......9.xfs_bma|

00024410  70 5f 62 74 72 65 65 2e  68 5f 6c 65 61 66 04 00  |p_btree.h_leaf..|

00024420  00 00 00 00 00 00 01 3f  0a 78 66 73 5f 62 6d 61  |.......?.xfs_bma|

00024430  70 2e 68 73 5f 61 04 20  00 00 00 00 00 00 01 40  |p.hs_a. .......@|

00024440  0b 78 66 73 5f 62 74 72  65 65 2e 68 00 00 04 38  |.xfs_btree.h...8|

00024450  00 00 00 00 00 00 01 44  11 78 66 73 5f 62 74 72  |.......D.xfs_btr|

00024460  65 65 5f 74 72 61 63 65  2e 68 00 00 00 00 04 50  |ee_trace.h.....P|

00024470  00 00 00 00 00 00 01 49  0e 78 66 73 5f 62 75 66  |.......I.xfs_buf|

00024480  5f 69 74 65 6d 2e 68 49  0a 78 66 73 5f 61 04 70  |_item.hI.xfs_a.p|

00024490  00 00 00 00 00 00 01 4b  0e 78 66 73 5f 64 61 5f  |.......K.xfs_da_|

000244a0  62 74 72 65 65 2e 68 61  70 5f 62 74 72 65 04 90  |btree.hap_btre..|

000244b0  00 00 00 00 00 00 01 50  0b 78 66 73 5f 64 66 72  |.......P.xfs_dfr|

000244c0  61 67 2e 68 5f 62 04 b0  00 00 00 00 00 00 01 51  |ag.h_b.........Q|

000244d0  0c 78 66 73 5f 64 69 6e  6f 64 65 2e 68 00 04 c8  |.xfs_dinode.h...|

000244e0  00 00 00 00 00 00 01 55  10 78 66 73 5f 64 69 72  |.......U.xfs_dir|

000244f0  32 5f 62 6c 6f 63 6b 2e  68 00 00 00 00 00 04 e0  |2_block.h.......|

00024500  00 00 00 00 00 00 01 5a  0f 78 66 73 5f 64 69 72  |.......Z.xfs_dir|

00024510  32 5f 64 61 74 61 2e 68  0b 78 66 73 5f 62 05 00  |2_data.h.xfs_b..|

00024520  00 00 00 00 00 00 09 60  0a 78 66 73 5f 64 69 72  |.......`.xfs_dir|

00024530  32 2e 68 73 5f 62 05 20  00 00 00 00 00 00 09 61  |2.hs_b. .......a|

00024540  0f 78 66 73 5f 64 69 72  32 5f 6c 65 61 66 2e 68  |.xfs_dir2_leaf.h|

00024550  65 65 2e 63 00 00 05 38  00 00 00 00 00 00 09 62  |ee.c...8.......b|

00024560  0f 78 66 73 5f 64 69 72  32 5f 6e 6f 64 65 2e 68  |.xfs_dir2_node.h|

00024570  ff ff 00 18 00 00 05 58  00 00 00 00 00 00 09 63  |.......X.......c|

00024580  0d 78 66 73 5f 64 69 72  32 5f 73 66 2e 68 05 78  |.xfs_dir2_sf.h.x|

00024590  00 00 00 00 00 00 09 65  0e 78 66 73 5f 64 69 72  |.......e.xfs_dir|

000245a0  5f 6c 65 61 66 2e 68 88  ff ff 00 40 00 00 05 90  |_leaf.h....@....|

000245b0  00 00 00 00 00 00 09 66  0c 78 66 73 5f 64 69 72  |.......f.xfs_dir|

000245c0  5f 73 66 2e 68 00 05 b0  00 00 00 00 00 00 09 67  |_sf.h..........g|

000245d0  12 78 66 73 5f 65 78 74  66 72 65 65 5f 69 74 65  |.xfs_extfree_ite|

000245e0  6d 2e 68 00 00 00 05 c8  00 00 00 00 00 00 09 68  |m.h............h|

000245f0  08 78 66 73 5f 66 73 2e  68 5f 62 6c 6f 63 05 e8  |.xfs_fs.h_bloc..|

00024600  00 00 00 00 00 00 09 69  05 78 66 73 2e 68 06 00  |.......i.xfs.h..|

00024610  00 00 00 00 00 00 09 6a  12 78 66 73 5f 69 61 6c  |.......j.xfs_ial|

00024620  6c 6f 63 5f 62 74 72 65  65 2e 68 20 00 00 06 10  |loc_btree.h ....|

00024630  00 00 00 00 00 00 09 6b  0c 78 66 73 5f 69 61 6c  |.......k.xfs_ial|

00024640  6c 6f 63 2e 68 00 06 30  00 00 00 00 00 00 09 6c  |loc.h..0.......l|

00024650  0b 78 66 73 5f 69 6e 6f  64 65 2e 68 00 00 06 48  |.xfs_inode.h...H|

00024660  00 00 00 00 00 00 09 6d  10 78 66 73 5f 69 6e 6f  |.......m.xfs_ino|

00024670  64 65 5f 69 74 65 6d 2e  68 00 00 00 00 00 06 60  |de_item.h......`|

00024680  00 00 00 00 00 00 09 6e  0a 78 66 73 5f 69 6e 75  |.......n.xfs_inu|

00024690  6d 2e 68 61 74 61 06 80  00 00 00 00 00 00 09 6f  |m.hata.........o|

000246a0  09 78 66 73 5f 6c 6f 67  2e 68 66 73 5f 64 06 98  |.xfs_log.hfs_d..|

000246b0  00 00 00 00 00 00 09 70  0e 78 66 73 5f 6c 6f 67  |.......p.xfs_log|

000246c0  5f 70 72 69 76 2e 68 6f  0f 78 66 73 5f 64 06 b0  |_priv.ho.xfs_d..|

000246d0  00 00 00 00 00 00 09 71  11 78 66 73 5f 6c 6f 67  |.......q.xfs_log|

000246e0  5f 72 65 63 6f 76 65 72  2e 68 66 73 5f 64 06 d0  |_recover.hfs_d..|

000246f0  00 00 00 00 00 00 09 72  0e 78 66 73 5f 6d 65 74  |.......r.xfs_met|

00024700  61 64 75 6d 70 2e 68 71  0f 78 66 73 5f 64 06 f0  |adump.hq.xfs_d..|

00024710  00 00 00 00 00 00 09 73  0b 78 66 73 5f 6d 6f 75  |.......s.xfs_mou|

00024720  6e 74 2e 68 00 00 07 10  00 00 00 00 00 00 09 74  |nt.h...........t|

00024730  0b 78 66 73 5f 71 75 6f  74 61 2e 68 00 00 07 28  |.xfs_quota.h...(|

00024740  00 00 00 00 00 00 09 75  0d 78 66 73 5f 72 74 61  |.......u.xfs_rta|

00024750  6c 6c 6f 63 2e 68 07 40  00 00 00 00 00 00 09 76  |[email protected]|

00024760  08 78 66 73 5f 73 62 2e  68 5f 6e 6f 64 65 07 58  |.xfs_sb.h_node.X|

00024770  00 00 00 00 00 00 09 77  0b 78 66 73 5f 74 72 61  |.......w.xfs_tra|

00024780  63 65 2e 68 5f 64 07 70  00 00 00 00 00 00 09 78  |ce.h_d.p.......x|

00024790  0b 78 66 73 5f 74 72 61  6e 73 2e 68 00 00 07 88  |.xfs_trans.h....|

000247a0  00 00 00 00 00 00 09 79  11 78 66 73 5f 74 72 61  |.......y.xfs_tra|

000247b0  6e 73 5f 73 70 61 63 65  2e 68 66 73 5f 64 07 a0  |ns_space.hfs_d..|

000247c0  00 00 00 00 00 00 09 7a  0b 78 66 73 5f 74 79 70  |.......z.xfs_typ|

000247d0  65 73 2e 68 5f 64 07 c0  00 00 00 00 00 00 09 7b  |es.h_d.........{|

000247e0  05 78 71 6d 2e 68 07 d8  ff ff 05 98 00 00 09 79  |.xqm.h.........y|

000247f0  0d 78 66 73 5f 64 69 72  32 5f 73 66 2e 6f 00 30  |.xfs_dir2_sf.o.0|

00024800  00 00 00 00 00 00 09 7a  05 78 66 73 2e 68 00 30  |.......z.xfs.h.0|

00024810  00 00 00 00 00 00 09 7b  12 78 66 73 5f 69 61 6c  |.......{.xfs_ial|

00024820  6c 6f 63 5f 62 74 72 65  65 2e 63 00 00 00 08 10  |loc_btree.c.....|

00024830  ff ff 00 40 00 00 09 7c  13 78 66 73 5f 69 61 6c  |...@...|.xfs_ial|

00024840  6c 6f 63 5f 62 74 72 65  65 2e 6c 6f 00 00 08 30  |loc_btree.lo...0|

00024850  ff ff 00 20 00 00 09 7d  12 78 66 73 5f 69 61 6c  |... ...}.xfs_ial|

00024860  6c 6f 63 5f 62 74 72 65  65 2e 6f 00 00 00 00 30  |loc_btree.o....0|

00024870  00 00 00 00 00 00 09 7e  0c 78 66 73 5f 69 61 6c  |.......~.xfs_ial|

00024880  6c 6f 63 2e 63 00 08 70  ff ff 00 30 00 00 09 7f  |loc.c..p...0....|

00024890  0d 78 66 73 5f 69 61 6c  6c 6f 63 2e 6c 6f 08 88  |.xfs_ialloc.lo..|

000248a0  ff ff 00 18 00 00 09 80  0c 78 66 73 5f 69 61 6c  |.........xfs_ial|

000248b0  6c 6f 63 2e 6f 00 00 30  00 00 00 00 00 00 09 81  |loc.o..0........|

000248c0  0b 78 66 73 5f 69 6e 6f  64 65 2e 63 00 00 08 b8  |.xfs_inode.c....|

000248d0  ff ff 00 30 00 00 09 82  0c 78 66 73 5f 69 6e 6f  |...0.....xfs_ino|

000248e0  64 65 2e 6c 6f 00 08 d0  ff ff 00 18 00 00 09 83  |de.lo...........|

000248f0  0b 78 66 73 5f 69 6e 6f  64 65 2e 6f 00 00 00 30  |.xfs_inode.o...0|

00024900  00 00 00 00 00 00 09 84  0b 78 66 73 5f 6d 6f 75  |.........xfs_mou|

00024910  6e 74 2e 63 00 00 09 00  ff ff 00 30 00 00 09 85  |nt.c.......0....|

00024920  0c 78 66 73 5f 6d 6f 75  6e 74 2e 6c 6f 00 09 18  |.xfs_mount.lo...|

00024930  ff ff 00 18 00 00 09 86  0b 78 66 73 5f 6d 6f 75  |.........xfs_mou|

00024940  6e 74 2e 6f 00 00 00 30  00 00 00 00 00 00 09 87  |nt.o...0........|

00024950  0d 78 66 73 5f 72 74 61  6c 6c 6f 63 2e 63 09 48  |.xfs_rtalloc.c.H|

00024960  ff ff 00 38 00 00 09 88  0e 78 66 73 5f 72 74 61  |...8.....xfs_rta|

00024970  6c 6c 6f 63 2e 6c 6f 00  00 00 00 00 00 00 09 60  |lloc.lo........`|

00024980  ff ff 00 18 00 00 09 89  0d 78 66 73 5f 72 74 61  |.........xfs_rta|

00024990  6c 6c 6f 63 2e 6f 00 30  00 00 00 00 00 00 09 8a  |lloc.o.0........|

000249a0  0b 78 66 73 5f 74 72 61  6e 73 2e 63 00 00 09 98  |.xfs_trans.c....|

000249b0  ff ff 06 50 00 00 09 8b  0c 78 66 73 5f 74 72 61  |...P.....xfs_tra|

000249c0  6e 73 2e 6c 6f 00 09 b0  ff ff 00 18 00 00 09 8c  |ns.lo...........|

000249d0  0b 78 66 73 5f 74 72 61  6e 73 2e 6f 00 00 09 b0  |.xfs_trans.o....|

000249e0  00 00 00 00 00 00 09 8d  08 61 74 6f 6d 69 63 2e  |.........atomic.|

000249f0  68 00 00 00 00 00 09 b0  00 00 00 00 00 00 09 8e  |h...............|

00024a00  08 62 69 74 6f 70 73 2e  68 00 00 00 00 00 09 b0  |.bitops.h.......|

00024a10  00 00 00 00 00 00 09 8f  09 62 75 69 6c 64 64 65  |.........buildde|

00024a20  66 73 00 00 00 00 09 b0  00 00 00 00 00 00 09 90  |fs..............|

00024a30  0c 62 75 69 6c 64 64 65  66 73 2e 69 6e 00 09 b0  |.builddefs.in...|

00024a40  00 00 00 00 00 00 09 91  0b 62 75 69 6c 64 6d 61  |.........buildma|

00024a50  63 72 6f 73 00 00 09 b0  00 00 00 00 00 00 09 92  |cros............|

00024a60  0a 62 75 69 6c 64 72 75  6c 65 73 00 00 00 09 b0  |.buildrules.....|

00024a70  00 00 00 00 00 00 09 93  07 63 61 63 68 65 2e 68  |.........cache.h|

00024a80  00 00 00 00 00 00 09 b0  00 00 00 00 00 00 09 94  |................|

00024a90  09 63 6f 6d 6d 61 6e 64  2e 68 00 00 00 00 09 b0  |.command.h......|

00024aa0  00 00 00 00 00 00 09 95  08 64 61 72 77 69 6e 2e  |.........darwin.|

00024ab0  68 00 00 00 00 00 09 b0  00 00 00 00 00 00 09 96  |h...............|

00024ac0  05 64 76 68 2e 68 09 b0  00 00 00 00 00 00 09 97  |.dvh.h..........|

00024ad0  09 66 72 65 65 62 73 64  2e 68 00 00 00 00 09 b0  |.freebsd.h......|

00024ae0  00 00 00 00 00 00 09 98  07 66 73 74 79 70 2e 68  |.........fstyp.h|

00024af0  00 00 00 00 00 00 09 b0  00 00 00 00 00 00 09 99  |................|

00024b00  0d 67 6e 75 6b 66 72 65  65 62 73 64 2e 68 09 b0  |.gnukfreebsd.h..|

00024b10  00 00 00 00 00 00 09 9a  08 68 61 6e 64 6c 65 2e  |.........handle.|

00024b20  68 00 00 00 00 00 09 b0  00 00 00 00 00 00 09 9b  |h...............|

00024b30  07 68 6c 69 73 74 2e 68  00 00 00 00 00 00 09 b0  |.hlist.h........|

00024b40  00 00 00 00 00 00 09 9c  07 69 6e 70 75 74 2e 68  |.........input.h|

00024b50  00 00 00 00 00 00 09 b0  00 00 00 00 00 00 09 9d  |................|

00024b60  0a 69 6e 73 74 61 6c 6c  2d 73 68 00 00 00 09 b0  |.install-sh.....|

00024b70  00 00 00 00 00 00 09 9e  06 69 72 69 78 2e 68 00  |.........irix.h.|

00024b80  00 00 00 00 00 00 09 b0  00 00 00 00 00 00 09 9f  |................|

00024b90  05 6a 64 6d 2e 68 09 b0  00 00 00 00 00 00 1b e4  |.jdm.h..........|

00024ba0  06 6b 6d 65 6d 2e 68 00  00 00 00 00 00 00 09 b0  |.kmem.h.........|

00024bb0  00 00 00 00 00 00 1b e5  08 6c 69 62 78 66 73 2e  |.........libxfs.|

00024bc0  68 00 00 00 00 00 09 b0  00 00 00 00 00 00 1b e8  |h...............|

00024bd0  09 6c 69 62 78 6c 6f 67  2e 68 00 00 00 00 09 b0  |.libxlog.h......|

00024be0  00 00 00 00 00 00 1b ea  07 6c 69 6e 75 78 2e 68  |.........linux.h|

00024bf0  00 00 00 00 00 00 09 b0  00 00 00 00 00 00 1b eb  |................|

00024c00  06 6c 69 73 74 2e 68 00  00 00 00 00 00 00 09 b0  |.list.h.........|

00024c10  00 00 00 00 00 00 1b ec  08 70 61 72 65 6e 74 2e  |.........parent.|

00024c20  68 00 00 00 00 00 09 b0  00 00 00 00 00 00 1b ed  |h...............|

00024c30  06 70 61 74 68 2e 68 02  00 00 17 2e 00 00 09 b0  |.path.h.........|

00024c40  00 00 00 00 00 00 1b ee  0f 70 6c 61 74 66 6f 72  |.........platfor|

00024c50  6d 5f 64 65 66 73 2e 68  12 24 49 bc 00 00 09 b0  |m_defs.h.$I.....|

00024c60  00 00 00 00 00 00 1b ef  12 70 6c 61 74 66 6f 72  |.........platfor|

00024c70  6d 5f 64 65 66 73 2e 68  2e 69 6e f5 00 00 09 b0  |m_defs.h.in.....|

00024c80  00 00 00 00 00 00 1b f4  09 70 72 6f 6a 65 63 74  |.........project|

00024c90  2e 68 11 9c 00 00 09 b0  00 00 00 00 00 00 1b f5  |.h..............|

00024ca0  0c 72 61 64 69 78 2d 74  72 65 65 2e 68 00 09 b0  |.radix-tree.h...|

00024cb0  00 00 00 00 00 00 1b fe  06 73 77 61 62 2e 68 7e  |.........swab.h~|

00024cc0  28 7b e8 5c 00 00 09 b0  00 00 00 00 00 00 1b ff  |({.\............|

00024cd0  08 76 6f 6c 75 6d 65 2e  68 62 be 23 00 00 09 b0  |.volume.hb.#....|

00024ce0  00 00 00 00 00 00 1c 00  08 78 66 73 5f 61 67 2e  |.........xfs_ag.|

00024cf0  68 5f 10 78 00 00 09 b0  00 00 00 00 00 00 1c 02  |h_.x............|

00024d00  11 78 66 73 5f 61 6c 6c  6f 63 5f 62 74 72 65 65  |.xfs_alloc_btree|

00024d10  2e 68 11 ff 00 00 09 b0  00 00 00 00 00 00 1c 03  |.h..............|

00024d20  0b 78 66 73 5f 61 6c 6c  6f 63 2e 68 00 00 09 b0  |.xfs_alloc.h....|

00024d30  00 00 00 00 00 00 1c 06  0a 78 66 73 5f 61 72 63  |.........xfs_arc|

00024d40  68 2e 68 66 00 00 09 b0  00 00 00 00 00 00 1c 07  |h.hf............|

00024d50  0f 78 66 73 5f 61 74 74  72 5f 6c 65 61 66 2e 68  |.xfs_attr_leaf.h|

00024d60  41 fa 76 2f 00 00 09 b0  00 00 00 00 00 00 1c 08  |A.v/............|

00024d70  0d 78 66 73 5f 61 74 74  72 5f 73 66 2e 68 07 e8  |.xfs_attr_sf.h..|

00024d80  00 00 00 2e 00 00 00 02  00 00 17 2e 00 00 00 04  |................|

00024d90  07 52 b7 c8 00 00 00 59  07 90 d5 82 00 00 00 8a  |.R.....Y........|

00024da0  0e bc b0 1f 00 00 00 32  12 24 49 b7 00 00 00 c6  |.......2.$I.....|

00024db0  18 1c 98 12 00 00 00 7a  1d 26 82 12 00 00 00 af  |.......z.&......|

00024dc0  1e 9a 14 ee 00 00 00 52  1f e7 11 97 00 00 00 76  |.......R.......v|

00024dd0  21 bf 29 44 00 00 00 b6  23 5f e9 a7 00 00 00 99  |!.)D....#_......|

00024de0  23 6c aa d2 00 00 00 35  2c 98 a8 3e 00 00 00 5d  |#l.....5,..>...]|

00024df0  2d 3e 14 27 00 00 00 38  2e 62 be 24 00 00 00 e2  |->.'...8.b.$....|

00024e00  2e 72 d4 15 00 00 00 0c  31 63 8a 36 00 00 00 6c  |.r......1c.6...l|

00024e10  35 8d e2 0b 00 00 00 cc  38 9d 8c e1 00 00 00 e8  |5.......8.......|

00024e20  39 c7 d0 c9 00 00 00 ab  3a 98 56 e1 00 00 00 b9  |9.......:.V.....|

00024e30  3d 18 d8 66 00 00 00 18  41 fa 76 24 00 00 00 80  |=..f....A.v$....|

00024e40  45 47 b8 bd 00 00 00 60  48 9c 80 46 00 00 00 23  |EG.....`H..F...#|

00024e50  4a 9d 68 5b 00 00 00 73  4d 48 d0 1e 00 00 00 2c  |J.h[...sMH.....,|

00024e60  4e da 17 6e 00 00 00 21  4f 3d 8c f7 00 00 00 26  |N..n...!O=.....&|

00024e70  53 39 37 ec 00 00 00 9c  55 f0 d9 96 00 00 00 7d  |S97.....U......}|

00024e80  5b 68 81 e5 00 00 00 15  5c 41 f1 3b 00 00 00 4c  |[h......\A.;...L|

00024e90  5d 3c 90 fe 00 00 00 4f  5d 54 e8 0f 00 00 00 66  |]<.....O]T.....f|

00024ea0  5f 06 c2 fc 00 00 00 87  5f 86 5a 6c 00 00 00 96  |_......._.Zl....|

00024eb0  60 c2 2c 36 00 00 00 da  6e 63 1a cd 00 00 00 f1  |`.,6....nc......|

00024ec0  6f c6 9a cd 00 00 00 ee  7c 38 94 f7 00 00 00 63  |o.......|8.....c|

00024ed0  7d f2 10 ff 00 00 00 1e  7e 06 a0 06 00 00 00 1b  |}.......~.......|

00024ee0  7e 3b e7 ba 00 00 00 de  7f 03 1a 94 00 00 00 f8  |~;..............|

00024ef0  82 ae 7a b4 00 00 00 0f  84 9c 9f 1a 00 00 00 d6  |..z.............|

00024f00  88 5c 28 1a 00 00 00 d0  8b 68 ab 3e 00 00 00 92  |.\(......h.>....|

00024f10  8c 05 70 7f 00 00 00 40  8c dc d7 6f 00 00 00 c0  |[email protected]....|

00024f20  8d 27 8e f5 00 00 00 e5  8e 3b 57 6f 00 00 00 fb  |.'.......;Wo....|

00024f30  8f 26 ee 2d 00 00 00 c9  90 f0 0d 57 00 00 00 f4  |.&.-.......W....|

00024f40  99 67 10 d9 00 00 00 a7  9e 7c b4 0e 00 00 00 2f  |.g.......|...../|

00024f50  9e 7d 14 0e 00 00 00 49  a1 2a 5c ae 00 00 00 43  |.}.....I.*\....C|

00024f60  ac 9b 57 6e 00 00 00 3b  b5 34 19 96 00 00 00 d3  |..Wn...;.4......|

00024f70  ba db 68 42 00 00 00 84  bd 7d a0 87 00 00 00 c2  |..hB.....}......|

00024f80  be 47 4e 3d 00 00 00 70  c8 19 30 3a 00 00 00 55  |.GN=...p..0:...U|

00024f90  ce e1 5d 33 00 00 00 29  db c6 d0 99 00 00 00 a0  |..]3...)........|

00024fa0  dc bb 54 36 00 00 00 3d  dd fb 04 16 00 00 00 06  |..T6...=........|

00024fb0  ee bf a4 26 00 00 00 46  f3 b2 9f ff 00 00 00 b2  |...&...F........|

00024fc0  f5 a5 3c 27 00 00 00 12  f8 ab e8 72 00 00 00 a4  |..<'.......r....|

00024fd0  fc 2d 4c f5 00 00 00 bd  fc c8 4c f5 00 00 00 69  |.-L.......L....i|

00024fe0  fe 89 0c f5 00 00 00 eb  fe d9 70 ce 00 00 00 09  |..........p.....|

00024ff0  ff 18 5f d5 00 00 00 8e  00 00 00 4f 00 00 00 00  |.._........O....|

00025000

[root@localhost loop]#

“directory block”块结构比较复杂,相关的结构体就有好几个:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

/*

 * Generic single-block structure, for xfs_db.

 */

typedef struct xfs_dir2_block {

    xfs_dir2_data_hdr_t hdr;        /* magic XFS_DIR2_BLOCK_MAGIC */

    xfs_dir2_data_union_t   u[1];

    xfs_dir2_leaf_entry_t   leaf[1];

    xfs_dir2_block_tail_t   tail;

} xfs_dir2_block_t;

/*

 * Header for the data blocks.

 * Always at the beginning of a directory-sized block.

 * The code knows that XFS_DIR2_DATA_FD_COUNT is 3.

 */

typedef struct xfs_dir2_data_hdr {

    __be32          magic;      /* XFS_DIR2_DATA_MAGIC */

                        /* or XFS_DIR2_BLOCK_MAGIC */

    xfs_dir2_data_free_t    bestfree[XFS_DIR2_DATA_FD_COUNT];

} xfs_dir2_data_hdr_t;

#define XFS_DIR2_DATA_FD_COUNT  3

/*

 * Describe a free area in the data block.

 * The freespace will be formatted as a xfs_dir2_data_unused_t.

 */

typedef struct xfs_dir2_data_free {

    __be16          offset;     /* start of freespace */

    __be16          length;     /* length of freespace */

} xfs_dir2_data_free_t;

typedef union {

    xfs_dir2_data_entry_t   entry;

    xfs_dir2_data_unused_t  unused;

} xfs_dir2_data_union_t;

/*

 * Active entry in a data block.  Aligned to 8 bytes.

 * Tag appears as the last 2 bytes.

 */

typedef struct xfs_dir2_data_entry {

    __be64          inumber;    /* inode number */

    __u8            namelen;    /* name length */

    __u8            name[1];    /* name bytes, no null */

                        /* variable offset */

    __be16          tag;        /* starting offset of us */

} xfs_dir2_data_entry_t;

/*

 * Unused entry in a data block.  Aligned to 8 bytes.

 * Tag appears as the last 2 bytes.

 */

typedef struct xfs_dir2_data_unused {

    __be16          freetag;    /* XFS_DIR2_DATA_FREE_TAG */

    __be16          length;     /* total free length */

                        /* variable offset */

    __be16          tag;        /* starting offset of us */

} xfs_dir2_data_unused_t;

/*

 * Leaf block entry.

 */

typedef struct xfs_dir2_leaf_entry {

    __be32          hashval;    /* hash value of name */

    __be32          address;    /* address of data entry */

} xfs_dir2_leaf_entry_t;

typedef struct xfs_dir2_block_tail {

    __be32      count;          /* count of leaf entries */

    __be32      stale;          /* count of stale lf entries */

} xfs_dir2_block_tail_t;

一块“directory block”的结构示意图如下所示:

Xfs文件系统磁盘布局_第15张图片
1,同样先是四字节的magic魔术数,0x58443242 “XD2B”,
2,接下来是长度为3的xfs_dir2_data_free_t数组变量bestfree,这个变量的每个元素记录了本“directory block”内空闲的磁盘块,因为只有三个元素所以只能记录三个空闲块,但这三个都是空闲容量按从大到小排列为前三的。如果空闲块少于三个,那么后面的数组元素就会为空,比如一开始时,还没有形成空洞,那么此时空闲块就只有一个,那么此时数组第1和第2元素为0,如前面实例所示;当用户进行了子文件删除等操作,这样就会释放一些entry形成空闲块,此时数组第1和第2元素才会有记录。记录的信息主要是:offset为空闲块的起始地址(相对比本“directory block”偏移),length为空闲块的长度。
3,空闲块以一个xfs_dir2_data_unused_t结构体变量作为头信息,这个头信息里的freetag恒为0xffff,length为本空闲块的长度,tag记录空闲块的起始地址(相对比本“directory block”偏移)。
4,紧接在数组变量bestfree之后就是存放子文件信息的地方,子文件信息由结构体xfs_dir2_data_entry_t表示,几个字段的含义也比较明显,其中tag表示本xfs_dir2_data_entry_t变量元素的起始地址(相对比本“directory block”偏移),该地址会按8 (XFS_DIR2_DATA_ALIGN)字节对齐。
5,在“directory block”的最后存放着xfs_dir2_block_tail_t结构体对应变量的值,两个字段,占用8个字节,分别为count和stale,其中count记录leaf元素的总数,而stale记录已失效的leaf元素个数,也即是,假设一开始有128个子文件,删除3个后,那么此时count=128,stale=3。
6,紧跟着xfs_dir2_block_tail_t结构体对应变量之前就是第5点中提到的leaf数组,这个数组的增长是从“directory block”末尾反向向前增长的,每个数组元素记录一个子文件的hash值与存放的起始地址(需要乘以8(XFS_DIR2_DATA_ALIGN)),整个数组按hash进行了排序,这样便于进一步快速查找。

当仅一块“directory block”无法存放和组织所有的子文件相关信息时,此时就需要更多块的“directory block”,这些“directory block”块信息仍以数组的形式组织起来存放在inode的data fork里,不过和只有一块“directory block”时稍有不同,将会把xfs_dir2_data_union_t和xfs_dir2_leaf_entry_t拆开放在不同的“directory block”内。leaf信息固定放在一个“directory block”内,因为一个leaf可以对应更多的data数据,所以可以有多个“directory block”存放data数据:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

[root@localhost loop]# /home/lenky/xfs/xfsprogs/db/xfs_db /dev/loop0

xfs_db> inode 137

xfs_db> p

core.magic = 0x494e

core.mode = 040755

core.version = 1

core.format = 2 (extents)

...

core.size = 8192

core.nblocks = 3

core.extsize = 0

core.nextents = 3

core.naextents = 0

...

next_unlinked = null

u.bmx[0-2] = [startoff,startblock,blockcount,extentflag] 0:[0,36,1,0] 1:[1,136,1,0] 2:[8388608,135,1,0]

xfs_db>

Xfs文件系统磁盘布局_第16张图片


前di_nextents-1个“directory block”用来存放data,而最后一个“directory block”存放leaf。如上图所示,阴影部分的extent元素即用于指示对应的leaf“directory block”,并且它有一个特定的offset值XFS_DIR2_LEAF_OFFSET,默认情况下数值为0x800000(十进制为8388608)。
上面示例中,data“directory block”在36和136逻辑block块上,而leaf“directory block”存放在135逻辑block块上。
相比上一篇文章里描述的“directory block”的结构示意图,这里由于把leaf信息单独出去了,所以磁盘布局里少了最后的与leaf相关的xfs_dir2_leaf_entry_t和xfs_dir2_block_tail_t,对应的结构体定义为(其中结构体xfs_dir2_block为上一篇提到的):

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

/*

 * Generic data block structure, for xfs_db.

 */

typedef struct xfs_dir2_data {

    xfs_dir2_data_hdr_t hdr;        /* magic XFS_DIR2_DATA_MAGIC */

    xfs_dir2_data_union_t   u[1];

} xfs_dir2_data_t;

/*

 * Generic single-block structure, for xfs_db.

 */

typedef struct xfs_dir2_block {

    xfs_dir2_data_hdr_t hdr;        /* magic XFS_DIR2_BLOCK_MAGIC */

    xfs_dir2_data_union_t   u[1];

    xfs_dir2_leaf_entry_t   leaf[1];

    xfs_dir2_block_tail_t   tail;

} xfs_dir2_block_t;

结构体示意图为(注意magic魔术数已经变成了0x58443244 “XD2D”):

Xfs文件系统磁盘布局_第17张图片

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

[root@localhost loop]# /home/lenky/xfs/xfsprogs/db/xfs_db /dev/loop0

xfs_db> fsblock 36

xfs_db> type dir2

xfs_db> p

dhdr.magic = 0x58443244

dhdr.bestfree[0].offset = 0

dhdr.bestfree[0].length = 0

dhdr.bestfree[1].offset = 0

dhdr.bestfree[1].length = 0

dhdr.bestfree[2].offset = 0

dhdr.bestfree[2].length = 0

du[0].inumber = 137

du[0].namelen = 1

du[0].name = "."

du[0].tag = 0x10

du[1].inumber = 128

du[1].namelen = 2

du[1].name = ".."

du[1].tag = 0x20

du[2].inumber = 143

du[2].namelen = 9

du[2].name = "ld-2.5.so"

du[2].tag = 0x30

du[3].inumber = 166

du[3].namelen = 20

du[3].name = "ld-linux-x86-64.so.2"

du[3].tag = 0x48

...

du[129].inumber = 7170

du[129].namelen = 17

du[129].name = "libpthread-2.5.so"

du[129].tag = 0xfc0

du[130].inumber = 7171

du[130].namelen = 15

du[130].name = "libpthread.so.0"

du[130].tag = 0xfe0

xfs_db> fsblock 136

xfs_db> type dir2

xfs_db> p

dhdr.magic = 0x58443244

dhdr.bestfree[0].offset = 0x330

dhdr.bestfree[0].length = 0xcd0

dhdr.bestfree[1].offset = 0

dhdr.bestfree[1].length = 0

dhdr.bestfree[2].offset = 0

dhdr.bestfree[2].length = 0

du[0].inumber = 7174

du[0].namelen = 16

du[0].name = "libresolv-2.5.so"

du[0].tag = 0x10

...

du[27].freetag = 0xffff

du[27].length = 0xcd0

du[27].tag = 0x330

xfs_db>

块36已经没有空闲区域了,所以bestfree元素全为0,而块136有一个空闲区域。
leaf“directory block”的布局采用同样的结构,没什么好多讲的,直接看图:

Xfs文件系统磁盘布局_第18张图片
bests元素内记录的是对应data“directory block”的bestfree[0].length的值。相关结构体定义如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

/*

 * Leaf block.

 * bests and tail are at the end of the block for single-leaf only

 * (magic = XFS_DIR2_LEAF1_MAGIC not XFS_DIR2_LEAFN_MAGIC).

 */

typedef struct xfs_dir2_leaf {

    xfs_dir2_leaf_hdr_t hdr;        /* leaf header */

    xfs_dir2_leaf_entry_t   ents[1];    /* entries */

                        /* ... */

    xfs_dir2_data_off_t bests[1];   /* best free counts */

    xfs_dir2_leaf_tail_t    tail;       /* leaf tail */

} xfs_dir2_leaf_t;

/*

 * Leaf block header.

 */

typedef struct xfs_dir2_leaf_hdr {

    xfs_da_blkinfo_t    info;       /* header for da routines */

    __be16          count;      /* count of entries */

    __be16          stale;      /* count of stale entries */

} xfs_dir2_leaf_hdr_t;

typedef struct xfs_da_blkinfo {

    __be32      forw;           /* previous block in list */

    __be32      back;           /* following block in list */

    __be16      magic;          /* validity check on block */

    __be16      pad;            /* unused */

} xfs_da_blkinfo_t;

/*

 * Leaf block entry.

 */

typedef struct xfs_dir2_leaf_entry {

    __be32          hashval;    /* hash value of name */

    __be32          address;    /* address of data entry */

} xfs_dir2_leaf_entry_t;

typedef __uint16_t  xfs_dir2_data_off_t;

/*

 * Leaf block tail.

 */

typedef struct xfs_dir2_leaf_tail {

    __be32          bestcount;

} xfs_dir2_leaf_tail_t;

实例:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

xfs_db> fsblock 135

xfs_db> type dir2

xfs_db> p

lhdr.info.forw = 0

lhdr.info.back = 0

lhdr.info.magic = 0xd2f1

lhdr.count = 158

lhdr.stale = 0

lbests[0-1] = 0:0 1:0xcd0

lents[0].hashval = 0x2e

lents[0].address = 0x2

lents[1].hashval = 0x172e

lents[1].address = 0x4

...

lents[157].hashval = 0xff1fa804

lents[157].address = 0x19f

ltail.bestcount = 2

xfs_db> q

[root@localhost loop]# hexdump -C -s 552960 -n 4096 /dev/loop0

00087000  00 00 00 00 00 00 00 00  d2 f1 00 01 00 9e 00 00  |................|

00087010  00 00 00 2e 00 00 00 02  00 00 17 2e 00 00 00 04  |................|

00087020  01 f1 d6 8c 00 00 00 92  04 6d 17 49 00 00 00 52  |.........m.I...R|

00087030  04 71 17 49 00 00 01 83  04 c8 21 b2 00 00 01 07  |.q.I......!.....|

00087040  08 10 1d 51 00 00 01 8f  09 b3 1a 2c 00 00 01 45  |...Q.......,...E|

00087050  0b 0c 8d 3b 00 00 00 d0  0b 71 90 18 00 00 01 2a  |...;.....q.....*|

00087060  0c 14 03 76 00 00 01 7f  0c 64 60 4f 00 00 02 5a  |...v.....d`O...Z|

00087070  0c 9a 4b 6e 00 00 01 e6  0c 9c 03 60 00 00 02 23  |..Kn.......`...#|

00087080  0c a6 03 67 00 00 01 8c  0c b1 07 84 00 00 00 f8  |...g............|

...

00087f20  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 01  |................|

00087f30  97 43 62 5e c4 61 46 81  98 08 0b e5 9b 5c a6 45  |.Cb^.aF......\.E|

00087f40  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00087ff0  00 00 00 00 00 00 00 00  00 00 0c d0 00 00 00 02  |................|

00088000

[root@localhost loop]#

十二,总结

关于Xfs文件系统磁盘布局结构的分析到此就算结束,经过一段时间的分析,Xfs在这方面主要设计基本已经了解,后面还有的磁盘布局,包括软链接、扩展属性等与前面的这些内容存放方式与布局并无多大差别,所以不准备继续写下去了,自己看一下即可。所有的文章内容主要依靠官方文档与实验简单验证而没有分析到具体的代码,所以很多细节可能被漏过,甚至还包含有错误,后续若看到后再进行文章修订。

后续仍会继续关注Xfs文件系统,当然,不再是磁盘布局这么基础的内容,而是会从它的一些特性上去去分析它是怎么设计的、代码怎么实现的、是否存在问题和是否可有改进等。

Xfs文件系统磁盘布局_第19张图片

你可能感兴趣的:(Linux文件系统,linux,xfs,文件系统)