]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: simplify adding and replacing references during log replay
authorFilipe Manana <fdmanana@suse.com>
Mon, 1 Aug 2022 13:57:53 +0000 (14:57 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 26 Sep 2022 10:27:57 +0000 (12:27 +0200)
commit44201b1bd6269945249e43bd540e81082f84d590
tree09fc0dc5527c6509af1887e8b7e580910c047dc9
parent7f2e220de61b2f5358e5ad25bc1570913f2df90c
btrfs: simplify adding and replacing references during log replay

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 1beabda88a3a17 ("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 52c3384db9be0a ("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: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/tree-log.c