From 130750ff23d260e59ba1b794fcc4f9208bb7bf07 Mon Sep 17 00:00:00 2001 From: Andriy Skulysh Date: Wed, 14 Feb 2024 00:49:30 -0800 Subject: [PATCH] LU-15477 osc: osc_extent_wait() deadlock Thread 1: vvp_io_write_commit osc_io_commit_async osc_page_cache_add osc_extent_find osc_extent_wait Thread 2: ptlrpcd_check ptlrpc_check_set brw_queue_work osc_extent_make_ready vvp_page_make_ready_start __lock_page We must not hold a page lock while we do osc_extent_find() Lustre-change: https://review.whamcloud.com/46281 Lustre-commit: 821a8d7b481d34a54044dfe871e4532f0996de8a Change-Id: Idf669bc8d9c943f28e3f5986826b9637d66ecfca HPE-bug-id: LUS-10414 Fixes: a7299cb012 "LU-9920 vvp: dirty pages with pagevec" Signed-off-by: Andriy Skulysh Reviewed-by: Patrick Farrell Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54032 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/osc/osc_cache.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index a4bdc58..27c320d 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -2439,15 +2439,16 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, LASSERT(ergo(grants > 0, grants >= tmp)); rc = 0; + + /* We must not hold a page lock while we do osc_enter_cache() + * or osc_extent_find(), so we must mark dirty & unlock + * any pages in the write commit pagevec. */ + if (pagevec_count(pvec)) { + cb(env, io, pvec); + pagevec_reinit(pvec); + } + if (grants == 0) { - /* We haven't allocated grant for this page, and we - * must not hold a page lock while we do enter_cache, - * so we must mark dirty & unlock any pages in the - * write commit pagevec. */ - if (pagevec_count(pvec)) { - cb(env, io, pvec); - pagevec_reinit(pvec); - } rc = osc_enter_cache(env, cli, oap, tmp); if (rc == 0) grants = tmp; -- 1.8.3.1