ext4: handle symlink properly with inline_data
ext4: handle symlink properly with inline_data

This commit tries to fix a bug that we can't read symlink properly with
inline data feature when the length of symlink is greater than 60 bytes
but less than extra space.

The key issue is in ext4_inode_is_fast_symlink() that it doesn't check
whether or not an inode has inline data.  When the user creates a new
symlink, an inode will be allocated with MAY_INLINE_DATA flag.  Then
symlink will be stored in ->i_block and extended attribute space.  In
the mean time, this inode is with inline data flag.  After remounting
it, ext4_inode_is_fast_symlink() function thinks that this inode is a
fast symlink so that the data in ->i_block is copied to the user, and
the data in extra space is trimmed.  In fact this inode should be as a
normal symlink.

The following script can hit this bug.

  #!/bin/bash

  cd ${MNT}
  filename=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
  rm -rf test
  mkdir test
  cd test
  echo "hello" >$filename
  ln -s $filename symlinkfile
  cd
  sudo umount /mnt/sda1
  sudo mount -t ext4 /dev/sda1 /mnt/sda1
  readlink /mnt/sda1/test/symlinkfile

After applying this patch, it will break the assumption in e2fsck
because the original implementation doesn't want to support symlink
with inline data.

Reported-by: "Darrick J. Wong" <206af32863b9fd2fc412cf38757e7321a0f2bd37@oracle.com>
Reported-by: Ian Nartowicz <12019914d274c69ee77e0e79cacda0c6b0f9b426@nartowicz.co.uk>
Cc: Ian Nartowicz <12019914d274c69ee77e0e79cacda0c6b0f9b426@nartowicz.co.uk>
Cc: Tao Ma <a547db31280d14f095c760a23a7523d0b1e55fe6@tao.ma>
Cc: "Darrick J. Wong" <206af32863b9fd2fc412cf38757e7321a0f2bd37@oracle.com>
Cc: Andreas Dilger <4b4177fd4bee9a83af4b5e2a7acf92bd6a42897f@dilger.ca>
Signed-off-by: Zheng Liu <927570c33013ae711b16b2f69d88304bb3fcc969@taobao.com>
Signed-off-by: Theodore Ts'o <4ed386e0495d3e109932df055831d9ec2f824927@mit.edu>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs