Commit 7a5c3c9b authored by Miao Xie's avatar Miao Xie Committed by Chris Mason

Btrfs: fix put dio bio twice when we submit dio bio fail

The caller of btrfs_submit_direct_hook() will put the original dio bio
when btrfs_submit_direct_hook() return a error number, so we needn't
put the original bio in btrfs_submit_direct_hook().
Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent 8d875f95
...@@ -7306,10 +7306,8 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip, ...@@ -7306,10 +7306,8 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
map_length = orig_bio->bi_iter.bi_size; map_length = orig_bio->bi_iter.bi_size;
ret = btrfs_map_block(root->fs_info, rw, start_sector << 9, ret = btrfs_map_block(root->fs_info, rw, start_sector << 9,
&map_length, NULL, 0); &map_length, NULL, 0);
if (ret) { if (ret)
bio_put(orig_bio);
return -EIO; return -EIO;
}
if (map_length >= orig_bio->bi_iter.bi_size) { if (map_length >= orig_bio->bi_iter.bi_size) {
bio = orig_bio; bio = orig_bio;
...@@ -7326,6 +7324,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip, ...@@ -7326,6 +7324,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
bio = btrfs_dio_bio_alloc(orig_bio->bi_bdev, start_sector, GFP_NOFS); bio = btrfs_dio_bio_alloc(orig_bio->bi_bdev, start_sector, GFP_NOFS);
if (!bio) if (!bio)
return -ENOMEM; return -ENOMEM;
bio->bi_private = dip; bio->bi_private = dip;
bio->bi_end_io = btrfs_end_dio_bio; bio->bi_end_io = btrfs_end_dio_bio;
atomic_inc(&dip->pending_bios); atomic_inc(&dip->pending_bios);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment