From: Miao Xie Date: Tue, 17 Jun 2014 10:58:59 +0000 (+0800) Subject: Btrfs: fix put dio bio twice when we submit dio bio fail X-Git-Tag: android-x86-4.4-r2~444^2~31 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=7a5c3c9be1059feed0e470c6dc0994dcaed4f12c;p=android-x86%2Fkernel.git 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: Miao Xie Signed-off-by: Chris Mason --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 73098328d040..33c05188cbf0 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -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; ret = btrfs_map_block(root->fs_info, rw, start_sector << 9, &map_length, NULL, 0); - if (ret) { - bio_put(orig_bio); + if (ret) return -EIO; - } if (map_length >= orig_bio->bi_iter.bi_size) { bio = orig_bio; @@ -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); if (!bio) return -ENOMEM; + bio->bi_private = dip; bio->bi_end_io = btrfs_end_dio_bio; atomic_inc(&dip->pending_bios);