Skip to contentSkip to conversation

Enable ext4 support for per-file/directory DAX operations

RFC PATCH In review [email protected] 7 participants 42 messages Apr 14, 2020 – Apr 21, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Enable ext4 support for per-file/directory DAX operations

From: Ira Weiny <[email protected]>

Enable the same per file DAX support to ext4 as was done for xfs. This series builds and depends on the V7 series for xfs.[1]

To summarize:

1. There exists an in-kernel access mode flag S_DAX that is set when file accesses go directly to persistent memory, bypassing the page cache. Applications must call statx to discover the current S_DAX state (STATX_ATTR_DAX).

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.

[1] https://lore.kernel.org/lkml/[email protected]/

To: [email protected]
Cc: "Darrick J. Wong" <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: Dave Chinner <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: "Theodore Y. Ts'o" <[email protected]>
Cc: Jan Kara <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

Ira Weiny (8):
fs/ext4: Narrow scope of DAX check in setflags fs/ext4: Disallow verity if inode is DAX fs/ext4: Disallow encryption if inode is DAX fs/ext4: Introduce DAX inode flag fs/ext4: Make DAX mount option a tri-state fs/ext4: Update ext4_should_use_dax() fs/ext4: Only change S_DAX on inode load Documentation/dax: Update DAX enablement for ext4

 Documentation/filesystems/dax.txt | 13 +------
 fs/ext4/ext4.h                    | 16 ++++++---
 fs/ext4/ialloc.c                  |  2 +-
 fs/ext4/inode.c                   | 22 ++++++++----
 fs/ext4/ioctl.c                   | 28 ++++++++++++---
 fs/ext4/super.c                   | 57 +++++++++++++++++++++++--------
 fs/ext4/verity.c                  |  5 ++-
 7 files changed, 99 insertions(+), 44 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

RFC PATCH 1/8 fs/ext4: Narrow scope of DAX check in setflags

From: Ira Weiny <[email protected]>

When preventing DAX and journaling on an inode. Use the effective DAX check rather than the mount option.

This will be required to support per inode DAX flags.

---
 fs/ext4/ioctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext4/ioctl.c +2 -2
