linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: linux-xfs@vger.kernel.org
Cc: john.g.garry@oracle.com
Subject: [PATCH 8/9] xfs: collapse near and exact bno allocation
Date: Wed,  4 Oct 2023 11:19:42 +1100	[thread overview]
Message-ID: <20231004001943.349265-9-david@fromorbit.com> (raw)
In-Reply-To: <20231004001943.349265-1-david@fromorbit.com>

From: Dave Chinner <dchinner@redhat.com>

As they are now identical functions exact for the allocation
function they call.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/libxfs/xfs_alloc.c | 84 ++++++++++++++++++---------------------
 fs/xfs/xfs_trace.h        |  1 +
 2 files changed, 40 insertions(+), 45 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 3190c8204903..27c62f303488 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -3649,6 +3649,43 @@ xfs_alloc_vextent_first_ag(
 	return xfs_alloc_vextent_finish(args, minimum_agno, error, true);
 }
 
+static int
+xfs_alloc_vextent_bno(
+	struct xfs_alloc_arg	*args,
+	xfs_fsblock_t		target,
+	bool			exact)
+{
+	struct xfs_mount	*mp = args->mp;
+	xfs_agnumber_t		minimum_agno;
+	int			error;
+
+	ASSERT(args->pag != NULL);
+	ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target));
+
+	args->agno = args->pag->pag_agno;
+	args->agbno = XFS_FSB_TO_AGBNO(mp, target);
+
+	trace_xfs_alloc_vextent_bno(args);
+
+	error = xfs_alloc_vextent_check_args(args, args->agno, args->agbno,
+			&minimum_agno);
+	if (error) {
+		if (error == -ENOSPC)
+			return 0;
+		return error;
+	}
+
+	error = xfs_alloc_vextent_prepare_ag(args, 0);
+	if (!error && args->agbp) {
+		if (exact)
+			error = xfs_alloc_ag_vextent_exact(args);
+		else
+			error = xfs_alloc_ag_vextent_near(args, 0);
+	}
+
+	return xfs_alloc_vextent_finish(args, minimum_agno, error, false);
+}
+
 /*
  * Allocate at the exact block target or fail. Caller is expected to hold a
  * perag reference in args->pag.
@@ -3658,28 +3695,8 @@ xfs_alloc_vextent_exact_bno(
 	struct xfs_alloc_arg	*args,
 	xfs_fsblock_t		target)
 {
-	struct xfs_mount	*mp = args->mp;
-	xfs_agnumber_t		minimum_agno;
-	int			error;
-
-	args->agno = args->pag->pag_agno;
-	args->agbno = XFS_FSB_TO_AGBNO(mp, target);
-
 	trace_xfs_alloc_vextent_exact_bno(args);
-
-	error = xfs_alloc_vextent_check_args(args, args->agno, args->agbno,
-			&minimum_agno);
-	if (error) {
-		if (error == -ENOSPC)
-			return 0;
-		return error;
-	}
-
-	error = xfs_alloc_vextent_prepare_ag(args, 0);
-	if (!error && args->agbp)
-		error = xfs_alloc_ag_vextent_exact(args);
-
-	return xfs_alloc_vextent_finish(args, minimum_agno, error, false);
+	return xfs_alloc_vextent_bno(args, target, true);
 }
 
 /*
@@ -3693,31 +3710,8 @@ xfs_alloc_vextent_near_bno(
 	struct xfs_alloc_arg	*args,
 	xfs_fsblock_t		target)
 {
-	struct xfs_mount	*mp = args->mp;
-	xfs_agnumber_t		minimum_agno;
-	uint32_t		alloc_flags = 0;
-	int			error;
-
-	ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target));
-
-	args->agno = args->pag->pag_agno;
-	args->agbno = XFS_FSB_TO_AGBNO(mp, target);
-
 	trace_xfs_alloc_vextent_near_bno(args);
-
-	error = xfs_alloc_vextent_check_args(args, args->agno, args->agbno,
-			&minimum_agno);
-	if (error) {
-		if (error == -ENOSPC)
-			return 0;
-		return error;
-	}
-
-	error = xfs_alloc_vextent_prepare_ag(args, alloc_flags);
-	if (!error && args->agbp)
-		error = xfs_alloc_ag_vextent_near(args, alloc_flags);
-
-	return xfs_alloc_vextent_finish(args, minimum_agno, error, false);
+	return xfs_alloc_vextent_bno(args, target, false);
 }
 
 /* Ensure that the freelist is at full capacity. */
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 3926cf7f2a6e..628da36b20b9 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -1884,6 +1884,7 @@ DEFINE_ALLOC_EVENT(xfs_alloc_vextent_start_ag);
 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_first_ag);
 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_exact_bno);
 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_near_bno);
+DEFINE_ALLOC_EVENT(xfs_alloc_vextent_bno);
 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_finish);
 
 TRACE_EVENT(xfs_alloc_cur_check,
-- 
2.40.1


  parent reply	other threads:[~2023-10-04  0:19 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04  0:19 [RFC PATCH 0/9] xfs: push perags further into allocation routines Dave Chinner
2023-10-04  0:19 ` [PATCH 1/9] xfs: split xfs_bmap_btalloc_at_eof() Dave Chinner
2023-10-04 23:41   ` Darrick J. Wong
2023-10-05  9:41   ` Christoph Hellwig
2023-10-04  0:19 ` [PATCH 2/9] xfs: contiguous EOF allocation across AGs Dave Chinner
2023-10-05  9:43   ` Christoph Hellwig
2023-10-06  5:27   ` Darrick J. Wong
2023-10-04  0:19 ` [PATCH 3/9] xfs: select the AG with the largest contiguous space Dave Chinner
2023-10-05  9:45   ` Christoph Hellwig
2023-10-05  9:46   ` Christoph Hellwig
2023-10-24 16:25     ` Darrick J. Wong
2023-10-04  0:19 ` [PATCH 4/9] xfs: push the perag outwards in initial allocation Dave Chinner
2023-10-05 11:57   ` Christoph Hellwig
2023-10-04  0:19 ` [PATCH 5/9] xfs: aligned EOF allocations don't need to scan AGs anymore Dave Chinner
2023-10-05 11:59   ` Christoph Hellwig
2023-10-06  5:55   ` Darrick J. Wong
2023-10-04  0:19 ` [PATCH 6/9] xfs: use agno/agbno in xfs_alloc_vextent functions Dave Chinner
2023-10-05 12:02   ` Christoph Hellwig
2023-10-06  5:56   ` Darrick J. Wong
2023-10-04  0:19 ` [PATCH 7/9] xfs: caller perag always supplied to xfs_alloc_vextent_near_bno Dave Chinner
2023-10-05 12:02   ` Christoph Hellwig
2023-10-06  5:59   ` Darrick J. Wong
2023-10-04  0:19 ` Dave Chinner [this message]
2023-10-05 12:03   ` [PATCH 8/9] xfs: collapse near and exact bno allocation Christoph Hellwig
2023-10-06  6:01   ` Darrick J. Wong
2023-10-04  0:19 ` [PATCH 9/9] xfs: return -ENOSPC rather than NULLFSBLOCK from allocation functions Dave Chinner
2023-10-05 12:21   ` 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=20231004001943.349265-9-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=john.g.garry@oracle.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).