Whamcloud - gitweb
LU-17344 lfsck: check the validity of the res_id 65/53565/2
authorHongchao Zhang <hongchao@whamcloud.com>
Mon, 11 Dec 2023 19:54:19 +0000 (03:54 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 2 Apr 2024 21:00:51 +0000 (21:00 +0000)
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 <hongchao@whamcloud.com>
Change-Id: Ibc5d16c3c7781fd92c44e48960c3746be81739d5
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53565
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lfsck/lfsck_layout.c

index 3dc699d..2caab2b 100644 (file)
@@ -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,