diff mbox series

ceph: update the dlease for the hashed dentry when removing

Message ID 20220330054956.271022-1-xiubli@redhat.com (mailing list archive)
State New, archived
Headers show
Series ceph: update the dlease for the hashed dentry when removing | expand

Commit Message

Xiubo Li March 30, 2022, 5:49 a.m. UTC
From: Xiubo Li <xiubli@redhat.com>

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>
---
 fs/ceph/inode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Jeff Layton March 30, 2022, 10:39 a.m. UTC | #1
On Wed, 2022-03-30 at 13:49 +0800, xiubli@redhat.com wrote:
> From: Xiubo Li <xiubli@redhat.com>
> 
> 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>
> ---
>  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 64b341f5e7bc..8cf55e6e609e 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -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;
>  		}
>  

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

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Xiubo Li March 30, 2022, 10:42 a.m. UTC | #2
On 3/30/22 6:39 PM, Jeff Layton wrote:
> On Wed, 2022-03-30 at 13:49 +0800, xiubli@redhat.com wrote:
>> From: Xiubo Li <xiubli@redhat.com>
>>
>> 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>
>> ---
>>   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 64b341f5e7bc..8cf55e6e609e 100644
>> --- a/fs/ceph/inode.c
>> +++ b/fs/ceph/inode.c
>> @@ -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;
>>   		}
>>   
> 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.

>
> Reviewed-by: Jeff Layton <jlayton@kernel.org>
>
diff mbox series

Patch

diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 64b341f5e7bc..8cf55e6e609e 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -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;
 		}