Whamcloud - gitweb
LU-13535 lfsck: fix possible PFL layout corruption
[fs/lustre-release.git] / lustre / lfsck / lfsck_layout.c
index b2aad04..68ca022 100644 (file)
@@ -2329,6 +2329,9 @@ static int lfsck_layout_recreate_parent(const struct lu_env *env,
        int                              rc     = 0;
        ENTRY;
 
+       if (lfsck_is_dryrun(lfsck))
+               GOTO(log, rc = 0);
+
        if (unlikely(lpf == NULL))
                GOTO(log, rc = -ENXIO);
 
@@ -2729,6 +2732,9 @@ static int lfsck_layout_conflict_create(const struct lu_env *env,
        if (rc != 0 && rc != -ENOENT)
                GOTO(unlock, rc);
 
+       if (lfsck_is_dryrun(com->lc_lfsck))
+               GOTO(unlock, rc = 0);
+
        th = dt_trans_create(env, dev);
        if (IS_ERR(th))
                GOTO(unlock, rc = PTR_ERR(th));
@@ -2808,6 +2814,9 @@ static int lfsck_layout_recreate_lovea(const struct lu_env *env,
        bool new_mirror = true;
        ENTRY;
 
+       if (lfsck_is_dryrun(lfsck))
+               RETURN(0);
+
        rc = lfsck_ibits_lock(env, lfsck, parent, &lh,
                              MDS_INODELOCK_LAYOUT | MDS_INODELOCK_XATTR,
                              LCK_EX);
@@ -5662,14 +5671,15 @@ again:
        lmm = buf->lb_buf;
        magic = le32_to_cpu(lmm->lmm_magic);
        if (magic == LOV_MAGIC_COMP_V1) {
+               struct lov_mds_md_v1 *v1;
                int i;
 
                lcm = buf->lb_buf;
                count = le16_to_cpu(lcm->lcm_entry_count);
                for (i = 0; i < count; i++) {
                        lcme = &lcm->lcm_entries[i];
-                       lmm = buf->lb_buf + le32_to_cpu(lcme->lcme_offset);
-                       if (memcmp(oi, &lmm->lmm_oi, sizeof(*oi)) != 0)
+                       v1 = buf->lb_buf + le32_to_cpu(lcme->lcme_offset);
+                       if (memcmp(oi, &v1->lmm_oi, sizeof(*oi)) != 0)
                                goto fix;
                }
 
@@ -5718,12 +5728,13 @@ fix:
        }
 
        if (magic == LOV_MAGIC_COMP_V1) {
+               struct lov_mds_md_v1 *v1;
                int i;
 
                for (i = 0; i < count; i++) {
                        lcme = &lcm->lcm_entries[i];
-                       lmm = buf->lb_buf + le32_to_cpu(lcme->lcme_offset);
-                       lmm->lmm_oi = *oi;
+                       v1 = buf->lb_buf + le32_to_cpu(lcme->lcme_offset);
+                       v1->lmm_oi = *oi;
                }
        } else {
                lmm->lmm_oi = *oi;