]> git.hungrycats.org Git - linux/commit
Btrfs: introduce ticketed enospc infrastructure
authorJosef Bacik <jbacik@fb.com>
Tue, 15 Sep 2015 13:56:49 +0000 (09:56 -0400)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Sat, 17 Oct 2015 03:13:41 +0000 (23:13 -0400)
commit33d49ee19a2b932376d01eae8717a3135a90ffb1
treec1a541c2fb12e4d8bd1e77cc8d45719884d08a04
parent5b6eb2ecf4cea68408468bffeba34bc758b56d14
Btrfs: introduce ticketed enospc infrastructure

Our enospc flushing sucks.  It is born from a time where we were early
enospc'ing constantly because multiple threads would race in for the same
reservation and randomly starve other ones out.  So I came up with this solution
to block any other reservations from happening while one guy tried to flush
stuff to satisfy his reservation.  This gives us pretty good correctness, but
completely crap latency.

The solution I've come up with is ticketed reservations.  Basically we try to
make our reservation, and if we can't we put a ticket on a list in order and
kick off an async flusher thread.  This async flusher thread does the same old
flushing we always did, just asynchronously.  As space is freed and added back
to the space_info it checks and sees if we have any tickets that need
satisfying, and adds space to the tickets and wakes up anything we've satisfied.

Once the flusher thread stops making progress it wakes up all the current
tickets and tells them to take a hike.

There is a priority list for things that can't flush, since the async flusher
could do anything we need to avoid deadlocks.  These guys get priority for
having their reservation made, and will still do manual flushing themselves in
case the async flusher isn't running.

This patch gives us significantly better latencies.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
(cherry picked from commit f3ccea64964f11736984f7ba63f02cf08d41322f)
(cherry picked from commit 369c05843b5bca638e03162548bfb11d4d084a2f)
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c