linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fuse: fix inconsistent status between faccess and mkdir
@ 2021-05-14  1:55 Fengnan Chang
  2021-05-14  2:26 ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: Fengnan Chang @ 2021-05-14  1:55 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 | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 06a18700a845..154dd4578762 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1065,6 +1065,14 @@ static int fuse_do_getattr(struct inode *inode, struct kstat *stat,
 				fuse_fillattr(inode, &outarg.attr, stat);
 		}
 	}
+	if (err == -ENOENT) {
+		struct dentry *entry;
+
+		entry = d_obtain_alias(inode);
+		if (!IS_ERR(entry) && get_node_id(inode) != FUSE_ROOT_ID)
+			fuse_invalidate_entry_cache(entry);
+	}
+
 	return err;
 }

@@ -1226,6 +1234,14 @@ static int fuse_access(struct inode *inode, int mask)
 		fm->fc->no_access = 1;
 		err = 0;
 	}
+	if (err == -ENOENT) {
+		struct dentry *entry;
+
+		entry = d_obtain_alias(inode);
+		if (!IS_ERR(entry) && get_node_id(inode) != FUSE_ROOT_ID)
+			fuse_invalidate_entry_cache(entry);
+	}
+
 	return err;
 }

-- 
2.29.0


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

* Re: [PATCH] fuse: fix inconsistent status between faccess and mkdir
  2021-05-14  1:55 [PATCH] fuse: fix inconsistent status between faccess and mkdir Fengnan Chang
@ 2021-05-14  2:26 ` Matthew Wilcox
  2021-05-14  3:27   ` 答复: " changfengnan
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2021-05-14  2:26 UTC (permalink / raw)
  To: Fengnan Chang; +Cc: miklos, linux-fsdevel

On Fri, May 14, 2021 at 09:55:17AM +0800, Fengnan Chang wrote:
> +++ b/fs/fuse/dir.c
> @@ -1065,6 +1065,14 @@ static int fuse_do_getattr(struct inode *inode, struct kstat *stat,
>  				fuse_fillattr(inode, &outarg.attr, stat);
>  		}
>  	}
> +	if (err == -ENOENT) {
> +		struct dentry *entry;
> +
> +		entry = d_obtain_alias(inode);

Why d_obtain_alias() instead of d_find_any_alias()?

And what if you find the wrong alias?  ie an inode with two links?
Or does fuse not support hardlinks?


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

* 答复: [PATCH] fuse: fix inconsistent status between faccess and mkdir
  2021-05-14  2:26 ` Matthew Wilcox
@ 2021-05-14  3:27   ` changfengnan
  0 siblings, 0 replies; 3+ messages in thread
From: changfengnan @ 2021-05-14  3:27 UTC (permalink / raw)
  To: 'Matthew Wilcox'; +Cc: miklos, linux-fsdevel

we should us d_find_any_alias() rather than d_obtain_alias(), it's my
mistake.

Fuse is support hardlinks, if an inode with two links, we may found wrong
alias, we may need invalidate all dentry, because of the file is not exist
anymore.
But in other kernel code, I didn't see any handling for this situation. I
can't figure out why.

Thanks.

-----邮件原件-----
发件人: Matthew Wilcox <willy@infradead.org> 
发送时间: 2021年5月14日 10:27
收件人: Fengnan Chang <changfengnan@vivo.com>
抄送: miklos@szeredi.hu; linux-fsdevel@vger.kernel.org
主题: Re: [PATCH] fuse: fix inconsistent status between faccess and mkdir

On Fri, May 14, 2021 at 09:55:17AM +0800, Fengnan Chang wrote:
> +++ b/fs/fuse/dir.c
> @@ -1065,6 +1065,14 @@ static int fuse_do_getattr(struct inode *inode,
struct kstat *stat,
>  				fuse_fillattr(inode, &outarg.attr, stat);
>  		}
>  	}
> +	if (err == -ENOENT) {
> +		struct dentry *entry;
> +
> +		entry = d_obtain_alias(inode);

Why d_obtain_alias() instead of d_find_any_alias()?

And what if you find the wrong alias?  ie an inode with two links?
Or does fuse not support hardlinks?




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

end of thread, other threads:[~2021-05-14  3:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14  1:55 [PATCH] fuse: fix inconsistent status between faccess and mkdir Fengnan Chang
2021-05-14  2:26 ` Matthew Wilcox
2021-05-14  3:27   ` 答复: " changfengnan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).