LASSERT(flags != 0);
+ if (unlikely(!fid_is_sane(fid)))
+ RETURN(0);
+
idx = lfsck_sub_trace_file_fid2idx(fid);
obj = com->lc_sub_trace_objs[idx].lsto_obj;
mutex_lock(&com->lc_sub_trace_objs[idx].lsto_mutex);
bool bad_hash = false;
int idx = 0;
int count = 0;
- int rc;
+ int rc = 0;
enum lfsck_namespace_inconsistency_type type = LNIT_NONE;
ENTRY;
GOTO(out, rc);
}
+ if (unlikely(!fid_is_sane(&lnr->lnr_fid))) {
+ CDEBUG(D_LFSCK, "%s: dir scan find invalid FID "DFID
+ " for the name entry %.*s under "DFID"\n",
+ lfsck_lfsck2name(lfsck), PFID(&lnr->lnr_fid),
+ lnr->lnr_namelen, lnr->lnr_name, PFID(pfid));
+
+ if (strcmp(lnr->lnr_name, dotdot) != 0)
+ /* invalid FID means bad name entry, remove it. */
+ type = LNIT_BAD_DIRENT;
+ else
+ /* If the parent FID is invalid, we cannot remove
+ * the ".." entry directly. */
+ rc = lfsck_namespace_trace_update(env, com, pfid,
+ LNTF_CHECK_PARENT, true);
+
+ GOTO(out, rc);
+ }
+
if (unlikely(lnr->lnr_dir_cookie == MDS_DIR_END_OFF)) {
rc = lfsck_namespace_striped_dir_rescan(env, com, lnr);
/* done with de, release bh */
brelse(bh);
if (rc != 0) {
- if (unlikely(ino == osd_remote_parent_ino(dev)))
+ if (unlikely(ino == osd_remote_parent_ino(dev))) {
+ const char *name = (const char *)key;
+
/* If the parent is on remote MDT, and there
* is no FID-in-dirent, then we have to get
* the parent FID from the linkEA. */
- rc = osd_get_pfid_from_linkea(env, obj, fid);
- else
+ if (likely(strlen(name) == 2 &&
+ name[0] == '.' && name[1] == '.'))
+ rc = osd_get_pfid_from_linkea(env, obj,
+ fid);
+ } else {
rc = osd_ea_fid_get(env, obj, ino, fid, id);
+ }
} else {
osd_id_gen(id, ino, OSD_OII_NOGEN);
}
/* If the parent is on remote MDT, and there
* is no FID-in-dirent, then we have to get
* the parent FID from the linkEA. */
- osd_get_pfid_from_linkea(env, obj, fid);
+ if (!fid_is_sane(fid) &&
+ it->oie_dirent->oied_namelen == 2 &&
+ it->oie_dirent->oied_name[0] == '.' &&
+ it->oie_dirent->oied_name[1] == '.')
+ osd_get_pfid_from_linkea(env, obj, fid);
} else {
rc = osd_dirent_check_repair(env, obj, it, fid, id,
&attr);
} else {
attr &= ~LU_DIRENT_ATTRS_MASK;
if (!fid_is_sane(fid)) {
- if (OBD_FAIL_CHECK(OBD_FAIL_FID_LOOKUP) &&
- likely(it->oie_dirent->oied_namelen != 2 ||
- it->oie_dirent->oied_name[0] != '.' ||
- it->oie_dirent->oied_name[1] != '.'))
- RETURN(-ENOENT);
-
- if (unlikely(ino == osd_remote_parent_ino(dev)))
+ if (it->oie_dirent->oied_namelen == 2 &&
+ it->oie_dirent->oied_name[0] == '.' &&
+ it->oie_dirent->oied_name[1] == '.') {
/* If the parent is on remote MDT, and there
* is no FID-in-dirent, then we have to get
* the parent FID from the linkEA. */
- rc = osd_get_pfid_from_linkea(env, obj, fid);
- else
+ if (ino == osd_remote_parent_ino(dev))
+ rc = osd_get_pfid_from_linkea(env, obj,
+ fid);
+ } else {
+ if (OBD_FAIL_CHECK(OBD_FAIL_FID_LOOKUP))
+ RETURN(-ENOENT);
+
rc = osd_ea_fid_get(env, obj, ino, fid, id);
+ }
} else {
osd_id_gen(id, ino, OSD_OII_NOGEN);
}