Linux-BTRFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/7] Rework reserve ticket handling
@ 2019-08-09 13:33 Josef Bacik
  2019-08-09 13:33 ` [PATCH 1/7] btrfs: do not allow reservations if we have pending tickets Josef Bacik
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Josef Bacik @ 2019-08-09 13:33 UTC (permalink / raw)
  To: linux-btrfs, kernel-team

While cleaning up some things around the global reserve and can_overcommit I
started getting ENOSPC's with plenty of space to make reservations.  The root
cause of the problem has to do with how we satisfy ticket reservations.

Previously we would add any space we were returning to the space info to the
first ticket we found.  The reason we did this was because new reservations just
check the counters to see if they can continue, so we didn't want them to get
reservations when we had waiters already queued up.  So instead of returning the
bytes to the space info, I'd add it to the ticket.  Then if we failed to satisfy
that ticket reservation we'd take any space we found and add it to the next guy
in case it satisfied the next ticket reservation.

This works generally well in practice, but there are several xfstests that run
ENOSPC tests against very small file systems.  These tests uncovered a corner
case when it comes to overcommitting.  If we overcommit the space, and then are
no longer allowed to overcommit, we won't actually give any returned space to
the tickets, because that would be really bad.  Instead we return that space to
the space_info and carry on.

What was biting us in these test cases was the fact that we had very small
metadata area, 8mib, and unlink asks for about 2mib of space.  If we had
overcommitted 8.1mib, we'd give back almost 2mib of space to the space_info,
which could have instead been used for the reservation.  This would result in an
early ENOSPC.

Since we are only doing this partial filling dance to avoid racing with new
reservations we just fix that race by checking if we have pending reservations
on the list, closing that race.  Then we are free to use the normal checks to
see if a ticket can be woken up.  This simplifies the code a bunch, we no longer
have to keep track of how much space the tickets were given and return those
bytes, and I could consolidate the wakeup code into one function instead of two.

The diffstat is as follows, this all passes xfstests, and sets us up nicely for
the upcoming changesets.

 fs/btrfs/block-group.c    |   5 +-
 fs/btrfs/block-rsv.c      |   5 --
 fs/btrfs/delalloc-space.c |   4 --
 fs/btrfs/extent-tree.c    |  13 +----
 fs/btrfs/space-info.c     | 140 +++++++++++-----------------------------------
 fs/btrfs/space-info.h     |  30 ++++++----
 6 files changed, 56 insertions(+), 141 deletions(-)

Thanks,

Josef


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, back to index

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-09 13:33 [PATCH 0/7] Rework reserve ticket handling Josef Bacik
2019-08-09 13:33 ` [PATCH 1/7] btrfs: do not allow reservations if we have pending tickets Josef Bacik
2019-08-09 13:33 ` [PATCH 2/7] btrfs: roll tracepoint into btrfs_space_info_update helper Josef Bacik
2019-08-09 13:33 ` [PATCH 3/7] btrfs: add space reservation tracepoint for reserved bytes Josef Bacik
2019-08-09 13:33 ` [PATCH 4/7] btrfs: rework btrfs_space_info_add_old_bytes Josef Bacik
2019-08-09 13:33 ` [PATCH 5/7] btrfs: refactor the ticket wakeup code Josef Bacik
2019-08-09 13:33 ` [PATCH 6/7] btrfs: rework wake_all_tickets Josef Bacik
2019-08-09 13:33 ` [PATCH 7/7] btrfs: remove orig_bytes from reserve_ticket Josef Bacik

Linux-BTRFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-btrfs/0 linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ https://lore.kernel.org/linux-btrfs \
		linux-btrfs@vger.kernel.org linux-btrfs@archiver.kernel.org
	public-inbox-index linux-btrfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-btrfs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox