]> www.infradead.org Git - users/jedix/linux-maple.git/commit
Btrfs: fix empty symlink after creating symlink and fsync parent dir
authorFilipe Manana <fdmanana@suse.com>
Mon, 25 Apr 2016 03:45:02 +0000 (04:45 +0100)
committerChuck Anderson <chuck.anderson@oracle.com>
Wed, 10 Aug 2016 21:21:53 +0000 (14:21 -0700)
commite96738027ce79e5e97f969894ae6010278db2990
tree3cd886e7559ec59345a324fbc55d943ab3c9714a
parent2b74a5b9f7a2015cfa24a6d74f5422718ea23b37
Btrfs: fix empty symlink after creating symlink and fsync parent dir

Orabug: 23748445

If we create a symlink, fsync its parent directory, crash/power fail and
mount the filesystem, we end up with an empty symlink, which not only is
useless it's also not allowed in linux (the man page symlink(2) is well
explicit about that).  So we just need to make sure to fully log an inode
if it's a symlink, to ensure its inline extent gets logged, ensuring the
same behaviour as ext3, ext4, xfs, reiserfs, f2fs, nilfs2, etc.

Example reproducer:

  $ mkfs.btrfs -f /dev/sdb
  $ mount /dev/sdb /mnt
  $ mkdir /mnt/testdir
  $ sync
  $ ln -s /mnt/foo /mnt/testdir/bar
  $ xfs_io -c fsync /mnt/testdir
  <power fail>
  $ mount /dev/sdb /mnt
  $ readlink /mnt/testdir/bar
  <empty string>

A test case for fstests follows soon.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
(cherry picked from commit 3f9749f6e9edcf8ec569fb542efc3be35e06e84a)
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
fs/btrfs/tree-log.c