index a0ec750018dd..ee3401a32e79 100644
@@ -405,9 +405,9 @@ static int ext4_ioctl_setflags(struct inode *inode,
 	if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) {
 		/*
 		 * Changes to the journaling mode can cause unsafe changes to
-		 * S_DAX if we are using the DAX mount option.
+		 * S_DAX if the inode is DAX
 		 */
-		if (test_opt(inode->i_sb, DAX)) {
+		if (IS_DAX(inode)) {
 			err = -EBUSY;
 			goto flags_out;
 		}
Signature · 1 line
2.25.1
reviewer Reviewed-by on v1 1/8
#2 lore raw

Re: [PATCH RFC 1/8] fs/ext4: Narrow scope of DAX check in setflags

Quoted 8 lines · On Mon 13-04-20 21:00:23, [email protected] wrote:

From: Ira Weiny <[email protected]>

When preventing DAX and journaling on an inode. Use the effective DAX check rather than the mount option.

This will be required to support per inode DAX flags.

Looks good to me. You can add:

Honza

Quoted 23 lines
---
 fs/ext4/ioctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext4/ioctl.c +2 -2
index a0ec750018dd..ee3401a32e79 100644
@@ -405,9 +405,9 @@ static int ext4_ioctl_setflags(struct inode *inode,
 	if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) {
 		/*
 		 * Changes to the journaling mode can cause unsafe changes to
-		 * S_DAX if we are using the DAX mount option.
+		 * S_DAX if the inode is DAX
 		 */
-		if (test_opt(inode->i_sb, DAX)) {
+		if (IS_DAX(inode)) {
 			err = -EBUSY;
 			goto flags_out;
 		}
Signature · 1 line
2.25.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#3 lore raw

RFC PATCH 2/8 fs/ext4: Disallow verity if inode is DAX

In reply to [email protected]

From: Ira Weiny <[email protected]>

Verity and DAX are incompatible. Changing the DAX mode due to a verity flag change is wrong without a corresponding address_space_operations update.

Make the 2 options mutually exclusive by returning an error if DAX was set first.

(Setting DAX is already disabled if Verity is set first.)

---
 fs/ext4/verity.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ext4/verity.c +3 -0
index dc5ec724d889..ce3f9a198d3b 100644
@@ -113,6 +113,9 @@ static int ext4_begin_enable_verity(struct file *filp)
 	handle_t *handle;
 	int err;
 
+	if (WARN_ON_ONCE(IS_DAX(inode)))
+		return -EINVAL;
+
 	if (ext4_verity_in_progress(inode))
 		return -EBUSY;
 
Signature · 1 line
2.25.1
reviewer Reviewed-by on v1 2/8
#4 lore raw

Re: [PATCH RFC 2/8] fs/ext4: Disallow verity if inode is DAX

Quoted 6 lines · On Mon 13-04-20 21:00:24, [email protected] wrote:

From: Ira Weiny <[email protected]>

Verity and DAX are incompatible. Changing the DAX mode due to a verity flag change is wrong without a corresponding address_space_operations update.

Quoted 6 lines

Make the 2 options mutually exclusive by returning an error if DAX was set first.

(Setting DAX is already disabled if Verity is set first.)

Looks good to me. You can add:

Honza

Quoted 21 lines
---
 fs/ext4/verity.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ext4/verity.c +3 -0
index dc5ec724d889..ce3f9a198d3b 100644
@@ -113,6 +113,9 @@ static int ext4_begin_enable_verity(struct file *filp)
 	handle_t *handle;
 	int err;
 
+	if (WARN_ON_ONCE(IS_DAX(inode)))
+		return -EINVAL;
+
 	if (ext4_verity_in_progress(inode))
 		return -EBUSY;
 
Signature · 1 line
2.25.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
reviewer
#5 lore raw

Re: [PATCH RFC 2/8] fs/ext4: Disallow verity if inode is DAX

In reply to [email protected]
Quoted 21 lines · On Mon 13-04-20 21:00:24, [email protected] wrote:

From: Ira Weiny <[email protected]>

Verity and DAX are incompatible. Changing the DAX mode due to a verity flag change is wrong without a corresponding address_space_operations update.

Make the 2 options mutually exclusive by returning an error if DAX was set first.

(Setting DAX is already disabled if Verity is set first.)

---
 fs/ext4/verity.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ext4/verity.c +0 -0
index dc5ec724d889..ce3f9a198d3b 100644

fs/ext4/verity.c static int ext4_begin_enable_verity(struct file *filp) · line 118

Quoted 6 lines
fs/ext4/verity.c +3 -0
@@ -113,6 +113,9 @@ static int ext4_begin_enable_verity(struct file *filp)
 	handle_t *handle;
 	int err;
 
+	if (WARN_ON_ONCE(IS_DAX(inode)))
+		return -EINVAL;
+

Hum, one question, is there a reason for WARN_ON_ONCE()? If I understand correctly, user could normally trigger this, couldn't he?

Honza

Quoted 6 lines
fs/ext4/verity.c +0 -0
 	if (ext4_verity_in_progress(inode))
 		return -EBUSY;
 
Signature · 1 line
2.25.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer
#6 lore raw

Re: [PATCH RFC 2/8] fs/ext4: Disallow verity if inode is DAX

Quoted 25 lines · Jan Kara
Quoted 24 lines · On Mon 13-04-20 21:00:24, [email protected] wrote:

From: Ira Weiny <[email protected]>

Verity and DAX are incompatible. Changing the DAX mode due to a verity flag change is wrong without a corresponding address_space_operations update.

Make the 2 options mutually exclusive by returning an error if DAX was set first.

(Setting DAX is already disabled if Verity is set first.)

---
 fs/ext4/verity.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ext4/verity.c +0 -0
index dc5ec724d889..ce3f9a198d3b 100644
@@ -113,6 +113,9 @@ static int ext4_begin_enable_verity(struct file *filp)
 	handle_t *handle;
 	int err;
 
Quoted 6 lines

fs/ext4/verity.c static int ext4_begin_enable_verity(struct file *filp) · line 118

Quoted 3 lines
fs/ext4/verity.c +3 -0
+	if (WARN_ON_ONCE(IS_DAX(inode)))
+		return -EINVAL;
+

Hum, one question, is there a reason for WARN_ON_ONCE()? If I understand correctly, user could normally trigger this, couldn't he?

Tes, the WARN_ON_ONCE isn't appropriate here. We should also disallow setting the DAX flag if the inode has the verity flag set already.

And if we need to decide what to if the file system is mounted with "-o dax=always" and the verity file system feature is enabled. We could either (a) reject the mount with if the mount option is given and the file system can have verity files, or (b) make "-o dax=always" mean "-o dax=mostly_always" and treat verity files as not using dax even when dax=always is selected.

Also, in theory, we *could* support dax and verity files, but verifying the crypto checksums of all of the pages when the file is first accessed, and then marking that in a flag in the in-inode flag. Or we could have a per-page flag stored somewhere that indicates that the page has been verified, so that we can on-demand verify the integrity of the page. Given that verity files are read-only, the main reason why someone might want to use dax && verity would be to reduce page cache overhead of system files; if executing out of dax pages doesn't have significant performance impacts, this might be something which might be a nice-to-have. I don't think we need to worry about this for now; if there are use cases where mobile devices want to use dax && verity, we can let them figure out how to make it work. I'm just pointing out that it's not really a completely insane combination.

Cheers,

- Ted

author
#7 lore raw

Re: [PATCH RFC 2/8] fs/ext4: Disallow verity if inode is DAX

Quoted 33 lines · Theodore Y. Ts'o
Quoted 25 lines · Jan Kara
Quoted 24 lines · On Mon 13-04-20 21:00:24, [email protected] wrote:

From: Ira Weiny <[email protected]>

Verity and DAX are incompatible. Changing the DAX mode due to a verity flag change is wrong without a corresponding address_space_operations update.

Make the 2 options mutually exclusive by returning an error if DAX was set first.

(Setting DAX is already disabled if Verity is set first.)

---
 fs/ext4/verity.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ext4/verity.c +0 -0
index dc5ec724d889..ce3f9a198d3b 100644
@@ -113,6 +113,9 @@ static int ext4_begin_enable_verity(struct file *filp)
 	handle_t *handle;
 	int err;
 
Quoted 6 lines

fs/ext4/verity.c static int ext4_begin_enable_verity(struct file *filp) · line 118

Quoted 3 lines
fs/ext4/verity.c +3 -0
+	if (WARN_ON_ONCE(IS_DAX(inode)))
+		return -EINVAL;
+

Hum, one question, is there a reason for WARN_ON_ONCE()? If I understand correctly, user could normally trigger this, couldn't he?

Quoted 2 lines

Tes, the WARN_ON_ONCE isn't appropriate here. We should also disallow setting the DAX flag if the inode has the verity flag set already.

This is taken care of and is part of ext4_enable_dax() after this series.

Quoted 7 lines

And if we need to decide what to if the file system is mounted with "-o dax=always" and the verity file system feature is enabled. We could either (a) reject the mount with if the mount option is given and the file system can have verity files, or (b) make "-o dax=always" mean "-o dax=mostly_always" and treat verity files as not using dax even when dax=always is selected.

The later is implemented in this series... Not the most explicit thing. :-(

Quoted 15 lines

Also, in theory, we *could* support dax and verity files, but verifying the crypto checksums of all of the pages when the file is first accessed, and then marking that in a flag in the in-inode flag. Or we could have a per-page flag stored somewhere that indicates that the page has been verified, so that we can on-demand verify the integrity of the page. Given that verity files are read-only, the main reason why someone might want to use dax && verity would be to reduce page cache overhead of system files; if executing out of dax pages doesn't have significant performance impacts, this might be something which might be a nice-to-have. I don't think we need to worry about this for now; if there are use cases where mobile devices want to use dax && verity, we can let them figure out how to make it work. I'm just pointing out that it's not really a completely insane combination.

Fair enough. The main issue I need to correct here is to keep the 2 mutually exclusive. Which AFAICT is not true today. This makes it so even without the per-file enablement.

Ira

Quoted 4 lines

Cheers,

- Ted

author
#8 lore raw

Re: [PATCH RFC 2/8] fs/ext4: Disallow verity if inode is DAX

In reply to Jan Kara
Quoted 25 lines · Jan Kara
Quoted 24 lines · On Mon 13-04-20 21:00:24, [email protected] wrote:

From: Ira Weiny <[email protected]>

Verity and DAX are incompatible. Changing the DAX mode due to a verity flag change is wrong without a corresponding address_space_operations update.

Make the 2 options mutually exclusive by returning an error if DAX was set first.

(Setting DAX is already disabled if Verity is set first.)

---
 fs/ext4/verity.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ext4/verity.c +0 -0
index dc5ec724d889..ce3f9a198d3b 100644
@@ -113,6 +113,9 @@ static int ext4_begin_enable_verity(struct file *filp)
 	handle_t *handle;
 	int err;
 
Quoted 6 lines

fs/ext4/verity.c static int ext4_begin_enable_verity(struct file *filp) · line 118

Quoted 3 lines
fs/ext4/verity.c +3 -0
+	if (WARN_ON_ONCE(IS_DAX(inode)))
+		return -EINVAL;
+

Hum, one question, is there a reason for WARN_ON_ONCE()? If I understand correctly, user could normally trigger this, couldn't he?

Ok. I did not think this through but I did think about this. I was following the code from the encryption side which issues a warning and was thinking that would be a good way to alert the user they are doing something wrong...

I think you are right about both of them but we also need to put something in the verity, dax, and ... (I can't find a file in Documentation which talks about encryption right off) documentation files.... For verity something like.

<quote>
Verity and DAX
--------------

Verity and DAX are not compatible and attempts to set both of these flags on a file will fail.
</quote>

And the same thing in the DAX doc?

And where would be appropriate for the encrypt doc?

Ira

Quoted 12 lines

Honza

Quoted 6 lines
fs/ext4/verity.c +0 -0
 	if (ext4_verity_in_progress(inode))
 		return -EBUSY;
 
Signature · 1 line
2.25.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#9 lore raw

Re: [PATCH RFC 2/8] fs/ext4: Disallow verity if inode is DAX

Quoted 45 lines · Ira Weiny
Quoted 25 lines · Jan Kara
Quoted 24 lines · On Mon 13-04-20 21:00:24, [email protected] wrote:

From: Ira Weiny <[email protected]>

Verity and DAX are incompatible. Changing the DAX mode due to a verity flag change is wrong without a corresponding address_space_operations update.

Make the 2 options mutually exclusive by returning an error if DAX was set first.

(Setting DAX is already disabled if Verity is set first.)

---
 fs/ext4/verity.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ext4/verity.c +0 -0
index dc5ec724d889..ce3f9a198d3b 100644
@@ -113,6 +113,9 @@ static int ext4_begin_enable_verity(struct file *filp)
 	handle_t *handle;
 	int err;
 
Quoted 6 lines

fs/ext4/verity.c static int ext4_begin_enable_verity(struct file *filp) · line 118

Quoted 3 lines
fs/ext4/verity.c +3 -0
+	if (WARN_ON_ONCE(IS_DAX(inode)))
+		return -EINVAL;
+

Hum, one question, is there a reason for WARN_ON_ONCE()? If I understand correctly, user could normally trigger this, couldn't he?

Ok. I did not think this through but I did think about this. I was following the code from the encryption side which issues a warning and was thinking that would be a good way to alert the user they are doing something wrong...

I think you are right about both of them but we also need to put something in the verity, dax, and ... (I can't find a file in Documentation which talks about encryption right off) documentation files.... For verity something like.

<quote>
Verity and DAX
--------------

Quoted 8 lines

Verity and DAX are not compatible and attempts to set both of these flags on a file will fail.
</quote>

And the same thing in the DAX doc?

And where would be appropriate for the encrypt doc?

Documentation/filesystems/fscrypt.rst mentions that DAX isn't supported on encrypted files, but it doesn't say what happens if someone tries to do it anyway. Feel free to improve the documentation.

- Eric

author
#10 lore raw

Re: [PATCH RFC 2/8] fs/ext4: Disallow verity if inode is DAX

Quoted 50 lines · Eric Biggers
Quoted 49 lines · Ira Weiny
Quoted 25 lines · Jan Kara
Quoted 24 lines · On Mon 13-04-20 21:00:24, [email protected] wrote:

From: Ira Weiny <[email protected]>

Verity and DAX are incompatible. Changing the DAX mode due to a verity flag change is wrong without a corresponding address_space_operations update.

Make the 2 options mutually exclusive by returning an error if DAX was set first.

(Setting DAX is already disabled if Verity is set first.)

---
 fs/ext4/verity.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ext4/verity.c +0 -0
index dc5ec724d889..ce3f9a198d3b 100644
@@ -113,6 +113,9 @@ static int ext4_begin_enable_verity(struct file *filp)
 	handle_t *handle;
 	int err;
 
Quoted 6 lines

fs/ext4/verity.c static int ext4_begin_enable_verity(struct file *filp) · line 118

Quoted 3 lines
fs/ext4/verity.c +3 -0
+	if (WARN_ON_ONCE(IS_DAX(inode)))
+		return -EINVAL;
+

Hum, one question, is there a reason for WARN_ON_ONCE()? If I understand correctly, user could normally trigger this, couldn't he?

Ok. I did not think this through but I did think about this. I was following the code from the encryption side which issues a warning and was thinking that would be a good way to alert the user they are doing something wrong...

I think you are right about both of them but we also need to put something in the verity, dax, and ... (I can't find a file in Documentation which talks about encryption right off) documentation files.... For verity something like.

<quote>
Verity and DAX
--------------

Verity and DAX are not compatible and attempts to set both of these flags on a file will fail.
</quote>

Quoted 8 lines
Quoted 4 lines

And the same thing in the DAX doc?

And where would be appropriate for the encrypt doc?

Documentation/filesystems/fscrypt.rst mentions that DAX isn't supported on encrypted files, but it doesn't say what happens if someone tries to do it anyway. Feel free to improve the documentation.

Thanks for pointing this out!

Ira

author
#11 lore raw

Re: [PATCH RFC 2/8] fs/ext4: Disallow verity if inode is DAX

In reply to Jan Kara
Quoted 25 lines · Jan Kara
Quoted 24 lines · On Mon 13-04-20 21:00:24, [email protected] wrote:

From: Ira Weiny <[email protected]>

Verity and DAX are incompatible. Changing the DAX mode due to a verity flag change is wrong without a corresponding address_space_operations update.

Make the 2 options mutually exclusive by returning an error if DAX was set first.

(Setting DAX is already disabled if Verity is set first.)

---
 fs/ext4/verity.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ext4/verity.c +0 -0
index dc5ec724d889..ce3f9a198d3b 100644
@@ -113,6 +113,9 @@ static int ext4_begin_enable_verity(struct file *filp)
 	handle_t *handle;
 	int err;
 
Quoted 6 lines

fs/ext4/verity.c static int ext4_begin_enable_verity(struct file *filp) · line 118

Quoted 3 lines
fs/ext4/verity.c +3 -0
+	if (WARN_ON_ONCE(IS_DAX(inode)))
+		return -EINVAL;
+

Hum, one question, is there a reason for WARN_ON_ONCE()? If I understand correctly, user could normally trigger this, couldn't he?

Removed and added to the verity doc.
Ira

Quoted 12 lines

Honza

Quoted 6 lines
fs/ext4/verity.c +0 -0
 	if (ext4_verity_in_progress(inode))
 		return -EBUSY;
 
Signature · 1 line
2.25.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#12 lore raw

RFC PATCH 3/8 fs/ext4: Disallow encryption if inode is DAX

In reply to [email protected]

From: Ira Weiny <[email protected]>

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.

---
 fs/ext4/super.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
fs/ext4/super.c +1 -9
index 0c7c4adb664e..b14863058115 100644
@@ -1325,7 +1325,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 (WARN_ON_ONCE(IS_DAX(inode)))
 		return -EINVAL;
 
 	res = ext4_convert_inline_data(inode);
@@ -1349,10 +1349,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;
@@ -1376,10 +1372,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)
Signature · 1 line
2.25.1
reviewer
#13 lore raw

Re: [PATCH RFC 3/8] fs/ext4: Disallow encryption if inode is DAX

Quoted 19 lines · On Mon 13-04-20 21:00:25, [email protected] wrote:

From: Ira Weiny <[email protected]>

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.

---
 fs/ext4/super.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
fs/ext4/super.c +0 -0
index 0c7c4adb664e..b14863058115 100644

fs/ext4/super.c static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, · line 1328

Quoted 5 lines
fs/ext4/super.c +1 -1
@@ -1325,7 +1325,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 (WARN_ON_ONCE(IS_DAX(inode)))

Also here I don't think WARN_ON_ONCE() is warranted once we allow per-inode setting of DAX. It will then become a regular error condition...

Honza

Quoted 28 lines
fs/ext4/super.c +0 -8
 		return -EINVAL;
 
 	res = ext4_convert_inline_data(inode);
@@ -1349,10 +1349,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;
@@ -1376,10 +1372,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)
Signature · 1 line
2.25.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author
#14 lore raw

Re: [PATCH RFC 3/8] fs/ext4: Disallow encryption if inode is DAX

Quoted 23 lines · Jan Kara
Quoted 22 lines · On Mon 13-04-20 21:00:25, [email protected] wrote:

From: Ira Weiny <[email protected]>

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.

---
 fs/ext4/super.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
fs/ext4/super.c +0 -0
index 0c7c4adb664e..b14863058115 100644
@@ -1325,7 +1325,7 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len,
 	if (inode->i_ino == EXT4_ROOT_INO)
 		return -EPERM;
 
Quoted 5 lines

fs/ext4/super.c static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, · line 1328

Quoted 2 lines
fs/ext4/super.c +1 -1
-	if (WARN_ON_ONCE(IS_DAX(inode) && i_size_read(inode)))
+	if (WARN_ON_ONCE(IS_DAX(inode)))

Also here I don't think WARN_ON_ONCE() is warranted once we allow per-inode setting of DAX. It will then become a regular error condition...

Removed.
Ira

Quoted 34 lines

Honza

Quoted 28 lines
fs/ext4/super.c +0 -8
 		return -EINVAL;
 
 	res = ext4_convert_inline_data(inode);
@@ -1349,10 +1349,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;
@@ -1376,10 +1372,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)
Signature · 1 line
2.25.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer
#15 lore raw

Re: [PATCH RFC 3/8] fs/ext4: Disallow encryption if inode is DAX

In reply to [email protected]
Quoted 10 lines · On Mon, Apr 13, 2020 at 09:00:25PM -0700, [email protected] wrote:

From: Ira Weiny <[email protected]>

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.

The encryption flag is inherited from the containing directory, and directories can't have the DAX flag set, so anything we do in ext4_set_context() will be safety belt / sanity checking in nature.

But we *do* need to figure out what we do with mount -o dax=always when the file system might have encrypted files. My previous comments about the verity flag and dax flag applies here.

Also note that encrypted files are read/write so we must never allow the combination of ENCRPYT_FL and DAX_FL. So that may be something where we should teach __ext4_iget() to check for this, and declare the file system as corrupted if it sees this combination. (For VERITY_FL && DAX_FL that is a combo that we might want to support in the future, so that's probably a case where arguably, we should just ignore the DAX_FL for now.)

- Ted

#16 lore raw

Re: [PATCH RFC 3/8] fs/ext4: Disallow encryption if inode is DAX

Quoted 21 lines · Theodore Y. Ts'o
Quoted 10 lines · On Mon, Apr 13, 2020 at 09:00:25PM -0700, [email protected] wrote:

From: Ira Weiny <[email protected]>

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.

The encryption flag is inherited from the containing directory, and directories can't have the DAX flag set, so anything we do in ext4_set_context() will be safety belt / sanity checking in nature.

But we *do* need to figure out what we do with mount -o dax=always when the file system might have encrypted files. My previous comments about the verity flag and dax flag applies here.

Quoted 7 lines

Also note that encrypted files are read/write so we must never allow the combination of ENCRPYT_FL and DAX_FL. So that may be something where we should teach __ext4_iget() to check for this, and declare the file system as corrupted if it sees this combination. (For VERITY_FL && DAX_FL that is a combo that we might want to support in the future, so that's probably a case where arguably, we should just ignore the DAX_FL for now.)

We also have a pending consideration for what MKTME (inline memory encryption with programmable hardware keys) means for file-encryption
+ dax. Certainly kernel based software encryption is incompatible with dax, but one of the hallway track discussions I wanted to have at LSF is whether fscrypt is the right interface for managing inline memory encryption. For now, disallowing ENCRPYT_FL + DAX_FL seems ok if ENCRPYT_FL always means software encryption, but this is something to circle back to once we get MKTME implemented for volume encryption and start to look at finer grained (per-directory key) encryption.

author
#17 lore raw

Re: [PATCH RFC 3/8] fs/ext4: Disallow encryption if inode is DAX

In reply to Theodore Y. Ts'o
Quoted 7 lines · Theodore Y. Ts'o
Quoted 6 lines · On Mon, Apr 13, 2020 at 09:00:25PM -0700, [email protected] wrote:

From: Ira Weiny <[email protected]>

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.

Quoted 7 lines
Quoted 4 lines

Make the 2 options mutually exclusive by returning an error if DAX was set first.

The encryption flag is inherited from the containing directory, and directories can't have the DAX flag set,

But they can have FS_XFLAG_DAX set.

Quoted 6 lines

so anything we do in
ext4_set_context() will be safety belt / sanity checking in nature.

But we *do* need to figure out what we do with mount -o dax=always when the file system might have encrypted files. My previous comments about the verity flag and dax flag applies here.

:-( agreed.

FWIW without these patches an inode which has encrypt or verity set is already turning off DAX... So we already have a '-o dax' flag which is not "always".

:-(

Unfortunately the 'always' designation kind of breaks semantically but it is equal to the current mount option.

Quoted 5 lines

Also note that encrypted files are read/write so we must never allow the combination of ENCRPYT_FL and DAX_FL. So that may be something where we should teach __ext4_iget() to check for this, and declare the file system as corrupted if it sees this combination.

ok...

Quoted 4 lines

(For VERITY_FL
&& DAX_FL that is a combo that we might want to support in the future, so that's probably a case where arguably, we should just ignore the DAX_FL for now.)

ok...

Ira

author
#18 lore raw

Re: [PATCH RFC 3/8] fs/ext4: Disallow encryption if inode is DAX

Quoted 2 lines · Ira Weiny
Quoted 1 line · Theodore Y. Ts'o

On Mon, Apr 13, 2020 at 09:00:25PM -0700, [email protected] wrote:

[snip]

Quoted 7 lines
Quoted 5 lines

Also note that encrypted files are read/write so we must never allow the combination of ENCRPYT_FL and DAX_FL. So that may be something where we should teach __ext4_iget() to check for this, and declare the file system as corrupted if it sees this combination.

ok...

After thinking about this...

Do we really want to declare the FS corrupted?

If so, I think we need to return errors when such a configuration is attempted. If in the future we have an encrypted mode which can co-exist with DAX (such as Dan mentioned) we can change this.

FWIW I think we should return errors when such a configuration is attempted but _not_ declare the FS corrupted. That allows users to enable this configuration later if we can figure out how to support it.

Quoted 7 lines
Quoted 5 lines

(For VERITY_FL
&& DAX_FL that is a combo that we might want to support in the future, so that's probably a case where arguably, we should just ignore the DAX_FL for now.)

ok...

I think this should work the same.

It looks like VERITY_FL and ENCRYPT_FL are _not_ user modifiable? Is that correct?

You said that ENCRPYT_FL is set from the parent directory? But I'm not seeing where that occurs?

Similarly I don't see where VERITY_FL is being set either? :-/

I think to make this work correctly we should restrict setting those flags if DAX_FL is set and vice versa. But I'm not finding where to do that. :-/

Ira

Quoted 3 lines

Ira

#19 lore raw

Re: [PATCH RFC 3/8] fs/ext4: Disallow encryption if inode is DAX

Quoted 12 lines · Ira Weiny
Quoted 2 lines · Ira Weiny
Quoted 1 line · Theodore Y. Ts'o

On Mon, Apr 13, 2020 at 09:00:25PM -0700, [email protected] wrote:

[snip]

Quoted 6 lines
Quoted 5 lines

Also note that encrypted files are read/write so we must never allow the combination of ENCRPYT_FL and DAX_FL. So that may be something where we should teach __ext4_iget() to check for this, and declare the file system as corrupted if it sees this combination.

Quoted 5 lines
Quoted 1 line

ok...

After thinking about this...

Do we really want to declare the FS corrupted?

Seeing as we're defining the dax inode flag to be advisory (since its value is ignored if the fs isn't on pmem, or the administrator overrode with dax=never mount option), I don't see why that's filesystem corruption.

I can see a case for returning errors if you're trying to change ENCRYPT or VERITY on a file that's has S_DAX set. We can't encrypt or set verity data for a file that could be changed behind our backs, so the kernel cannot satisfy /that/ request.

As for changing FS_DAX_FL on an encrypted/verity'd file, the API says that it might not have an immedate effect on S_DAX and that programs have to check S_DAX after changing FS_DAX_FL. It'll never result in S_DAX being set, but the current spec never guarantees that. ;)

(If FS_DAX_FL were *mandatory* then yes that would be corruption.)

--D

Quoted 34 lines

If so, I think we need to return errors when such a configuration is attempted. If in the future we have an encrypted mode which can co-exist with DAX (such as Dan mentioned) we can change this.

FWIW I think we should return errors when such a configuration is attempted but _not_ declare the FS corrupted. That allows users to enable this configuration later if we can figure out how to support it.

Quoted 7 lines
Quoted 5 lines

(For VERITY_FL
&& DAX_FL that is a combo that we might want to support in the future, so that's probably a case where arguably, we should just ignore the DAX_FL for now.)

ok...

I think this should work the same.

It looks like VERITY_FL and ENCRYPT_FL are _not_ user modifiable? Is that correct?

You said that ENCRPYT_FL is set from the parent directory? But I'm not seeing where that occurs?

Similarly I don't see where VERITY_FL is being set either? :-/

I think to make this work correctly we should restrict setting those flags if DAX_FL is set and vice versa. But I'm not finding where to do that. :-/

Ira

Quoted 3 lines

Ira

#20 lore raw

RFC PATCH 4/8 fs/ext4: Introduce DAX inode flag

In reply to [email protected]

From: Ira Weiny <[email protected]>

Add a flag to preserve FS_XFLAG_DAX in the ext4 inode.

Set the flag to be user visible and changeable. Set the flag to be inherited. Allow applications to change the flag at any time.

Finally, on regular files, flag the inode to not be cached to facilitate changing S_DAX on the next creation of the inode.

---
 fs/ext4/ext4.h  | 13 +++++++++----
 fs/ext4/ioctl.c | 21 ++++++++++++++++++++-
 2 files changed, 29 insertions(+), 5 deletions(-)
fs/ext4/ext4.h +9 -4
index 61b37a052052..434021fcec88 100644
@@ -415,13 +415,16 @@ struct flex_groups {
 #define EXT4_VERITY_FL			0x00100000 /* Verity protected inode */
 #define EXT4_EA_INODE_FL	        0x00200000 /* Inode used for large EA */
 #define EXT4_EOFBLOCKS_FL		0x00400000 /* Blocks allocated beyond EOF */
+
+#define EXT4_DAX_FL			0x00800000 /* Inode is DAX */
+
 #define EXT4_INLINE_DATA_FL		0x10000000 /* Inode has inline data. */
 #define EXT4_PROJINHERIT_FL		0x20000000 /* Create with parents projid */
 #define EXT4_CASEFOLD_FL		0x40000000 /* Casefolded file */
 #define EXT4_RESERVED_FL		0x80000000 /* reserved for ext4 lib */
 
-#define EXT4_FL_USER_VISIBLE		0x705BDFFF /* User visible flags */
-#define EXT4_FL_USER_MODIFIABLE		0x604BC0FF /* User modifiable flags */
+#define EXT4_FL_USER_VISIBLE		0x70DBDFFF /* User visible flags */
+#define EXT4_FL_USER_MODIFIABLE		0x60CBC0FF /* User modifiable flags */
 
 /* Flags we can manipulate with through EXT4_IOC_FSSETXATTR */
 #define EXT4_FL_XFLAG_VISIBLE		(EXT4_SYNC_FL | \
@@ -429,14 +432,16 @@ struct flex_groups {
 					 EXT4_APPEND_FL | \
 					 EXT4_NODUMP_FL | \
 					 EXT4_NOATIME_FL | \
-					 EXT4_PROJINHERIT_FL)
+					 EXT4_PROJINHERIT_FL | \
+					 EXT4_DAX_FL)
 
 /* Flags that should be inherited by new inodes from their parent. */
 #define EXT4_FL_INHERITED (EXT4_SECRM_FL | EXT4_UNRM_FL | EXT4_COMPR_FL |\
 			   EXT4_SYNC_FL | EXT4_NODUMP_FL | EXT4_NOATIME_FL |\
 			   EXT4_NOCOMPR_FL | EXT4_JOURNAL_DATA_FL |\
 			   EXT4_NOTAIL_FL | EXT4_DIRSYNC_FL |\
-			   EXT4_PROJINHERIT_FL | EXT4_CASEFOLD_FL)
+			   EXT4_PROJINHERIT_FL | EXT4_CASEFOLD_FL |\
+			   EXT4_DAX_FL)
 
 /* Flags that are appropriate for regular files (all but dir-specific ones). */
 #define EXT4_REG_FLMASK (~(EXT4_DIRSYNC_FL | EXT4_TOPDIR_FL | EXT4_CASEFOLD_FL |\
fs/ext4/ioctl.c +20 -1
index ee3401a32e79..ca07d5086f03 100644
@@ -539,12 +539,15 @@ static inline __u32 ext4_iflags_to_xflags(unsigned long iflags)
 		xflags |= FS_XFLAG_NOATIME;
 	if (iflags & EXT4_PROJINHERIT_FL)
 		xflags |= FS_XFLAG_PROJINHERIT;
+	if (iflags & EXT4_DAX_FL)
+		xflags |= FS_XFLAG_DAX;
 	return xflags;
 }
 
 #define EXT4_SUPPORTED_FS_XFLAGS (FS_XFLAG_SYNC | FS_XFLAG_IMMUTABLE | \
 				  FS_XFLAG_APPEND | FS_XFLAG_NODUMP | \
-				  FS_XFLAG_NOATIME | FS_XFLAG_PROJINHERIT)
+				  FS_XFLAG_NOATIME | FS_XFLAG_PROJINHERIT | \
+				  FS_XFLAG_DAX)
 
 /* Transfer xflags flags to internal */
 static inline unsigned long ext4_xflags_to_iflags(__u32 xflags)
@@ -563,6 +566,8 @@ static inline unsigned long ext4_xflags_to_iflags(__u32 xflags)
 		iflags |= EXT4_NOATIME_FL;
 	if (xflags & FS_XFLAG_PROJINHERIT)
 		iflags |= EXT4_PROJINHERIT_FL;
+	if (xflags & FS_XFLAG_DAX)
+		iflags |= EXT4_DAX_FL;
 
 	return iflags;
 }
@@ -813,6 +818,17 @@ static int ext4_ioctl_get_es_cache(struct file *filp, unsigned long arg)
 	return error;
 }
 
+static void ext4_dax_dontcache(struct inode *inode, unsigned int flags)
+{
+	struct ext4_inode_info *ei = EXT4_I(inode);
+
+	if (S_ISDIR(inode->i_mode))
+		return;
+
+	if ((ei->i_flags ^ flags) == EXT4_DAX_FL)
+		inode->i_state |= I_DONTCACHE;
+}
+
 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
 	struct inode *inode = file_inode(filp);
@@ -1273,6 +1289,9 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 			return err;
 
 		inode_lock(inode);
+
+		ext4_dax_dontcache(inode, flags);
+
 		ext4_fill_fsxattr(inode, &old_fa);
 		err = vfs_ioc_fssetxattr_check(inode, &old_fa, &fa);
 		if (err)
Signature · 1 line
2.25.1
reviewer
#21 lore raw

Re: [PATCH RFC 4/8] fs/ext4: Introduce DAX inode flag

Quoted 21 lines · On Mon 13-04-20 21:00:26, [email protected] wrote:

From: Ira Weiny <[email protected]>

Add a flag to preserve FS_XFLAG_DAX in the ext4 inode.

Set the flag to be user visible and changeable. Set the flag to be inherited. Allow applications to change the flag at any time.

Finally, on regular files, flag the inode to not be cached to facilitate changing S_DAX on the next creation of the inode.

---
 fs/ext4/ext4.h  | 13 +++++++++----
 fs/ext4/ioctl.c | 21 ++++++++++++++++++++-
 2 files changed, 29 insertions(+), 5 deletions(-)
fs/ext4/ext4.h +0 -0
index 61b37a052052..434021fcec88 100644

fs/ext4/ext4.h struct flex_groups { · line 420

Quoted 6 lines
fs/ext4/ext4.h +3 -0
@@ -415,13 +415,16 @@ struct flex_groups {
 #define EXT4_VERITY_FL			0x00100000 /* Verity protected inode */
 #define EXT4_EA_INODE_FL	        0x00200000 /* Inode used for large EA */
 #define EXT4_EOFBLOCKS_FL		0x00400000 /* Blocks allocated beyond EOF */
+
+#define EXT4_DAX_FL			0x00800000 /* Inode is DAX */
+

You seem to be using somewhat older kernel... EXT4_EOFBLOCKS_FL doesn't exist anymore (but still it's good to leave it reserved for some time so the value you've chosen is OK).

Quoted 5 lines
fs/ext4/ext4.h +1 -0
@@ -813,6 +818,17 @@ static int ext4_ioctl_get_es_cache(struct file *filp, unsigned long arg)
 	return error;
 }
 
+static void ext4_dax_dontcache(struct inode *inode, unsigned int flags)

fs/ext4/ext4.h static int ext4_ioctl_get_es_cache(struct file *filp, unsigned long arg) · line 831

Quoted 10 lines
fs/ext4/ext4.h +10 -0
+{
+	struct ext4_inode_info *ei = EXT4_I(inode);
+
+	if (S_ISDIR(inode->i_mode))
+		return;
+
+	if ((ei->i_flags ^ flags) == EXT4_DAX_FL)
+		inode->i_state |= I_DONTCACHE;
+}
+

You probably want to use the function you've introduced in the XFS series here...

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author
#22 lore raw

Re: [PATCH RFC 4/8] fs/ext4: Introduce DAX inode flag

Quoted 17 lines · Jan Kara
Quoted 16 lines · On Mon 13-04-20 21:00:26, [email protected] wrote:

From: Ira Weiny <[email protected]>

Add a flag to preserve FS_XFLAG_DAX in the ext4 inode.

Set the flag to be user visible and changeable. Set the flag to be inherited. Allow applications to change the flag at any time.

Finally, on regular files, flag the inode to not be cached to facilitate changing S_DAX on the next creation of the inode.

---
 fs/ext4/ext4.h  | 13 +++++++++----
 fs/ext4/ioctl.c | 21 ++++++++++++++++++++-
 2 files changed, 29 insertions(+), 5 deletions(-)
Quoted 15 lines

fs/ext4/ext4.h struct flex_groups { · line 420

Quoted 11 lines
fs/ext4/ext4.h +3 -0
index 61b37a052052..434021fcec88 100644
@@ -415,13 +415,16 @@ struct flex_groups {
 #define EXT4_VERITY_FL			0x00100000 /* Verity protected inode */
 #define EXT4_EA_INODE_FL	        0x00200000 /* Inode used for large EA */
 #define EXT4_EOFBLOCKS_FL		0x00400000 /* Blocks allocated beyond EOF */
+
+#define EXT4_DAX_FL			0x00800000 /* Inode is DAX */
+

You seem to be using somewhat older kernel... EXT4_EOFBLOCKS_FL doesn't exist anymore (but still it's good to leave it reserved for some time so the value you've chosen is OK).

I'm on top of 5.6 released. Did this get removed for 5.7? I've heard there are some boot issues with 5.7-rc1 so I'm holding out for rc2.

Quoted 5 lines
Quoted 5 lines
fs/ext4/ext4.h +0 -0
@@ -813,6 +818,17 @@ static int ext4_ioctl_get_es_cache(struct file *filp, unsigned long arg)
 	return error;
 }
 
Quoted 14 lines

fs/ext4/ext4.h static int ext4_ioctl_get_es_cache(struct file *filp, unsigned long arg) · line 831

Quoted 11 lines
fs/ext4/ext4.h +11 -0
+static void ext4_dax_dontcache(struct inode *inode, unsigned int flags)
+{
+	struct ext4_inode_info *ei = EXT4_I(inode);
+
+	if (S_ISDIR(inode->i_mode))
+		return;
+
+	if ((ei->i_flags ^ flags) == EXT4_DAX_FL)
+		inode->i_state |= I_DONTCACHE;
+}
+

You probably want to use the function you've introduced in the XFS series here...

you mean:

flag_inode_dontcache()
???

Yes that is done. I sent this prior to v8 (where that was added) of the other series...

Ira

Quoted 5 lines

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
reviewer
#23 lore raw

Re: [PATCH RFC 4/8] fs/ext4: Introduce DAX inode flag

Quoted 19 lines · Ira Weiny
Quoted 4 lines
Quoted 4 lines
fs/ext4/ioctl.c +0 -0
@@ -813,6 +818,17 @@ static int ext4_ioctl_get_es_cache(struct file *filp, unsigned long arg)
 	return error;
 }
 
Quoted 14 lines

fs/ext4/ioctl.c static int ext4_ioctl_get_es_cache(struct file *filp, unsigned long arg) · line 831

Quoted 11 lines
fs/ext4/ioctl.c +11 -0
+static void ext4_dax_dontcache(struct inode *inode, unsigned int flags)
+{
+	struct ext4_inode_info *ei = EXT4_I(inode);
+
+	if (S_ISDIR(inode->i_mode))
+		return;
+
+	if ((ei->i_flags ^ flags) == EXT4_DAX_FL)
+		inode->i_state |= I_DONTCACHE;
+}
+

You probably want to use the function you've introduced in the XFS series here...

Quoted 4 lines

you mean:

flag_inode_dontcache()
???

Yeah, that's what I meant.

Quoted 2 lines

Yes that is done. I sent this prior to v8 (where that was added) of the other series...

Yep, I thought that was the case but I wanted to mention it as a reminder.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer
#24 lore raw

Re: [PATCH RFC 4/8] fs/ext4: Introduce DAX inode flag

In reply to Ira Weiny
Quoted 3 lines · Ira Weiny

I'm on top of 5.6 released. Did this get removed for 5.7? I've heard there are some boot issues with 5.7-rc1 so I'm holding out for rc2.

Yes, it got removed in 5.7-rc1 in commit 4337ecd1fe99.

The boot issues with 5.7-rc1 is why ext4.git tree is now based off of v5.7-rc1-35-g00086336a8d9: Merge tag 'efi-urgent-2020-04-15'....

You might want to see if 00086336a8d9 works for you (and if not, let the x86 and/or efi folks know).

- Ted

#25 lore raw

Re: [PATCH RFC 4/8] fs/ext4: Introduce DAX inode flag

In reply to [email protected]
Quoted 21 lines · On Mon, Apr 13, 2020 at 09:00:26PM -0700, [email protected] wrote:

From: Ira Weiny <[email protected]>

Add a flag to preserve FS_XFLAG_DAX in the ext4 inode.

Set the flag to be user visible and changeable. Set the flag to be inherited. Allow applications to change the flag at any time.

Finally, on regular files, flag the inode to not be cached to facilitate changing S_DAX on the next creation of the inode.

---
 fs/ext4/ext4.h  | 13 +++++++++----
 fs/ext4/ioctl.c | 21 ++++++++++++++++++++-
 2 files changed, 29 insertions(+), 5 deletions(-)
fs/ext4/ext4.h +0 -0
index 61b37a052052..434021fcec88 100644

fs/ext4/ext4.h struct flex_groups { · line 419

Quoted 5 lines
fs/ext4/ext4.h +2 -0
@@ -415,13 +415,16 @@ struct flex_groups {
 #define EXT4_VERITY_FL			0x00100000 /* Verity protected inode */
 #define EXT4_EA_INODE_FL	        0x00200000 /* Inode used for large EA */
 #define EXT4_EOFBLOCKS_FL		0x00400000 /* Blocks allocated beyond EOF */
+
+#define EXT4_DAX_FL			0x00800000 /* Inode is DAX */

Sooo, fun fact about ext4 vs. the world--

The GETFLAGS/SETFLAGS ioctl, since it came from ext2, shares the same flag values as the ondisk inode flags in ext*. Therefore, each of these EXT4_[whatever]_FL values are supposed to have a FS_[whatever]_FL equivalent in include/uapi/linux/fs.h.

(Note that the "[whatever]" is a straight translation since the same uapi header also defines the FS_XFLAG_[xfswhatever] flag values; ignore those.)

Evidently, FS_NOCOW_FL already took 0x800000, but ext4.h was never updated to note that the value was taken. I think Ted might be inclined to reserve the ondisk inode bit just in case ext4 ever does support copy on write, though that's his call. :)

Long story short - can you use 0x1000000 for this instead, and add the corresponding value to the uapi fs.h? I guess that also means that we can change FS_XFLAG_DAX (in the form of FS_DAX_FL in FSSETFLAGS) after that.

--D

Quoted 93 lines
fs/ext4/ext4.h +7 -4
+
 #define EXT4_INLINE_DATA_FL		0x10000000 /* Inode has inline data. */
 #define EXT4_PROJINHERIT_FL		0x20000000 /* Create with parents projid */
 #define EXT4_CASEFOLD_FL		0x40000000 /* Casefolded file */
 #define EXT4_RESERVED_FL		0x80000000 /* reserved for ext4 lib */
 
-#define EXT4_FL_USER_VISIBLE		0x705BDFFF /* User visible flags */
-#define EXT4_FL_USER_MODIFIABLE		0x604BC0FF /* User modifiable flags */
+#define EXT4_FL_USER_VISIBLE		0x70DBDFFF /* User visible flags */
+#define EXT4_FL_USER_MODIFIABLE		0x60CBC0FF /* User modifiable flags */
 
 /* Flags we can manipulate with through EXT4_IOC_FSSETXATTR */
 #define EXT4_FL_XFLAG_VISIBLE		(EXT4_SYNC_FL | \
@@ -429,14 +432,16 @@ struct flex_groups {
 					 EXT4_APPEND_FL | \
 					 EXT4_NODUMP_FL | \
 					 EXT4_NOATIME_FL | \
-					 EXT4_PROJINHERIT_FL)
+					 EXT4_PROJINHERIT_FL | \
+					 EXT4_DAX_FL)
 
 /* Flags that should be inherited by new inodes from their parent. */
 #define EXT4_FL_INHERITED (EXT4_SECRM_FL | EXT4_UNRM_FL | EXT4_COMPR_FL |\
 			   EXT4_SYNC_FL | EXT4_NODUMP_FL | EXT4_NOATIME_FL |\
 			   EXT4_NOCOMPR_FL | EXT4_JOURNAL_DATA_FL |\
 			   EXT4_NOTAIL_FL | EXT4_DIRSYNC_FL |\
-			   EXT4_PROJINHERIT_FL | EXT4_CASEFOLD_FL)
+			   EXT4_PROJINHERIT_FL | EXT4_CASEFOLD_FL |\
+			   EXT4_DAX_FL)
 
 /* Flags that are appropriate for regular files (all but dir-specific ones). */
 #define EXT4_REG_FLMASK (~(EXT4_DIRSYNC_FL | EXT4_TOPDIR_FL | EXT4_CASEFOLD_FL |\
fs/ext4/ioctl.c +20 -1
index ee3401a32e79..ca07d5086f03 100644
@@ -539,12 +539,15 @@ static inline __u32 ext4_iflags_to_xflags(unsigned long iflags)
 		xflags |= FS_XFLAG_NOATIME;
 	if (iflags & EXT4_PROJINHERIT_FL)
 		xflags |= FS_XFLAG_PROJINHERIT;
+	if (iflags & EXT4_DAX_FL)
+		xflags |= FS_XFLAG_DAX;
 	return xflags;
 }
 
 #define EXT4_SUPPORTED_FS_XFLAGS (FS_XFLAG_SYNC | FS_XFLAG_IMMUTABLE | \
 				  FS_XFLAG_APPEND | FS_XFLAG_NODUMP | \
-				  FS_XFLAG_NOATIME | FS_XFLAG_PROJINHERIT)
+				  FS_XFLAG_NOATIME | FS_XFLAG_PROJINHERIT | \
+				  FS_XFLAG_DAX)
 
 /* Transfer xflags flags to internal */
 static inline unsigned long ext4_xflags_to_iflags(__u32 xflags)
