diff mbox series

[3/6] xfs: return maximum free size from xfs_rtany_summary()

Message ID d3d0aad4dbf6999c5fe07d89d63ea6cfabee3ff4.1687296675.git.osandov@osandov.com (mailing list archive)
State Superseded, archived
Headers show
Series xfs: CPU usage optimizations for realtime allocator | expand

Commit Message

Omar Sandoval June 20, 2023, 9:32 p.m. UTC
From: Omar Sandoval <osandov@fb.com>

Instead of only returning whether there is any free space, return the
maximum size, which is fast thanks to the previous commit. This will be
used by two upcoming optimizations.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 fs/xfs/xfs_rtalloc.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Comments

Darrick J. Wong July 12, 2023, 10:44 p.m. UTC | #1
On Tue, Jun 20, 2023 at 02:32:13PM -0700, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
> 
> Instead of only returning whether there is any free space, return the
> maximum size, which is fast thanks to the previous commit. This will be
> used by two upcoming optimizations.
> 
> Signed-off-by: Omar Sandoval <osandov@fb.com>

Assuming I understood the changes in the /last/ two patches, this seems
like a reasonable thing to pass upwards...

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/xfs_rtalloc.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index d3c76532d20e..ba7d42e0090f 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -50,7 +50,7 @@ xfs_rtany_summary(
>  	int		high,		/* high log2 extent size */
>  	xfs_rtblock_t	bbno,		/* bitmap block number */
>  	struct xfs_rtbuf_cache *rtbufc,	/* in/out: cache of realtime blocks */
> -	int		*stat)		/* out: any good extents here? */
> +	int		*maxlog)	/* out: maximum log2 extent size free */
>  {
>  	int		error;		/* error value */
>  	int		log;		/* loop counter, log2 of ext. size */
> @@ -60,7 +60,7 @@ xfs_rtany_summary(
>  	if (mp->m_rsum_cache) {
>  		high = min(high, mp->m_rsum_cache[bbno] - 1);
>  		if (low > high) {
> -			*stat = 0;
> +			*maxlog = -1;
>  			return 0;
>  		}
>  	}
> @@ -80,14 +80,14 @@ xfs_rtany_summary(
>  		 * If there are any, return success.
>  		 */
>  		if (sum) {
> -			*stat = 1;
> +			*maxlog = log;
>  			goto out;
>  		}
>  	}
>  	/*
>  	 * Found nothing, return failure.
>  	 */
> -	*stat = 0;
> +	*maxlog = -1;
>  out:
>  	/* There were no extents at levels > log. */
>  	if (mp->m_rsum_cache && log + 1 < mp->m_rsum_cache[bbno])
> @@ -427,7 +427,7 @@ xfs_rtallocate_extent_near(
>  	xfs_extlen_t	prod,		/* extent product factor */
>  	xfs_rtblock_t	*rtblock)	/* out: start block allocated */
>  {
> -	int		any;		/* any useful extents from summary */
> +	int		maxlog;		/* maximum useful extent from summary */
>  	xfs_rtblock_t	bbno;		/* bitmap block number */
>  	int		error;		/* error value */
>  	int		i;		/* bitmap block offset (loop control) */
> @@ -479,7 +479,7 @@ xfs_rtallocate_extent_near(
>  		 * starting in this bitmap block.
>  		 */
>  		error = xfs_rtany_summary(mp, tp, log2len, mp->m_rsumlevels - 1,
> -			bbno + i, rtbufc, &any);
> +			bbno + i, rtbufc, &maxlog);
>  		if (error) {
>  			return error;
>  		}
> @@ -487,7 +487,7 @@ xfs_rtallocate_extent_near(
>  		 * If there are any useful extents starting here, try
>  		 * allocating one.
>  		 */
> -		if (any) {
> +		if (maxlog >= 0) {
>  			/*
>  			 * On the positive side of the starting location.
>  			 */
> @@ -527,7 +527,7 @@ xfs_rtallocate_extent_near(
>  					 */
>  					error = xfs_rtany_summary(mp, tp,
>  						log2len, mp->m_rsumlevels - 1,
> -						bbno + j, rtbufc, &any);
> +						bbno + j, rtbufc, &maxlog);
>  					if (error) {
>  						return error;
>  					}
> @@ -539,7 +539,7 @@ xfs_rtallocate_extent_near(
>  					 * extent given, we've already tried
>  					 * that allocation, don't do it again.
>  					 */
> -					if (any)
> +					if (maxlog >= 0)
>  						continue;
>  					error = xfs_rtallocate_extent_block(mp,
>  						tp, bbno + j, minlen, maxlen,
> -- 
> 2.41.0
>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index d3c76532d20e..ba7d42e0090f 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -50,7 +50,7 @@  xfs_rtany_summary(
 	int		high,		/* high log2 extent size */
 	xfs_rtblock_t	bbno,		/* bitmap block number */
 	struct xfs_rtbuf_cache *rtbufc,	/* in/out: cache of realtime blocks */
-	int		*stat)		/* out: any good extents here? */
+	int		*maxlog)	/* out: maximum log2 extent size free */
 {
 	int		error;		/* error value */
 	int		log;		/* loop counter, log2 of ext. size */
@@ -60,7 +60,7 @@  xfs_rtany_summary(
 	if (mp->m_rsum_cache) {
 		high = min(high, mp->m_rsum_cache[bbno] - 1);
 		if (low > high) {
-			*stat = 0;
+			*maxlog = -1;
 			return 0;
 		}
 	}
@@ -80,14 +80,14 @@  xfs_rtany_summary(
 		 * If there are any, return success.
 		 */
 		if (sum) {
-			*stat = 1;
+			*maxlog = log;
 			goto out;
 		}
 	}
 	/*
 	 * Found nothing, return failure.
 	 */
-	*stat = 0;
+	*maxlog = -1;
 out:
 	/* There were no extents at levels > log. */
 	if (mp->m_rsum_cache && log + 1 < mp->m_rsum_cache[bbno])
@@ -427,7 +427,7 @@  xfs_rtallocate_extent_near(
 	xfs_extlen_t	prod,		/* extent product factor */
 	xfs_rtblock_t	*rtblock)	/* out: start block allocated */
 {
-	int		any;		/* any useful extents from summary */
+	int		maxlog;		/* maximum useful extent from summary */
 	xfs_rtblock_t	bbno;		/* bitmap block number */
 	int		error;		/* error value */
 	int		i;		/* bitmap block offset (loop control) */
@@ -479,7 +479,7 @@  xfs_rtallocate_extent_near(
 		 * starting in this bitmap block.
 		 */
 		error = xfs_rtany_summary(mp, tp, log2len, mp->m_rsumlevels - 1,
-			bbno + i, rtbufc, &any);
+			bbno + i, rtbufc, &maxlog);
 		if (error) {
 			return error;
 		}
@@ -487,7 +487,7 @@  xfs_rtallocate_extent_near(
 		 * If there are any useful extents starting here, try
 		 * allocating one.
 		 */
-		if (any) {
+		if (maxlog >= 0) {
 			/*
 			 * On the positive side of the starting location.
 			 */
@@ -527,7 +527,7 @@  xfs_rtallocate_extent_near(
 					 */
 					error = xfs_rtany_summary(mp, tp,
 						log2len, mp->m_rsumlevels - 1,
-						bbno + j, rtbufc, &any);
+						bbno + j, rtbufc, &maxlog);
 					if (error) {
 						return error;
 					}
@@ -539,7 +539,7 @@  xfs_rtallocate_extent_near(
 					 * extent given, we've already tried
 					 * that allocation, don't do it again.
 					 */
-					if (any)
+					if (maxlog >= 0)
 						continue;
 					error = xfs_rtallocate_extent_block(mp,
 						tp, bbno + j, minlen, maxlen,