On 3/9/20 5:32 PM, Omar Sandoval wrote:
From: Omar Sandoval <osandov@xxxxxx>
If we submit orig_bio in btrfs_submit_direct_hook(), we never increment
pending_bios. Then, if btrfs_submit_dio_bio() fails, we decrement
pending_bios to -1, and we never complete orig_bio. Fix it by
initializing pending_bios to 1 instead of incrementing later.
Fixing this exposes another bug: we put orig_bio prematurely and then
put it again from end_io. Fix it by not putting orig_bio.
After this change, pending_bios is really more of a reference count, but
I'll leave that cleanup separate to keep the fix small.
Fixes: e65e15355429 ("btrfs: fix panic caused by direct IO")
Signed-off-by: Omar Sandoval <osandov@xxxxxx>
Reviewed-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
Thanks,
Josef