btrfs: change how we decide to commit transactions during flushing
authorJosef Bacik <jbacik@fb.com>
Tue, 22 Aug 2017 20:00:39 +0000 (16:00 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 30 Oct 2017 11:27:57 +0000 (12:27 +0100)
commit996478ca9c460886ac147eb0d00e99841b71d31b
tree49221569fe3d0b995fa3357347cf5d5cf70d10c1
parenteef16ba269ea1d55ca1b4eab8d91f02e185835c9
btrfs: change how we decide to commit transactions during flushing

Nikolay reported that generic/273 was failing currently with ENOSPC.
Turns out this is because we get to the point where the outstanding
reservations are greater than the pinned space on the fs.  This is a
mistake, previously we used the current reservation amount in
may_commit_transaction, not the entire outstanding reservation amount.
Fix this to find the minimum byte size needed to make progress in
flushing, and pass that into may_commit_transaction.  From there we can
make a smarter decision on whether to commit the transaction or not.
This fixes the failure in generic/273.

From Nikolai, IOW: when we go to the final stage of deciding whether to
do trans commit, instead of passing all the reservations from all
tickets we just pass the reservation for the current ticket. Otherwise,
in case all reservations exceed pinned space, then we don't commit
transaction and fail prematurely. Before we passed num_bytes from
flush_space, where num_bytes was the sum of all pending reserverations,
but now all we do is take the first ticket and commit the trans if we
can satisfy that.

Fixes: 957780eb2788 ("Btrfs: introduce ticketed enospc infrastructure")
Cc: stable@vger.kernel.org # 4.8
Reported-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Tested-by: Nikolay Borisov <nborisov@suse.com>
[ added Nikolai's comment ]
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c