Whamcloud - gitweb
LU-11862 lfsck: avoid unexpected repairing 33/34033/2
authorAlexey Lyashkov <c17817@cray.com>
Tue, 15 Jan 2019 13:08:08 +0000 (16:08 +0300)
committerOleg Drokin <green@whamcloud.com>
Mon, 11 Feb 2019 03:22:03 +0000 (03:22 +0000)
lfsck can called with create in parallel,
so some OST objects will don't have a right owner.
Don't treat it as wrong owner issue.

Cray-bug-id: LUS-6181
Signed-off-by: Alexey Lyashkov <c17817@cray.com>
Change-Id: Id9c067a67d558dcfcb0a2f0fdd790b446b4f54d0
Reviewed-on: https://review.whamcloud.com/34033
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alexander Zarochentsev <c17826@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lfsck/lfsck_layout.c
lustre/tests/sanity-lfsck.sh

index 9f45c9a..6cdbd83 100644 (file)
@@ -3979,6 +3979,7 @@ static int lfsck_layout_repair_owner(const struct lu_env *env,
        struct dt_device                *dev    = lfsck_obj2dev(child);
        struct thandle                  *handle;
        int                              rc;
+       dt_obj_version_t                 version;
        ENTRY;
 
        tla->la_uid = pla->la_uid;
@@ -4001,14 +4002,18 @@ static int lfsck_layout_repair_owner(const struct lu_env *env,
        if (unlikely(lfsck_is_dead_obj(parent)))
                GOTO(unlock, rc = 1);
 
+       version = dt_version_get(env, child);
+       if (version == -EOPNOTSUPP)
+               version = 0;
+
        /* Get the latest parent's owner. */
        rc = dt_attr_get(env, parent, pla);
        if (rc != 0)
                GOTO(unlock, rc);
 
        /* Some others chown/chgrp during the LFSCK, needs to do nothing. */
-       if (unlikely(tla->la_uid != pla->la_uid ||
-                    tla->la_gid != pla->la_gid))
+       if (unlikely((!version && tla->la_ctime == 0) ||
+                    tla->la_uid != pla->la_uid || tla->la_gid != pla->la_gid))
                rc = 1;
        else
                rc = dt_attr_set(env, child, tla, handle);
index fdd987f..69f2783 100644 (file)
@@ -1882,6 +1882,11 @@ test_16() {
        dd if=/dev/zero of=$DIR/$tdir/f0 bs=1M count=1
        cancel_lru_locks osc
 
+       # created but no setattr or write to the file.
+       mkdir $DIR/$tdir/d1
+       chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/d1
+       $RUNAS createmany -o $DIR/$tdir/d1/o 100 || error "create failed"
+
        echo "Inject failure stub to skip OST-object owner changing"
        #define OBD_FAIL_LFSCK_BAD_OWNER        0x1613
        do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1613