Whamcloud - gitweb
LU-8998 debugfs: handle combined LMA EA and PFID EA 36/19436/5
authorFan Yong <fan.yong@intel.com>
Sat, 26 Mar 2016 15:12:59 +0000 (23:12 +0800)
committerAndreas Dilger <andreas.dilger@intel.com>
Wed, 19 Apr 2017 23:27:00 +0000 (23:27 +0000)
We need to store the stripe size and stripe count information in
the OST object's PFID EA for the layout LFSCK to recover the MDT
object or its (lost or corrupted) LOV EA. On the other hand, for
PFL file, we also need to store its PFL ID and extent information
in its OST object's PFID EA.

Consider performance, we will store the PFID EA inside the inode
body to avoid extra IO when read/write the PFID EA. Unfortunately,
the space inside current 256-bytes inode for EA is very limited,
and above enlarged PFID EA exceeds such limitation. So we have to
make some hack with the PFID EA and LMA EA combined together. The
patch makes the debugfs tool to handle such case properly.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: I1380d16d94d6d05272e22fdfff07ada038685669
Reviewed-on: https://review.whamcloud.com/19436
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
debugfs/debugfs.c
lib/ext2fs/lfsck.h

index 52bb5d1..2ff3642 100644 (file)
@@ -549,17 +549,32 @@ static void print_fidstr(FILE *out, ext2_ino_t inode_num, void *data, int len)
        fprintf(out, "  fid: ");
        /* Old larger filter_fid should only ever be used with seq = 0.
         * FID-on-OST should use LMA for FID_SEQ_NORMAL OST objects. */
-       if (len > sizeof(ff->ff_parent))
+       if (len == sizeof(*ff))
                fprintf(out, "objid=%llu seq=%llu ",
                        ext2fs_le64_to_cpu(ff->ff_objid),
                        ext2fs_le64_to_cpu(ff->ff_seq));
 
-       fprintf(out, "parent="DFID" stripe=%u\n", PFID(&ff->ff_parent), stripe);
+       fprintf(out, "parent="DFID" stripe=%u", PFID(&ff->ff_parent), stripe);
+       if (len > sizeof(*ff)) {
+               struct filter_fid *ff_new = data;
+
+               fprintf(out, " stripe_size=%u stripe_count=%u",
+                       ext2fs_le32_to_cpu(ff_new->ff_stripe_size),
+                       ext2fs_le32_to_cpu(ff_new->ff_stripe_count));
+               if (ff_new->ff_pfl_id != 0)
+                       fprintf(out, " component_id=%u component_start=%llu "
+                               "component_end=%llu",
+                               ext2fs_le32_to_cpu(ff_new->ff_pfl_id),
+                               ext2fs_le64_to_cpu(ff_new->ff_pfl_start),
+                               ext2fs_le64_to_cpu(ff_new->ff_pfl_end));
+       }
+       fprintf(out, "\n");
 }
 
 static void print_lmastr(FILE *out, ext2_ino_t inode_num, void *data, int len)
 {
        struct lustre_mdt_attrs *lma = data;
+       struct lustre_ost_attrs *loa = data;
 
        if (len < offsetof(typeof(*lma), lma_self_fid) +
                  sizeof(lma->lma_self_fid)) {
@@ -572,6 +587,27 @@ static void print_lmastr(FILE *out, ext2_ino_t inode_num, void *data, int len)
        fprintf(out, "  lma: fid="DFID" compat=%x incompat=%x\n",
                PFID(&lma->lma_self_fid), ext2fs_le32_to_cpu(lma->lma_compat),
                ext2fs_le32_to_cpu(lma->lma_incompat));
+       if (len >= offsetof(typeof(*loa), loa_pfl_end) +
+                 sizeof(loa->loa_pfl_end)) {
+               int idx;
+               int cnt;
+
+               fid_le_to_cpu(&loa->loa_parent_fid, &loa->loa_parent_fid);
+               idx = loa->loa_parent_fid.f_ver & PFID_STRIPE_COUNT_MASK;
+               cnt = loa->loa_parent_fid.f_ver >> PFID_STRIPE_IDX_BITS;
+               loa->loa_parent_fid.f_ver = 0;
+
+               fprintf(out, "  fid: parent="DFID" stripe=%u stripe_size=%u "
+                       "stripe_count=%u", PFID(&loa->loa_parent_fid), idx,
+                       ext2fs_le32_to_cpu(loa->loa_stripe_size), cnt);
+               if (loa->loa_pfl_id != 0)
+                       fprintf(out, " component_id=%u component_start=%llu "
+                               "component_end=%llu",
+                               ext2fs_le32_to_cpu(loa->loa_pfl_id),
+                               ext2fs_le64_to_cpu(loa->loa_pfl_start),
+                               ext2fs_le64_to_cpu(loa->loa_pfl_end));
+               fprintf(out, "\n");
+       }
 }
 
 static void internal_dump_inode_extra(FILE *out,
index 3fadd66..00071f2 100644 (file)
@@ -55,6 +55,14 @@ struct lustre_mdt_attrs {
        __u32           lma_incompat;
        struct lu_fid   lma_self_fid;
 };
+struct lustre_ost_attrs {
+       struct lustre_mdt_attrs loa_lma;
+       struct lu_fid           loa_parent_fid;
+       __u32                   loa_stripe_size;
+       __u32                   loa_pfl_id;
+       __u64                   loa_pfl_start;
+       __u64                   loa_pfl_end;
+};
 #endif
 
 struct filter_fid_old {
@@ -63,7 +71,19 @@ struct filter_fid_old {
        __u64           ff_seq;
 };
 
+struct filter_fid {
+       struct lu_fid   ff_parent;
+       __u32           ff_stripe_size;
+       __u32           ff_stripe_count;
+       __u64           ff_pfl_start;
+       __u64           ff_pfl_end;
+       __u32           ff_pfl_id;
+};
+
 #define LMA_OLD_SIZE 64
 #endif /* !LMA_OLD_SIZE */
 
+#define PFID_STRIPE_IDX_BITS   16
+#define PFID_STRIPE_COUNT_MASK ((1 << PFID_STRIPE_IDX_BITS) - 1)
+
 #endif /* LFSCK_H */