diff mbox series

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

Message ID 20250208003027.180076-17-jsimmons@infradead.org (mailing list archive)
State New
Headers show
Series lustre: sync to OpenSFS branch June 28, 2023 | expand

Commit Message

James Simmons Feb. 8, 2025, 12:30 a.m. UTC
From: Patrick Farrell <pfarrell@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@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50067
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/osc/osc_object.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
diff mbox series

Patch

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);
 	}
 }