From: ira.weiny@intel.com
To: linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org,
"Darrick J. Wong" <darrick.wong@oracle.com>
Cc: Ira Weiny <ira.weiny@intel.com>, Jan Kara <jack@suse.cz>,
Al Viro <viro@zeniv.linux.org.uk>,
Dan Williams <dan.j.williams@intel.com>,
Dave Chinner <david@fromorbit.com>,
Christoph Hellwig <hch@lst.de>,
"Theodore Y. Ts'o" <tytso@mit.edu>,
Jeff Moyer <jmoyer@redhat.com>,
linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-api@vger.kernel.org
Subject: [PATCH V10 04/11] Documentation/dax: Update Usage section
Date: Wed, 22 Apr 2020 14:20:55 -0700 [thread overview]
Message-ID: <20200422212102.3757660-5-ira.weiny@intel.com> (raw)
In-Reply-To: <20200422212102.3757660-1-ira.weiny@intel.com>
From: Ira Weiny <ira.weiny@intel.com>
Update the Usage section to reflect the new individual dax selection
functionality.
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
Changes from V9:
Fix missing ')'
Fix trialing '"'
Changes from V8:
Updates from Darrick
Changes from V7:
Cleanups/clarifications from Darrick and Dan
Changes from V6:
Update to allow setting FS_XFLAG_DAX any time.
Update with list of behaviors from Darrick
https://lore.kernel.org/lkml/20200409165927.GD6741@magnolia/
Changes from V5:
Update to reflect the agreed upon semantics
https://lore.kernel.org/lkml/20200405061945.GA94792@iweiny-DESK2.sc.intel.com/
---
Documentation/filesystems/dax.txt | 164 +++++++++++++++++++++++++++++-
1 file changed, 161 insertions(+), 3 deletions(-)
diff --git a/Documentation/filesystems/dax.txt b/Documentation/filesystems/dax.txt
index 679729442fd2..553712c5054e 100644
--- a/Documentation/filesystems/dax.txt
+++ b/Documentation/filesystems/dax.txt
@@ -17,11 +17,169 @@ For file mappings, the storage device is mapped directly into userspace.
Usage
-----
-If you have a block device which supports DAX, you can make a filesystem
+If you have a block device which supports DAX, you can make a file system
on it as usual. The DAX code currently only supports files with a block
size equal to your kernel's PAGE_SIZE, so you may need to specify a block
-size when creating the filesystem. When mounting it, use the "-o dax"
-option on the command line or add 'dax' to the options in /etc/fstab.
+size when creating the file system.
+
+Currently 3 filesystems support DAX: ext2, ext4 and xfs. Enabling DAX on them
+is different.
+
+Enabling DAX on ext4 and ext2
+-----------------------------
+
+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.
+
+
+Enabling DAX on xfs
+-------------------
+
+Summary
+-------
+
+ 1. There exists an in-kernel file access mode flag S_DAX that corresponds to
+ the statx flag STATX_ATTR_DAX. See the manpage for statx(2) for details
+ about this access mode.
+
+ 2. There exists an advisory file inode flag FS_XFLAG_DAX that is
+ inherited from the parent directory FS_XFLAG_DAX inode flag at file
+ creation time. This advisory flag can be set or cleared at any
+ time, but doing so does not immediately affect the S_DAX state.
+
+ Unless overridden by mount options (see (3)), if FS_XFLAG_DAX is set
+ and the fs is on pmem then it will enable S_DAX at inode load time;
+ if FS_XFLAG_DAX is not set, it will not enable S_DAX.
+
+ 3. There exists a dax= mount option.
+
+ "-o dax=never" means "never set S_DAX, ignore FS_XFLAG_DAX."
+
+ "-o dax=always" means "always set S_DAX (at least on pmem),
+ and ignore FS_XFLAG_DAX."
+
+ "-o dax" is an alias for "dax=always".
+
+ "-o dax=inode" means "follow FS_XFLAG_DAX" and is the default.
+
+ 4. There exists an advisory directory inode flag FS_XFLAG_DAX that can
+ be set or cleared at any time. The flag state is inherited by any files or
+ subdirectories when they are created within that directory.
+
+ 5. Programs that require a specific file access mode (DAX or not DAX)
+ can do one of the following:
+
+ (a) Create files in directories that the FS_XFLAG_DAX flag set as
+ needed; or
+
+ (b) Have the administrator set an override via mount option; or
+
+ (c) Set or clear the file's FS_XFLAG_DAX flag as needed. Programs
+ must then cause the kernel to evict the inode from memory. This
+ can be done by:
+
+ i> Closing the file and re-opening the file and using statx to
+ see if the fs has changed the S_DAX flag; and
+
+ ii> If the file still does not have the desired S_DAX access
+ mode, either unmount and remount the filesystem, or close
+ the file and use drop_caches.
+
+ 6. It is expected that users who want to squeeze every last bit of performance
+ out of the particular rough and tumble bits of their storage will also be
+ exposed to the difficulties of what happens when the operating system can't
+ totally virtualize those hardware capabilities. DAX is such a feature.
+
+
+Details
+-------
+
+There are 2 per-file dax flags. One is a physical inode setting (FS_XFLAG_DAX)
+and the other a currently enabled state (S_DAX).
+
+FS_XFLAG_DAX is maintained, on disk, on individual inodes. It is preserved
+within the file system. This 'physical' config setting can be set using an
+ioctl and/or an application such as "xfs_io -c 'chattr [-+]x'". 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. (Doing so on the
+root directory acts to set a default for the entire file system.)
+
+To clarify inheritance here are 3 examples:
+
+Example A:
+
+mkdir -p a/b/c
+xfs_io 'chattr +x' a
+mkdir a/b/c/d
+mkdir a/e
+
+ dax: a,e
+ no dax: b,c,d
+
+Example B:
+
+mkdir a
+xfs_io 'chattr +x' a
+mkdir -p a/b/c/d
+
+ dax: a,b,c,d
+ no dax:
+
+Example C:
+
+mkdir -p a/b/c
+xfs_io 'chattr +x' c
+mkdir a/b/c/d
+
+ dax: c,d
+ no dax: a,b
+
+
+The current enabled state (S_DAX) is set when a file inode is _loaded_ based on
+the underlying media support, the value of FS_XFLAG_DAX, and the file systems
+dax mount option setting. See below.
+
+statx can be used to query S_DAX. NOTE that a directory will never have S_DAX
+set and therefore statx will never indicate that S_DAX is set on directories.
+
+NOTE: Setting the FS_XFLAG_DAX (specifically or through inheritance) occurs
+even if the underlying media does not support dax and/or the file system is
+overridden with a mount option.
+
+
+Overriding FS_XFLAG_DAX (dax= mount option)
+-------------------------------------------
+
+There exists a dax mount option. Using the mount option does not change the
+physical configured state of individual files but overrides the S_DAX operating
+state when inodes are loaded.
+
+Given underlying media support, the dax mount option is a tri-state option
+(never, always, inode) with the following meanings:
+
+ "-o dax=never" means "never set S_DAX, ignore FS_XFLAG_DAX"
+ "-o dax=always" means "always set S_DAX, ignore FS_XFLAG_DAX"
+ "-o dax" by itself means "dax=always" to remain compatible with older
+ kernels
+ "-o dax=inode" means "follow FS_XFLAG_DAX"
+
+The default state is 'inode'. Given underlying media support, the following
+algorithm is used to determine the effective mode of the file S_DAX on a
+capable device.
+
+ S_DAX = FS_XFLAG_DAX;
+
+ if (dax_mount == "always")
+ S_DAX = true;
+ else if (dax_mount == "off")
+ S_DAX = false;
+
+To reiterate: Setting, and inheritance, continues to affect FS_XFLAG_DAX even
+while the file system is mounted with a dax override. However, in-core inode
+state (S_DAX) will continue to be overridden until the filesystem is remounted
+with dax=inode and the inode is evicted.
Implementation Tips for Block Driver Writers
--
2.25.1
next prev parent reply other threads:[~2020-04-22 21:21 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-22 21:20 [PATCH V10 00/11] XFS - Enable per-file/per-directory DAX operations V10 ira.weiny
2020-04-22 21:20 ` [PATCH V10 01/11] fs/xfs: Remove unnecessary initialization of i_rwsem ira.weiny
2020-04-22 21:20 ` [PATCH V10 02/11] fs: Remove unneeded IS_DAX() check in io_is_direct() ira.weiny
2020-04-23 21:41 ` Dave Chinner
2020-04-22 21:20 ` [PATCH V10 03/11] fs/stat: Define DAX statx attribute ira.weiny
2020-04-22 21:20 ` ira.weiny [this message]
2020-04-23 2:33 ` [PATCH V10 04/11] Documentation/dax: Update Usage section Yasunori Goto
2020-04-23 5:05 ` Ira Weiny
2020-04-23 22:27 ` Dave Chinner
2020-04-23 23:25 ` Ira Weiny
2020-04-24 2:15 ` Dave Chinner
2020-04-24 5:55 ` Ira Weiny
2020-04-22 21:20 ` [PATCH V10 05/11] fs/xfs: Change XFS_MOUNT_DAX to XFS_MOUNT_DAX_ALWAYS ira.weiny
2020-04-23 22:27 ` Dave Chinner
2020-04-22 21:20 ` [PATCH V10 06/11] fs/xfs: Make DAX mount option a tri-state ira.weiny
2020-04-23 22:35 ` Dave Chinner
2020-04-23 23:33 ` Ira Weiny
2020-04-22 21:20 ` [PATCH V10 07/11] fs/xfs: Create function xfs_inode_should_enable_dax() ira.weiny
2020-04-23 22:36 ` Dave Chinner
2020-04-22 21:20 ` [PATCH V10 08/11] fs/xfs: Combine xfs_diflags_to_linux() and xfs_diflags_to_iflags() ira.weiny
2020-04-23 22:37 ` Dave Chinner
2020-04-22 21:21 ` [PATCH V10 09/11] fs: Lift XFS_IDONTCACHE to the VFS layer ira.weiny
2020-04-23 22:38 ` Dave Chinner
2020-04-22 21:21 ` [PATCH V10 10/11] fs: Introduce DCACHE_DONTCACHE ira.weiny
2020-04-23 8:40 ` Jan Kara
2020-04-23 22:57 ` Dave Chinner
2020-04-23 23:38 ` Ira Weiny
2020-04-22 21:21 ` [PATCH V10 11/11] fs/xfs: Update xfs_ioctl_setattr_dax_invalidate() ira.weiny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200422212102.3757660-5-ira.weiny@intel.com \
--to=ira.weiny@intel.com \
--cc=dan.j.williams@intel.com \
--cc=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=jmoyer@redhat.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).