@@ -563,6 +566,8 @@ static inline unsigned long ext4_xflags_to_iflags(__u32 xflags)
 		iflags |= EXT4_NOATIME_FL;
 	if (xflags & FS_XFLAG_PROJINHERIT)
 		iflags |= EXT4_PROJINHERIT_FL;
+	if (xflags & FS_XFLAG_DAX)
+		iflags |= EXT4_DAX_FL;
 
 	return iflags;
 }
@@ -813,6 +818,17 @@ static int ext4_ioctl_get_es_cache(struct file *filp, unsigned long arg)
 	return error;
 }
 
+static void ext4_dax_dontcache(struct inode *inode, unsigned int flags)
+{
+	struct ext4_inode_info *ei = EXT4_I(inode);
+
+	if (S_ISDIR(inode->i_mode))
+		return;
+
+	if ((ei->i_flags ^ flags) == EXT4_DAX_FL)
+		inode->i_state |= I_DONTCACHE;
+}
+
 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
 	struct inode *inode = file_inode(filp);
@@ -1273,6 +1289,9 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 			return err;
 
 		inode_lock(inode);
+
+		ext4_dax_dontcache(inode, flags);
+
 		ext4_fill_fsxattr(inode, &old_fa);
 		err = vfs_ioc_fssetxattr_check(inode, &old_fa, &fa);
 		if (err)
