linux-IllusionX/fs
Filipe Manana 9a6509c4da Btrfs: fix log replay failure after linking special file and fsync
If in the same transaction we rename a special file (fifo, character/block
device or symbolic link), create a hard link for it having its old name
then sync the log, we will end up with a log that can not be replayed and
at when attempting to replay it, an EEXIST error is returned and mounting
the filesystem fails. Example scenario:

  $ mkfs.btrfs -f /dev/sdc
  $ mount /dev/sdc /mnt
  $ mkdir /mnt/testdir
  $ mkfifo /mnt/testdir/foo
  # Make sure everything done so far is durably persisted.
  $ sync

  # Create some unrelated file and fsync it, this is just to create a log
  # tree. The file must be in the same directory as our special file.
  $ touch /mnt/testdir/f1
  $ xfs_io -c "fsync" /mnt/testdir/f1

  # Rename our special file and then create a hard link with its old name.
  $ mv /mnt/testdir/foo /mnt/testdir/bar
  $ ln /mnt/testdir/bar /mnt/testdir/foo

  # Create some other unrelated file and fsync it, this is just to persist
  # the log tree which was modified by the previous rename and link
  # operations. Alternatively we could have modified file f1 and fsync it.
  $ touch /mnt/f2
  $ xfs_io -c "fsync" /mnt/f2

  <power failure>

  $ mount /dev/sdc /mnt
  mount: mount /dev/sdc on /mnt failed: File exists

This happens because when both the log tree and the subvolume's tree have
an entry in the directory "testdir" with the same name, that is, there
is one key (258 INODE_REF 257) in the subvolume tree and another one in
the log tree (where 258 is the inode number of our special file and 257
is the inode for directory "testdir"). Only the data of those two keys
differs, in the subvolume tree the index field for inode reference has
a value of 3 while the log tree it has a value of 5. Because the same key
exists in both trees, but have different index, the log replay fails with
an -EEXIST error when attempting to replay the inode reference from the
log tree.

Fix this by setting the last_unlink_trans field of the inode (our special
file) to the current transaction id when a hard link is created, as this
forces logging the parent directory inode, solving the conflict at log
replay time.

