aboutsummaryrefslogtreecommitdiff
path: root/fs/btrfs/xattr.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2022-04-21 10:56:39 +0100
committerDavid Sterba <dsterba@suse.com>2022-04-27 22:20:21 +0200
commitd0e64a981fd841cb0f28fcd6afcac55e6f1e6994 (patch)
tree0dda508f1b2cae4a5726ac8eca2808839849dd49 /fs/btrfs/xattr.c
parent0e852ab8974cd2b5946766b2d9baf82c78ace03d (diff)
btrfs: always log symlinks in full mode
On Linux, empty symlinks are invalid, and attempting to create one with the system call symlink(2) results in an -ENOENT error and this is explicitly documented in the man page. If we rename a symlink that was created in the current transaction and its parent directory was logged before, we actually end up logging the symlink without logging its content, which is stored in an inline extent. That means that after a power failure we can end up with an empty symlink, having no content and an i_size of 0 bytes. It can be easily reproduced like this: $ mkfs.btrfs -f /dev/sdc $ mount /dev/sdc /mnt $ mkdir /mnt/testdir $ sync # Create a file inside the directory and fsync the directory. $ touch /mnt/testdir/foo $ xfs_io -c "fsync" /mnt/testdir # Create a symlink inside the directory and then rename the symlink. $ ln -s /mnt/testdir/foo /mnt/testdir/bar $ mv /mnt/testdir/bar /mnt/testdir/baz # Now fsync again the directory, this persist the log tree. $ xfs_io -c "fsync" /mnt/testdir <power failure> $ mount /dev/sdc /mnt $ stat -c %s /mnt/testdir/baz 0 $ readlink /mnt/testdir/baz $ Fix this by always logging symlinks in full mode (LOG_INODE_ALL), so that their content is also logged. A test case for fstests will follow. CC: stable@vger.kernel.org # 4.9+ Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/xattr.c')
0 files changed, 0 insertions, 0 deletions