From: Fan Yong Date: Sat, 26 Mar 2016 15:12:59 +0000 (+0800) Subject: LU-8998 debugfs: handle combined LMA EA and PFID EA X-Git-Tag: v1.42.13.wc6~4 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F36%2F19436%2F5;p=tools%2Fe2fsprogs.git LU-8998 debugfs: handle combined LMA EA and PFID EA 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 Change-Id: I1380d16d94d6d05272e22fdfff07ada038685669 Reviewed-on: https://review.whamcloud.com/19436 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo --- diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 52bb5d1..2ff3642 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -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, diff --git a/lib/ext2fs/lfsck.h b/lib/ext2fs/lfsck.h index 3fadd66..00071f2 100644 --- a/lib/ext2fs/lfsck.h +++ b/lib/ext2fs/lfsck.h @@ -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 */