Patch "Btrfs: fix empty symlink after creating symlink and fsync parent dir" has been added to the 4.5-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
Btrfs: fix empty symlink after creating symlink and fsync parent dir
to the 4.5-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
btrfs-fix-empty-symlink-after-creating-symlink-and-fsync-parent-dir.patch
and it can be found in the queue-4.5 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
3f9749f6e9edcf8ec569fb542efc3be35e06e84aMon Sep 17 00:00:00 2001
From: Filipe Manana <[email protected]>
Date: Mon, 25 Apr 2016 04:45:02 +0100
Subject: Btrfs: fix empty symlink after creating symlink and fsync parent dir
From: Filipe Manana <[email protected]>
commit 3f9749f6e9edcf8ec569fb542efc3be35e06e84a upstream.
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.
--- fs/btrfs/tree-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/tree-log.c +1 -1
@@ -5157,7 +5157,7 @@ process_leaf: } ctx->log_new_dentries = false; -if (type ==BTRFS_FT_DIR ) +if (type ==BTRFS_FT_DIR || type ==BTRFS_FT_SYMLINK ) log_mode =LOG_INODE_ALL ;btrfs_release_path (path); ret = btrfs_log_inode(trans, root, di_inode,
Patches currently in stable-queue which might be from [email protected] are
queue-4.5/btrfs-fix-empty-symlink-after-creating-symlink-and-fsync-parent-dir.patch queue-4.5/btrfs-fix-for-incorrect-directory-entries-after-fsync-log-replay.patch