Whamcloud - gitweb
LU-10580 lfsck: GPF in lfsck_namespace_repair_dirent 86/31086/3
authorAndriy Skulysh <c17819@cray.com>
Wed, 10 Jan 2018 03:07:02 +0000 (05:07 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 9 Feb 2018 05:58:30 +0000 (05:58 +0000)
chlid object can be NULL if we want just to remove a dirent

Change-Id: I330fc690b36c48c4be7fa4062304c39028f0b878
Cray-bug-id: MRP-4606
Signed-off-by: Andriy Skulysh <c17819@cray.com>
Reviewed-on: https://review.whamcloud.com/31086
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Alexandr Boyko <c17825@cray.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lfsck/lfsck_namespace.c

index 4c971ed..b613511 100644 (file)
@@ -2027,7 +2027,7 @@ int lfsck_namespace_repair_dirent(const struct lu_env *env,
        struct lfsck_thread_info        *info   = lfsck_env_info(env);
        struct dt_insert_rec            *rec    = &info->lti_dt_rec;
        const struct lu_fid             *pfid   = lfsck_dto2fid(parent);
-       const struct lu_fid             *cfid   = lfsck_dto2fid(child);
+       struct lu_fid                   cfid    = {0};
        struct lu_fid                    tfid;
        struct lfsck_instance           *lfsck  = com->lc_lfsck;
        struct dt_device                *dev    = lfsck->li_next;
@@ -2037,6 +2037,8 @@ int lfsck_namespace_repair_dirent(const struct lu_env *env,
        int                              rc     = 0;
        ENTRY;
 
+       if (child)
+               cfid = *lfsck_dto2fid(child);
        parent = lfsck_object_locate(dev, parent);
        if (IS_ERR(parent))
                GOTO(log, rc = PTR_ERR(parent));
@@ -2063,7 +2065,8 @@ int lfsck_namespace_repair_dirent(const struct lu_env *env,
 
        if (update) {
                rec->rec_type = lfsck_object_type(child) & S_IFMT;
-               rec->rec_fid = cfid;
+               LASSERT(!fid_is_zero(&cfid));
+               rec->rec_fid = &cfid;
                rc = dt_declare_insert(env, parent,
                                       (const struct dt_rec *)rec,
                                       (const struct dt_key *)name2, th);
@@ -2094,7 +2097,7 @@ int lfsck_namespace_repair_dirent(const struct lu_env *env,
 
        /* Someone has removed the bad name entry and reused it for other
         * object by race. */
-       if (!lu_fid_eq(&tfid, cfid))
+       if (!lu_fid_eq(&tfid, &cfid))
                GOTO(unlock2, rc = 0);
 
        if (lfsck->li_bookmark_ram.lb_param & LPF_DRYRUN)
@@ -2129,8 +2132,8 @@ stop:
        /* We are not sure whether the child will become orphan or not.
         * Record it in the LFSCK trace file for further checking in
         * the second-stage scanning. */
-       if (!update && !dec && rc == 0)
-               lfsck_namespace_trace_update(env, com, cfid,
+       if (!update && !dec && child && rc == 0)
+               lfsck_namespace_trace_update(env, com, &cfid,
                                             LNTF_CHECK_LINKEA, true);
 
 unlock1:
@@ -2143,7 +2146,7 @@ log:
               "entry for: parent "DFID", child "DFID", name %s, type "
               "in name entry %o, type claimed by child %o. repair it "
               "by %s with new name2 %s: rc = %d\n",
-              lfsck_lfsck2name(lfsck), PFID(pfid), PFID(cfid),
+              lfsck_lfsck2name(lfsck), PFID(pfid), PFID(&cfid),
               name, type, update ? lfsck_object_type(child) : 0,
               update ? "updating" : "removing", name2, rc);