Skip to contentSkip to conversation

fs/stat: set attributes_mask for STATX_ATTR_DAX

PATCH Superseded XiaoLi Feng 4 participants 5 messages Nov 21, 2020 – Nov 23, 2020 VFS

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/stat: set attributes_mask for STATX_ATTR_DAX

From: Xiaoli Feng <[email protected]>

keep attributes and attributes_mask are consistent for STATX_ATTR_DAX.

---
 fs/stat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/stat.c +1 -1
index dacecdda2e79..914a61d256b0 100644
@@ -82,7 +82,7 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat,
 
 	if (IS_DAX(inode))
 		stat->attributes |= STATX_ATTR_DAX;
-
+	stat->attributes_mask |= STATX_ATTR_DAX;
 	if (inode->i_op->getattr)
 		return inode->i_op->getattr(path, stat, request_mask,
 					    query_flags);
Signature · 1 line
2.18.1
#1 lore raw

Hi,

I don't know this code, but:

Quoted 13 lines · XiaoLi Feng

From: Xiaoli Feng <[email protected]>

keep attributes and attributes_mask are consistent for STATX_ATTR_DAX.

---
 fs/stat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/stat.c +0 -0
index dacecdda2e79..914a61d256b0 100644

fs/stat.c int vfs_getattr_nosec(const struct path *path, struct kstat *stat, · line 85

Quoted 5 lines
fs/stat.c +1 -1
@@ -82,7 +82,7 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat,
 
 	if (IS_DAX(inode))
 		stat->attributes |= STATX_ATTR_DAX;
-
+	stat->attributes_mask |= STATX_ATTR_DAX;

Why shouldn't that be:

	if (IS_DAX(inode))
		stat->attributes_mask |= STATX_ATTR_DAX;

or combine them, like this:

	if (IS_DAX(inode)) {
		stat->attributes |= STATX_ATTR_DAX;
		stat->attributes_mask |= STATX_ATTR_DAX;
	}

and no need to delete that blank line.

fs/stat.c int vfs_getattr_nosec(const struct path *path, struct kstat *stat, · line 88

Quoted 4 lines
fs/stat.c +0 -0
 	if (inode->i_op->getattr)
 		return inode->i_op->getattr(path, stat, request_mask,
 					    query_flags);

thanks.

Signature · 1 line
~Randy
#2 lore raw

[Adding fsdevel to cc since this is a filesystems question]

Quoted 31 lines · Randy Dunlap

Hi,

I don't know this code, but:

Quoted 13 lines · XiaoLi Feng

From: Xiaoli Feng <[email protected]>

keep attributes and attributes_mask are consistent for STATX_ATTR_DAX.

---
 fs/stat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/stat.c +0 -0
index dacecdda2e79..914a61d256b0 100644

fs/stat.c int vfs_getattr_nosec(const struct path *path, struct kstat *stat, · line 85

Quoted 5 lines
fs/stat.c +1 -1
@@ -82,7 +82,7 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat,
 
 	if (IS_DAX(inode))
 		stat->attributes |= STATX_ATTR_DAX;
-
+	stat->attributes_mask |= STATX_ATTR_DAX;

Why shouldn't that be:

	if (IS_DAX(inode))
		stat->attributes_mask |= STATX_ATTR_DAX;

or combine them, like this:

Quoted 7 lines
	if (IS_DAX(inode)) {
		stat->attributes |= STATX_ATTR_DAX;
		stat->attributes_mask |= STATX_ATTR_DAX;
	}

and no need to delete that blank line.

Some filesystems could support DAX but not have it enabled for this particular file, so this won't work.

General question: should filesystems that are /capable/ of DAX signal this by setting the DAX bit in the attributes mask? Or is this a VFS feature and hence here is the appropriate place to be setting the mask?

Extra question: should we only set this in the attributes mask if CONFIG_FS_DAX=y ?

--D

Quoted 9 lines

fs/stat.c int vfs_getattr_nosec(const struct path *path, struct kstat *stat, · line 88

Quoted 4 lines
fs/stat.c +0 -0
 	if (inode->i_op->getattr)
 		return inode->i_op->getattr(path, stat, request_mask,
 					    query_flags);

thanks.

Signature · 1 line
~Randy
#3 lore raw

Hi,

Thanks for review.

----- Original Message -----

Quoted 48 lines

From: "Darrick J. Wong" <[email protected]>
To: "XiaoLi Feng" <[email protected]>
Cc: "Randy Dunlap" <[email protected]>, [email protected], "ira weiny" <[email protected]>, "Xiaoli Feng" <[email protected]>, "linux-fsdevel" <[email protected]>
Sent: Saturday, November 21, 2020 10:03:18 AM
Subject: Re: [PATCH] fs/stat: set attributes_mask for STATX_ATTR_DAX

[Adding fsdevel to cc since this is a filesystems question]

Quoted 38 lines · Randy Dunlap

Hi,

I don't know this code, but:

Quoted 13 lines · XiaoLi Feng

From: Xiaoli Feng <[email protected]>

keep attributes and attributes_mask are consistent for STATX_ATTR_DAX.

---
 fs/stat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/stat.c +0 -0
index dacecdda2e79..914a61d256b0 100644

fs/stat.c int vfs_getattr_nosec(const struct path *path, struct · line 86

Quoted 6 lines
fs/stat.c +1 -1
@@ -82,7 +82,7 @@ int vfs_getattr_nosec(const struct path *path, struct
 kstat *stat,
 
 	if (IS_DAX(inode))
 		stat->attributes |= STATX_ATTR_DAX;
-
+	stat->attributes_mask |= STATX_ATTR_DAX;

Why shouldn't that be:

	if (IS_DAX(inode))
		stat->attributes_mask |= STATX_ATTR_DAX;

or combine them, like this:

	if (IS_DAX(inode)) {
		stat->attributes |= STATX_ATTR_DAX;
		stat->attributes_mask |= STATX_ATTR_DAX;
	}
Quoted 8 lines
Quoted 1 line

and no need to delete that blank line.

Some filesystems could support DAX but not have it enabled for this particular file, so this won't work.

General question: should filesystems that are /capable/ of DAX signal this by setting the DAX bit in the attributes mask? Or is this a VFS feature and hence here is the appropriate place to be setting the mask?

Actually I just see here set the attributes. Then set the attributes mask after it.

Quoted 3 lines

Extra question: should we only set this in the attributes mask if CONFIG_FS_DAX=y ?

No, my origin patch always set this attributes mask. It's out of if condition.

        if (IS_DAX(inode))
                stat->attributes |= STATX_ATTR_DAX;

-
+ stat->attributes_mask |= STATX_ATTR_DAX;

Quoted 14 lines

--D

Quoted 9 lines
Quoted 4 lines
fs/stat.c +0 -0
 	if (inode->i_op->getattr)
 		return inode->i_op->getattr(path, stat, request_mask,

query_flags);

thanks.
--
~Randy

#4 lore raw
In reply to Darrick J. Wong
Quoted 40 lines · Darrick J. Wong

[Adding fsdevel to cc since this is a filesystems question]

Quoted 37 lines · Randy Dunlap

Hi,

I don't know this code, but:

Quoted 13 lines · XiaoLi Feng

From: Xiaoli Feng <[email protected]>

keep attributes and attributes_mask are consistent for STATX_ATTR_DAX.

---
 fs/stat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/stat.c +0 -0
index dacecdda2e79..914a61d256b0 100644

fs/stat.c int vfs_getattr_nosec(const struct path *path, struct kstat *stat, · line 85

Quoted 5 lines
fs/stat.c +1 -1
@@ -82,7 +82,7 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat,
 
 	if (IS_DAX(inode))
 		stat->attributes |= STATX_ATTR_DAX;
-
+	stat->attributes_mask |= STATX_ATTR_DAX;

Why shouldn't that be:

	if (IS_DAX(inode))
		stat->attributes_mask |= STATX_ATTR_DAX;

or combine them, like this:

	if (IS_DAX(inode)) {
		stat->attributes |= STATX_ATTR_DAX;
		stat->attributes_mask |= STATX_ATTR_DAX;
	}
Quoted 7 lines
Quoted 1 line

and no need to delete that blank line.

Some filesystems could support DAX but not have it enabled for this particular file, so this won't work.

General question: should filesystems that are /capable/ of DAX signal this by setting the DAX bit in the attributes mask?

I think so, yes. It could be set if the right bit on the inode is set, but it currently isn't so the bit in the mask is set but the bit in the attributes is not. i.e "DAX is valid status bit, but it is not set for this file".

Quoted 2 lines

Or is this a VFS
feature and hence here is the appropriate place to be setting the mask?

Well, in the end it's a filesystem feature bit because the filesystem policy that decides whether DAX is used or not. e.g. if the block device is not DAX capable or dax=never mount option is set, we should not ever set STATX_ATTR_DAX in statx for either the attributes or attributes_mask field because the filesystem is not DAX capable. And given that we have filesystems with multiple block devices that can have different DAX capabilities, I think this statx() attr state (and mask) really has to come from the filesystem, not VFS...

Quoted 2 lines

Extra question: should we only set this in the attributes mask if CONFIG_FS_DAX=y ?

IMO, yes, because it will always be false on CONFIG_FS_DAX=n and so it may well as not be emitted as a supported bit in the mask.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]