From 5d0c8fed33b1e214d6c633712699c4c969d2bf6e Mon Sep 17 00:00:00 2001 From: Hongchao Zhang Date: Tue, 12 Dec 2023 03:54:19 +0800 Subject: [PATCH] LU-17344 lfsck: check the validity of the res_id During processing the object destroying request in LFSCK, the incoming FID could generate invalid ldlm_res_id even if the dt_object is loaded successfully by this FID, this patch adds checks for the validity of the generated res_id and return error instead of triggering the panic. Signed-off-by: Hongchao Zhang Change-Id: Ibc5d16c3c7781fd92c44e48960c3746be81739d5 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53565 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- lustre/lfsck/lfsck_layout.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lustre/lfsck/lfsck_layout.c b/lustre/lfsck/lfsck_layout.c index 3dc699d..2caab2b 100644 --- a/lustre/lfsck/lfsck_layout.c +++ b/lustre/lfsck/lfsck_layout.c @@ -2683,6 +2683,17 @@ static int lfsck_layout_slave_conditional_destroy(const struct lu_env *env, memset(policy, 0, sizeof(*policy)); policy->l_extent.end = OBD_OBJECT_EOF; ost_fid_build_resid(fid, resid); + + /* LU-17344: check the validity of the ldlm_res_id */ + if (unlikely(resid->name[0] == 0)) { + CERROR("%s: the res_id "DLDLMRES" built by the FID "DFID" (the obj %p) is invalid\n", + lfsck_lfsck2name(lfsck), resid->name[0], resid->name[1], + resid->name[2], resid->name[3], PFID(fid), obj); + + dump_stack(); + return -EIO; + } + rc = ldlm_cli_enqueue_local(env, lfsck->li_namespace, resid, LDLM_EXTENT, policy, LCK_EX, &flags, ldlm_blocking_ast, ldlm_completion_ast, -- 1.8.3.1