From: Christoph Hellwig <hch@lst.de>
To: linux-xfs@vger.kernel.org
Cc: eguan@redhat.com, darrick.wong@oracle.com
Subject: [PATCH 4/4] xfs: don't rely on ->total in xfs_alloc_space_available
Date: Tue, 13 Dec 2016 16:59:27 +0100 [thread overview]
Message-ID: <1481644767-9098-5-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1481644767-9098-1-git-send-email-hch@lst.de>
->total is a bit of an odd parameter passed down to the low-level
allocator all the way from the high-level callers. It's supposed to
contain the maximum number of blocks to be allocated for the whole
transaction [1].
But in xfs_iomap_write_allocate we only convert existing delayed
allocations and thus only have a minimal block reservation for the
current transaction, so xfs_alloc_space_available can't use it for
the allocation decisions. Use the maximum of args->total and the
calculated block requirement to make a decision. We probably should
get rid of args->total eventually and instead apply ->minleft more
broadly, but that will require some extensive changes all over.
[1] which creates lots of confusion as most callers don't decrement it
once doing a first allocation. But that's for a separate series.
---
fs/xfs/libxfs/xfs_alloc.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 87328a8..85039e5 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -1998,7 +1998,7 @@ xfs_alloc_space_available(
int flags)
{
struct xfs_perag *pag = args->pag;
- xfs_extlen_t longest;
+ xfs_extlen_t alloc_len, longest;
xfs_extlen_t reservation; /* blocks that are still reserved */
int available;
@@ -2008,15 +2008,16 @@ xfs_alloc_space_available(
reservation = xfs_ag_resv_needed(pag, args->resv);
/* do we have enough contiguous free space for the allocation? */
+ alloc_len = args->minlen + (args->alignment - 1)+ args->minalignslop;
longest = xfs_alloc_longest_free_extent(args->mp, pag, min_free,
reservation);
- if ((args->minlen + args->alignment + args->minalignslop - 1) > longest)
+ if (longest < alloc_len)
return false;
/* do we have enough free space remaining for the allocation? */
available = (int)(pag->pagf_freeblks + pag->pagf_flcount -
reservation - min_free - args->minleft);
- if (available < (int)args->total)
+ if (available < (int)max(args->total, alloc_len))
return false;
/*
--
2.1.4
next prev parent reply other threads:[~2016-12-13 15:59 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-13 15:59 minleft fixes Christoph Hellwig
2016-12-13 15:59 ` [PATCH 1/4] xfs: fix bogus minleft manipulations Christoph Hellwig
2016-12-14 17:35 ` Brian Foster
2016-12-14 19:36 ` Christoph Hellwig
2016-12-14 21:51 ` Brian Foster
[not found] ` <20161215143430.GB29477@bfoster.bfoster>
2016-12-16 8:21 ` Christoph Hellwig
2016-12-19 11:38 ` Christoph Hellwig
2016-12-20 14:17 ` Brian Foster
2016-12-20 21:45 ` Dave Chinner
2016-12-15 22:09 ` Dave Chinner
2016-12-16 8:20 ` Christoph Hellwig
2017-01-04 6:32 ` Darrick J. Wong
2017-01-04 8:50 ` Christoph Hellwig
2016-12-13 15:59 ` [PATCH 2/4] xfs: calculate minleft correctly for bmap allocations Christoph Hellwig
2016-12-14 18:24 ` Brian Foster
2016-12-13 15:59 ` [PATCH 3/4] xfs: adjust allocation length in xfs_alloc_space_available Christoph Hellwig
2016-12-14 18:24 ` Brian Foster
2016-12-14 19:37 ` Christoph Hellwig
2016-12-15 20:41 ` Libor Klepáč
2016-12-16 8:20 ` Christoph Hellwig
2016-12-16 0:28 ` Dave Chinner
2016-12-16 8:25 ` Christoph Hellwig
2016-12-18 23:55 ` Dave Chinner
2016-12-13 15:59 ` Christoph Hellwig [this message]
2016-12-14 18:30 ` [PATCH 4/4] xfs: don't rely on ->total " Brian Foster
2016-12-14 19:38 ` Christoph Hellwig
2016-12-14 21:51 ` Brian Foster
2016-12-15 8:55 ` Christoph Hellwig
2016-12-15 12:00 ` Brian Foster
2016-12-14 10:51 ` minleft fixes Eryu Guan
2016-12-15 10:24 ` Eryu Guan
-- strict thread matches above, loose matches on Subject: below --
2017-01-09 19:53 minleft fixes V3 Christoph Hellwig
2017-01-09 19:53 ` [PATCH 4/4] xfs: don't rely on ->total in xfs_alloc_space_available Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1481644767-9098-5-git-send-email-hch@lst.de \
--to=hch@lst.de \
--cc=darrick.wong@oracle.com \
--cc=eguan@redhat.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).