[lustre-devel] [PATCH 16/21] lustre: osc: Don't include lock for srvlock

James Simmons jsimmons at infradead.org
Fri Feb 7 16:30:22 PST 2025


From: Patrick Farrell <pfarrell at whamcloud.com>

When doing server side locking, it doesn't make sense to do
the 'search for covering lock and send it to the server'
step when building an RPC, because we will not use that
lock.

This can disguise issues on the client, because prolonging
a lock is supposed to let a client avoid eviction if it is
still doing IO under the lock, but we are not.  This can
result in delaying an eviction which should be occurring
because the client can't give the lock back.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13805
Lustre-commit: 9a34ec2b09864a933 ("LU-13805 osc: Don't include lock for srvlock")
Signed-off-by: Patrick Farrell <pfarrell at whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50067
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/osc/osc_object.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/fs/lustre/osc/osc_object.c b/fs/lustre/osc/osc_object.c
index efb053323dda..dd2820b8049a 100644
--- a/fs/lustre/osc/osc_object.c
+++ b/fs/lustre/osc/osc_object.c
@@ -344,10 +344,12 @@ static void osc_req_attr_set(const struct lu_env *env, struct cl_object *obj,
 	struct lov_oinfo *oinfo;
 	struct ost_lvb *lvb;
 	struct obdo *oa;
+	struct osc_page *opg;
 
 	oinfo = cl2osc(obj)->oo_oinfo;
 	lvb = &oinfo->loi_lvb;
 	oa = attr->cra_oa;
+	opg = osc_cl_page_osc(attr->cra_page, cl2osc(obj));
 
 	if (flags & OBD_MD_FLMTIME) {
 		oa->o_mtime = lvb->lvb_mtime;
@@ -381,14 +383,15 @@ static void osc_req_attr_set(const struct lu_env *env, struct cl_object *obj,
 		}
 		oa->o_valid |= OBD_MD_FLID;
 	}
-	if (flags & OBD_MD_FLHANDLE) {
+	/* if srvlock is set, don't look for a local lock, since we won't use
+	 * it and shouldn't note it in the RPC
+	 */
+	if (flags & OBD_MD_FLHANDLE && !opg->ops_srvlock) {
 		struct ldlm_lock *lock;
-		struct osc_page *opg;
 
-		opg = osc_cl_page_osc(attr->cra_page, cl2osc(obj));
 		lock = osc_dlmlock_at_pgoff(env, cl2osc(obj), osc_index(opg),
 					    OSC_DAP_FL_TEST_LOCK | OSC_DAP_FL_CANCELING);
-		if (!lock && !opg->ops_srvlock) {
+		if (!lock) {
 			struct ldlm_namespace *ns;
 			struct ldlm_resource *res;
 			struct ldlm_res_id *resname;
@@ -405,12 +408,9 @@ static void osc_req_attr_set(const struct lu_env *env, struct cl_object *obj,
 			LBUG();
 		}
 
-		/* check for lockless io. */
-		if (lock) {
-			oa->o_handle = lock->l_remote_handle;
-			oa->o_valid |= OBD_MD_FLHANDLE;
-			LDLM_LOCK_PUT(lock);
-		}
+		oa->o_handle = lock->l_remote_handle;
+		oa->o_valid |= OBD_MD_FLHANDLE;
+		LDLM_LOCK_PUT(lock);
 	}
 }
 
-- 
2.39.3



More information about the lustre-devel mailing list