lkml.org 
[lkml]   [2023]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 08/11] vfs: move file_accessed() to the beginning of iterate_dir()
Date
From: Hao Xu <howeyxu@tencent.com>

Move file_accessed() to the beginning of iterate_dir() so that we don't
need to rollback all the work done when file_accessed() returns -EAGAIN
at the end of getdents.

Signed-off-by: Hao Xu <howeyxu@tencent.com>
---
fs/readdir.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/readdir.c b/fs/readdir.c
index 2f4c9c663a39..6469f076ba6e 100644
--- a/fs/readdir.c
+++ b/fs/readdir.c
@@ -61,6 +61,10 @@ int iterate_dir(struct file *file, struct dir_context *ctx)

res = -ENOENT;
if (!IS_DEADDIR(inode)) {
+ res = file_accessed(file, ctx->flags & DIR_CONTEXT_F_NOWAIT);
+ if (res == -EAGAIN)
+ goto out_unlock;
+
ctx->pos = file->f_pos;
if (shared)
res = file->f_op->iterate_shared(file, ctx);
@@ -68,8 +72,9 @@ int iterate_dir(struct file *file, struct dir_context *ctx)
res = file->f_op->iterate(file, ctx);
file->f_pos = ctx->pos;
fsnotify_access(file);
- file_accessed(file, ctx->flags & DIR_CONTEXT_F_NOWAIT);
}
+
+out_unlock:
if (shared)
inode_unlock_shared(inode);
else
--
2.25.1
\
 
 \ /
  Last update: 2023-08-27 15:36    [W:2.668 / U:1.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site