linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: Support fast symlinks from ext3 file systems
@ 2017-11-27 17:37 Andi Kleen
  2017-11-27 18:08 ` Andreas Dilger
  0 siblings, 1 reply; 3+ messages in thread
From: Andi Kleen @ 2017-11-27 17:37 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4, linux-kernel, linux-fsdevel, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

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 ...)
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 fs/ext4/inode.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 0992d76f7ab1..6b82b0ff5e0b 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -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);
 }
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ext4: Support fast symlinks from ext3 file systems
  2017-11-27 17:37 [PATCH] ext4: Support fast symlinks from ext3 file systems Andi Kleen
@ 2017-11-27 18:08 ` Andreas Dilger
  2017-12-04  3:49   ` Theodore Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Dilger @ 2017-11-27 18:08 UTC (permalink / raw)
  To: Andi Kleen; +Cc: tytso, linux-ext4, linux-kernel, linux-fsdevel, Andi Kleen

[-- Attachment #1: Type: text/plain, Size: 1708 bytes --]

On Nov 27, 2017, at 10:37 AM, Andi Kleen <andi@firstfloor.org> wrote:
> 
> From: Andi Kleen <ak@linux.intel.com>
> 
> 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 ...)
> Signed-off-by: Andi Kleen <ak@linux.intel.com>

Reviewed-by: Andreas Dilger <adilger@dilger.ca>

> ---
> fs/ext4/inode.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 0992d76f7ab1..6b82b0ff5e0b 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -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);
> }
> --
> 2.13.6
> 


Cheers, Andreas






[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ext4: Support fast symlinks from ext3 file systems
  2017-11-27 18:08 ` Andreas Dilger
@ 2017-12-04  3:49   ` Theodore Ts'o
  0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2017-12-04  3:49 UTC (permalink / raw)
  To: Andreas Dilger
  Cc: Andi Kleen, linux-ext4, linux-kernel, linux-fsdevel, Andi Kleen

On Mon, Nov 27, 2017 at 11:08:53AM -0700, Andreas Dilger wrote:
> On Nov 27, 2017, at 10:37 AM, Andi Kleen <andi@firstfloor.org> wrote:
> > 
> > From: Andi Kleen <ak@linux.intel.com>
> > 
> > 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 ...)
> > Signed-off-by: Andi Kleen <ak@linux.intel.com>
> 
> Reviewed-by: Andreas Dilger <adilger@dilger.ca>

Thanks, applied.

					- Ted

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-12-04  3:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-27 17:37 [PATCH] ext4: Support fast symlinks from ext3 file systems Andi Kleen
2017-11-27 18:08 ` Andreas Dilger
2017-12-04  3:49   ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).