Whamcloud - gitweb
LU-11584 osd-ldiskfs: fix lost+found object replace 46/33546/3
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 1 Nov 2018 08:59:04 +0000 (02:59 -0600)
committerOleg Drokin <green@whamcloud.com>
Wed, 27 Feb 2019 02:00:43 +0000 (02:00 +0000)
Fix the case where an OST object is being moved from lost+found
and an unused OST object is found in the object tree with the
same OID.  The unused object was being deleted, but the object
was not being moved from lost+found in this case.

Continue on with moving the object from lost+found unless an
error was returned from the unlink (excluding -ENOENT).

Fix sanity-scrub.sh test_14 to run e2fsck after the test to
verify that OI Scrub repaired the lost+found objects correctly.

The check_and_prep() helper erases the filesystem and should
only be used in cases like sanity-scrub and sanity-lfsck where
it matters.  Remove unnecessary call from sanity test_409().

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I6fc6a15b1ca3d8e34bfd2d1266f80fc0730540e5
Reviewed-on: https://review.whamcloud.com/33546
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osd-ldiskfs/osd_compat.c
lustre/osd-ldiskfs/osd_scrub.c
lustre/tests/sanity-scrub.sh
lustre/tests/sanity.sh

index 680d236..40e6d76 100644 (file)
@@ -1260,7 +1260,8 @@ int osd_obj_map_recover(struct osd_thread_info *info,
                        if (unlikely(rc == -ENOENT))
                                rc = 0;
                }
-               RETURN(rc);
+               if (rc)
+                       RETURN(rc);
        }
 
        bh = osd_ldiskfs_find_entry(src_parent, &src_child->d_name, &de,
index 6232235..efe89a4 100644 (file)
@@ -627,8 +627,8 @@ static int osd_scrub_check_local_fldb(struct osd_thread_info *info,
         *      quite possible for FID-on-MDT. */
        if (dev->od_is_ost)
                return SCRUB_NEXT_OSTOBJ_OLD;
-       else
-               return 0;
+
+       return 0;
 }
 
 static int osd_scrub_get_fid(struct osd_thread_info *info,
@@ -636,8 +636,8 @@ static int osd_scrub_get_fid(struct osd_thread_info *info,
                             struct lu_fid *fid, bool scrub)
 {
        struct lustre_mdt_attrs *lma = &info->oti_ost_attrs.loa_lma;
-       int rc;
        bool has_lma = false;
+       int rc;
 
        rc = osd_get_lma(info, inode, &info->oti_obj_dentry,
                         &info->oti_ost_attrs);
index f7dc22f..16cac0b 100644 (file)
@@ -1142,10 +1142,10 @@ run_test 13 "OI scrub can rebuild missed /O entries"
 
 test_14() {
        [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] &&
-               skip "ldiskfs special test" && return
+               skip "ldiskfs special test"
 
        check_mount_and_prep
-       $SETSTRIPE -c 1 -i 0 $DIR/$tdir
+       $LFS setstripe -c 1 -i 0 $DIR/$tdir
 
        #define OBD_FAIL_OSD_COMPAT_NO_ENTRY            0x196
        do_facet ost1 $LCTL set_param fail_loc=0x196
@@ -1168,13 +1168,19 @@ test_14() {
        mount_client $MOUNT || error "(5) Fail to start client!"
 
        local LF_REPAIRED=$($SHOW_SCRUB_ON_OST |
-                           awk '/^lf_repa[ri]*ed/ { print $2 }')
+                           awk '/^lf_repa[ir]*ed/ { print $2 }')
        [ $LF_REPAIRED -ge 1000 ] ||
                error "(6) Some entry under /lost+found should be repaired"
 
        ls -ail $DIR/$tdir > /dev/null || error "(7) ls should succeed"
+
+       stopall
+
+       echo "run e2fsck again after LFSCK"
+       run_e2fsck $(facet_host ost1) $(ostdevname 1) "-y" ||
+               error "(8) Fail to run e2fsck error"
 }
-run_test 14 "OI scrub can repair objects under lost+found"
+run_test 14 "OI scrub can repair OST objects under lost+found"
 
 test_15() {
        local repaired
index e78788a..daa8994 100755 (executable)
@@ -19188,8 +19188,7 @@ run_test 408 "drop_caches should not hang due to page leaks"
 
 test_409()
 {
-       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
-       check_mount_and_prep
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
 
        mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
        $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
@@ -19213,6 +19212,7 @@ test_409()
        echo "Unlink hard links start at $(date)"
        unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
                error "(7) Fail to unlink"
+       echo "Unlink hard links finished at $(date)"
 }
 run_test 409 "Large amount of cross-MDTs hard links on the same file"