xfs_logprint prints the log of a XFS file system. The basic Syntzx is:

xfs_logprint [option] device

The device argument is the pathname of the partition or logical volume containing the filesystem. The device can be a regular file if the "-f" option is used. The contents of the file system remain undisturbed.

There are two major modes of operation in xfs_logprint, transactional view and log record view, below are some xfs_logprint command examples:

Transactional view

One mode is better for filesystem operation debugging. It is called the transactional view and is enabled through the "-t" option. The transactional view prints only the portion of the log that pertains to recovery. In other words, it prints out complete transactions between the tail and the head. This view tries to display each transaction without regard to how they are split across log records.

Here are some examples:

Optione '-t', print out transactional view of an xfs log

# xfs_logprint -t /dev/mapper/SATA_A3_LUN22
xfs_logprint: /dev/mapper/SATA_A3_LUN22 contains a mounted and writable filesystem
xfs_logprint:
    data device: 0xfd0b
    log device: 0xfd0b daddr: 25769803712 length: 4173824

    log tail: 1873172 head: 1873190 state: <DIRTY>

LOG REC AT LSN cycle 9 block 1873172 (0x9, 0x1c9514)
============================================================================
TRANS: tid:0x68d37d56  type:SWAPEXT  #items:35  trans:0x68d37d56  q:0xa5b9d0
INO: cnt:2 total:2 a:0xa63e10 len:56 a:0xa4a220 len:96
    INODE: #regs:2   ino:0x244  flags:0x1   dsize:0
    CORE inode:
INO: cnt:3 total:3 a:0xa5bc10 len:56 a:0xa5bcc0 len:96 a:0xa5bd30 len:32
    INODE: #regs:3   ino:0x23e  flags:0x3   dsize:32
    CORE inode:
        DATA FORK LOCAL inode data:
INO: cnt:2 total:2 a:0xa5bd60 len:56 a:0xa63e50 len:96
    INODE: #regs:2   ino:0x256  flags:0x1   dsize:0
    CORE inode:
BUF: cnt:4 total:4 a:0xa63fd0 len:24 a:0xa64070 len:128 a:0xa64100 len:128 a:0xa64190 len:256
    BUF:  #regs:4   start blkno:0x130   len:8   bmap size:1   flags:0x5000
    BUF DATA
    BUF DATA
    ...

Option '-i', extract and print inode info

# xfs_logprint -t -i /dev/mapper/SATA_A3_LUN22 | more
xfs_logprint: /dev/mapper/SATA_A3_LUN22 contains a mounted and writable filesystem
xfs_logprint:
    data device: 0xfd0b
    log device: 0xfd0b daddr: 25769803712 length: 4173824

    log tail: 1873172 head: 1873190 state: <DIRTY>

LOG REC AT LSN cycle 9 block 1873172 (0x9, 0x1c9514)
============================================================================
TRANS: tid:0x68d37d56  type:SWAPEXT  #items:35  trans:0x68d37d56  q:0xad29d0
INO: cnt:2 total:2 a:0xadae10 len:56 a:0xac1220 len:96
    INODE: #regs:2   ino:0x244  flags:0x1   dsize:0
    CORE inode:
        magic:IN  mode:0x81a4  ver:2  format:2  onlink:0
        uid:0  gid:0  nlink:1 projid:0
        atime:1507873230  mtime:1507873230  ctime:1507873230
        flushiter:54130
        size:0x0  nblks:0x0  exsize:0  nextents:0  anextents:0
        forkoff:0  dmevmask:0x0  dmstate:0  flags:0x0  gen:1739766111
...

Option '-q', extract and print quota info

# xfs_logprint -t -q /dev/mapper/SATA_A3_LUN22 | more
xfs_logprint: /dev/mapper/SATA_A3_LUN22 contains a mounted and writable filesystem
xfs_logprint:
    data device: 0xfd0b
    log device: 0xfd0b daddr: 25769803712 length: 4173824

    log tail: 1873172 head: 1873190 state: <DIRTY>

LOG REC AT LSN cycle 9 block 1873172 (0x9, 0x1c9514)
============================================================================
TRANS: tid:0x68d37d56  type:SWAPEXT  #items:35  trans:0x68d37d56  q:0x124c9d0
INO: cnt:2 total:2 a:0x1254e10 len:56 a:0x123b220 len:96
    INODE: #regs:2   ino:0x244  flags:0x1   dsize:0
    CORE inode:
