• Filipe Manana's avatar
    btrfs: simplify adding and replacing references during log replay · 7059c658
    Filipe Manana authored
    During log replay, when adding/replacing inode references, there are two
    special cases that have special code for them:
    
    1) When we have an inode with two or more hardlinks in the same directory,
       therefore two or more names encoded in the same inode reference item,
       and one of the hard links gets renamed to the old name of another hard
       link - that is, the index number for a name changes. This was added in
       commit 0d836392 ("Btrfs: fix mount failure after fsync due to
       hard link recreation"), and is covered by test case generic/502 from
       fstests;
    
    2) When we have several inodes that got renamed to an old name of some
       other inode, in a cascading style. The code to deal with this special
       case was added in commit 6b5fc433 ("Btrfs: fix fsync after
       succession of renames of different files"), and is covered by test
       cases generic/526 and generic/527 from fstests.
    
    Both cases can be deal with by making sure __add_inode_ref() is always
    called by add_inode_ref() for every name encoded in the inode reference
    item, and not just for the first name that has a conflict. With such
    change we no longer need that special casing for the two cases mentioned
    before. So do those changes.
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    7059c658
tree-log.c 208 KB