Product SiteDocumentation Site

4.2.4. Exercise 4 – ondisk EA’s in different formats

  1. Recreate the filesystem
    # cd /
    # umount $SCRATCH_MNT
    # mkfs.xfs -f $SCRATCH_DEV
    # mount $SCRATCH_DEV $SCRATCH_MNT
    
  2. Add an attribute to a file
    # cd $SCRATCH_MNT
    # echo data1>file1
    # setfattr -n user.name1 -v value1 file1
    # getfattr -d file1
    
  3. Examine the inode’s format to see it is in short-form with a fork offset of 120 bytes:
    # ls –i file1
    # cd /
    # umount $SCRATCH_MNT
    # xfs_db -r -c "inode inode_number" -c "p a" -c "p core.forkoff" -c "p core.aformat" $SCRATCH_DEV
    
  4. A another EA, name2, but this time with a big value of 60K.
    # cd $SCRATCH_MNT
    # man bash | strings | dd bs=1024 count=60 of=file2
    # ls -s file2
    61440 file2
    # attr -s name2 file1 < file2 >/ dev/null
    
  5. Dump the inode and explore its structure
    # ls –i file1
    # cd /
    # umount $SCRATCH_MNT
    # xfs_ncheck $SCRATCH_DEV
    # xfs_db -r $SCRATCH_DEV
    xfs_db> inode inode_number
    xfs_db> p
    
    The EA is quite large and will not fit within the inode, instead it is in its own set of blocks
    a.bmx[0] = [startoff,startblock,blockcount,extentflag] 0:[0,28,16,0]
    
  6. The first block at 28 contains the main EA information and the remaining 15 blocks (15 * 4K = 60K) starting from block 29 contain the value for name2, in this case the bash(1) man page.
    	xfs_db> fsb 28
    xfs_db> type attr
    xfs_db> p
    xfs_db> fsb 29
    xfs_db> type text
    xfs_db> p
    
  7. Now add 1000 attributes to the file:
    # for i in {1..1000}
    > do
    > attr -s name.$i -V value.$i file1
    > done
    # cd /
    # umount /mnt/scratch
    # xfs_db -r $SCRATCH_DEV
    
    This time we now have the EA in btree form with the root within the inode and the actual EA data in the leaf blocks of the btree, similar to:
    btree[0-11] = [hashval,before] 0:[0x55101e5a,16] 1:[0x55105dd8,24] 2:[0x55109c5b,25] 3:[0x55109fde,23] 4:[0x5510dfde,21] 5:[0x55111ed7,22] 6:[0x55115ed7,19] 7:[0x5511dd5a,20] 8:[0x55139d5a,18] 9:[0x5513dd5a,26] 10:[0xdcaa20bd,27] 11:[0xec3b72b4,17]
    
  8. Examine one of the leafblocks (in this example block16):
    xfs_db> ablock 16
    xfs_db> p