diff mbox series

[1/3] fs: add support for AT_STATX_CACHED

Message ID 20210125213614.24001-2-axboe@kernel.dk (mailing list archive)
State New
Headers show
Series [1/3] fs: add support for AT_STATX_CACHED | expand

Commit Message

Jens Axboe Jan. 25, 2021, 9:36 p.m. UTC
Since we now have LOOKUP_CACHED to only perform a fast lookup of the
dentry cache for path resolution, expose this as AT_STATX_CACHED to
provide the same functionality on the statx side.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/stat.c                  | 4 +++-
 include/uapi/linux/fcntl.h | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/stat.c b/fs/stat.c
index dacecdda2e79..f42d6fa1ec20 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -171,7 +171,7 @@  static int vfs_statx(int dfd, const char __user *filename, int flags,
 	int error;
 
 	if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT | AT_EMPTY_PATH |
-		      AT_STATX_SYNC_TYPE))
+		      AT_STATX_SYNC_TYPE | AT_STATX_CACHED))
 		return -EINVAL;
 
 	if (!(flags & AT_SYMLINK_NOFOLLOW))
@@ -180,6 +180,8 @@  static int vfs_statx(int dfd, const char __user *filename, int flags,
 		lookup_flags |= LOOKUP_AUTOMOUNT;
 	if (flags & AT_EMPTY_PATH)
 		lookup_flags |= LOOKUP_EMPTY;
+	if (flags & AT_STATX_CACHED)
+		lookup_flags |= LOOKUP_CACHED;
 
 retry:
 	error = user_path_at(dfd, filename, lookup_flags, &path);
diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h
index 2f86b2ad6d7e..19d5059393e7 100644
--- a/include/uapi/linux/fcntl.h
+++ b/include/uapi/linux/fcntl.h
@@ -111,4 +111,6 @@ 
 
 #define AT_RECURSIVE		0x8000	/* Apply to the entire subtree */
 
+#define AT_STATX_CACHED		0x10000 /* Only succeeds if inode/dentry is already cached */
+
 #endif /* _UAPI_LINUX_FCNTL_H */