Signature · 1 line
2.25.1
author
#26 lore raw

Re: [PATCH RFC 4/8] fs/ext4: Introduce DAX inode flag

Quoted 30 lines · Darrick J. Wong
Quoted 21 lines · On Mon, Apr 13, 2020 at 09:00:26PM -0700, [email protected] wrote:

From: Ira Weiny <[email protected]>

Add a flag to preserve FS_XFLAG_DAX in the ext4 inode.

Set the flag to be user visible and changeable. Set the flag to be inherited. Allow applications to change the flag at any time.

Finally, on regular files, flag the inode to not be cached to facilitate changing S_DAX on the next creation of the inode.

---
 fs/ext4/ext4.h  | 13 +++++++++----
 fs/ext4/ioctl.c | 21 ++++++++++++++++++++-
 2 files changed, 29 insertions(+), 5 deletions(-)
fs/ext4/ext4.h +0 -0
index 61b37a052052..434021fcec88 100644

fs/ext4/ext4.h struct flex_groups { · line 419

Quoted 5 lines
fs/ext4/ext4.h +2 -0
@@ -415,13 +415,16 @@ struct flex_groups {
 #define EXT4_VERITY_FL			0x00100000 /* Verity protected inode */
 #define EXT4_EA_INODE_FL	        0x00200000 /* Inode used for large EA */
 #define EXT4_EOFBLOCKS_FL		0x00400000 /* Blocks allocated beyond EOF */
+
+#define EXT4_DAX_FL			0x00800000 /* Inode is DAX */

Sooo, fun fact about ext4 vs. the world--

Quoted 4 lines

The GETFLAGS/SETFLAGS ioctl, since it came from ext2, shares the same flag values as the ondisk inode flags in ext*. Therefore, each of these EXT4_[whatever]_FL values are supposed to have a FS_[whatever]_FL equivalent in include/uapi/linux/fs.h.

Interesting...

Quoted 9 lines

(Note that the "[whatever]" is a straight translation since the same uapi header also defines the FS_XFLAG_[xfswhatever] flag values; ignore those.)

Evidently, FS_NOCOW_FL already took 0x800000, but ext4.h was never updated to note that the value was taken. I think Ted might be inclined to reserve the ondisk inode bit just in case ext4 ever does support copy on write, though that's his call. :)

Seems like I should change this... And I did not realize I was inherently changing a bit definition which was exposed to other FS's...

Quoted 5 lines

Long story short - can you use 0x1000000 for this instead, and add the corresponding value to the uapi fs.h? I guess that also means that we can change FS_XFLAG_DAX (in the form of FS_DAX_FL in FSSETFLAGS) after that.

:-/

Are there any potential users of FS_XFLAG_DAX now?

From what it looks like, changing FS_XFLAG_DAX to FS_DAX_FL would be pretty straight forward. Just to be sure, looks like XFS converts the FS_[xxx]_FL to FS_XFLAGS_[xxx] in xfs_merge_ioc_xflags()? But it does not look like all the FS_[xxx]_FL flags are converted. Is is that XFS does not support those options? Or is it depending on the VFS layer for some of them?

Ira

Quoted 96 lines

--D

Quoted 93 lines
fs/ext4/ext4.h +7 -4
+
 #define EXT4_INLINE_DATA_FL		0x10000000 /* Inode has inline data. */
 #define EXT4_PROJINHERIT_FL		0x20000000 /* Create with parents projid */
 #define EXT4_CASEFOLD_FL		0x40000000 /* Casefolded file */
 #define EXT4_RESERVED_FL		0x80000000 /* reserved for ext4 lib */
 
-#define EXT4_FL_USER_VISIBLE		0x705BDFFF /* User visible flags */
-#define EXT4_FL_USER_MODIFIABLE		0x604BC0FF /* User modifiable flags */
+#define EXT4_FL_USER_VISIBLE		0x70DBDFFF /* User visible flags */
+#define EXT4_FL_USER_MODIFIABLE		0x60CBC0FF /* User modifiable flags */
 
 /* Flags we can manipulate with through EXT4_IOC_FSSETXATTR */
 #define EXT4_FL_XFLAG_VISIBLE		(EXT4_SYNC_FL | \
@@ -429,14 +432,16 @@ struct flex_groups {
 					 EXT4_APPEND_FL | \
 					 EXT4_NODUMP_FL | \
 					 EXT4_NOATIME_FL | \
-					 EXT4_PROJINHERIT_FL)
+					 EXT4_PROJINHERIT_FL | \
+					 EXT4_DAX_FL)
 
 /* Flags that should be inherited by new inodes from their parent. */
 #define EXT4_FL_INHERITED (EXT4_SECRM_FL | EXT4_UNRM_FL | EXT4_COMPR_FL |\
 			   EXT4_SYNC_FL | EXT4_NODUMP_FL | EXT4_NOATIME_FL |\
 			   EXT4_NOCOMPR_FL | EXT4_JOURNAL_DATA_FL |\
 			   EXT4_NOTAIL_FL | EXT4_DIRSYNC_FL |\
-			   EXT4_PROJINHERIT_FL | EXT4_CASEFOLD_FL)
+			   EXT4_PROJINHERIT_FL | EXT4_CASEFOLD_FL |\
+			   EXT4_DAX_FL)
 
 /* Flags that are appropriate for regular files (all but dir-specific ones). */
 #define EXT4_REG_FLMASK (~(EXT4_DIRSYNC_FL | EXT4_TOPDIR_FL | EXT4_CASEFOLD_FL |\
fs/ext4/ioctl.c +20 -1
index ee3401a32e79..ca07d5086f03 100644
@@ -539,12 +539,15 @@ static inline __u32 ext4_iflags_to_xflags(unsigned long iflags)
 		xflags |= FS_XFLAG_NOATIME;
 	if (iflags & EXT4_PROJINHERIT_FL)
 		xflags |= FS_XFLAG_PROJINHERIT;
+	if (iflags & EXT4_DAX_FL)
+		xflags |= FS_XFLAG_DAX;
 	return xflags;
 }
 
 #define EXT4_SUPPORTED_FS_XFLAGS (FS_XFLAG_SYNC | FS_XFLAG_IMMUTABLE | \
 				  FS_XFLAG_APPEND | FS_XFLAG_NODUMP | \
-				  FS_XFLAG_NOATIME | FS_XFLAG_PROJINHERIT)
+				  FS_XFLAG_NOATIME | FS_XFLAG_PROJINHERIT | \
+				  FS_XFLAG_DAX)
 
 /* Transfer xflags flags to internal */
 static inline unsigned long ext4_xflags_to_iflags(__u32 xflags)
@@ -563,6 +566,8 @@ static inline unsigned long ext4_xflags_to_iflags(__u32 xflags)
 		iflags |= EXT4_NOATIME_FL;
 	if (xflags & FS_XFLAG_PROJINHERIT)
 		iflags |= EXT4_PROJINHERIT_FL;
+	if (xflags & FS_XFLAG_DAX)
+		iflags |= EXT4_DAX_FL;
 
 	return iflags;
 }
@@ -813,6 +818,17 @@ static int ext4_ioctl_get_es_cache(struct file *filp, unsigned long arg)
 	return error;
 }
 
+static void ext4_dax_dontcache(struct inode *inode, unsigned int flags)
+{
+	struct ext4_inode_info *ei = EXT4_I(inode);
+
+	if (S_ISDIR(inode->i_mode))
+		return;
+
+	if ((ei->i_flags ^ flags) == EXT4_DAX_FL)
+		inode->i_state |= I_DONTCACHE;
+}
+
 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
 	struct inode *inode = file_inode(filp);
