Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp271373ybz; Wed, 15 Apr 2020 08:27:47 -0700 (PDT) X-Google-Smtp-Source: APiQypJVpoVG8AlV01XqR6JiQ/FuVHBHYm5n7Wvjhvq2WUQ45ZvTn5+Az1NDv8tfsOvHjRGFi09k X-Received: by 2002:a17:906:2410:: with SMTP id z16mr5572614eja.1.1586964467497; Wed, 15 Apr 2020 08:27:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586964467; cv=none; d=google.com; s=arc-20160816; b=h1eEewTUv5wfwvHyf4vTch8aVpqIigNQdCf6sQk3QhmLAQQJLQapWsB0wXS9mbAd1h TBpWXAJ67kerQEkPaZ8pwuqTfVnrxfctFB3JQ62AofJGXkFmScGnqSzW61Y1f3nxPi6u knEBlKz75zcNO54iGEcrL92m/1aPNo6wNRcfjbH+Ek1YdDWD/7L5iNfBLovjWV2VwmE8 Ye4NrO8GavWY4ZOvTBALbB4oGWLaz1/NhOxLcaI9LeDXNVDY+A3a5CK+gspuHAcRGQU9 PiAUcWnSHyrv2yXme1lQDuRO2QkHqYMfDgv/7HEDOY5zoV3s1nG1UTd/EXnL+TlwEqMt 23jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=uHi5lk63rrKDmZMIfR5a4LZuMN208ApyOY4dNRLpR10=; b=KD8OPJNi8M+U9T3e4sQaB427NBUmZrH8PHMWRHfqbAtt0DX2LPT+JdR695wA9l5eoK gXmTxk9DgZ5pXtcc+pqQWPSYmtp5lXTrrt2HC8xizXfCeuU7F5VraEh8s74J4ygy+Vj4 3YvFDTm3S3XXhypJsdaTahaT/Pr/JGFuFD1Y661W8zyO8TsQ53ycdu9bnfkTmQ+xVkCL XpzmT7TiNvE5IuS1BqdNA80ZdO8P7jXogt5EsO1HQtogsJOAZ9BiKkMTbLqV+b1C6xuC XhQe/vSLsn+SrFqPmYj3SaAaqHcrv5BNkpoaemN+9d3SwzbNZkUXuX2IoPAhlN5BU7/Z ILFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bi17si11130029edb.370.2020.04.15.08.27.20; Wed, 15 Apr 2020 08:27:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2634990AbgDOGp5 (ORCPT + 99 others); Wed, 15 Apr 2020 02:45:57 -0400 Received: from mga11.intel.com ([192.55.52.93]:19907 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2634976AbgDOGpw (ORCPT ); Wed, 15 Apr 2020 02:45:52 -0400 IronPort-SDR: onuFbZBdn9UK5PNdXriBE8kpavtXyX2ALD1CFhJQTV+QaFrHWwOn5QVzg0r3mYgdZonT6IpN2G mf1HkJlJ2bSQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2020 23:45:45 -0700 IronPort-SDR: ZiAT/LqTlmf9reG9Qv86u6SdhFcTR7uP/IKSPz3WZrjtqVv4qQMd9cUALUgMEiz7YbP0hsqRvm 0s5kdZgxWRMA== X-IronPort-AV: E=Sophos;i="5.72,386,1580803200"; d="scan'208";a="400214315" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2020 23:45:44 -0700 From: ira.weiny@intel.com To: linux-kernel@vger.kernel.org, "Darrick J. Wong" Cc: Ira Weiny , Jan Kara , Dan Williams , Dave Chinner , Christoph Hellwig , "Theodore Y. Ts'o" , Jeff Moyer , linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH V8 11/11] Documentation/dax: Update Usage section Date: Tue, 14 Apr 2020 23:45:23 -0700 Message-Id: <20200415064523.2244712-12-ira.weiny@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200415064523.2244712-1-ira.weiny@intel.com> References: <20200415064523.2244712-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Ira Weiny Update the Usage section to reflect the new individual dax selection functionality. Signed-off-by: Ira Weiny --- 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 | 166 +++++++++++++++++++++++++++++- 1 file changed, 163 insertions(+), 3 deletions(-) diff --git a/Documentation/filesystems/dax.txt b/Documentation/filesystems/dax.txt index 679729442fd2..893820c53f49 100644 --- a/Documentation/filesystems/dax.txt +++ b/Documentation/filesystems/dax.txt @@ -17,11 +17,171 @@ 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 +with the exception that the STATX_ATTR_DAX flag is not supported, nor needed, +as it is always true. + + +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