[Devel,vz7] fuse: revert Dcache is always invalid

Submitted by Maxim Patlasov on July 17, 2017, 10:06 p.m.

Details

Message ID 150032912505.15785.9223806188265634040.stgit@maxim-thinkpad
State New
Series "fuse: revert Dcache is always invalid"
Headers show

Commit Message

Maxim Patlasov July 17, 2017, 10:06 p.m.
The patch reverts 4ae1fa01a5d865c3a96e0753be26b1d874f25827 initially
sent by Pavel Emelyanov three years ago with description:

> The existing behavior -- a dentry is valid for some time period. Then
> revalidation in the userpsace is required. This is wrong for PCS, since
> dentry effectively becomes invalid once a file is closed, i.e. -- always.

This justification above does not look reasonable anymore because, as AK
pointed out:

> What's about correctness of the statement, it is even formally wrong.
> No matter how frequently you invalidate, the file can disappear right
> after lookup, so that full disable of dcache is meaningless.

The policy must be set by fused. Currently it always gives entry_valid=0
ensuring that behavior stays the same with or without 4ae1..5827. But the
policy is going to change in near future to support usecases of directories
with > 100000 entries. Hence reverting 4ae1..5827 is required: otherwise fused
won't be able to utilize readdirplus.

Signed-off-by: Alexey Kuznetsov <kuznet@virtuozzo.com>
Signed-off-by: Maxim Patlasov <mpatlasov@virtuozzo.com>
---
 fs/fuse/dir.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 1d41bfe..68e09f9 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -187,7 +187,8 @@  static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
 	inode = ACCESS_ONCE(entry->d_inode);
 	if (inode && is_bad_inode(inode))
 		goto invalid;
-	else if (1) {
+	else if (time_before64(fuse_dentry_time(entry), get_jiffies_64()) ||
+		 (flags & LOOKUP_REVAL)) {
 		int err;
 		struct fuse_entry_out outarg;
 		struct fuse_req *req;
@@ -245,6 +246,13 @@  static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
 				       entry_attr_timeout(&outarg),
 				       attr_version);
 		fuse_change_entry_timeout(entry, &outarg);
+	} else if (inode) {
+		fc = get_fuse_conn(inode);
+		if (fc->readdirplus_auto) {
+			parent = dget_parent(entry);
+			fuse_advise_use_readdirplus(parent->d_inode);
+			dput(parent);
+		}
 	}
 	ret = 1;
 out: