From: Alexander Zarochentsev Date: Fri, 7 Jun 2024 17:19:08 +0000 (+0000) Subject: LU-17635 lfsck: detect missing LMV hash X-Git-Tag: 2.15.65~65 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=57b992fceb593942b9ea6facd88cbda4db9786e9;p=fs%2Flustre-release.git LU-17635 lfsck: detect missing LMV hash Detect striped dirs with a missing LMV hash, attempting to set it for trivial cases mark BAD_TYPE otherwise. HPE-bug-id: LUS-12379 Signed-off-by: Alexander Zarochentsev Change-Id: Ibce4dd9cf01d653c431f7b7968691a4d704af9d9 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55364 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Andrew Perepechko Reviewed-by: Oleg Drokin --- diff --git a/lustre/lfsck/lfsck_striped_dir.c b/lustre/lfsck/lfsck_striped_dir.c index 6716522..61ea4bd 100644 --- a/lustre/lfsck/lfsck_striped_dir.c +++ b/lustre/lfsck/lfsck_striped_dir.c @@ -1957,16 +1957,31 @@ int lfsck_namespace_striped_dir_rescan(const struct lu_env *env, llmv->ll_lmv_updated = 1; } - if (!lmv_is_known_hash_type(lmv->lmv_hash_type) && - !(lmv->lmv_hash_type & LMV_HASH_FLAG_BAD_TYPE) && + hash_type = lmv->lmv_hash_type; + if (!lmv_is_known_hash_type(hash_type) && + !(hash_type & LMV_HASH_FLAG_BAD_TYPE) && lmv_is_known_hash_type(llmv->ll_hash_type)) { - hash_type = llmv->ll_hash_type & LMV_HASH_TYPE_MASK; - lmv->lmv_hash_type = llmv->ll_hash_type; + hash_type = lmv->lmv_hash_type = llmv->ll_hash_type; llmv->ll_lmv_updated = 1; } else { - hash_type = lmv->lmv_hash_type & LMV_HASH_TYPE_MASK; - if (!lmv_is_known_hash_type(hash_type)) - hash_type = LMV_HASH_TYPE_UNKNOWN; + if (!lmv_is_known_hash_type(hash_type)) { + /* Unknown hash type is not correct for a striped dir, + * let's mark such dirs with BAD_TYPE flag unless a + * hash type can be set for dirs with only one stripe + * or for 2-striped dirs in a process of migration */ + if (lmv->lmv_stripe_count == 1 || + (lmv->lmv_stripe_count == 2 && + (hash_type & LMV_HASH_FLAG_MIGRATION) && + lmv->lmv_migrate_offset == 1)) { + hash_type = LMV_HASH_TYPE_FNV_1A_64 | + LMV_HASH_FLAG_MIGRATION; + } else { + hash_type = LMV_HASH_TYPE_UNKNOWN | + LMV_HASH_FLAG_BAD_TYPE; + } + lmv->lmv_hash_type = hash_type; + llmv->ll_lmv_updated = 1; + } } if (llmv->ll_lmv_updated) { @@ -2038,8 +2053,7 @@ int lfsck_namespace_striped_dir_rescan(const struct lu_env *env, case LSLF_NONE: if (llmv->ll_inline || lslr->lslr_stripe_count != stripe_count || - (lslr->lslr_hash_type & LMV_HASH_TYPE_MASK) != - hash_type) + (lslr->lslr_hash_type != hash_type)) repair_lmvea = true; break; case LSLF_BAD_INDEX2: @@ -2051,8 +2065,7 @@ int lfsck_namespace_striped_dir_rescan(const struct lu_env *env, DFID":%u", PFID(cfid), lslr->lslr_index); if (llmv->ll_inline || lslr->lslr_stripe_count != stripe_count || - (lslr->lslr_hash_type & LMV_HASH_TYPE_MASK) != - hash_type) + (lslr->lslr_hash_type != hash_type)) repair_lmvea = true; break; case LSLF_BAD_INDEX1: