From: ira.weiny@intel.com To: linux-ext4@vger.kernel.org, Andreas Dilger <adilger.kernel@dilger.ca>, "Theodore Y. Ts'o" <tytso@mit.edu>, Jan Kara <jack@suse.cz> Cc: Ira Weiny <ira.weiny@intel.com>, Al Viro <viro@zeniv.linux.org.uk>, Dan Williams <dan.j.williams@intel.com>, Dave Chinner <david@fromorbit.com>, Christoph Hellwig <hch@lst.de>, Jeff Moyer <jmoyer@redhat.com>, "Darrick J. Wong" <darrick.wong@oracle.com>, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V1 3/9] fs/ext4: Disallow encryption if inode is DAX Date: Wed, 13 May 2020 23:53:09 -0700 [thread overview] Message-ID: <20200514065316.2500078-4-ira.weiny@intel.com> (raw) In-Reply-To: <20200514065316.2500078-1-ira.weiny@intel.com> From: Ira Weiny <ira.weiny@intel.com> Encryption and DAX are incompatible. Changing the DAX mode due to a change in Encryption mode is wrong without a corresponding address_space_operations update. Make the 2 options mutually exclusive by returning an error if DAX was set first. Furthermore, clarify the documentation of the exclusivity and how that will work. Signed-off-by: Ira Weiny <ira.weiny@intel.com> --- Changes: remove WARN_ON_ONCE Add documentation to the encrypt doc WRT DAX --- Documentation/filesystems/fscrypt.rst | 4 +++- fs/ext4/super.c | 10 +--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Documentation/filesystems/fscrypt.rst b/Documentation/filesystems/fscrypt.rst index aa072112cfff..1475b8d52fef 100644 --- a/Documentation/filesystems/fscrypt.rst +++ b/Documentation/filesystems/fscrypt.rst @@ -1038,7 +1038,9 @@ astute users may notice some differences in behavior: - The ext4 filesystem does not support data journaling with encrypted regular files. It will fall back to ordered data mode instead. -- DAX (Direct Access) is not supported on encrypted files. +- DAX (Direct Access) is not supported on encrypted files. Attempts to enable + DAX on an encrypted file will fail. Mount options will _not_ enable DAX on + encrypted files. - The st_size of an encrypted symlink will not necessarily give the length of the symlink target as required by POSIX. It will actually diff --git a/fs/ext4/super.c b/fs/ext4/super.c index bf5fcb477f66..9873ab27e3fa 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1320,7 +1320,7 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, if (inode->i_ino == EXT4_ROOT_INO) return -EPERM; - if (WARN_ON_ONCE(IS_DAX(inode) && i_size_read(inode))) + if (IS_DAX(inode)) return -EINVAL; res = ext4_convert_inline_data(inode); @@ -1344,10 +1344,6 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, ext4_set_inode_flag(inode, EXT4_INODE_ENCRYPT); ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA); - /* - * Update inode->i_flags - S_ENCRYPTED will be enabled, - * S_DAX may be disabled - */ ext4_set_inode_flags(inode); } return res; @@ -1371,10 +1367,6 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, ctx, len, 0); if (!res) { ext4_set_inode_flag(inode, EXT4_INODE_ENCRYPT); - /* - * Update inode->i_flags - S_ENCRYPTED will be enabled, - * S_DAX may be disabled - */ ext4_set_inode_flags(inode); res = ext4_mark_inode_dirty(handle, inode); if (res) -- 2.25.1
next prev parent reply other threads:[~2020-05-14 6:53 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-14 6:53 [PATCH V1 0/9] Enable ext4 support for per-file/directory DAX operations ira.weiny 2020-05-14 6:53 ` [PATCH V1 1/9] fs/ext4: Narrow scope of DAX check in setflags ira.weiny 2020-05-14 6:53 ` [PATCH V1 2/9] fs/ext4: Disallow verity if inode is DAX ira.weiny 2020-05-14 10:21 ` Jan Kara 2020-05-14 6:53 ` ira.weiny [this message] 2020-05-14 10:23 ` [PATCH V1 3/9] fs/ext4: Disallow encryption " Jan Kara 2020-05-14 6:53 ` [PATCH V1 4/9] fs/ext4: Change EXT4_MOUNT_DAX to EXT4_MOUNT_DAX_ALWAYS ira.weiny 2020-05-14 6:53 ` [PATCH V1 5/9] fs/ext4: Update ext4_should_use_dax() ira.weiny 2020-05-14 6:53 ` [PATCH V1 6/9] fs/ext4: Only change S_DAX on inode load ira.weiny 2020-05-14 6:53 ` [PATCH V1 7/9] fs/ext4: Make DAX mount option a tri-state ira.weiny 2020-05-14 11:25 ` Jan Kara 2020-05-14 14:27 ` Ira Weiny 2020-05-14 15:08 ` Darrick J. Wong 2020-05-15 3:38 ` Ira Weiny 2020-05-14 6:53 ` [PATCH V1 8/9] fs/ext4: Introduce DAX inode flag ira.weiny 2020-05-14 11:06 ` Jan Kara 2020-05-14 6:53 ` [PATCH V1 9/9] Documentation/dax: Update DAX enablement for ext4 ira.weiny 2020-05-14 11:15 ` Jan Kara
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=20200514065316.2500078-4-ira.weiny@intel.com \ --to=ira.weiny@intel.com \ --cc=adilger.kernel@dilger.ca \ --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-ext4@vger.kernel.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=tytso@mit.edu \ --cc=viro@zeniv.linux.org.uk \ --subject='Re: [PATCH V1 3/9] fs/ext4: Disallow encryption if inode is DAX' \ /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
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).