All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] fuse: fix inconsistent status between faccess and mkdir
@ 2021-05-14  6:17 Fengnan Chang
  2021-05-18 13:32 ` Miklos Szeredi
  0 siblings, 1 reply; 2+ messages in thread
From: Fengnan Chang @ 2021-05-14  6:17 UTC (permalink / raw)
  To: miklos, linux-fsdevel; +Cc: Fengnan Chang

since FUSE caches dentries and attributes with separate timeout, It may
happen that checking the permission returns -ENOENT, but because the
dentries cache has not timed out, creating the file returns -EEXIST.
Fix this by when return -ENOENT, mark the entry as stale.

Signed-off-by: Fengnan Chang <changfengnan@vivo.com>
---
 fs/fuse/dir.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 06a18700a845..a22206290da9 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1065,6 +1065,24 @@ static int fuse_do_getattr(struct inode *inode, struct kstat *stat,
 				fuse_fillattr(inode, &outarg.attr, stat);
 		}
 	}
+	if (err == -ENOENT && get_node_id(inode) != FUSE_ROOT_ID) {
+		if (S_ISDIR(inode->i_mode)) {
+			struct dentry *dir = d_find_any_alias(inode);
+
+			if (dir) {
+				fuse_invalidate_entry_cache(dir);
+				dput(dir);
+			}
+		} else {
+			struct dentry *dentry;
+
+			while ((dentry = d_find_alias(inode))) {
+				fuse_invalidate_entry_cache(dentry);
+				dput(dentry);
+			}
+		}
+	}
+
 	return err;
 }
 
@@ -1226,6 +1244,24 @@ static int fuse_access(struct inode *inode, int mask)
 		fm->fc->no_access = 1;
 		err = 0;
 	}
+	if (err == -ENOENT && get_node_id(inode) != FUSE_ROOT_ID) {
+		if (S_ISDIR(inode->i_mode)) {
+			struct dentry *dir = d_find_any_alias(inode);
+
+			if (dir) {
+				fuse_invalidate_entry_cache(dir);
+				dput(dir);
+			}
+		} else {
+			struct dentry *dentry;
+
+			while ((dentry = d_find_alias(inode))) {
+				fuse_invalidate_entry_cache(dentry);
+				dput(dentry);
+			}
+		}
+	}
+
 	return err;
 }
 
-- 
2.29.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] fuse: fix inconsistent status between faccess and mkdir
  2021-05-14  6:17 [PATCH v2] fuse: fix inconsistent status between faccess and mkdir Fengnan Chang
@ 2021-05-18 13:32 ` Miklos Szeredi
  0 siblings, 0 replies; 2+ messages in thread
From: Miklos Szeredi @ 2021-05-18 13:32 UTC (permalink / raw)
  To: Fengnan Chang; +Cc: linux-fsdevel

On Fri, 14 May 2021 at 08:18, Fengnan Chang <changfengnan@vivo.com> wrote:
>
> since FUSE caches dentries and attributes with separate timeout, It may
> happen that checking the permission returns -ENOENT, but because the
> dentries cache has not timed out, creating the file returns -EEXIST.

This should be fixed in v5.11 and later by commit df8629af2934 ("fuse:
always revalidate if exclusive create").

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-18 13:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14  6:17 [PATCH v2] fuse: fix inconsistent status between faccess and mkdir Fengnan Chang
2021-05-18 13:32 ` Miklos Szeredi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.