A new generic test case for fstests was also submitted.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-03-01 16:18:34 +01:00
..
9p Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
adfs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
affs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
afs afs: Fix missing error handling in afs_write_end() 2018-01-02 10:02:19 +00:00
autofs4 autofs: fix careless error in recent commit 2017-12-14 16:00:48 -08:00
befs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
bfs
btrfs Btrfs: fix log replay failure after linking special file and fsync 2018-03-01 16:18:34 +01:00
cachefiles
ceph ceph: drop negative child dentries before try pruning inode's alias 2017-12-08 11:07:12 +01:00
cifs CIFS: don't log STATUS_NOT_FOUND errors for DFS 2017-12-06 12:48:01 -06:00
coda Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
configfs
cramfs cramfs: fix MTD dependency 2017-12-17 12:20:58 -08:00
crypto
debugfs
devpts
dlm
ecryptfs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
efivarfs
efs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
exofs
exportfs
ext2 Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
ext4 ext4: fix crash when a directory's i_size is too small 2017-12-11 15:00:57 -05:00
f2fs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
fat fs/fat/inode.c: fix sb_rdonly() change 2017-11-29 18:40:43 -08:00
freevxfs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
fscache AFS development 2017-11-16 11:41:22 -08:00
fuse Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
gfs2 Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
hfs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
hfsplus Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
hostfs
hpfs hpfs: don't bother with the i_version counter or f_version 2017-12-10 12:58:18 -08:00
hugetlbfs fs/hugetlbfs/inode.c: change put_page/unlock_page order in hugetlbfs_fallocate() 2017-11-29 18:40:43 -08:00
isofs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
jbd2 libnvdimm for 4.15 2017-11-17 09:51:57 -08:00
jffs2 Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
jfs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
kernfs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
lockd nlm_shutdown_hosts_net() cleanup 2017-11-27 16:45:11 -05:00
minix Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
ncpfs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
nfs NFS client fixes for Linux 4.15-rc4 2017-12-16 13:12:53 -08:00
nfs_common lockd: fix "list_add double add" caused by legacy signal interface 2017-11-27 16:45:11 -05:00
nfsd kernel: make groups_sort calling a responsibility group_info allocators 2017-12-14 16:00:49 -08:00
nilfs2 Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
nls
notify Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
ntfs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
ocfs2 Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
omfs
openpromfs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
orangefs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
overlayfs ovl: fix overlay: warning prefix 2017-12-14 11:14:52 +01:00
proc proc: fix coredump vs read /proc/*/stat race 2018-01-19 10:09:41 -08:00
pstore treewide: Switch DEFINE_TIMER callbacks to struct timer_list * 2017-11-21 15:57:05 -08:00
qnx4 Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
qnx6 Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
quota quota: Check for register_shrinker() failure. 2017-11-29 16:46:48 +01:00
ramfs
reiserfs Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs 2017-11-30 18:38:47 -05:00
romfs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
squashfs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
sysfs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
sysv Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
tracefs
ubifs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
udf Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
ufs Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
xfs Changes since last update: 2018-01-05 12:59:32 -08:00
aio.c Merge branch 'misc.compat' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2017-11-17 11:54:55 -08:00
anon_inodes.c
attr.c
bad_inode.c
binfmt_aout.c
binfmt_elf.c Merge branch 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm 2017-11-16 12:50:35 -08:00
binfmt_elf_fdpic.c Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2017-11-17 12:54:01 -08:00
binfmt_em86.c
binfmt_flat.c
binfmt_misc.c
binfmt_script.c
block_dev.c
buffer.c
char_dev.c
compat.c
compat_binfmt_elf.c
compat_ioctl.c Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2017-11-17 12:54:01 -08:00
coredump.c Merge branch 'misc.compat' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2017-11-17 11:54:55 -08:00
dax.c Revert "mm: replace p??_write with pte_access_permitted in fault + gup paths" 2017-12-15 18:53:22 -08:00
dcache.c
dcookies.c
direct-io.c
drop_caches.c
eventfd.c
eventpoll.c Merge branch 'akpm' (patches from Andrew) 2017-11-17 16:56:17 -08:00
exec.c exec: Weaken dumpability for secureexec 2018-01-03 10:13:36 -08:00
fcntl.c
fhandle.c Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2017-11-17 12:54:01 -08:00
file.c Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2017-11-17 12:54:01 -08:00
file_table.c
filesystems.c
fs-writeback.c Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
fs_pin.c
fs_struct.c
inode.c Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
internal.h
ioctl.c
iomap.c Merge branch 'work.iov_iter' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2017-11-17 12:08:18 -08:00
Kconfig
Kconfig.binfmt
libfs.c Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
locks.c Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
Makefile
mbcache.c fs/mbcache.c: make count_objects() more robust 2017-11-29 18:40:43 -08:00
mount.h
mpage.c
namei.c autofs: revert "autofs: fix AT_NO_AUTOMOUNT not being honored" 2017-11-29 18:40:43 -08:00
namespace.c VFS: Handle lazytime in do_mount() 2017-12-09 20:16:33 -05:00
no-block.c
nsfs.c Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
open.c
pipe.c pipe: add proc_dopipe_max_size() to safely assign pipe_max_size 2017-11-17 16:10:03 -08:00
pnode.c
pnode.h
posix_acl.c
proc_namespace.c Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
read_write.c Merge branch 'work.iov_iter' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2017-11-17 12:08:18 -08:00
readdir.c
select.c Merge branch 'misc.compat' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2017-11-17 11:54:55 -08:00
seq_file.c
signalfd.c Merge branch 'misc.compat' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2017-11-17 11:54:55 -08:00
splice.c
stack.c
stat.c
statfs.c Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
super.c sget(): handle failures of register_shrinker() 2017-12-18 15:05:07 -05:00
sync.c
timerfd.c
userfaultfd.c userfaultfd: clear the vma->vm_userfaultfd_ctx if UFFD_EVENT_FORK fails 2018-01-04 16:45:09 -08:00
utimes.c
xattr.c