From: Artem Blagodarenko <artem.blagodarenko@xxxxxxxxx> Keep the INO64 field over LUFID, since it is both smaller, and more important. Lustre-bug: https://jira.hpdd.intel.com/browse/LU-9309 Signed-off-by: Artem Blagodarenko <artem.blagodarenko@xxxxxxxxx> --- e2fsck/pass2.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index ef0b97c0..21cbcd8e 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -377,10 +377,14 @@ void ext2_fix_dirent_dirdata(struct ext2_dir_entry *de) __u8 de_flags = (de->name_len >> 8) & ~EXT2_FT_MASK; __u8 name_len = de->name_len & EXT2_NAME_LEN; __u8 new_flag = 0; + char *startp = de->name + (de->name_len & EXT2_NAME_LEN) + 1 /* NUL */; + char *lenp = startp; + char *inop = NULL; int i; for (i = 0; i < 4; i++) { - __u8 flags = new_flag | (1 << i) << 4; + __u8 current_flag = (1 << i) << 4; + __u8 flags = new_flag | current_flag; /* new_flag is accumulating flags that are set in de_flags * and still fit inside rec_len. ext2_get_dirent_dirdata_size() @@ -392,6 +396,11 @@ void ext2_fix_dirent_dirdata(struct ext2_dir_entry *de) flags); int rlen = EXT2_DIR_NAME_LEN(name_len + dirdatalen); + if (current_flag == EXT2_DIRENT_INODE) + inop = lenp; + + lenp += *lenp; + if (rlen > de->rec_len) break; @@ -399,6 +408,17 @@ void ext2_fix_dirent_dirdata(struct ext2_dir_entry *de) } } + /* Keep the INO64 field over LUFID, since it is both smaller, + * and more important. + */ + if (inop && (ext2_get_dirdata_field_size(de, new_flag) >= 5) && + !(new_flag & EXT2_DIRENT_INODE)) { + new_flag &= ~EXT2_DIRENT_LUFID; + new_flag |= EXT2_DIRENT_INODE; + memmove(startp, inop, + ext2_get_dirdata_field_size(de, new_flag)); + } + de->name_len = name_len | file_type | (new_flag << 8); } -- 2.14.3 (Apple Git-98)