This is an old revision of the document!
NOTE: kernel 5.8 is yet to be released. This document is therefore preliminary until it's release and subject to change.
Prior to kernel 5.8 enabling dax is done on an entire file system basis. It is done with a “-o dax” mount option.
$ mount -o dax /dev/pmem0p1 /mnt/ext4-pmem0 $ mount -o dax /dev/pmem0p2 /mnt/xfs-pmem0
As of kernel 5.8 additional DAX enabling options are available on some file systems, specifically:
When mounting the filesystem, use the “-o dax” option on the command line or add 'dax' to the options in /etc/fstab. This works to enable DAX on all files within the filesystem. It is equivalent to the '-o dax=always' behavior below.
As of kernel 5.8 xfs supports the new per-file dax configuration.
NOTE: Modifications to and the inheritance behavior of FS_XFLAG_DAX remain the same even when the filesystem is mounted with a dax option. However, in-core inode state (S_DAX) will be overridden until the filesystem is remounted with dax=inode and the inode is evicted from kernel memory.
There are 2 per-file dax flags. One is a persistent inode setting (FS_XFLAG_DAX) and the other is a volatile flag indicating the active state of the feature (S_DAX).
FS_XFLAG_DAX is preserved within the filesystem. This persistent config setting can be set, cleared and/or queried using the FS_IOC_FS[GS]ETXATTR ioctl (see ioctl_xfs_fsgetxattr(2)) or an utility such as 'xfs_io'.
New files and directories automatically inherit FS_XFLAG_DAX from their parent directory _when_ _created_. Therefore, setting FS_XFLAG_DAX at directory creation time can be used to set a default behavior for an entire sub-tree.
To clarify inheritance, here are 3 examples:
$ mkdir -p a/b/c $ xfs_io -c 'chattr +x' a $ mkdir a/b/c/d $ mkdir a/e
Results in: dax: a,e no dax: b,c,d
$ mkdir a $ xfs_io -c 'chattr +x' a $ mkdir -p a/b/c/d
Results in: dax: a,b,c,d no dax:
$ mkdir -p a/b/c $ xfs_io -c 'chattr +x' c $ mkdir a/b/c/d
Results in: dax: c,d no dax: a,b
The current enabled state (S_DAX) is set when a file inode is instantiated in memory by the kernel. It is set based on the underlying media support, the value of FS_XFLAG_DAX and the filesystem's dax mount option.
statx can be used to query S_DAX. NOTE that only regular files will ever have S_DAX set and therefore statx will never indicate that S_DAX is set on directories.
Setting the FS_XFLAG_DAX flag (specifically or through inheritance) occurs even if the underlying media does not support dax and/or the filesystem is overridden with a mount option.