From 7d3b69f44e9279e9f29e480b4c66c35f4d5c2201 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. Lustre-change: https://review.whamcloud.com/48209 Lustre-commit: 85941b9fb9ef5c27870550469f2e088c4e690603 Signed-off-by: Alex Zhuravlev Change-Id: I782f0cc6c96251ad88d5fb8d15c9ac91d382bf7e Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54535 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/ofd/ofd_io.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index 33321be..42c3fae 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -618,15 +618,8 @@ static int ofd_preprw_read(const struct lu_env *env, struct obd_export *exp, ofd_handle_attrs(env, ofd, fo, oa); - 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; @@ -750,20 +743,29 @@ 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, compr_unaligned_read); if (unlikely(rc)) - GOTO(buf_put, rc); + GOTO(unlock, rc); if (compr_unaligned_read) { rc = ofd_decompress_read(env, exp, oa, rnb, lnb, obj, *nr_local, eof_rnb, type, lvl, chunk_bits, false); if (unlikely(rc)) - GOTO(buf_put, rc); + GOTO(unlock, rc); } - ofd_read_unlock(env, fo); ofd_access(env, ofd, @@ -779,10 +781,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