Whamcloud - gitweb
LU-7268 scrub: NOT assign LMA for EA inode
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_scrub.c
index 72c6759..ff639e2 100644 (file)
@@ -497,6 +497,10 @@ osd_scrub_check_update(struct osd_thread_info *info, struct osd_device *dev,
                        GOTO(out, rc);
                }
 
+               /* The inode has been reused as EA inode, ignore it. */
+               if (unlikely(osd_is_ea_inode(inode)))
+                       GOTO(out, rc = 0);
+
                sf->sf_flags |= SF_UPGRADE;
                sf->sf_internal_flags &= ~SIF_NO_HANDLE_OLD_FID;
                dev->od_check_ff = 1;
@@ -536,6 +540,10 @@ iget:
                                        rc = 0;
                                GOTO(out, rc);
                        }
+
+                       /* The inode has been reused as EA inode, ignore it. */
+                       if (unlikely(osd_is_ea_inode(inode)))
+                               GOTO(out, rc = 0);
                }
 
                if (!scrub->os_partial_scan)
@@ -740,9 +748,10 @@ static int osd_scrub_checkpoint(struct osd_scrub *scrub)
        return rc;
 }
 
-static void osd_scrub_post(struct osd_scrub *scrub, int result)
+static int osd_scrub_post(struct osd_scrub *scrub, int result)
 {
        struct scrub_file *sf = &scrub->os_file;
+       int rc;
        ENTRY;
 
        CDEBUG(D_LFSCK, "%.16s: OI scrub post, result = %d\n",
@@ -782,10 +791,10 @@ static void osd_scrub_post(struct osd_scrub *scrub, int result)
        }
        sf->sf_run_time += cfs_duration_sec(cfs_time_current() + HALF_SEC -
                                            scrub->os_time_last_checkpoint);
-       result = osd_scrub_file_store(scrub);
+       rc = osd_scrub_file_store(scrub);
        up_write(&scrub->os_rwsem);
 
-       EXIT;
+       RETURN(rc < 0 ? rc : result);
 }
 
 /* iteration engine */
@@ -957,6 +966,10 @@ static int osd_iit_iget(struct osd_thread_info *info, struct osd_device *dev,
                RETURN(rc);
        }
 
+       /* It is an EA inode, no OI mapping for it, skip it. */
+       if (osd_is_ea_inode(inode))
+               GOTO(put, rc = SCRUB_NEXT_CONTINUE);
+
        if (scrub &&
            ldiskfs_test_inode_state(inode, LDISKFS_STATE_LUSTRE_NOSCRUB)) {
                /* Only skip it for the first OI scrub accessing. */
@@ -1502,7 +1515,7 @@ static int osd_scrub_main(void *args)
        GOTO(post, rc);
 
 post:
-       osd_scrub_post(scrub, rc);
+       rc = osd_scrub_post(scrub, rc);
        CDEBUG(D_LFSCK, "%.16s: OI scrub: stop, pos = %u: rc = %d\n",
               osd_scrub2name(scrub), scrub->os_pos_current, rc);
 
@@ -1734,7 +1747,19 @@ osd_ios_lookup_one_len(const char *name, struct dentry *parent, int namelen)
        struct dentry *dentry;
 
        dentry = ll_lookup_one_len(name, parent, namelen);
-       if (!IS_ERR(dentry) && dentry->d_inode == NULL) {
+       if (IS_ERR(dentry)) {
+               int rc = PTR_ERR(dentry);
+
+               if (rc != -ENOENT)
+                       CERROR("Fail to find %.*s in %.*s (%lu/%u): rc = %d\n",
+                              namelen, name, parent->d_name.len,
+                              parent->d_name.name, parent->d_inode->i_ino,
+                              parent->d_inode->i_generation, rc);
+
+               return dentry;
+       }
+
+       if (dentry->d_inode == NULL) {
                dput(dentry);
                return ERR_PTR(-ENOENT);
        }
@@ -2487,8 +2512,29 @@ int osd_scrub_setup(const struct lu_env *env, struct osd_device *dev)
                GOTO(cleanup_inode, rc);
        } else {
                if (memcmp(sf->sf_uuid, es->s_uuid, 16) != 0) {
+                       struct obd_uuid *old_uuid;
+                       struct obd_uuid *new_uuid;
+
+                       OBD_ALLOC_PTR(old_uuid);
+                       OBD_ALLOC_PTR(new_uuid);
+                       if (old_uuid == NULL || new_uuid == NULL) {
+                               CERROR("%.16s: UUID has been changed, but"
+                                      "failed to allocate RAM for report\n",
+                                      LDISKFS_SB(sb)->s_es->s_volume_name);
+                       } else {
+                               class_uuid_unparse(sf->sf_uuid, old_uuid);
+                               class_uuid_unparse(es->s_uuid, new_uuid);
+                               CERROR("%.16s: UUID has been changed from "
+                                      "%s to %s\n",
+                                      LDISKFS_SB(sb)->s_es->s_volume_name,
+                                      old_uuid->uuid, new_uuid->uuid);
+                       }
                        osd_scrub_file_reset(scrub, es->s_uuid,SF_INCONSISTENT);
                        dirty = 1;
+                       if (old_uuid != NULL)
+                               OBD_FREE_PTR(old_uuid);
+                       if (new_uuid != NULL)
+                               OBD_FREE_PTR(new_uuid);
                } else if (sf->sf_status == SS_SCANNING) {
                        sf->sf_status = SS_CRASHED;
                        dirty = 1;