@@ -1273,6 +1289,9 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 			return err;
 
 		inode_lock(inode);
+
+		ext4_dax_dontcache(inode, flags);
+
 		ext4_fill_fsxattr(inode, &old_fa);
 		err = vfs_ioc_fssetxattr_check(inode, &old_fa, &fa);
 		if (err)
Signature · 1 line
2.25.1
#27 lore raw

Re: [PATCH RFC 4/8] fs/ext4: Introduce DAX inode flag

Quoted 43 lines · Ira Weiny
Quoted 30 lines · Darrick J. Wong
Quoted 21 lines · On Mon, Apr 13, 2020 at 09:00:26PM -0700, [email protected] wrote:

From: Ira Weiny <[email protected]>

Add a flag to preserve FS_XFLAG_DAX in the ext4 inode.

Set the flag to be user visible and changeable. Set the flag to be inherited. Allow applications to change the flag at any time.

Finally, on regular files, flag the inode to not be cached to facilitate changing S_DAX on the next creation of the inode.

---
 fs/ext4/ext4.h  | 13 +++++++++----
 fs/ext4/ioctl.c | 21 ++++++++++++++++++++-
 2 files changed, 29 insertions(+), 5 deletions(-)
fs/ext4/ext4.h +0 -0
index 61b37a052052..434021fcec88 100644

fs/ext4/ext4.h struct flex_groups { · line 419

Quoted 5 lines
fs/ext4/ext4.h +2 -0
@@ -415,13 +415,16 @@ struct flex_groups {
 #define EXT4_VERITY_FL			0x00100000 /* Verity protected inode */
 #define EXT4_EA_INODE_FL	        0x00200000 /* Inode used for large EA */
 #define EXT4_EOFBLOCKS_FL		0x00400000 /* Blocks allocated beyond EOF */
+
+#define EXT4_DAX_FL			0x00800000 /* Inode is DAX */

Sooo, fun fact about ext4 vs. the world--

Quoted 4 lines

The GETFLAGS/SETFLAGS ioctl, since it came from ext2, shares the same flag values as the ondisk inode flags in ext*. Therefore, each of these EXT4_[whatever]_FL values are supposed to have a FS_[whatever]_FL equivalent in include/uapi/linux/fs.h.

Interesting...

Quoted 5 lines

(Note that the "[whatever]" is a straight translation since the same uapi header also defines the FS_XFLAG_[xfswhatever] flag values; ignore those.)

Quoted 7 lines
Quoted 4 lines

Evidently, FS_NOCOW_FL already took 0x800000, but ext4.h was never updated to note that the value was taken. I think Ted might be inclined to reserve the ondisk inode bit just in case ext4 ever does support copy on write, though that's his call. :)

Seems like I should change this... And I did not realize I was inherently changing a bit definition which was exposed to other FS's...

<nod> This whole thing is a mess, particularly now that we have two vfs ioctls to set per-fs inode attributes, both of which were inherited from other filesystems... :(

Quoted 9 lines
Quoted 5 lines

Long story short - can you use 0x1000000 for this instead, and add the corresponding value to the uapi fs.h? I guess that also means that we can change FS_XFLAG_DAX (in the form of FS_DAX_FL in FSSETFLAGS) after that.

:-/

Are there any potential users of FS_XFLAG_DAX now?

Yes, it's in the userspace ABI so we can't get rid of it.

(FWIW there are several flags that exist in both FS_XFLAG_* and FS_*_FL form.)

Quoted 5 lines

From what it looks like, changing FS_XFLAG_DAX to FS_DAX_FL would be pretty straight forward. Just to be sure, looks like XFS converts the FS_[xxx]_FL to FS_XFLAGS_[xxx] in xfs_merge_ioc_xflags()? But it does not look like all the FS_[xxx]_FL flags are converted. Is is that XFS does not support those options? Or is it depending on the VFS layer for some of them?

XFS doesn't support most of the FS_*_FL flags.

--D

Quoted 98 lines

Ira

Quoted 96 lines

--D

Quoted 93 lines
fs/ext4/ext4.h +7 -4
+
 #define EXT4_INLINE_DATA_FL		0x10000000 /* Inode has inline data. */
 #define EXT4_PROJINHERIT_FL		0x20000000 /* Create with parents projid */
 #define EXT4_CASEFOLD_FL		0x40000000 /* Casefolded file */
 #define EXT4_RESERVED_FL		0x80000000 /* reserved for ext4 lib */
 
-#define EXT4_FL_USER_VISIBLE		0x705BDFFF /* User visible flags */
-#define EXT4_FL_USER_MODIFIABLE		0x604BC0FF /* User modifiable flags */
+#define EXT4_FL_USER_VISIBLE		0x70DBDFFF /* User visible flags */
+#define EXT4_FL_USER_MODIFIABLE		0x60CBC0FF /* User modifiable flags */
 
 /* Flags we can manipulate with through EXT4_IOC_FSSETXATTR */
 #define EXT4_FL_XFLAG_VISIBLE		(EXT4_SYNC_FL | \
@@ -429,14 +432,16 @@ struct flex_groups {
 					 EXT4_APPEND_FL | \
 					 EXT4_NODUMP_FL | \
 					 EXT4_NOATIME_FL | \
-					 EXT4_PROJINHERIT_FL)
+					 EXT4_PROJINHERIT_FL | \
+					 EXT4_DAX_FL)
 
 /* Flags that should be inherited by new inodes from their parent. */
 #define EXT4_FL_INHERITED (EXT4_SECRM_FL | EXT4_UNRM_FL | EXT4_COMPR_FL |\
 			   EXT4_SYNC_FL | EXT4_NODUMP_FL | EXT4_NOATIME_FL |\
 			   EXT4_NOCOMPR_FL | EXT4_JOURNAL_DATA_FL |\
 			   EXT4_NOTAIL_FL | EXT4_DIRSYNC_FL |\
-			   EXT4_PROJINHERIT_FL | EXT4_CASEFOLD_FL)
+			   EXT4_PROJINHERIT_FL | EXT4_CASEFOLD_FL |\
+			   EXT4_DAX_FL)
 
 /* Flags that are appropriate for regular files (all but dir-specific ones). */
 #define EXT4_REG_FLMASK (~(EXT4_DIRSYNC_FL | EXT4_TOPDIR_FL | EXT4_CASEFOLD_FL |\
fs/ext4/ioctl.c +20 -1
index ee3401a32e79..ca07d5086f03 100644
@@ -539,12 +539,15 @@ static inline __u32 ext4_iflags_to_xflags(unsigned long iflags)
 		xflags |= FS_XFLAG_NOATIME;
 	if (iflags & EXT4_PROJINHERIT_FL)
 		xflags |= FS_XFLAG_PROJINHERIT;
+	if (iflags & EXT4_DAX_FL)
+		xflags |= FS_XFLAG_DAX;
 	return xflags;
 }
 
 #define EXT4_SUPPORTED_FS_XFLAGS (FS_XFLAG_SYNC | FS_XFLAG_IMMUTABLE | \
 				  FS_XFLAG_APPEND | FS_XFLAG_NODUMP | \
-				  FS_XFLAG_NOATIME | FS_XFLAG_PROJINHERIT)
+				  FS_XFLAG_NOATIME | FS_XFLAG_PROJINHERIT | \
+				  FS_XFLAG_DAX)
 
 /* Transfer xflags flags to internal */
 static inline unsigned long ext4_xflags_to_iflags(__u32 xflags)
@@ -563,6 +566,8 @@ static inline unsigned long ext4_xflags_to_iflags(__u32 xflags)
 		iflags |= EXT4_NOATIME_FL;
 	if (xflags & FS_XFLAG_PROJINHERIT)
 		iflags |= EXT4_PROJINHERIT_FL;
+	if (xflags & FS_XFLAG_DAX)
+		iflags |= EXT4_DAX_FL;
 
 	return iflags;
 }
@@ -813,6 +818,17 @@ static int ext4_ioctl_get_es_cache(struct file *filp, unsigned long arg)
 	return error;
 }
 
+static void ext4_dax_dontcache(struct inode *inode, unsigned int flags)
+{
+	struct ext4_inode_info *ei = EXT4_I(inode);
+
+	if (S_ISDIR(inode->i_mode))
+		return;
+
+	if ((ei->i_flags ^ flags) == EXT4_DAX_FL)
+		inode->i_state |= I_DONTCACHE;
+}
+
 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
 	struct inode *inode = file_inode(filp);
@@ -1273,6 +1289,9 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 			return err;
 
 		inode_lock(inode);
+
+		ext4_dax_dontcache(inode, flags);
+
 		ext4_fill_fsxattr(inode, &old_fa);
 		err = vfs_ioc_fssetxattr_check(inode, &old_fa, &fa);
 		if (err)
Signature · 1 line
2.25.1
author
#28 lore raw

Re: [PATCH RFC 4/8] fs/ext4: Introduce DAX inode flag

Quoted 49 lines · Darrick J. Wong
Quoted 48 lines · Ira Weiny
Quoted 30 lines · Darrick J. Wong
Quoted 21 lines · On Mon, Apr 13, 2020 at 09:00:26PM -0700, [email protected] wrote:

From: Ira Weiny <[email protected]>

Add a flag to preserve FS_XFLAG_DAX in the ext4 inode.

Set the flag to be user visible and changeable. Set the flag to be inherited. Allow applications to change the flag at any time.

Finally, on regular files, flag the inode to not be cached to facilitate changing S_DAX on the next creation of the inode.

---
 fs/ext4/ext4.h  | 13 +++++++++----
 fs/ext4/ioctl.c | 21 ++++++++++++++++++++-
 2 files changed, 29 insertions(+), 5 deletions(-)
fs/ext4/ext4.h +0 -0
index 61b37a052052..434021fcec88 100644

