@@ -443,7 +443,7 @@ static inline bool lmv_is_sane(const struct lmv_mds_md_v1 *lmv)
if (le32_to_cpu(lmv->lmv_stripe_count) == 0)
goto insane;
- if (!lmv_is_known_hash_type(le32_to_cpu(lmv->lmv_hash_type)))
+ if (!lmv_is_sane_hash_type(le32_to_cpu(lmv->lmv_hash_type)))
goto insane;
return true;
@@ -465,7 +465,7 @@ static inline bool lmv_is_sane2(const struct lmv_mds_md_v1 *lmv)
if (le32_to_cpu(lmv->lmv_stripe_count) == 0)
goto insane;
- if (!lmv_is_known_hash_type(le32_to_cpu(lmv->lmv_hash_type)))
+ if (!lmv_is_sane_hash_type(le32_to_cpu(lmv->lmv_hash_type)))
goto insane;
return true;
@@ -794,6 +794,16 @@ static inline bool lmv_is_known_hash_type(__u32 type)
#define LMV_HASH_FLAG_KNOWN 0xbe000000
+/* migration failure may leave hash type as
+ * LMV_HASH_TYPE_UNKNOWN|LMV_HASH_FLAG_BAD_TYPE, which should be treated as
+ * sane, so such directory can be accessed (resume migration or unlink).
+ */
+static inline bool lmv_is_sane_hash_type(__u32 type)
+{
+ return lmv_is_known_hash_type(type) ||
+ type == (LMV_HASH_TYPE_UNKNOWN | LMV_HASH_FLAG_BAD_TYPE);
+}
+
/* both SPLIT and MIGRATION are set for directory split */
static inline bool lmv_hash_is_splitting(__u32 hash)
{