Whamcloud - gitweb
LU-15886 lfsck: remove unreasonable assertions
[fs/lustre-release.git] / lustre / lfsck / lfsck_namespace.c
index e954edf..df57d18 100644 (file)
@@ -1464,7 +1464,8 @@ static int lfsck_namespace_create_orphan_dir(const struct lu_env *env,
                GOTO(log, rc = 1);
 
        if (dt_object_remote(orphan)) {
-               LASSERT(lfsck->li_lpf_root_obj != NULL);
+               if (lfsck->li_lpf_root_obj == NULL)
+                       GOTO(log, rc = -EBADF);
 
                idx = lfsck_find_mdt_idx_by_fid(env, lfsck, cfid);
                if (idx < 0)
@@ -3493,10 +3494,6 @@ static int lfsck_namespace_linkea_clear_overflow(const struct lu_env *env,
        if (lfsck->li_bookmark_ram.lb_param & LPF_DRYRUN)
                GOTO(unlock, rc = 1);
 
-       /* If all known entries are in the linkEA, then the 'leh_reccount'
-        * should NOT be zero. */
-       LASSERT(ldata->ld_leh->leh_reccount > 0);
-
        lfsck_buf_init(&linkea_buf, ldata->ld_buf->lb_buf,
                       ldata->ld_leh->leh_len);
        rc = dt_xattr_set(env, obj, &linkea_buf, XATTR_NAME_LINK, 0, th);
@@ -3778,7 +3775,7 @@ static int lfsck_namespace_double_scan_one(const struct lu_env *env,
 
                        repaired = true;
 
-                       /* fall through */
+                       /* fallthrough */
                }
 
                parent = lfsck_object_find_bottom(env, lfsck, pfid);
@@ -6129,13 +6126,19 @@ static int lfsck_namespace_scan_local_lpf_one(const struct lu_env *env,
        int                              rc     = 0;
        __u8                             flags  = 0;
        bool                             exist  = false;
+
        ENTRY;
 
        child = lfsck_object_find_by_dev(env, dev, &ent->lde_fid);
        if (IS_ERR(child))
                RETURN(PTR_ERR(child));
 
-       LASSERT(dt_object_exists(child));
+       if (!dt_object_exists(child)) {
+               CDEBUG(D_LFSCK, "%s: lost+found/%s doesn't exist\n",
+                      lfsck_lfsck2name(lfsck), ent->lde_name);
+               GOTO(out, rc = -ENOENT);
+       }
+
        LASSERT(!dt_object_remote(child));
 
        idx = lfsck_sub_trace_file_fid2idx(&ent->lde_fid);
@@ -6892,9 +6895,14 @@ int lfsck_verify_linkea(const struct lu_env *env, struct lfsck_instance *lfsck,
        int                      rc;
        int                      fl     = LU_XATTR_CREATE;
        bool                     dirty  = false;
+
        ENTRY;
 
-       LASSERT(S_ISDIR(lfsck_object_type(obj)));
+       if (!dt_object_exists(obj))
+               RETURN(-ENOENT);
+
+       if (!S_ISDIR(lfsck_object_type(obj)))
+               RETURN(-ENOTDIR);
 
        rc = lfsck_links_read_with_rec(env, obj, &ldata);
        if (rc == -ENODATA) {
@@ -7152,14 +7160,14 @@ int lfsck_namespace_setup(const struct lu_env *env,
        default:
                CERROR("%s: unknown lfsck_namespace status %d\n",
                       lfsck_lfsck2name(lfsck), ns->ln_status);
-               /* fall through */
+               fallthrough;
        case LS_SCANNING_PHASE1:
        case LS_SCANNING_PHASE2:
                /* No need to store the status to disk right now.
                 * If the system crashed before the status stored,
                 * it will be loaded back when next time. */
                ns->ln_status = LS_CRASHED;
-               /* fall through */
+               fallthrough;
        case LS_PAUSED:
        case LS_CRASHED:
                spin_lock(&lfsck->li_lock);