aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2016-04-24 23:45:02 -0400
committerFilipe Manana <fdmanana@suse.com>2016-05-12 20:59:12 -0400
commit3f9749f6e9edcf8ec569fb542efc3be35e06e84a (patch)
tree7cc406f97a7fbca0a52e80bf63e123fd15c7201d /fs/btrfs/tree-log.c
parent657ed1aa4898c8304500e0d13f240d5a67e8be5f (diff)
Btrfs: fix empty symlink after creating symlink and fsync parent dir
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>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 4709932c62fb..a24a0ba523d6 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -5158,7 +5158,7 @@ process_leaf:
5158 } 5158 }
5159 5159
5160 ctx->log_new_dentries = false; 5160 ctx->log_new_dentries = false;
5161 if (type == BTRFS_FT_DIR) 5161 if (type == BTRFS_FT_DIR || type == BTRFS_FT_SYMLINK)
5162 log_mode = LOG_INODE_ALL; 5162 log_mode = LOG_INODE_ALL;
5163 btrfs_release_path(path); 5163 btrfs_release_path(path);
5164 ret = btrfs_log_inode(trans, root, di_inode, 5164 ret = btrfs_log_inode(trans, root, di_inode,