Skip to contentSkip to conversation

ext4: Support fast symlinks from ext3 file systems

PATCH Applied Andi Kleen 3 participants 3 messages Nov 27, 2017 – Dec 4, 2017

Subsystems (2)
lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 ext4: Support fast symlinks from ext3 file systems

From: Andi Kleen <[email protected]>

dbb3c27f5b91c4 (ext4: change fast symlink test to not rely on i_blocks) broke ~10 years old ext3 file systems created by 2.6.17. Any ELF executable fails because the /lib/ld-linux.so.2 fast symlink cannot be read anymore.

The patch assumed fast symlinks were created in a specific way, but that's not true on these really old file systems.

The new behavior is apparently needed only with the large EA inode feature.

Revert to the old behavior if the large EA inode feature is not set.

This makes my old VM boot again.

Fixes dbb3c27f5b91c4 (ext4: change fast symlink test to not rely ...)
---
 fs/ext4/inode.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/ext4/inode.c +9 -0
index 0992d76f7ab1..6b82b0ff5e0b 100644
@@ -149,6 +149,15 @@ static int ext4_meta_trans_blocks(struct inode *inode, int lblocks,
  */
 int ext4_inode_is_fast_symlink(struct inode *inode)
 {
+	if (!(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL)) {
+		int ea_blocks = EXT4_I(inode)->i_file_acl ?
+				EXT4_CLUSTER_SIZE(inode->i_sb) >> 9 : 0;
+
+		if (ext4_has_inline_data(inode))
+			return 0;
+
+		return (S_ISLNK(inode->i_mode) && inode->i_blocks - ea_blocks == 0);
+	}
 	return S_ISLNK(inode->i_mode) && inode->i_size &&
 	       (inode->i_size < EXT4_N_BLOCKS * 4);
 }
Signature · 1 line
2.13.6
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Andi Kleen

From: Andi Kleen <[email protected]>

dbb3c27f5b91c4 (ext4: change fast symlink test to not rely on i_blocks) broke ~10 years old ext3 file systems created by 2.6.17. Any ELF executable fails because the /lib/ld-linux.so.2 fast symlink cannot be read anymore.

The patch assumed fast symlinks were created in a specific way, but that's not true on these really old file systems.

The new behavior is apparently needed only with the large EA inode feature.

Quoted 6 lines

Revert to the old behavior if the large EA inode feature is not set.

This makes my old VM boot again.

Fixes dbb3c27f5b91c4 (ext4: change fast symlink test to not rely ...)
Quoted 25 lines

---
fs/ext4/inode.c | 9 +++++++++

1 file changed, 9 insertions(+)
fs/ext4/inode.c +9 -1
index 0992d76f7ab1..6b82b0ff5e0b 100644
@@ -149,6 +149,15 @@ static int ext4_meta_trans_blocks(struct inode *inode, int lblocks,
 */
 int ext4_inode_is_fast_symlink(struct inode *inode)
 {
+	if (!(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL)) {
+		int ea_blocks = EXT4_I(inode)->i_file_acl ?
+				EXT4_CLUSTER_SIZE(inode->i_sb) >> 9 : 0;
+
+		if (ext4_has_inline_data(inode))
+			return 0;
+
+		return (S_ISLNK(inode->i_mode) && inode->i_blocks - ea_blocks == 0);
+	}
 	return S_ISLNK(inode->i_mode) && inode->i_size &&
 	       (inode->i_size < EXT4_N_BLOCKS * 4);
 }
--
Quoted 2 lines

2.13.6

Cheers, Andreas

maintainer Applied
#2 lore raw
Quoted 15 lines · Andreas Dilger
Quoted 14 lines · Andi Kleen

From: Andi Kleen <[email protected]>

dbb3c27f5b91c4 (ext4: change fast symlink test to not rely on i_blocks) broke ~10 years old ext3 file systems created by 2.6.17. Any ELF executable fails because the /lib/ld-linux.so.2 fast symlink cannot be read anymore.

The patch assumed fast symlinks were created in a specific way, but that's not true on these really old file systems.

The new behavior is apparently needed only with the large EA inode feature.

Quoted 8 lines
Quoted 6 lines

Revert to the old behavior if the large EA inode feature is not set.

This makes my old VM boot again.

Fixes dbb3c27f5b91c4 (ext4: change fast symlink test to not rely ...)

Thanks, applied.

- Ted