Whamcloud - gitweb
LU-2041 oi: keep oi mapping cache consistency
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_handler.c
index 2cf7076..1ebf741 100644 (file)
@@ -287,7 +287,7 @@ osd_iget_verify(struct osd_thread_info *info, struct osd_device *dev,
                CDEBUG(D_LFSCK, "inconsistent obj: "DFID", %lu, "DFID"\n",
                       PFID(&lma->lma_self_fid), inode->i_ino, PFID(fid));
                iput(inode);
-               return ERR_PTR(EREMCHG);
+               return ERR_PTR(-EREMCHG);
        }
 
        return inode;
@@ -319,15 +319,18 @@ static int osd_fid_lookup(const struct lu_env *env, struct osd_object *obj,
        info = osd_oti_get(env);
        LASSERT(info);
        oic = &info->oti_cache;
-       id  = &oic->oic_lid;
 
        if (OBD_FAIL_CHECK(OBD_FAIL_OST_ENOENT))
                RETURN(-ENOENT);
 
        /* Search order: 1. per-thread cache. */
        if (lu_fid_eq(fid, &oic->oic_fid)) {
+               id = &oic->oic_lid;
                goto iget;
-       } else if (!cfs_list_empty(&scrub->os_inconsistent_items)) {
+       }
+
+       id = &info->oti_id;
+       if (!cfs_list_empty(&scrub->os_inconsistent_items)) {
                /* Search order: 2. OI scrub pending list. */
                result = osd_oii_lookup(dev, fid, id);
                if (result == 0)
@@ -3328,7 +3331,7 @@ static int osd_ea_add_rec(const struct lu_env *env, struct osd_object *pobj,
         return rc;
 }
 
-static int
+static void
 osd_consistency_check(struct osd_thread_info *oti, struct osd_device *dev,
                      struct osd_idmap_cache *oic)
 {
@@ -3340,15 +3343,15 @@ osd_consistency_check(struct osd_thread_info *oti, struct osd_device *dev,
        ENTRY;
 
        if (!fid_is_norm(fid) && !fid_is_igif(fid))
-               RETURN(0);
+               RETURN_EXIT;
 
 again:
        rc = osd_oi_lookup(oti, dev, fid, id);
        if (rc != 0 && rc != -ENOENT)
-               RETURN(rc);
+               RETURN_EXIT;
 
        if (rc == 0 && osd_id_eq(id, &oic->oic_lid))
-               RETURN(0);
+               RETURN_EXIT;
 
        if (thread_is_running(&scrub->os_thread)) {
                rc = osd_oii_insert(dev, oic, rc == -ENOENT);
@@ -3359,7 +3362,7 @@ again:
                if (unlikely(rc == -EAGAIN))
                        goto again;
 
-               RETURN(rc);
+               RETURN_EXIT;
        }
 
        if (!dev->od_noscrub && ++once == 1) {
@@ -3374,7 +3377,7 @@ again:
                        goto again;
        }
 
-       RETURN(0);
+       EXIT;
 }
 
 /**
@@ -4159,8 +4162,10 @@ static inline int osd_it_ea_rec(const struct lu_env *env,
 
        if (!fid_is_sane(fid)) {
                rc = osd_ea_fid_get(env, obj, ino, fid, &oic->oic_lid);
-               if (rc != 0)
+               if (rc != 0) {
+                       fid_zero(&oic->oic_fid);
                        RETURN(rc);
+               }
        } else {
                osd_id_gen(&oic->oic_lid, ino, OSD_OII_NOGEN);
        }