fs/ext4/ext4.h struct flex_groups { · line 419

Quoted 5 lines
fs/ext4/ext4.h +2 -0
@@ -415,13 +415,16 @@ struct flex_groups {
 #define EXT4_VERITY_FL			0x00100000 /* Verity protected inode */
 #define EXT4_EA_INODE_FL	        0x00200000 /* Inode used for large EA */
 #define EXT4_EOFBLOCKS_FL		0x00400000 /* Blocks allocated beyond EOF */
+
+#define EXT4_DAX_FL			0x00800000 /* Inode is DAX */

Sooo, fun fact about ext4 vs. the world--

Quoted 4 lines

The GETFLAGS/SETFLAGS ioctl, since it came from ext2, shares the same flag values as the ondisk inode flags in ext*. Therefore, each of these EXT4_[whatever]_FL values are supposed to have a FS_[whatever]_FL equivalent in include/uapi/linux/fs.h.

Interesting...

Quoted 9 lines

(Note that the "[whatever]" is a straight translation since the same uapi header also defines the FS_XFLAG_[xfswhatever] flag values; ignore those.)

Evidently, FS_NOCOW_FL already took 0x800000, but ext4.h was never updated to note that the value was taken. I think Ted might be inclined to reserve the ondisk inode bit just in case ext4 ever does support copy on write, though that's his call. :)

Quoted 7 lines
Quoted 2 lines

Seems like I should change this... And I did not realize I was inherently changing a bit definition which was exposed to other FS's...

<nod> This whole thing is a mess, particularly now that we have two vfs ioctls to set per-fs inode attributes, both of which were inherited from other filesystems... :(

Ok I've changed it.

Quoted 16 lines
Quoted 10 lines
Quoted 6 lines

Long story short - can you use 0x1000000 for this instead, and add the corresponding value to the uapi fs.h? I guess that also means that we can change FS_XFLAG_DAX (in the form of FS_DAX_FL in FSSETFLAGS) after that.

:-/

Are there any potential users of FS_XFLAG_DAX now?

Yes, it's in the userspace ABI so we can't get rid of it.

(FWIW there are several flags that exist in both FS_XFLAG_* and FS_*_FL form.)

Quoted 7 lines
Quoted 5 lines

From what it looks like, changing FS_XFLAG_DAX to FS_DAX_FL would be pretty straight forward. Just to be sure, looks like XFS converts the FS_[xxx]_FL to FS_XFLAGS_[xxx] in xfs_merge_ioc_xflags()? But it does not look like all the FS_[xxx]_FL flags are converted. Is is that XFS does not support those options? Or is it depending on the VFS layer for some of them?

XFS doesn't support most of the FS_*_FL flags.

If FS_XFLAG_DAX needs to continue to be user visible I think we need to keep that flag and we should not expose the EXT4_DAX_FL flag...

I think that works for XFS.

But for ext4 it looks like EXT4_FL_XFLAG_VISIBLE was intended to be used for [GET|SET]XATTR where EXT4_FL_USER_VISIBLE was intended to for [GET|SET]FLAGS... But if I don't add EXT4_DAX_FL in EXT4_FL_XFLAG_VISIBLE my test fails.

I've been playing with the flags and looking at the code and I _thought_ the following patch would ensure that FS_XFLAG_DAX is the only one visible but for some reason FS_XFLAG_DAX can't be set with this patch. I still need the EXT4_FL_USER_VISIBLE mask altered... Which I believe would expose EXT4_DAX_FL directly as well.

Jan, Ted? Any ideas? Or should we expose EXT4_DAX_FL and FS_XFLAG_DAX in ext4?

Ira

fs/ext4/ext4.h +1 -1
index fb7e66089a74..c3823f057755 100644
@@ -423,7 +423,7 @@ struct flex_groups {
 #define EXT4_CASEFOLD_FL               0x40000000 /* Casefolded file */
 #define EXT4_RESERVED_FL               0x80000000 /* reserved for ext4 lib */
 
-#define EXT4_FL_USER_VISIBLE           0x715BDFFF /* User visible flags */
+#define EXT4_FL_USER_VISIBLE           0x705BDFFF /* User visible flags */
 #define EXT4_FL_USER_MODIFIABLE                0x614BC0FF /* User modifiable flags */
 
 /* Flags we can manipulate with through EXT4_IOC_FSSETXATTR */
fs/ext4/ioctl.c +2 -2
index b3c6e891185e..8bd0d3f9ca0b 100644
@@ -744,8 +744,8 @@ static void ext4_fill_fsxattr(struct inode *inode, struct fsxattr *fa)
 {
        struct ext4_inode_info *ei = EXT4_I(inode);
 
-       simple_fill_fsxattr(fa, ext4_iflags_to_xflags(ei->i_flags &
-                                                     EXT4_FL_USER_VISIBLE));
+       simple_fill_fsxattr(fa, (ext4_iflags_to_xflags(ei->i_flags) &
+                                                     EXT4_FL_XFLAG_VISIBLE));
 
        if (ext4_has_feature_project(inode->i_sb))
                fa->fsx_projid = from_kprojid(&init_user_ns, ei->i_projid);
#29 lore raw

Re: [PATCH RFC 4/8] fs/ext4: Introduce DAX inode flag

Quoted 93 lines · Ira Weiny
Quoted 49 lines · Darrick J. Wong
Quoted 48 lines · Ira Weiny
Quoted 30 lines · Darrick J. Wong
Quoted 21 lines · On Mon, Apr 13, 2020 at 09:00:26PM -0700, [email protected] wrote:

From: Ira Weiny <[email protected]>

Add a flag to preserve FS_XFLAG_DAX in the ext4 inode.

Set the flag to be user visible and changeable. Set the flag to be inherited. Allow applications to change the flag at any time.

Finally, on regular files, flag the inode to not be cached to facilitate changing S_DAX on the next creation of the inode.

---
 fs/ext4/ext4.h  | 13 +++++++++----
 fs/ext4/ioctl.c | 21 ++++++++++++++++++++-
 2 files changed, 29 insertions(+), 5 deletions(-)
fs/ext4/ext4.h +0 -0
index 61b37a052052..434021fcec88 100644

fs/ext4/ext4.h struct flex_groups { · line 419

Quoted 5 lines
fs/ext4/ext4.h +2 -0
@@ -415,13 +415,16 @@ struct flex_groups {
 #define EXT4_VERITY_FL			0x00100000 /* Verity protected inode */
 #define EXT4_EA_INODE_FL	        0x00200000 /* Inode used for large EA */
 #define EXT4_EOFBLOCKS_FL		0x00400000 /* Blocks allocated beyond EOF */
+
+#define EXT4_DAX_FL			0x00800000 /* Inode is DAX */

Sooo, fun fact about ext4 vs. the world--

Quoted 4 lines

The GETFLAGS/SETFLAGS ioctl, since it came from ext2, shares the same flag values as the ondisk inode flags in ext*. Therefore, each of these EXT4_[whatever]_FL values are supposed to have a FS_[whatever]_FL equivalent in include/uapi/linux/fs.h.

Interesting...

Quoted 9 lines

(Note that the "[whatever]" is a straight translation since the same uapi header also defines the FS_XFLAG_[xfswhatever] flag values; ignore those.)

Evidently, FS_NOCOW_FL already took 0x800000, but ext4.h was never updated to note that the value was taken. I think Ted might be inclined to reserve the ondisk inode bit just in case ext4 ever does support copy on write, though that's his call. :)

Quoted 7 lines
Quoted 2 lines

Seems like I should change this... And I did not realize I was inherently changing a bit definition which was exposed to other FS's...

<nod> This whole thing is a mess, particularly now that we have two vfs ioctls to set per-fs inode attributes, both of which were inherited from other filesystems... :(

Ok I've changed it.

Quoted 16 lines
Quoted 10 lines
Quoted 6 lines

Long story short - can you use 0x1000000 for this instead, and add the corresponding value to the uapi fs.h? I guess that also means that we can change FS_XFLAG_DAX (in the form of FS_DAX_FL in FSSETFLAGS) after that.

:-/

Are there any potential users of FS_XFLAG_DAX now?

Yes, it's in the userspace ABI so we can't get rid of it.

(FWIW there are several flags that exist in both FS_XFLAG_* and FS_*_FL form.)

Quoted 7 lines
Quoted 5 lines

From what it looks like, changing FS_XFLAG_DAX to FS_DAX_FL would be pretty straight forward. Just to be sure, looks like XFS converts the FS_[xxx]_FL to FS_XFLAGS_[xxx] in xfs_merge_ioc_xflags()? But it does not look like all the FS_[xxx]_FL flags are converted. Is is that XFS does not support those options? Or is it depending on the VFS layer for some of them?

XFS doesn't support most of the FS_*_FL flags.

If FS_XFLAG_DAX needs to continue to be user visible I think we need to keep that flag and we should not expose the EXT4_DAX_FL flag...

I think that works for XFS.

But for ext4 it looks like EXT4_FL_XFLAG_VISIBLE was intended to be used for [GET|SET]XATTR where EXT4_FL_USER_VISIBLE was intended to for [GET|SET]FLAGS... But if I don't add EXT4_DAX_FL in EXT4_FL_XFLAG_VISIBLE my test fails.

Quoted 8 lines

I've been playing with the flags and looking at the code and I _thought_ the following patch would ensure that FS_XFLAG_DAX is the only one visible but for some reason FS_XFLAG_DAX can't be set with this patch. I still need the EXT4_FL_USER_VISIBLE mask altered... Which I believe would expose EXT4_DAX_FL directly as well.

Jan, Ted? Any ideas? Or should we expose EXT4_DAX_FL and FS_XFLAG_DAX in ext4?

Both flags should be exposed through their respective ioctl interfaces in both filesystems. That way we don't have to add even more verbiage to the documentation to instruct userspace programmers on how to special case ext4 and XFS for the same piece of functionality.

--D

Quoted 30 lines

Ira

fs/ext4/ext4.h +1 -1
index fb7e66089a74..c3823f057755 100644
@@ -423,7 +423,7 @@ struct flex_groups {
 #define EXT4_CASEFOLD_FL               0x40000000 /* Casefolded file */
 #define EXT4_RESERVED_FL               0x80000000 /* reserved for ext4 lib */
 
-#define EXT4_FL_USER_VISIBLE           0x715BDFFF /* User visible flags */
+#define EXT4_FL_USER_VISIBLE           0x705BDFFF /* User visible flags */
 #define EXT4_FL_USER_MODIFIABLE                0x614BC0FF /* User modifiable flags */
 
 /* Flags we can manipulate with through EXT4_IOC_FSSETXATTR */
fs/ext4/ioctl.c +2 -2
index b3c6e891185e..8bd0d3f9ca0b 100644
@@ -744,8 +744,8 @@ static void ext4_fill_fsxattr(struct inode *inode, struct fsxattr *fa)
 {
        struct ext4_inode_info *ei = EXT4_I(inode);
 
-       simple_fill_fsxattr(fa, ext4_iflags_to_xflags(ei->i_flags &
-                                                     EXT4_FL_USER_VISIBLE));
+       simple_fill_fsxattr(fa, (ext4_iflags_to_xflags(ei->i_flags) &
+                                                     EXT4_FL_XFLAG_VISIBLE));
 
        if (ext4_has_feature_project(inode->i_sb))
                fa->fsx_projid = from_kprojid(&init_user_ns, ei->i_projid);
author
#30 lore raw

Re: [PATCH RFC 4/8] fs/ext4: Introduce DAX inode flag

Quoted 100 lines · Darrick J. Wong
Quoted 99 lines · Ira Weiny
Quoted 49 lines · Darrick J. Wong
Quoted 48 lines · Ira Weiny
Quoted 30 lines · Darrick J. Wong
Quoted 21 lines · On Mon, Apr 13, 2020 at 09:00:26PM -0700, [email protected] wrote:

From: Ira Weiny <[email protected]>

Add a flag to preserve FS_XFLAG_DAX in the ext4 inode.

Set the flag to be user visible and changeable. Set the flag to be inherited. Allow applications to change the flag at any time.

Finally, on regular files, flag the inode to not be cached to facilitate changing S_DAX on the next creation of the inode.

---
 fs/ext4/ext4.h  | 13 +++++++++----
 fs/ext4/ioctl.c | 21 ++++++++++++++++++++-
 2 files changed, 29 insertions(+), 5 deletions(-)
fs/ext4/ext4.h +0 -0
index 61b37a052052..434021fcec88 100644

fs/ext4/ext4.h struct flex_groups { · line 419

Quoted 5 lines
fs/ext4/ext4.h +2 -0
@@ -415,13 +415,16 @@ struct flex_groups {
 #define EXT4_VERITY_FL			0x00100000 /* Verity protected inode */
 #define EXT4_EA_INODE_FL	        0x00200000 /* Inode used for large EA */
 #define EXT4_EOFBLOCKS_FL		0x00400000 /* Blocks allocated beyond EOF */
+
+#define EXT4_DAX_FL			0x00800000 /* Inode is DAX */

Sooo, fun fact about ext4 vs. the world--

Quoted 4 lines

The GETFLAGS/SETFLAGS ioctl, since it came from ext2, shares the same flag values as the ondisk inode flags in ext*. Therefore, each of these EXT4_[whatever]_FL values are supposed to have a FS_[whatever]_FL equivalent in include/uapi/linux/fs.h.

Interesting...

Quoted 9 lines

(Note that the "[whatever]" is a straight translation since the same uapi header also defines the FS_XFLAG_[xfswhatever] flag values; ignore those.)

Evidently, FS_NOCOW_FL already took 0x800000, but ext4.h was never updated to note that the value was taken. I think Ted might be inclined to reserve the ondisk inode bit just in case ext4 ever does support copy on write, though that's his call. :)

Quoted 7 lines
Quoted 2 lines

Seems like I should change this... And I did not realize I was inherently changing a bit definition which was exposed to other FS's...

<nod> This whole thing is a mess, particularly now that we have two vfs ioctls to set per-fs inode attributes, both of which were inherited from other filesystems... :(

Ok I've changed it.

Quoted 16 lines
Quoted 10 lines
Quoted 6 lines

Long story short - can you use 0x1000000 for this instead, and add the corresponding value to the uapi fs.h? I guess that also means that we can change FS_XFLAG_DAX (in the form of FS_DAX_FL in FSSETFLAGS) after that.

:-/

Are there any potential users of FS_XFLAG_DAX now?

Yes, it's in the userspace ABI so we can't get rid of it.

(FWIW there are several flags that exist in both FS_XFLAG_* and FS_*_FL form.)

Quoted 7 lines
Quoted 5 lines

From what it looks like, changing FS_XFLAG_DAX to FS_DAX_FL would be pretty straight forward. Just to be sure, looks like XFS converts the FS_[xxx]_FL to FS_XFLAGS_[xxx] in xfs_merge_ioc_xflags()? But it does not look like all the FS_[xxx]_FL flags are converted. Is is that XFS does not support those options? Or is it depending on the VFS layer for some of them?

XFS doesn't support most of the FS_*_FL flags.

If FS_XFLAG_DAX needs to continue to be user visible I think we need to keep that flag and we should not expose the EXT4_DAX_FL flag...

I think that works for XFS.

But for ext4 it looks like EXT4_FL_XFLAG_VISIBLE was intended to be used for [GET|SET]XATTR where EXT4_FL_USER_VISIBLE was intended to for [GET|SET]FLAGS... But if I don't add EXT4_DAX_FL in EXT4_FL_XFLAG_VISIBLE my test fails.

I've been playing with the flags and looking at the code and I _thought_ the following patch would ensure that FS_XFLAG_DAX is the only one visible but for some reason FS_XFLAG_DAX can't be set with this patch. I still need the EXT4_FL_USER_VISIBLE mask altered... Which I believe would expose EXT4_DAX_FL directly as well.

Quoted 7 lines
Quoted 2 lines

Jan, Ted? Any ideas? Or should we expose EXT4_DAX_FL and FS_XFLAG_DAX in ext4?

Both flags should be exposed through their respective ioctl interfaces in both filesystems. That way we don't have to add even more verbiage to the documentation to instruct userspace programmers on how to special case ext4 and XFS for the same piece of functionality.

Wouldn't it be more confusing for the user to have 2 different flags which do the same thing?

I would think that using FS_XFLAG_DAX _only_ (for both ext4 and xfs) would be easier without special cases?

Ira

#31 lore raw

Re: [PATCH RFC 4/8] fs/ext4: Introduce DAX inode flag

We still need to store an on-disk DAX flag for Ext4, and at that point it doesn't make sense not to expose it via the standard Ext4 chattr utility.

So having EXT4_DAX_FL (== FS_DAX_FL) is no extra effort to add.

Cheers, Andreas

Quoted 119 lines · Ira Weiny
Quoted 100 lines · Darrick J. Wong
Quoted 100 lines · Ira Weiny
Quoted 49 lines · Darrick J. Wong
Quoted 48 lines · Ira Weiny
Quoted 30 lines · Darrick J. Wong
Quoted 21 lines · On Mon, Apr 13, 2020 at 09:00:26PM -0700, [email protected] wrote:

From: Ira Weiny <[email protected]>

Add a flag to preserve FS_XFLAG_DAX in the ext4 inode.

Set the flag to be user visible and changeable. Set the flag to be inherited. Allow applications to change the flag at any time.

Finally, on regular files, flag the inode to not be cached to facilitate changing S_DAX on the next creation of the inode.

---
fs/ext4/ext4.h | 13 +++++++++----
fs/ext4/ioctl.c | 21 ++++++++++++++++++++-

2 files changed, 29 insertions(+), 5 deletions(-)
fs/ext4/ext4.h +0 -0
index 61b37a052052..434021fcec88 100644

fs/ext4/ext4.h struct flex_groups { · line 419

Quoted 5 lines
fs/ext4/ext4.h +2 -0
@@ -415,13 +415,16 @@ struct flex_groups {
 #define EXT4_VERITY_FL            0x00100000 /* Verity protected inode */
 #define EXT4_EA_INODE_FL            0x00200000 /* Inode used for large EA */
 #define EXT4_EOFBLOCKS_FL        0x00400000 /* Blocks allocated beyond EOF */
+
+#define EXT4_DAX_FL            0x00800000 /* Inode is DAX */

Sooo, fun fact about ext4 vs. the world--

Quoted 4 lines

The GETFLAGS/SETFLAGS ioctl, since it came from ext2, shares the same flag values as the ondisk inode flags in ext*. Therefore, each of these EXT4_[whatever]_FL values are supposed to have a FS_[whatever]_FL equivalent in include/uapi/linux/fs.h.

Interesting...

Quoted 9 lines

(Note that the "[whatever]" is a straight translation since the same uapi header also defines the FS_XFLAG_[xfswhatever] flag values; ignore those.)

Evidently, FS_NOCOW_FL already took 0x800000, but ext4.h was never updated to note that the value was taken. I think Ted might be inclined to reserve the ondisk inode bit just in case ext4 ever does support copy on write, though that's his call. :)

Quoted 7 lines
Quoted 2 lines

Seems like I should change this... And I did not realize I was inherently changing a bit definition which was exposed to other FS's...

<nod> This whole thing is a mess, particularly now that we have two vfs ioctls to set per-fs inode attributes, both of which were inherited from other filesystems... :(

Ok I've changed it.

Quoted 16 lines
Quoted 10 lines
Quoted 6 lines

Long story short - can you use 0x1000000 for this instead, and add the corresponding value to the uapi fs.h? I guess that also means that we can change FS_XFLAG_DAX (in the form of FS_DAX_FL in FSSETFLAGS) after that.

:-/

Are there any potential users of FS_XFLAG_DAX now?

Yes, it's in the userspace ABI so we can't get rid of it.

(FWIW there are several flags that exist in both FS_XFLAG_* and FS_*_FL form.)

Quoted 7 lines
Quoted 5 lines

From what it looks like, changing FS_XFLAG_DAX to FS_DAX_FL would be pretty straight forward. Just to be sure, looks like XFS converts the FS_[xxx]_FL to FS_XFLAGS_[xxx] in xfs_merge_ioc_xflags()? But it does not look like all the FS_[xxx]_FL flags are converted. Is is that XFS does not support those options? Or is it depending on the VFS layer for some of them?

XFS doesn't support most of the FS_*_FL flags.

If FS_XFLAG_DAX needs to continue to be user visible I think we need to keep that flag and we should not expose the EXT4_DAX_FL flag...

I think that works for XFS.

But for ext4 it looks like EXT4_FL_XFLAG_VISIBLE was intended to be used for [GET|SET]XATTR where EXT4_FL_USER_VISIBLE was intended to for [GET|SET]FLAGS... But if I don't add EXT4_DAX_FL in EXT4_FL_XFLAG_VISIBLE my test fails.

I've been playing with the flags and looking at the code and I _thought_ the following patch would ensure that FS_XFLAG_DAX is the only one visible but for some reason FS_XFLAG_DAX can't be set with this patch. I still need the EXT4_FL_USER_VISIBLE mask altered... Which I believe would expose EXT4_DAX_FL directly as well.

Quoted 7 lines
Quoted 2 lines

Jan, Ted? Any ideas? Or should we expose EXT4_DAX_FL and FS_XFLAG_DAX in ext4?

Both flags should be exposed through their respective ioctl interfaces in both filesystems. That way we don't have to add even more verbiage to the documentation to instruct userspace programmers on how to special case ext4 and XFS for the same piece of functionality.

Wouldn't it be more confusing for the user to have 2 different flags which do the same thing?

I would think that using FS_XFLAG_DAX _only_ (for both ext4 and xfs) would be easier without special cases?

Ira

author
#32 lore raw

Re: [PATCH RFC 4/8] fs/ext4: Introduce DAX inode flag

Quoted 4 lines · Andreas Dilger

We still need to store an on-disk DAX flag for Ext4, and at that point it doesn't make sense not to expose it via the standard Ext4 chattr utility.

So having EXT4_DAX_FL (== FS_DAX_FL) is no extra effort to add.

I'll leave it exposed then.

Thanks,
Ira

Quoted 122 lines

Cheers, Andreas

Quoted 119 lines · Ira Weiny
Quoted 100 lines · Darrick J. Wong
Quoted 100 lines · Ira Weiny
Quoted 49 lines · Darrick J. Wong
Quoted 48 lines · Ira Weiny
Quoted 30 lines · Darrick J. Wong
Quoted 21 lines · On Mon, Apr 13, 2020 at 09:00:26PM -0700, [email protected] wrote:

From: Ira Weiny <[email protected]>

Add a flag to preserve FS_XFLAG_DAX in the ext4 inode.

Set the flag to be user visible and changeable. Set the flag to be inherited. Allow applications to change the flag at any time.

Finally, on regular files, flag the inode to not be cached to facilitate changing S_DAX on the next creation of the inode.

---
fs/ext4/ext4.h | 13 +++++++++----
fs/ext4/ioctl.c | 21 ++++++++++++++++++++-

2 files changed, 29 insertions(+), 5 deletions(-)
fs/ext4/ext4.h +0 -0
index 61b37a052052..434021fcec88 100644

fs/ext4/ext4.h struct flex_groups { · line 419

Quoted 5 lines
fs/ext4/ext4.h +2 -0
@@ -415,13 +415,16 @@ struct flex_groups {
 #define EXT4_VERITY_FL            0x00100000 /* Verity protected inode */
 #define EXT4_EA_INODE_FL            0x00200000 /* Inode used for large EA */
 #define EXT4_EOFBLOCKS_FL        0x00400000 /* Blocks allocated beyond EOF */
+
+#define EXT4_DAX_FL            0x00800000 /* Inode is DAX */

Sooo, fun fact about ext4 vs. the world--

Quoted 4 lines

The GETFLAGS/SETFLAGS ioctl, since it came from ext2, shares the same flag values as the ondisk inode flags in ext*. Therefore, each of these EXT4_[whatever]_FL values are supposed to have a FS_[whatever]_FL equivalent in include/uapi/linux/fs.h.

Interesting...

Quoted 9 lines

(Note that the "[whatever]" is a straight translation since the same uapi header also defines the FS_XFLAG_[xfswhatever] flag values; ignore those.)

Evidently, FS_NOCOW_FL already took 0x800000, but ext4.h was never updated to note that the value was taken. I think Ted might be inclined to reserve the ondisk inode bit just in case ext4 ever does support copy on write, though that's his call. :)

Quoted 7 lines
Quoted 2 lines

Seems like I should change this... And I did not realize I was inherently changing a bit definition which was exposed to other FS's...

<nod> This whole thing is a mess, particularly now that we have two vfs ioctls to set per-fs inode attributes, both of which were inherited from other filesystems... :(

Ok I've changed it.

Quoted 16 lines
Quoted 10 lines
Quoted 6 lines

Long story short - can you use 0x1000000 for this instead, and add the corresponding value to the uapi fs.h? I guess that also means that we can change FS_XFLAG_DAX (in the form of FS_DAX_FL in FSSETFLAGS) after that.

:-/

Are there any potential users of FS_XFLAG_DAX now?

Yes, it's in the userspace ABI so we can't get rid of it.

(FWIW there are several flags that exist in both FS_XFLAG_* and FS_*_FL form.)

Quoted 7 lines
Quoted 5 lines

From what it looks like, changing FS_XFLAG_DAX to FS_DAX_FL would be pretty straight forward. Just to be sure, looks like XFS converts the FS_[xxx]_FL to FS_XFLAGS_[xxx] in xfs_merge_ioc_xflags()? But it does not look like all the FS_[xxx]_FL flags are converted. Is is that XFS does not support those options? Or is it depending on the VFS layer for some of them?

XFS doesn't support most of the FS_*_FL flags.

If FS_XFLAG_DAX needs to continue to be user visible I think we need to keep that flag and we should not expose the EXT4_DAX_FL flag...

I think that works for XFS.

But for ext4 it looks like EXT4_FL_XFLAG_VISIBLE was intended to be used for [GET|SET]XATTR where EXT4_FL_USER_VISIBLE was intended to for [GET|SET]FLAGS... But if I don't add EXT4_DAX_FL in EXT4_FL_XFLAG_VISIBLE my test fails.

I've been playing with the flags and looking at the code and I _thought_ the following patch would ensure that FS_XFLAG_DAX is the only one visible but for some reason FS_XFLAG_DAX can't be set with this patch. I still need the EXT4_FL_USER_VISIBLE mask altered... Which I believe would expose EXT4_DAX_FL directly as well.

Quoted 7 lines
Quoted 2 lines

Jan, Ted? Any ideas? Or should we expose EXT4_DAX_FL and FS_XFLAG_DAX in ext4?

Both flags should be exposed through their respective ioctl interfaces in both filesystems. That way we don't have to add even more verbiage to the documentation to instruct userspace programmers on how to special case ext4 and XFS for the same piece of functionality.

Wouldn't it be more confusing for the user to have 2 different flags which do the same thing?

I would think that using FS_XFLAG_DAX _only_ (for both ext4 and xfs) would be easier without special cases?

Ira

#33 lore raw

RFC PATCH 5/8 fs/ext4: Make DAX mount option a tri-state

In reply to [email protected]

From: Ira Weiny <[email protected]>

We add 'always', 'never', and 'inode' (default). '-o dax' continue to operate the same.

Specifically we introduce a 2nd DAX mount flag EXT4_MOUNT_NODAX and set it and EXT4_MOUNT_DAX appropriately.

We also force EXT4_MOUNT_NODAX if !CONFIG_FS_DAX.

https://lore.kernel.org/lkml/[email protected]/

---
 fs/ext4/ext4.h  |  1 +
 fs/ext4/super.c | 43 +++++++++++++++++++++++++++++++++++++++----
 2 files changed, 40 insertions(+), 4 deletions(-)
fs/ext4/ext4.h +1 -0
index 434021fcec88..aadf33d5b37d 100644
@@ -1174,6 +1174,7 @@ struct ext4_inode_info {
 						      blocks */
 #define EXT4_MOUNT2_HURD_COMPAT		0x00000004 /* Support HURD-castrated
 						      file systems */
+#define EXT4_MOUNT2_NODAX		0x00000008 /* Do not allow Direct Access */
 
 #define EXT4_MOUNT2_EXPLICIT_JOURNAL_CHECKSUM	0x00000008 /* User explicitly
 						specified journal checksum */
fs/ext4/super.c +39 -4

82 lines not on this page · raw message

Signature · 1 line
2.25.1
reviewer
#34 lore raw

Re: [PATCH RFC 5/8] fs/ext4: Make DAX mount option a tri-state

Quoted 13 lines · On Mon 13-04-20 21:00:27, [email protected] wrote:

From: Ira Weiny <[email protected]>

We add 'always', 'never', and 'inode' (default). '-o dax' continue to operate the same.

Specifically we introduce a 2nd DAX mount flag EXT4_MOUNT_NODAX and set it and EXT4_MOUNT_DAX appropriately.

We also force EXT4_MOUNT_NODAX if !CONFIG_FS_DAX.

https://lore.kernel.org/lkml/[email protected]/

...

fs/ext4/super.c static int _ext4_show_options(struct seq_file *seq, struct super_block *sb, · line 2334

Quoted 11 lines
fs/ext4/super.c +7 -0
@@ -2303,6 +2325,13 @@ static int _ext4_show_options(struct seq_file *seq, struct super_block *sb,
 	if (DUMMY_ENCRYPTION_ENABLED(sbi))
 		SEQ_OPTS_PUTS("test_dummy_encryption");
 
+	if (test_opt2(sb, NODAX))
+		SEQ_OPTS_PUTS("dax=never");
+	else if (test_opt(sb, DAX))
+		SEQ_OPTS_PUTS("dax=always");
+	else
+		SEQ_OPTS_PUTS("dax=inode");
+

We try to show only mount options that were explicitely set by the user, or that are different from defaults - e.g., see how 'data=' mount option printing is handled.

Quoted 5 lines
fs/ext4/super.c +0 -0
 	ext4_show_quota_options(seq, sb);
 	return 0;
 }
@@ -5424,6 +5453,12 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
 		sbi->s_mount_opt ^= EXT4_MOUNT_DAX;

fs/ext4/super.c static int ext4_remount(struct super_block *sb, int *flags, char *data) · line 5463

Quoted 10 lines
fs/ext4/super.c +6 -0
 	}
 
+	if ((sbi->s_mount_opt2 ^ old_opts.s_mount_opt2) & EXT4_MOUNT2_NODAX) {
+		ext4_msg(sb, KERN_WARNING, "warning: refusing change of "
+			"non-dax flag with busy inodes while remounting");
+		sbi->s_mount_opt2 ^= EXT4_MOUNT2_NODAX;
+	}
+
 	if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
 		ext4_abort(sb, "Abort forced by user");

I'd just merge this with the check whether EXT4_MOUNT_DAX changed.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#35 lore raw

RFC PATCH 6/8 fs/ext4: Update ext4_should_use_dax()

In reply to [email protected]

From: Ira Weiny <[email protected]>

Change the logic of ext4_should_use_dax() to support using the inode dax flag OR the overriding tri-state mount option.

While we are at it change the function to ext4_enable_dax() as this better reflects the ask.

---
 fs/ext4/inode.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
fs/ext4/inode.c +12 -4
index fa0ff78dc033..e9d582e516bc 100644
@@ -4383,9 +4383,11 @@ int ext4_get_inode_loc(struct inode *inode, struct ext4_iloc *iloc)
 		!ext4_test_inode_state(inode, EXT4_STATE_XATTR));
 }
 
-static bool ext4_should_use_dax(struct inode *inode)
+static bool ext4_enable_dax(struct inode *inode)
 {
-	if (!test_opt(inode->i_sb, DAX))
+	unsigned int flags = EXT4_I(inode)->i_flags;
+
+	if (test_opt2(inode->i_sb, NODAX))
 		return false;
 	if (!S_ISREG(inode->i_mode))
 		return false;
@@ -4397,7 +4399,13 @@ static bool ext4_should_use_dax(struct inode *inode)
 		return false;
 	if (ext4_test_inode_flag(inode, EXT4_INODE_VERITY))
 		return false;
-	return true;
+	if (!bdev_dax_supported(inode->i_sb->s_bdev,
+				inode->i_sb->s_blocksize))
+		return false;
+	if (test_opt(inode->i_sb, DAX))
+		return true;
+
+	return (flags & EXT4_DAX_FL) == EXT4_DAX_FL;
 }
 
 void ext4_set_inode_flags(struct inode *inode)
@@ -4415,7 +4423,7 @@ void ext4_set_inode_flags(struct inode *inode)
 		new_fl |= S_NOATIME;
 	if (flags & EXT4_DIRSYNC_FL)
 		new_fl |= S_DIRSYNC;
-	if (ext4_should_use_dax(inode))
+	if (ext4_enable_dax(inode))
 		new_fl |= S_DAX;
 	if (flags & EXT4_ENCRYPT_FL)
 		new_fl |= S_ENCRYPTED;
Signature · 1 line
2.25.1
reviewer
#36 lore raw

Re: [PATCH RFC 6/8] fs/ext4: Update ext4_should_use_dax()

Quoted 7 lines · On Mon 13-04-20 21:00:28, [email protected] wrote:

From: Ira Weiny <[email protected]>

Change the logic of ext4_should_use_dax() to support using the inode dax flag OR the overriding tri-state mount option.

While we are at it change the function to ext4_enable_dax() as this better reflects the ask.

I disagree with the renaming. ext4_enable_dax() suggests it enables something. It does not. I'd either leave ext4_should_use_dax() or maybe change it to ext4_should_enable_dax() if you really like the "enable" word :).

Quoted 26 lines
---
 fs/ext4/inode.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
fs/ext4/inode.c +4 -2
index fa0ff78dc033..e9d582e516bc 100644
@@ -4383,9 +4383,11 @@ int ext4_get_inode_loc(struct inode *inode, struct ext4_iloc *iloc)
 		!ext4_test_inode_state(inode, EXT4_STATE_XATTR));
 }
 
-static bool ext4_should_use_dax(struct inode *inode)
+static bool ext4_enable_dax(struct inode *inode)
 {
-	if (!test_opt(inode->i_sb, DAX))
+	unsigned int flags = EXT4_I(inode)->i_flags;
+
+	if (test_opt2(inode->i_sb, NODAX))
 		return false;
 	if (!S_ISREG(inode->i_mode))
 		return false;
@@ -4397,7 +4399,13 @@ static bool ext4_should_use_dax(struct inode *inode)
 		return false;

fs/ext4/inode.c static bool ext4_should_use_dax(struct inode *inode) · line 4408

Quoted 10 lines
fs/ext4/inode.c +7 -1
 	if (ext4_test_inode_flag(inode, EXT4_INODE_VERITY))
 		return false;
-	return true;
+	if (!bdev_dax_supported(inode->i_sb->s_bdev,
+				inode->i_sb->s_blocksize))
+		return false;
+	if (test_opt(inode->i_sb, DAX))
+		return true;
+
+	return (flags & EXT4_DAX_FL) == EXT4_DAX_FL;

flags & EXT4_DAX_FL is enough here, isn't it?

Honza

Quoted 15 lines
fs/ext4/inode.c +1 -1
 }
 
 void ext4_set_inode_flags(struct inode *inode)
@@ -4415,7 +4423,7 @@ void ext4_set_inode_flags(struct inode *inode)
 		new_fl |= S_NOATIME;
 	if (flags & EXT4_DIRSYNC_FL)
 		new_fl |= S_DIRSYNC;
-	if (ext4_should_use_dax(inode))
+	if (ext4_enable_dax(inode))
 		new_fl |= S_DAX;
 	if (flags & EXT4_ENCRYPT_FL)
 		new_fl |= S_ENCRYPTED;
Signature · 1 line
2.25.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author
#37 lore raw

Re: [PATCH RFC 6/8] fs/ext4: Update ext4_should_use_dax()

Quoted 6 lines · Jan Kara
Quoted 5 lines · On Mon 13-04-20 21:00:28, [email protected] wrote:

From: Ira Weiny <[email protected]>

Change the logic of ext4_should_use_dax() to support using the inode dax flag OR the overriding tri-state mount option.

Quoted 7 lines
Quoted 2 lines

While we are at it change the function to ext4_enable_dax() as this better reflects the ask.

I disagree with the renaming. ext4_enable_dax() suggests it enables something. It does not. I'd either leave ext4_should_use_dax() or maybe change it to ext4_should_enable_dax() if you really like the "enable" word :).

Ok that does sound better. And I've changed it in the xfs series as well.

but I kept Darrick's review on that patch...

Quoted 31 lines
Quoted 31 lines
---
 fs/ext4/inode.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
fs/ext4/inode.c +5 -3
index fa0ff78dc033..e9d582e516bc 100644
@@ -4383,9 +4383,11 @@ int ext4_get_inode_loc(struct inode *inode, struct ext4_iloc *iloc)
 		!ext4_test_inode_state(inode, EXT4_STATE_XATTR));
 }
 
-static bool ext4_should_use_dax(struct inode *inode)
+static bool ext4_enable_dax(struct inode *inode)
 {
-	if (!test_opt(inode->i_sb, DAX))
+	unsigned int flags = EXT4_I(inode)->i_flags;
+
+	if (test_opt2(inode->i_sb, NODAX))
 		return false;
 	if (!S_ISREG(inode->i_mode))
 		return false;
@@ -4397,7 +4399,13 @@ static bool ext4_should_use_dax(struct inode *inode)
 		return false;
 	if (ext4_test_inode_flag(inode, EXT4_INODE_VERITY))
 		return false;
-	return true;
+	if (!bdev_dax_supported(inode->i_sb->s_bdev,
Quoted 8 lines

fs/ext4/inode.c static bool ext4_should_use_dax(struct inode *inode) · line 4408

Quoted 6 lines
fs/ext4/inode.c +6 -0
+				inode->i_sb->s_blocksize))
+		return false;
+	if (test_opt(inode->i_sb, DAX))
+		return true;
+
+	return (flags & EXT4_DAX_FL) == EXT4_DAX_FL;

flags & EXT4_DAX_FL is enough here, isn't it?

Yes, changed.

Ira

Quoted 21 lines

Honza

Quoted 15 lines
fs/ext4/inode.c +1 -1
 }
 
 void ext4_set_inode_flags(struct inode *inode)
@@ -4415,7 +4423,7 @@ void ext4_set_inode_flags(struct inode *inode)
 		new_fl |= S_NOATIME;
 	if (flags & EXT4_DIRSYNC_FL)
 		new_fl |= S_DIRSYNC;
-	if (ext4_should_use_dax(inode))
+	if (ext4_enable_dax(inode))
 		new_fl |= S_DAX;
 	if (flags & EXT4_ENCRYPT_FL)
 		new_fl |= S_ENCRYPTED;
Signature · 1 line
2.25.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#38 lore raw

RFC PATCH 7/8 fs/ext4: Only change S_DAX on inode load

In reply to [email protected]

From: Ira Weiny <[email protected]>

To prevent complications with in memory inodes we only set S_DAX on inode load. FS_XFLAG_DAX can be changed at any time and S_DAX will change after inode eviction and reload.

Add init bool to ext4_set_inode_flags() to indicate if the inode is being newly initialized.

Assert that S_DAX is not set on an inode which is just being loaded.

---
 fs/ext4/ext4.h   | 2 +-
 fs/ext4/ialloc.c | 2 +-
 fs/ext4/inode.c  | 8 +++++---
 fs/ext4/ioctl.c  | 3 ++-
 fs/ext4/super.c  | 4 ++--
 fs/ext4/verity.c | 2 +-
 6 files changed, 12 insertions(+), 9 deletions(-)
fs/ext4/ext4.h +1 -1
index aadf33d5b37d..7f9234cce5b8 100644
@@ -2699,7 +2699,7 @@ extern int ext4_can_truncate(struct inode *inode);
 extern int ext4_truncate(struct inode *);
 extern int ext4_break_layouts(struct inode *);
 extern int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length);
-extern void ext4_set_inode_flags(struct inode *);
+extern void ext4_set_inode_flags(struct inode *, bool init);
 extern int ext4_alloc_da_blocks(struct inode *inode);
 extern void ext4_set_aops(struct inode *inode);
 extern int ext4_writepage_trans_blocks(struct inode *);
fs/ext4/ialloc.c +1 -1
index f95ee99091e4..1519a4bf42fa 100644
@@ -1104,7 +1104,7 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
 	ei->i_block_group = group;
 	ei->i_last_alloc_group = ~0;
 
-	ext4_set_inode_flags(inode);
+	ext4_set_inode_flags(inode, true);
 	if (IS_DIRSYNC(inode))
 		ext4_handle_sync(handle);
 	if (insert_inode_locked(inode) < 0) {
fs/ext4/inode.c +5 -3
index e9d582e516bc..e9dfdfd6c698 100644
@@ -4408,11 +4408,13 @@ static bool ext4_enable_dax(struct inode *inode)
 	return (flags & EXT4_DAX_FL) == EXT4_DAX_FL;
 }
 
-void ext4_set_inode_flags(struct inode *inode)
+void ext4_set_inode_flags(struct inode *inode, bool init)
 {
 	unsigned int flags = EXT4_I(inode)->i_flags;
 	unsigned int new_fl = 0;
 
+	J_ASSERT(!(IS_DAX(inode) && init));
+
 	if (flags & EXT4_SYNC_FL)
 		new_fl |= S_SYNC;
 	if (flags & EXT4_APPEND_FL)
@@ -4423,7 +4425,7 @@ void ext4_set_inode_flags(struct inode *inode)
 		new_fl |= S_NOATIME;
 	if (flags & EXT4_DIRSYNC_FL)
 		new_fl |= S_DIRSYNC;
-	if (ext4_enable_dax(inode))
+	if (init && ext4_enable_dax(inode))
 		new_fl |= S_DAX;
 	if (flags & EXT4_ENCRYPT_FL)
 		new_fl |= S_ENCRYPTED;
@@ -4639,7 +4641,7 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
 		 * not initialized on a new filesystem. */
 	}
 	ei->i_flags = le32_to_cpu(raw_inode->i_flags);
-	ext4_set_inode_flags(inode);
+	ext4_set_inode_flags(inode, true);
 	inode->i_blocks = ext4_inode_blocks(raw_inode, ei);
 	ei->i_file_acl = le32_to_cpu(raw_inode->i_file_acl_lo);
 	if (ext4_has_feature_64bit(sb))
fs/ext4/ioctl.c +2 -1
index ca07d5086f03..efe41dcc8807 100644
@@ -393,7 +393,8 @@ static int ext4_ioctl_setflags(struct inode *inode,
 			ext4_clear_inode_flag(inode, i);
 	}
 
-	ext4_set_inode_flags(inode);
+	ext4_set_inode_flags(inode, false);
+
 	inode->i_ctime = current_time(inode);
 
 	err = ext4_mark_iloc_dirty(handle, inode, &iloc);
fs/ext4/super.c +2 -2
index 0175fbfeb2ea..43cc52ea7918 100644
@@ -1349,7 +1349,7 @@ 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);
-			ext4_set_inode_flags(inode);
+			ext4_set_inode_flags(inode, false);
 		}
 		return res;
 	}
@@ -1372,7 +1372,7 @@ 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);
-		ext4_set_inode_flags(inode);
+		ext4_set_inode_flags(inode, false);
 		res = ext4_mark_inode_dirty(handle, inode);
 		if (res)
 			EXT4_ERROR_INODE(inode, "Failed to mark inode dirty");
fs/ext4/verity.c +1 -1
index ce3f9a198d3b..4f7d780ff6da 100644
@@ -244,7 +244,7 @@ static int ext4_end_enable_verity(struct file *filp, const void *desc,
 		if (err)
 			goto out_stop;
 		ext4_set_inode_flag(inode, EXT4_INODE_VERITY);
-		ext4_set_inode_flags(inode);
+		ext4_set_inode_flags(inode, false);
 		err = ext4_mark_iloc_dirty(handle, inode, &iloc);
 	}
 out_stop:
Signature · 1 line
2.25.1
reviewer
#39 lore raw

Re: [PATCH RFC 7/8] fs/ext4: Only change S_DAX on inode load

Quoted 13 lines · On Mon 13-04-20 21:00:29, [email protected] wrote:

From: Ira Weiny <[email protected]>

To prevent complications with in memory inodes we only set S_DAX on inode load. FS_XFLAG_DAX can be changed at any time and S_DAX will change after inode eviction and reload.

Add init bool to ext4_set_inode_flags() to indicate if the inode is being newly initialized.

Assert that S_DAX is not set on an inode which is just being loaded.

fs/ext4/inode.c +0 -0
@@ -4408,11 +4408,13 @@ static bool ext4_enable_dax(struct inode *inode)
 	return (flags & EXT4_DAX_FL) == EXT4_DAX_FL;

fs/ext4/inode.c static bool ext4_enable_dax(struct inode *inode) · line 4417

Quoted 10 lines
fs/ext4/inode.c +3 -1
 }
 
-void ext4_set_inode_flags(struct inode *inode)
+void ext4_set_inode_flags(struct inode *inode, bool init)
 {
 	unsigned int flags = EXT4_I(inode)->i_flags;
 	unsigned int new_fl = 0;
 
+	J_ASSERT(!(IS_DAX(inode) && init));
+

WARN_ON or BUG_ON here? J_ASSERT is for journalling assertions...

Otherwise the patch looks good.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author
#40 lore raw

Re: [PATCH RFC 7/8] fs/ext4: Only change S_DAX on inode load

Quoted 22 lines · Jan Kara
Quoted 21 lines · On Mon 13-04-20 21:00:29, [email protected] wrote:

From: Ira Weiny <[email protected]>

To prevent complications with in memory inodes we only set S_DAX on inode load. FS_XFLAG_DAX can be changed at any time and S_DAX will change after inode eviction and reload.

Add init bool to ext4_set_inode_flags() to indicate if the inode is being newly initialized.

Assert that S_DAX is not set on an inode which is just being loaded.

fs/ext4/inode.c +1 -1
@@ -4408,11 +4408,13 @@ static bool ext4_enable_dax(struct inode *inode)
 	return (flags & EXT4_DAX_FL) == EXT4_DAX_FL;
 }
 
-void ext4_set_inode_flags(struct inode *inode)
+void ext4_set_inode_flags(struct inode *inode, bool init)
 {
 	unsigned int flags = EXT4_I(inode)->i_flags;
 	unsigned int new_fl = 0;
 
Quoted 4 lines

fs/ext4/inode.c static bool ext4_enable_dax(struct inode *inode) · line 4417

Quoted 2 lines
fs/ext4/inode.c +2 -0
+	J_ASSERT(!(IS_DAX(inode) && init));
+

WARN_ON or BUG_ON here? J_ASSERT is for journalling assertions...

Ah sorry, did not realize that J_ was specific.

Changed to WARN_ON_ONCE()

Ira

Quoted 8 lines

Otherwise the patch looks good.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#41 lore raw

RFC PATCH 8/8 Documentation/dax: Update DAX enablement for ext4

In reply to [email protected]

From: Ira Weiny <[email protected]>

Update the document to reflect ext4 and xfs now behave the same.

---
 Documentation/filesystems/dax.txt | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
Documentation/filesystems/dax.txt +1 -12
index af14c1b330a9..5f28b22d2815 100644
@@ -22,18 +22,7 @@ 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 file system.
 
-Currently 2 filesystems support DAX, ext4 and xfs.  Enabling DAX on them is
-different at this time.
-
-Enabling DAX on ext4
---------------------
-
-When mounting the filesystem, use the "-o dax" option on the command line or
-add 'dax' to the options in /etc/fstab.
-
-
-Enabling DAX on xfs
--------------------
+Currently 2 filesystems support DAX, ext4 and xfs.
 
 Summary
 -------
Signature · 1 line
2.25.1