Whamcloud - gitweb
LU-12635 build: Support for gcc -Wimplicit-fallthrough
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_scrub.c
index 22ee164..dfdd87c 100644 (file)
@@ -207,7 +207,7 @@ osd_scrub_convert_ff(struct osd_thread_info *info, struct osd_device *dev,
        rc = __osd_xattr_get(inode, dentry, XATTR_NAME_FID, ff, sizeof(*ff));
        if (rc == sizeof(*ff)) {
                /* 2) delete the old XATTR_NAME_FID */
-               ll_vfs_dq_init(inode);
+               dquot_initialize(inode);
                rc = osd_removexattr(dentry, inode, XATTR_NAME_FID);
                if (rc)
                        GOTO(stop, rc);
@@ -1896,6 +1896,12 @@ osd_ios_scan_one(struct osd_thread_info *info, struct osd_device *dev,
        int                      rc;
        ENTRY;
 
+       if (!inode) {
+               CDEBUG(D_INODE, "%s: child '%.*s' lacks inode: rc = -2\n",
+                      osd_name(dev), namelen, name);
+               RETURN(-ENOENT);
+       }
+
        rc = osd_get_lma(info, inode, &info->oti_obj_dentry,
                         &info->oti_ost_attrs);
        if (rc != 0 && rc != -ENODATA) {
@@ -2021,6 +2027,11 @@ static int osd_ios_lf_fill(void *buf,
                CDEBUG(D_LFSCK, "%s: cannot lookup child '%.*s': rc = %d\n",
                      osd_name(dev), namelen, name, (int)PTR_ERR(child));
                RETURN(0);
+       } else if (!child->d_inode) {
+               dput(child);
+               CDEBUG(D_INODE, "%s: child '%.*s' lacks inode\n",
+                      osd_name(dev), namelen, name);
+               RETURN(0);
        }
 
        inode = child->d_inode;
@@ -2219,6 +2230,8 @@ static int osd_ios_root_fill(void *buf,
        child = osd_ios_lookup_one_len(name, fill_buf->oifb_dentry, namelen);
        if (IS_ERR(child))
                RETURN(PTR_ERR(child));
+       else if (!child->d_inode)
+               GOTO(out_put, rc = -ENOENT);
 
        if (!(map->olm_flags & OLF_NO_OI))
                rc = osd_ios_scan_one(fill_buf->oifb_info, dev,
@@ -2227,6 +2240,7 @@ static int osd_ios_root_fill(void *buf,
        if (rc == 0 && map->olm_flags & OLF_SCAN_SUBITEMS)
                rc = osd_ios_new_item(dev, child, map->olm_scandir,
                                      map->olm_filldir);
+out_put:
        dput(child);
 
        RETURN(rc);
@@ -2305,19 +2319,20 @@ osd_ios_ROOT_scan(struct osd_thread_info *info, struct osd_device *dev,
        scrub->os_convert_igif = 1;
        child = osd_ios_lookup_one_len(dot_lustre_name, dentry,
                                       strlen(dot_lustre_name));
-       if (IS_ERR(child)) {
+       if (IS_ERR(child) && PTR_ERR(child) != -ENOENT) {
                rc = PTR_ERR(child);
-               if (rc == -ENOENT) {
-                       /* It is 1.8 MDT device. */
-                       if (!(sf->sf_flags & SF_UPGRADE)) {
-                               scrub_file_reset(scrub, dev->od_uuid,
-                                                SF_UPGRADE);
-                               sf->sf_internal_flags &= ~SIF_NO_HANDLE_OLD_FID;
-                               rc = scrub_file_store(info->oti_env, scrub);
-                       } else {
-                               rc = 0;
-                       }
+       } else if (IS_ERR(child) || !child->d_inode) {
+               /* It is 1.8 MDT device. */
+               if (!(sf->sf_flags & SF_UPGRADE)) {
+                       scrub_file_reset(scrub, dev->od_uuid,
+                                        SF_UPGRADE);
+                       sf->sf_internal_flags &= ~SIF_NO_HANDLE_OLD_FID;
+                       rc = scrub_file_store(info->oti_env, scrub);
+               } else {
+                       rc = 0;
                }
+               if (!IS_ERR(child))
+                       dput(child);
        } else {
                /* For lustre-2.x (x <= 3), the ".lustre" has NO FID-in-LMA,
                 * so the client will get IGIF for the ".lustre" object when
@@ -2373,32 +2388,28 @@ osd_ios_OBJECTS_scan(struct osd_thread_info *info, struct osd_device *dev,
        }
 
        child = osd_ios_lookup_one_len(ADMIN_USR, dentry, strlen(ADMIN_USR));
-       if (!IS_ERR(child)) {
+       if (IS_ERR(child)) {
+               rc = PTR_ERR(child);
+       } else {
                rc = osd_ios_scan_one(info, dev, dentry->d_inode,
                                      child->d_inode, NULL, ADMIN_USR,
                                      strlen(ADMIN_USR), 0);
                dput(child);
-       } else {
-               rc = PTR_ERR(child);
        }
 
        if (rc != 0 && rc != -ENOENT)
-               RETURN(rc);
+               GOTO(out, rc);
 
        child = osd_ios_lookup_one_len(ADMIN_GRP, dentry, strlen(ADMIN_GRP));
-       if (!IS_ERR(child)) {
-               rc = osd_ios_scan_one(info, dev, dentry->d_inode,
-                                     child->d_inode, NULL, ADMIN_GRP,
-                                     strlen(ADMIN_GRP), 0);
-               dput(child);
-       } else {
-               rc = PTR_ERR(child);
-       }
-
-       if (rc == -ENOENT)
-               rc = 0;
+       if (IS_ERR(child))
+               GOTO(out, rc = PTR_ERR(child));
 
-       RETURN(rc);
+       rc = osd_ios_scan_one(info, dev, dentry->d_inode,
+                             child->d_inode, NULL, ADMIN_GRP,
+                             strlen(ADMIN_GRP), 0);
+       dput(child);
+out:
+       RETURN(rc == -ENOENT ? 0 : rc);
 }
 
 static void osd_initial_OI_scrub(struct osd_thread_info *info,
@@ -2448,12 +2459,13 @@ static void osd_initial_OI_scrub(struct osd_thread_info *info,
                child = osd_ios_lookup_one_len(map->olm_name,
                                               osd_sb(dev)->s_root,
                                               map->olm_namelen);
-               if (!IS_ERR(child))
-                       dput(child);
-               else if (PTR_ERR(child) == -ENOENT)
+               if (PTR_ERR(child) == -ENOENT ||
+                   (!IS_ERR(child) && !child->d_inode))
                        osd_scrub_refresh_mapping(info, dev, &map->olm_fid,
                                                  NULL, DTO_INDEX_DELETE,
                                                  true, 0, NULL);
+               if (!IS_ERR(child))
+                       dput(child);
                map++;
        }