Blob Blame History Raw
From: Xiubo Li <xiubli@redhat.com>
Date: Wed, 30 Mar 2022 12:21:12 +0800
Subject: ceph: update the dlease for the hashed dentry when removing
Git-commit: 7ffe4fcea789552fac47216188f30559c329c847
Patch-mainline: v5.19-rc1
References: jsc#SES-1880

The MDS will always refresh the dentry lease when removing the files
or directories. And if the dentry is still hashed, we can update
the dentry lease and no need to do the lookup from the MDS later.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Acked-by: Luis Henriques <lhenriques@suse.com>
---
 fs/ceph/inode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 63113e2a4890..f9b68b2c9b12 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1466,10 +1466,12 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req)
 			} else if (have_lease) {
 				if (d_unhashed(dn))
 					d_add(dn, NULL);
+			}
+
+			if (!d_unhashed(dn) && have_lease)
 				update_dentry_lease(dir, dn,
 						    rinfo->dlease, session,
 						    req->r_request_started);
-			}
 			goto done;
 		}