diff mbox series

[v4,7/7] e2fsck: INODE64 high part is more important then LUFID

Message ID 20180504070923.45140-8-c17828@cray.com
State Changes Requested
Headers show
Series 64bit inode e2fsprogs support | expand

Commit Message

Artem Blagodarenko May 4, 2018, 7:09 a.m. UTC
From: Artem Blagodarenko <artem.blagodarenko@gmail.com>

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@gmail.com>
---
 e2fsck/pass2.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

Comments

Andreas Dilger May 4, 2018, 9:38 a.m. UTC | #1
On May 4, 2018, at 1:09 AM, c17828 <artem.blagodarenko@gmail.com> wrote:
> 
> From: Artem Blagodarenko <artem.blagodarenko@gmail.com>
> 
> 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@gmail.com>
> ---
> e2fsck/pass2.c | 22 +++++++++++++++++++++-
> 1 file changed, 21 insertions(+), 1 deletion(-)
> 
> @@ -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) &&

Wasn't there a structure added to hold the inode64 value?  That should be
used here for sizeof(ext2fs_dirdata_inode64) (or whatever it is named)
instead of "5", which doesn't pass very much information to the reader.

I don't see it in this patch, so it might have only been added in the
kernel part of the dirdata patch.  It should also be used in e2fsprogs.

> +	    !(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)
> 


Cheers, Andreas
diff mbox series

Patch

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);
 }