Skip to content

Commit 712b269

Browse files
weiny2djwong
authored andcommitted
fs/stat: Define DAX statx attribute
In order for users to determine if a file is currently operating in DAX state (effective DAX). Define a statx attribute value and set that attribute if the effective DAX flag is set. To go along with this we propose the following addition to the statx man page: STATX_ATTR_DAX The file is in the DAX (cpu direct access) state. DAX state attempts to minimize software cache effects for both I/O and memory mappings of this file. It requires a file system which has been configured to support DAX. DAX generally assumes all accesses are via cpu load / store instructions which can minimize overhead for small accesses, but may adversely affect cpu utilization for large transfers. File I/O is done directly to/from user-space buffers and memory mapped I/O may be performed with direct memory mappings that bypass kernel page cache. While the DAX property tends to result in data being transferred synchronously, it does not give the same guarantees of O_SYNC where data and the necessary metadata are transferred together. A DAX file may support being mapped with the MAP_SYNC flag, which enables a program to use CPU cache flush instructions to persist CPU store operations without an explicit fsync(2). See mmap(2) for more information. Reviewed-by: Dave Chinner <[email protected]> Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Ira Weiny <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent efbe3c2 commit 712b269

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

fs/stat.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat,
7979
if (IS_AUTOMOUNT(inode))
8080
stat->attributes |= STATX_ATTR_AUTOMOUNT;
8181

82+
if (IS_DAX(inode))
83+
stat->attributes |= STATX_ATTR_DAX;
84+
8285
if (inode->i_op->getattr)
8386
return inode->i_op->getattr(path, stat, request_mask,
8487
query_flags);

include/uapi/linux/stat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ struct statx {
169169
#define STATX_ATTR_ENCRYPTED 0x00000800 /* [I] File requires key to decrypt in fs */
170170
#define STATX_ATTR_AUTOMOUNT 0x00001000 /* Dir: Automount trigger */
171171
#define STATX_ATTR_VERITY 0x00100000 /* [I] Verity protected file */
172+
#define STATX_ATTR_DAX 0x00002000 /* [I] File is DAX */
172173

173174

174175
#endif /* _UAPI_LINUX_STAT_H */

0 commit comments

Comments
 (0)