btrfs: abort in rename_exchange if we fail to insert the second ref
authorJosef Bacik <josef@toxicpanda.com>
Wed, 19 May 2021 18:04:21 +0000 (14:04 -0400)
committerDavid Sterba <dsterba@suse.com>
Thu, 27 May 2021 21:31:16 +0000 (23:31 +0200)
commitdc09ef3562726cd520c8338c1640872a60187af5
treefc978138bceaf5b64800dc03c796e82cc3fa16a8
parentf96d44743a44e3332f75d23d2075bb8270900e1d
btrfs: abort in rename_exchange if we fail to insert the second ref

Error injection stress uncovered a problem where we'd leave a dangling
inode ref if we failed during a rename_exchange.  This happens because
we insert the inode ref for one side of the rename, and then for the
other side.  If this second inode ref insert fails we'll leave the first
one dangling and leave a corrupt file system behind.  Fix this by
aborting if we did the insert for the first inode ref.

CC: stable@vger.kernel.org # 4.9+
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c