Whamcloud - gitweb
LU-8300 e2fsck: print out FID with dirent inode number 66/20866/8
authorAndreas Dilger <andreas.dilger@intel.com>
Sat, 18 Jun 2016 10:50:41 +0000 (04:50 -0600)
committerAndreas Dilger <andreas.dilger@intel.com>
Wed, 2 May 2018 03:12:19 +0000 (03:12 +0000)
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 <andreas.dilger@intel.com>
Change-Id: Id0ec22c47d83f16c392e93328d2869e7a53ebbe5
Reviewed-on: https://review.whamcloud.com/20866
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Artem Blagodarenko <c17828@cray.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
e2fsck/message.c

index 97f53fa..f416d4c 100644 (file)
@@ -94,6 +94,7 @@
 #include <termios.h>
 
 #include "e2fsck.h"
+#include "ext2fs/lfsck.h"
 
 #include "problem.h"
 
@@ -355,6 +356,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
  */
@@ -370,9 +398,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 = dirent->name_len & 0xFF;
                if ((ext2fs_get_rec_len(fs, dirent, &rec_len) == 0) &&