From 0038843dcd4ce52ce3ef2e9dd5ec145211e0f09c Mon Sep 17 00:00:00 2001
From: yangxin <245051644@qq.com>
Date: Mon, 5 Dec 2022 10:42:04 +0800
Subject: [PATCH 2/3] Add drop link and dentry invalid in unlink and rmdir.

Signed-off-by: yangxin <245051644@qq.com>
---
 qtfs/qtfs/sb.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/qtfs/qtfs/sb.c b/qtfs/qtfs/sb.c
index 4ad4aed..5fd2c8f 100644
--- a/qtfs/qtfs/sb.c
+++ b/qtfs/qtfs/sb.c
@@ -989,6 +989,7 @@ int qtfs_rmdir(struct inode *dir, struct dentry *dentry)
 	struct qtreq_rmdir *req;
 	struct qtrsp_rmdir *rsp;
 	int ret;
+	struct inode *inode = d_inode(dentry);
 
 	if (!pvar) {
 		qtfs_err("Failed to get qtfs sock var\n");
@@ -1012,6 +1013,9 @@ int qtfs_rmdir(struct inode *dir, struct dentry *dentry)
 	}
 	qtfs_info("qtfs rmdir success:<%s>.\n", req->path);
 	qtfs_conn_put_param(pvar);
+	if (inode->i_nlink > 0)
+                drop_nlink(inode);
+        d_invalidate(dentry);
 	return 0;
 }
 
@@ -1046,6 +1050,9 @@ int qtfs_unlink(struct inode *dir, struct dentry *dentry)
 	}
 	ret = rsp->errno;
 	qtfs_conn_put_param(pvar);
+	if (inode->i_nlink > 0)
+                drop_nlink(inode);
+        d_invalidate(dentry);
 	return ret;
 }
 
-- 
2.23.0

