Skip to contentSkip to conversation

ceph: update the dlease for the hashed dentry when removing

PATCH In review [email protected] 2 participants 3 messages Mar 30, 2022 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: update the dlease for the hashed dentry when removing

From: Xiubo Li <[email protected]>

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.

---
 fs/ceph/inode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ceph/inode.c +3 -1
index 64b341f5e7bc..8cf55e6e609e 100644
@@ -1467,10 +1467,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;
 		}
 
Signature · 1 line
2.27.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · On Wed, 2022-03-30 at 13:49 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

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.

---
 fs/ceph/inode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ceph/inode.c +0 -0
index 64b341f5e7bc..8cf55e6e609e 100644
@@ -1467,10 +1467,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);

fs/ceph/inode.c int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req) · line 1478

Quoted 10 lines
fs/ceph/inode.c +3 -1
+			}
+
+			if (!d_unhashed(dn) && have_lease)
 				update_dentry_lease(dir, dn,
 						    rinfo->dlease, session,
 						    req->r_request_started);
-			}
 			goto done;
 		}
 

I think this makes sense, since we can have a lease for a negative dentry.

author
#2 lore raw
Quoted 24 lines · Jeff Layton
Quoted 23 lines · On Wed, 2022-03-30 at 13:49 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

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.

---
  fs/ceph/inode.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
fs/ceph/inode.c +3 -0
index 64b341f5e7bc..8cf55e6e609e 100644
@@ -1467,10 +1467,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,
Quoted 8 lines

fs/ceph/inode.c int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req) · line 1478

Quoted 6 lines
fs/ceph/inode.c +0 -1
  						    rinfo->dlease, session,
  						    req->r_request_started);
-			}
  			goto done;
  		}
 

I think this makes sense, since we can have a lease for a negative dentry.

Yeah, from the logs there really has many case will do that.

Thanks Jeff.

Quoted 3 lines