From: Andreas Dilger Date: Sat, 18 Jun 2016 10:50:41 +0000 (-0600) Subject: LU-8300 e2fsck: print out FID with dirent inode number X-Git-Tag: v1.44.3.wc1~8 X-Git-Url: https://git.whamcloud.com/tools/e2fsprogs.git/?a=commitdiff_plain;h=f6b5aca68e6901706966c4bd2daf1d1bebfa6eee;p=tools%2Fe2fsprogs.git LU-8300 e2fsck: print out FID with dirent inode number When printing out the dirent inode number in e2fsck, also print out the FID, if available, for reference in the future if needed. Entry 'lustre.conf' in /ROOT/etc/yum/protected.d (50132) has deleted/unused inode=1964 fid=[0x200000401:0x844:0x0]. Clear? yes This can be useful if LFSCK is able to rebuild the MDT layout from the OST object xattrs, but the filename isn't stored on the OST. Signed-off-by: Andreas Dilger Change-Id: Id0ec22c47d83f16c392e93328d2869e7a53ebbe5 Reviewed-on: https://review.whamcloud.com/20866 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Artem Blagodarenko Reviewed-by: Fan Yong --- diff --git a/e2fsck/message.c b/e2fsck/message.c index 727f71d..eca280a 100644 --- a/e2fsck/message.c +++ b/e2fsck/message.c @@ -99,6 +99,7 @@ #include "e2fsck.h" #include "problem.h" +#include "ext2fs/lfsck.h" #ifdef __GNUC__ #define _INLINE_ __inline__ @@ -348,6 +349,33 @@ static _INLINE_ void expand_inode_expression(FILE *f, ext2_filsys fs, char ch, } } +const struct lu_fid *get_dirent_fid(struct ext2_dir_entry *dirent) +{ + unsigned char *data = (unsigned char *)dirent->name + + (dirent->name_len & EXT2_NAME_LEN) + 1; + __u8 file_type = dirent->name_len >> 8; + struct lu_fid *fid = NULL; + __u8 dirdata_mask; + + for (dirdata_mask = EXT2_FT_MASK + 1; + dirdata_mask != 0; dirdata_mask <<= 1) { + int dlen; + + if ((dirdata_mask & file_type) == 0) + continue; + + dlen = data[0]; + if (dirdata_mask == EXT2_DIRENT_LUFID) { + fid = (struct lu_fid *)(data + 1); + fid_be_to_cpu(fid, fid); + break; + } + data += dlen; + } + + return fid; +} + /* * This function expands '%dX' expressions */ @@ -363,9 +391,17 @@ static _INLINE_ void expand_dirent_expression(FILE *f, ext2_filsys fs, char ch, dirent = ctx->dirent; switch (ch) { - case 'i': + case 'i': { + const struct lu_fid *fid; + fprintf(f, "%u", dirent->inode); + + fid = get_dirent_fid(dirent); + if (fid != NULL) + fprintf(f, " fid="DFID, PFID(fid)); + break; + } case 'n': len = ext2fs_dirent_name_len(dirent); if ((ext2fs_get_rec_len(fs, dirent, &rec_len) == 0) &&