From 85941b9fb9ef5c27870550469f2e088c4e690603 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Fri, 12 Aug 2022 14:24:17 +0300 Subject: [PATCH] LU-15117 ofd: no lock for dt_bufs_get() in read path osd_bufs_get() allocates the pages and can cause new transactions as part of memory release procedure. this would break Lustre's "start a transaction, then do locking" rule. Signed-off-by: Alex Zhuravlev Change-Id: I782f0cc6c96251ad88d5fb8d15c9ac91d382bf7e Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48209 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Yang Sheng Reviewed-by: Andreas Dilger --- lustre/ofd/ofd_io.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index 1ff552e..27da3ed 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -580,15 +580,8 @@ static int ofd_preprw_read(const struct lu_env *env, struct obd_export *exp, if (oa->o_valid & OBD_MD_FLATIME) ofd_handle_atime(env, ofd, fo, oa->o_atime); - ofd_read_lock(env, fo); if (!ofd_object_exists(fo)) - GOTO(unlock, rc = -ENOENT); - - if (ofd->ofd_lfsck_verify_pfid && oa->o_valid & OBD_MD_FLFID) { - rc = ofd_verify_ff(env, fo, oa); - if (rc != 0) - GOTO(unlock, rc); - } + GOTO(obj_put, rc = -ENOENT); if (ptlrpc_connection_is_local(exp->exp_connection)) dbt |= DT_BUFS_TYPE_LOCAL; @@ -616,10 +609,20 @@ static int ofd_preprw_read(const struct lu_env *env, struct obd_export *exp, tot_bytes += rnb[i].rnb_len; } + ofd_read_lock(env, fo); + if (!ofd_object_exists(fo)) + GOTO(unlock, rc = -ENOENT); + + if (ofd->ofd_lfsck_verify_pfid && oa->o_valid & OBD_MD_FLFID) { + rc = ofd_verify_ff(env, fo, oa); + if (rc != 0) + GOTO(unlock, rc); + } + LASSERT(*nr_local > 0 && *nr_local <= PTLRPC_MAX_BRW_PAGES); rc = dt_read_prep(env, ofd_object_child(fo), lnb, *nr_local); if (unlikely(rc)) - GOTO(buf_put, rc); + GOTO(unlock, rc); ofd_read_unlock(env, fo); ofd_access(env, ofd, @@ -635,10 +638,11 @@ static int ofd_preprw_read(const struct lu_env *env, struct obd_export *exp, RETURN(0); -buf_put: - dt_bufs_put(env, ofd_object_child(fo), lnb, *nr_local); unlock: ofd_read_unlock(env, fo); +buf_put: + dt_bufs_put(env, ofd_object_child(fo), lnb, *nr_local); +obj_put: ofd_object_put(env, fo); return rc; } -- 1.8.3.1