Setting-Up a DAX-Capable File System

Learn how to create and mount a DAX-capable file system.

The XFS file system features DAX-capable mounts. Ensure that XFS creates mappings from the physical pages in the PMEM device to virtual pages using HugePages mappings.

XFS allows you to specify the minimum contiguous unit size and the minimum number of contiguous units in a stripe. These specifications are known as stripe unit and stripe width. The stripe unit and stripe width may be used to ensure HugePages mappings.

  1. Format the device by specifying the stripe unit size (su) as 2 MB and stripe width size (sw) as 1.
    # mkfs.xfs -f -d su=2m,sw=1 /dev/pmem0
    ...
    ...
    data     = bsize=4096 blocks=777240064, imaxpct=5
             = sunit=512 swidth=512 blks
    naming   =version 2 bsize=4096 ascii-ci=0 ftype=1
    log      =internal log bsize=4096 blocks=379511, version=2
             = sectsz=4096 sunit=1 blks, lazy-count=1
    realtime =none

    In this example, the data section of the output has bsize=4096. So, the data block size for this file system is 4096 bytes. The sunit=512 and the swidth=512 blks. This implies that the stripe unit is 512*4096 bytes = 2 MB and the stripe width is 512*4096 bytes = 2 MB. A single stripe of this file system is composed of a single stripe unit (512 blocks / 512 blocks per unit).

    A minimum contiguous allocation of 2 MB or contiguous allocations in exact multiples of 2 MB is enforced for data to enable the address space to be represented with HugePages mappings and to bypass the page cache.

  2. Mount the device using the dax option.
    # mount -o dax /dev/pmem0 /mnt/pmem0
  3. Verify if the file system is mounted with the dax option.
    # mount|grep dax
    /dev/pmem0 on /mnt/pmem0 type xfs
    (rw,relatime,attr2,dax,inode64,sunit=4096,swidth=4096,noquota)
    

    In this example, the sunit and swidth from the mount are in 512-byte blocks.

  4. Format the /dev/pmem1 device and mount and verify the dax option in the mount point.
    # mkfs.xfs -f -d su=2m,sw=1 /dev/pmem1
    # mount -o dax /dev/pmem0 /mnt/pmem1
    # mount|grep dax
    /dev/pmem0 on /mnt/pmem0 type xfs
    (rw,relatime,attr2,dax,inode64,sunit=4096,swidth=4096,noquota)
    /dev/pmem1 on /mnt/pmem1 type xfs
    (rw,relatime,attr2,dax,inode64,sunit=4096,swidth=4096,noquota)