diff mbox series

[03/27] lustre: llite: protect cp_state with vmpage lock

Message ID 1681739243-29375-4-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: sync to OpenSFS branch April 17, 2023 | expand

Commit Message

James Simmons April 17, 2023, 1:46 p.m. UTC
From: Bobi Jam <bobijam@whamcloud.com>

cl_page_make_ready() calls cl_page_io_start() without vmpage lock
protection, and that could mess up cl_page's cp_state/cp_owner.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16612
Lustre-commit: d03b038d0dd8360dc ("LU-16612 llite: protect cp_state with vmpage lock")
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50180
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/obdclass/cl_page.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/lustre/obdclass/cl_page.c b/fs/lustre/obdclass/cl_page.c
index 8320293..80423b7 100644
--- a/fs/lustre/obdclass/cl_page.c
+++ b/fs/lustre/obdclass/cl_page.c
@@ -871,6 +871,7 @@  int cl_page_make_ready(const struct lu_env *env, struct cl_page *cp,
 		       enum cl_req_type crt)
 {
 	struct page *vmpage = cp->cp_vmpage;
+	bool unlock = false;
 	int rc = 0;
 
 	PASSERT(env, cp, crt == CRT_WRITE);
@@ -879,6 +880,7 @@  int cl_page_make_ready(const struct lu_env *env, struct cl_page *cp,
 		goto out;
 
 	lock_page(vmpage);
+	unlock = true;
 
 	if (clear_page_dirty_for_io(vmpage)) {
 		LASSERT(cp->cp_state == CPS_CACHED);
@@ -899,13 +901,15 @@  int cl_page_make_ready(const struct lu_env *env, struct cl_page *cp,
 		LBUG();
 	}
 
-	unlock_page(vmpage);
 out:
 	if (rc == 0) {
 		PASSERT(env, cp, cp->cp_state == CPS_CACHED);
 		cl_page_io_start(env, cp, crt);
 	}
 
+	if (unlock)
+		unlock_page(vmpage);
+
 	CL_PAGE_HEADER(D_TRACE, env, cp, "%d %d\n", crt, rc);
 
 	return rc;