Whamcloud - gitweb
LU-6235 scrub: replace the stale OI mapping 45/13745/3
authorFan Yong <fan.yong@intel.com>
Thu, 20 Nov 2014 04:54:59 +0000 (12:54 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 18 Feb 2015 22:08:32 +0000 (22:08 +0000)
If the OI mapping on the OST contains an invalid one, then the OI
lookup via osd_obj_map_lookup() may return -ENOENT. From the view
of OI scrub, it is indistinguishable from the case of there is no
such OI mapping, then it will cause the OI scrub to use "INSERT"
@ops for osd_scrub_refresh_mapping() to repair such inconsistency
by wrong. So the osd_obj_map_lookup() should return -ESTALE under
the case of invalid OI mapping exists, then the OI scrub can use
"UPDATE" @ops for osd_scrub_refresh_mapping() to repair.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: I013125eb0aaec683ac8f56ec32a30e7858262f87
Reviewed-on: http://review.whamcloud.com/13745
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osd-ldiskfs/osd_compat.c
lustre/osd-ldiskfs/osd_scrub.c

index ca2dc18..9e0c0d7 100644 (file)
@@ -905,8 +905,11 @@ int osd_obj_map_lookup(struct osd_thread_info *info, struct osd_device *dev,
        brelse(bh);
 
        inode = osd_iget(info, dev, id);
-       if (IS_ERR(inode))
-               RETURN(PTR_ERR(inode));
+       if (IS_ERR(inode)) {
+               int rc = PTR_ERR(inode);
+
+               RETURN(rc == -ENOENT ? -ESTALE : rc);
+       }
 
        iput(inode);
        RETURN(0);
index a92db02..d59ad51 100644 (file)
@@ -509,14 +509,19 @@ osd_scrub_check_update(struct osd_thread_info *info, struct osd_device *dev,
            (!scrub->os_convert_igif || OBD_FAIL_CHECK(OBD_FAIL_FID_NOLMA)))
                GOTO(out, rc = 0);
 
-       if ((oii != NULL && oii->oii_insert) || (val == SCRUB_NEXT_NOLMA))
+       if ((oii != NULL && oii->oii_insert) || (val == SCRUB_NEXT_NOLMA)) {
+               ops = DTO_INDEX_INSERT;
+
                goto iget;
+       }
 
        rc = osd_oi_lookup(info, dev, fid, lid2,
                (val == SCRUB_NEXT_OSTOBJ ||
                 val == SCRUB_NEXT_OSTOBJ_OLD) ? OI_KNOWN_ON_OST : 0);
        if (rc != 0) {
-               if (rc != -ENOENT && rc != -ESTALE)
+               if (rc == -ENOENT)
+                       ops = DTO_INDEX_INSERT;
+               else if (rc != -ESTALE)
                        GOTO(out, rc);
 
 iget:
@@ -534,7 +539,6 @@ iget:
                if (!scrub->os_partial_scan)
                        scrub->os_full_speed = 1;
 
-               ops = DTO_INDEX_INSERT;
                idx = osd_oi_fid2idx(dev, fid);
                switch (val) {
                case SCRUB_NEXT_NOLMA: