btrfs: merge btrfs_orig_bbio_end_io() into btrfs_bio_end_io()
authorQu Wenruo <wqu@suse.com>
Sat, 24 Aug 2024 10:06:43 +0000 (19:36 +0930)
committerDavid Sterba <dsterba@suse.com>
Tue, 10 Sep 2024 14:51:20 +0000 (16:51 +0200)
commit9ca0e58cb752b09816f56f7a3147a39773d5e831
tree8c77a8bb3590efea95e1503642cf5a29ae3aae8b
parentac325fc2aad513072722387a71bf857c938aae4e
btrfs: merge btrfs_orig_bbio_end_io() into btrfs_bio_end_io()

There are only two differences between the two functions:

- btrfs_orig_bbio_end_io() does extra error propagation
  This is mostly to allow tolerance for write errors.

- btrfs_orig_bbio_end_io() does extra pending_ios check
  This check can handle both the original bio, or the cloned one.
  (All accounting happens in the original one).

This makes btrfs_orig_bbio_end_io() a much safer call.
In fact we already had a double freeing error due to usage of
btrfs_bio_end_io() in the error path of btrfs_submit_chunk().

So just move the whole content of btrfs_orig_bbio_end_io() into
btrfs_bio_end_io().

For normal paths this brings no change, because they are already calling
btrfs_orig_bbio_end_io() in the first place.

For error paths (not only inside bio.c but also external callers), this
change will introduce extra checks, especially for external callers, as
they will error out without submitting the btrfs bio.

But considering it's already in the error path, such slower but much
safer checks are still an overall win.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/bio.c