]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
btrfs: mark ordered extent and inode with error if we fail to finish
authorJosef Bacik <josef@toxicpanda.com>
Wed, 19 May 2021 13:38:27 +0000 (09:38 -0400)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 30 Jun 2021 06:27:57 +0000 (08:27 +0200)
commitca8e14e7f5b03a80cb35c2f83b0dc7da4320f996
treecc8e1bf38b448996ad2e6cb6e7f373888fad0d2a
parent36a58303347230217dc24322e673e651a46f9c3f
btrfs: mark ordered extent and inode with error if we fail to finish

BugLink: https://bugs.launchpad.net/bugs/1933691
commit d61bec08b904cf171835db98168f82bc338e92e4 upstream.

While doing error injection testing I saw that sometimes we'd get an
abort that wouldn't stop the current transaction commit from completing.
This abort was coming from finish ordered IO, but at this point in the
transaction commit we should have gotten an error and stopped.

It turns out the abort came from finish ordered io while trying to write
out the free space cache.  It occurred to me that any failure inside of
finish_ordered_io isn't actually raised to the person doing the writing,
so we could have any number of failures in this path and think the
ordered extent completed successfully and the inode was fine.

Fix this by marking the ordered extent with BTRFS_ORDERED_IOERR, and
marking the mapping of the inode with mapping_set_error, so any callers
that simply call fdatawait will also get the error.

With this we're seeing the IO error on the free space inode when we fail
to do the finish_ordered_io.

CC: stable@vger.kernel.org # 4.19+
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
fs/btrfs/inode.c