From 1de051ba9761e6bcf9410b759a3c8cd225d04a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20Figui=C3=A8re?= Date: Thu, 11 Jan 2024 20:36:19 -0500 Subject: [PATCH] document-portal: Don't invalidate directories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This works around issue #1234. This is a followup from #1190. fuse_lowlevel_notify_inval_entry() will invalidate directories too, which is a problem as it invalidate the current workdir directory. So now we don't invalidate them and will let the kernel deal with it. This is consistent with the passthrough_hp example from fuse. But this still make the directory being held for longer than necessary. Signed-off-by: Hubert Figuière --- document-portal/document-portal-fuse.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/document-portal/document-portal-fuse.c b/document-portal/document-portal-fuse.c index ac2014a10..f8a95abd7 100644 --- a/document-portal/document-portal-fuse.c +++ b/document-portal/document-portal-fuse.c @@ -1847,17 +1847,21 @@ xdp_fuse_lookup (fuse_req_t req, } else { + g_autoptr(XdpInode) inode = NULL; + struct stat buf; + g_assert (parent_domain->type == XDP_DOMAIN_DOCUMENT); fd = xdp_document_inode_open_child_fd (parent, name, open_flags, 0); if (fd < 0) return xdp_reply_err (op, req, -fd); - res = ensure_docdir_inode (parent, fd, &e, NULL); /* Takes ownership of fd */ + res = ensure_docdir_inode (parent, fd, &e, &inode); /* Takes ownership of fd */ if (res != 0) return xdp_reply_err (op, req, -res); - queue_invalidate_dentry (parent, name); + if (fstat (inode->physical->fd, &buf) != 0 || !S_ISDIR(buf.st_mode)) + queue_invalidate_dentry (parent, name); } g_debug ("LOOKUP %lx:%s => %lx", parent_ino, name, e.ino);