INO: cnt:3 total:3 a:0x124cc10 len:56 a:0x124ccc0 len:96 a:0x124cd30 len:32
    INODE: #regs:3   ino:0x23e  flags:0x3   dsize:32
    CORE inode:
        DATA FORK LOCAL inode data:
...

Log record view

The second mode starts printing out information from the beginning of the log. Some error blocks might print out in the beginning because the last log record usually overlaps the oldest log record. A message is printed when the physical end of the log is reached and when the logical end of the log is reached. A log record view is displayed one record at a time. Transactions that span log records may not be decoded fully.

Here are some examples:

Option '-C', Copy the log from the filesystem to the filename, no printing

# xfs_logprint -C sata_a3_lun22.log /dev/mapper/SATA_A3_LUN22 
xfs_logprint:
xfs_logprint: /dev/mapper/SATA_A3_LUN22 contains a mounted and writable filesystem
    data device: 0xfd0b
    log device: 0xfd0b daddr: 25769803712 length: 4173824

# ls -l sata_a3_lun22.log
-rw-r--r-- 1 root root 2136997888 Oct 12 23:07 sata_a3_lun22.log

Option '-d' Dump the log from front to end

It prints where each log record is located on disk

# xfs_logprint -d /dev/mapper/SATA_A3_LUN22 | more
xfs_logprint: /dev/mapper/SATA_A3_LUN22 contains a mounted and writable filesystem
xfs_logprint:
    data device: 0xfd0b
    log device: 0xfd0b daddr: 25769803712 length: 4173824

[00000 - 00000] Cycle 0xffffffff New Cycle 0x00000009
     6 HEADER Cycle 9 tail 8:4173821 len   4096 ops 38
    15 HEADER Cycle 9 tail 9:000006 len   2048 ops 20
    20 HEADER Cycle 9 tail 9:000015 len   3072 ops 25
    27 HEADER Cycle 9 tail 9:000020 len   2048 ops 20
    32 HEADER Cycle 9 tail 9:000027 len   3072 ops 25
    39 HEADER Cycle 9 tail 9:000032 len   2048 ops 20
...

There are other options that can be used for both modes:

Option '-V', prints out xfs_logprint version

xfs_logprint -V
xfs_logprint version 4.5.0

Option '-e', exit when an error is found in the log

xfs_logprint -e /dev/mapper/SATA_A3_LUN22

Option 'c', Attempt to continue when an error is detected

xfs_logprint -c /dev/mapper/SATA_A3_LUN22

Option '-f',specify a file system image

xfs_logprint -f /home/lun22.img

Option '-l', specify the external log device

xfs_logprint -l /dev/mapper/sata_a3_log  /dev/mapper/SATA_A3_LUN22

Options that can be passed:


       -b     Extract and print buffer information. Only used in transactional
              view.

       -c     Attempt to continue when an error is detected.

       -C filename
              Copy  the log from the filesystem to the file filename.  The log
              itself is not printed.

       -d     Dump the log from front to end, printing where each  log  record
              is located on disk.

       -D     Do not decode anything; just print data.

       -e     Exit  when  an error is found in the log. Normally, xfs_logprint
              tries to continue and unwind from bad logs.  However,  sometimes
              it  just  dies  in  bad  ways.   Using this option prevents core
              dumps.
       
       -f     Specifies that the filesystem image to be processed is stored in
              a  regular  file at device (see the mkfs.xfs(8) -d file option).
              This might happen if an image copy of a filesystem has been made
              into an ordinary file with xfs_copy(8).

       -l logdev
              External  log  device.  Only  for those filesystems which use an
              external log.

       -i     Extract and print inode information. Only used in  transactional
              view.

       -q     Extract  and print quota information. Only used in transactional
              view.

       -n     Do not try and interpret log data;  just  interpret  log  header
              information.

       -o     Also  print  buffer  data in hex.  Normally, buffer data is just
              decoded, so better information can be printed.
       -s start-block
              Override any notion of where to start printing.

       -t     Print out the transactional view.

       -v     Print "overwrite" data.

       -V     Prints the version number and exits.