Hacks of xfs file system Part — 2

Case 6 : Allocation in xfs file system. I have create new file system on top of one partition. This file system has count of 4 for AGs each agsize is 32768 blocks.

Mounted that file system on /mnt and created three directories inside it.

[root@localhost ~]# cd /mnt/
[root@localhost mnt]# mkdir a b c
[root@localhost mnt]# ls -i
131 a   524416 b  1116960 c

If you see the inode number of directories you will see huge difference between them even when we have created all of them in single command. Because by default xfs will try to put the directories in different Allocation groups.

Now if we are going to create the files inside the directory they will be having contiguous inode number.

Created two files inside directory a. Directory was having 131 number and files are having 132 and 133 allocation. This is to reduce the access time for these files.

[root@localhost mnt]# ls -iR
.:
131 a   524416 b  1116960 c

./a:
132 test1  133 test2

./b:

./c:

Case 7 : As we know that now a days all filesystems possess the extent based allocation same goes for xfs as well.

I am creating file of 200MB in directory a.

[root@localhost mnt]# dd if=/dev/zero of=/mnt/a/testfile1 bs=1M count=200
200+0 records in
200+0 records out
209715200 bytes (210 MB) copied, 0.368653 s, 569 MB/s

Now check the AG from which the blocks are allocate for this newly created file.

[root@localhost mnt]# xfs_bmap -v a/*
a/test1: no extents
a/test2: no extents
a/testfile1:
EXT: FILE-OFFSET       BLOCK-RANGE      AG AG-OFFSET         TOTAL
0: [0..262039]:      96..262135        0 (96..262135)     262040
1: [262040..409599]: 262240..409799    1 (96..147655)     147560

Total blocks used are 409600 which is equivalent to 200MB.

Case 8 : How to determine the name of file from inode.

[root@localhost ~]# xfs_ncheck -i 132 /dev/sdg2
132 a/test1

Case 9 : Now to gather all deep relevant information related to file system we need to unmount the file system go to xfs debug mode.

[root@localhost ~]# umount /mnt/
[root@localhost ~]# xfs_db -x /dev/sdg2
xfs_db>

To print the superblock information. Some outputs are truncated.

xfs_db> sb
xfs_db> p
magicnum = 0x58465342
blocksize = 4096

To print particular inode information.

xfs_db> inode 132
xfs_db> p
core.magic = 0x494e
core.mode = 0100644
core.version = 2
core.format = 2 (extents)

To print in text form.

[root@localhost ~]# xfs_db -x /dev/sdg2
xfs_db> inode 133
xfs_db> type text
xfs_db> print
00:  49 4e 81 a4 02 02 00 00 00 00 00 00 00 00 00 00  IN…………..
10:  00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01  …………….
20:  54 70 b8 f3 04 c9 19 18 54 70 b8 f3 04 c9 19 18  Tp……Tp……
30:  54 70 b8 f3 04 c9 19 18 00 00 00 00 00 00 00 00  Tp…………..
40:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  …………….

To print the particular block information.

xfs_db> fsblock 97
xfs_db> type bmapbtd
xfs_db> print
magic = 0
level = 0
numrecs = 0
leftsib = 0
rightsib = 0

To check the fragmentation factor.

xfs_db> frag -d
actual 0, ideal 0, fragmentation factor 0.00%
xfs_db> frag -f
actual 5, ideal 2, fragmentation factor 60.00%

Here value can be misleading somtimes.  Showing high value may be due to extent based files which are present in the file system. Let me remove those files and will issue the commands again.

I have removed the files and it came down to 0.

xfs_db> frag -f
actual 0, ideal 0, fragmentation factor 0.00%
xfs_db> frag -d
actual 0, ideal 0, fragmentation factor 0.00%

There are lot of other command which can be issued with xfs_db for troubleshooting.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s