Btrfs: adjust outstanding_extents counter properly when dio write is split
authorLiu Bo <bo.li.liu@oracle.com>
Fri, 23 Dec 2016 01:13:54 +0000 (17:13 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 7 Aug 2017 01:59:47 +0000 (18:59 -0700)
commitf76ddff6c5215131483efed20acc896e021abb9f
tree54705f2208d369bd32e0ef9da908f44f80562991
parent49fc90b443c71b3cdbfaf15c0c15fc7e3ffc5731
Btrfs: adjust outstanding_extents counter properly when dio write is split

[ Upstream commit c2931667c83ded6504b3857e99cc45b21fa496fb ]

Currently how btrfs dio deals with split dio write is not good
enough if dio write is split into several segments due to the
lack of contiguous space, a large dio write like 'dd bs=1G count=1'
can end up with incorrect outstanding_extents counter and endio
would complain loudly with an assertion.

This fixes the problem by compensating the outstanding_extents
counter in inode if a large dio write gets split.

Reported-by: Anand Jain <anand.jain@oracle.com>
Tested-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/inode.c