return rc;
}
-static struct dt_object *
-lfsck_namespace_load_one_trace_file(const struct lu_env *env,
- struct lfsck_component *com,
- struct dt_object *parent,
- const char *name, bool reset)
-{
- struct lfsck_instance *lfsck = com->lc_lfsck;
- struct dt_object *obj;
- int rc;
-
- if (reset) {
- rc = local_object_unlink(env, lfsck->li_bottom, parent, name);
- if (rc != 0 && rc != -ENOENT)
- return ERR_PTR(rc);
- }
-
- obj = local_index_find_or_create(env, lfsck->li_los, parent, name,
- S_IFREG | S_IRUGO | S_IWUSR,
- &dt_lfsck_features);
-
- return obj;
-}
-
-static int lfsck_namespace_load_sub_trace_files(const struct lu_env *env,
- struct lfsck_component *com,
- bool reset)
-{
- char *name = lfsck_env_info(env)->lti_key;
- struct lfsck_sub_trace_obj *lsto;
- struct dt_object *obj;
- int rc;
- int i;
-
- for (i = 0, lsto = &com->lc_sub_trace_objs[0];
- i < LFSCK_STF_COUNT; i++, lsto++) {
- snprintf(name, NAME_MAX, "%s_%02d", LFSCK_NAMESPACE, i);
- mutex_lock(&lsto->lsto_mutex);
- if (lsto->lsto_obj != NULL) {
- if (!reset) {
- mutex_unlock(&lsto->lsto_mutex);
- continue;
- }
-
- lfsck_object_put(env, lsto->lsto_obj);
- lsto->lsto_obj = NULL;
- }
-
- obj = lfsck_namespace_load_one_trace_file(env, com,
- com->lc_lfsck->li_lfsck_dir, name, reset);
- LASSERT(obj != NULL);
- if (IS_ERR(obj)) {
- rc = PTR_ERR(obj);
- } else {
- lsto->lsto_obj = obj;
- rc = obj->do_ops->do_index_try(env, obj,
- &dt_lfsck_features);
- }
- mutex_unlock(&lsto->lsto_mutex);
- if (rc != 0)
- return rc;
- }
-
- return 0;
-}
-
static int lfsck_namespace_init(const struct lu_env *env,
struct lfsck_component *com)
{
ns->ln_time_latest_reset = cfs_time_current_sec();
down_write(&com->lc_sem);
rc = lfsck_namespace_store(env, com);
- up_write(&com->lc_sem);
if (rc == 0)
- rc = lfsck_namespace_load_sub_trace_files(env, com, true);
+ rc = lfsck_load_sub_trace_files(env, com,
+ &dt_lfsck_namespace_features, LFSCK_NAMESPACE, true);
+ up_write(&com->lc_sem);
return rc;
}
* When the LFSCK runs again, if the dangling name is still
* there, the LFSCK should move the orphan directory object
* back to the normal namespace. */
- if (!lpf && !lu_fid_eq(pfid, &tfid) && once) {
+ if (!lpf && !fid_is_zero(pfid) &&
+ !lu_fid_eq(pfid, &tfid) && once) {
linkea_next_entry(ldata);
continue;
}
* directory contains the specified child, but such
* parent does not match the dotdot name entry, then
* trust the linkEA. */
- if (!lu_fid_eq(pfid, pfid2)) {
+ if (!fid_is_zero(pfid) && !lu_fid_eq(pfid, pfid2)) {
*type = LNIT_UNMATCHED_PAIRS;
rc = lfsck_namespace_repair_unmatched_pairs(env,
com, child, pfid2, cname);
struct lfsck_namespace *ns = com->lc_file_ram;
struct lfsck_assistant_data *lad = com->lc_data;
struct dt_object *root;
- struct dt_object *dto;
int rc;
ENTRY;
ns->ln_status = LS_INIT;
ns->ln_time_latest_reset = cfs_time_current_sec();
- lfsck_object_put(env, com->lc_obj);
- com->lc_obj = NULL;
- dto = lfsck_namespace_load_one_trace_file(env, com, root,
- LFSCK_NAMESPACE, true);
- if (IS_ERR(dto))
- GOTO(out, rc = PTR_ERR(dto));
+ rc = lfsck_load_one_trace_file(env, com, root, &com->lc_obj,
+ &dt_lfsck_namespace_features,
+ LFSCK_NAMESPACE, true);
+ if (rc)
+ GOTO(out, rc);
- com->lc_obj = dto;
- rc = lfsck_namespace_load_sub_trace_files(env, com, true);
+ rc = lfsck_load_sub_trace_files(env, com, &dt_lfsck_namespace_features,
+ LFSCK_NAMESPACE, true);
if (rc != 0)
GOTO(out, rc);
down_write(&com->lc_sem);
com->lc_new_checked++;
com->lc_new_scanned++;
- if (rc >= 0 && fid_is_sane(&fid))
+ if (rc >= 0)
ns->ln_fid_latest_scanned_phase2 = fid;
+
if (rc > 0)
ns->ln_objs_repaired_phase2++;
else if (rc < 0)
ns->ln_time_last_checkpoint = cfs_time_current_sec();
ns->ln_objs_checked_phase2 += com->lc_new_checked;
com->lc_new_checked = 0;
- rc = lfsck_namespace_store(env, com);
+ lfsck_namespace_store(env, com);
up_write(&com->lc_sem);
- if (rc != 0)
- GOTO(put, rc);
com->lc_time_last_checkpoint = cfs_time_current();
com->lc_time_next_checkpoint =
obj = local_index_find_or_create(env, lfsck->li_los, root,
LFSCK_NAMESPACE,
S_IFREG | S_IRUGO | S_IWUSR,
- &dt_lfsck_features);
+ &dt_lfsck_namespace_features);
if (IS_ERR(obj))
GOTO(out, rc = PTR_ERR(obj));
else if (rc < 0)
rc = lfsck_namespace_reset(env, com, true);
else
- rc = lfsck_namespace_load_sub_trace_files(env, com, false);
+ rc = lfsck_load_sub_trace_files(env, com,
+ &dt_lfsck_namespace_features, LFSCK_NAMESPACE, false);
if (rc != 0)
GOTO(out, rc);