diff mbox series

[29/43] xfs: wire up zoned block freeing in xfs_rtextent_free_finish_item

Message ID 20241211085636.1380516-30-hch@lst.de (mailing list archive)
State New
Headers show
Series [01/43] xfs: constify feature checks | expand

Commit Message

Christoph Hellwig Dec. 11, 2024, 8:54 a.m. UTC
Make xfs_rtextent_free_finish_item call into the zoned allocator to free
blocks on zoned RT devices.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_extfree_item.c | 35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

Comments

Darrick J. Wong Dec. 13, 2024, 10:40 p.m. UTC | #1
On Wed, Dec 11, 2024 at 09:54:54AM +0100, Christoph Hellwig wrote:
> Make xfs_rtextent_free_finish_item call into the zoned allocator to free
> blocks on zoned RT devices.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks good,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  fs/xfs/xfs_extfree_item.c | 35 +++++++++++++++++++++++++----------
>  1 file changed, 25 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
> index a25c713ff888..777438b853da 100644
> --- a/fs/xfs/xfs_extfree_item.c
> +++ b/fs/xfs/xfs_extfree_item.c
> @@ -29,6 +29,7 @@
>  #include "xfs_inode.h"
>  #include "xfs_rtbitmap.h"
>  #include "xfs_rtgroup.h"
> +#include "xfs_zone_alloc.h"
>  
>  struct kmem_cache	*xfs_efi_cache;
>  struct kmem_cache	*xfs_efd_cache;
> @@ -767,21 +768,35 @@ xfs_rtextent_free_finish_item(
>  
>  	trace_xfs_extent_free_deferred(mp, xefi);
>  
> -	if (!(xefi->xefi_flags & XFS_EFI_CANCELLED)) {
> -		if (*rtgp != to_rtg(xefi->xefi_group)) {
> -			*rtgp = to_rtg(xefi->xefi_group);
> -			xfs_rtgroup_lock(*rtgp, XFS_RTGLOCK_BITMAP);
> -			xfs_rtgroup_trans_join(tp, *rtgp,
> -					XFS_RTGLOCK_BITMAP);
> -		}
> -		error = xfs_rtfree_blocks(tp, *rtgp,
> -				xefi->xefi_startblock, xefi->xefi_blockcount);
> +	if (xefi->xefi_flags & XFS_EFI_CANCELLED)
> +		goto done;
> +
> +	if (*rtgp != to_rtg(xefi->xefi_group)) {
> +		unsigned int		lock_flags;
> +
> +		if (xfs_has_zoned(mp))
> +			lock_flags = XFS_RTGLOCK_RMAP;
> +		else
> +			lock_flags = XFS_RTGLOCK_BITMAP;
> +
> +		*rtgp = to_rtg(xefi->xefi_group);
> +		xfs_rtgroup_lock(*rtgp, lock_flags);
> +		xfs_rtgroup_trans_join(tp, *rtgp, lock_flags);
>  	}
> +
> +	if (xfs_has_zoned(mp)) {
> +		error = xfs_zone_free_blocks(tp, *rtgp, xefi->xefi_startblock,
> +				xefi->xefi_blockcount);
> +	} else {
> +		error = xfs_rtfree_blocks(tp, *rtgp, xefi->xefi_startblock,
> +				xefi->xefi_blockcount);
> +	}
> +
>  	if (error == -EAGAIN) {
>  		xfs_efd_from_efi(efdp);
>  		return error;
>  	}
> -
> +done:
>  	xfs_efd_add_extent(efdp, xefi);
>  	xfs_extent_free_cancel_item(item);
>  	return error;
> -- 
> 2.45.2
> 
>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index a25c713ff888..777438b853da 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -29,6 +29,7 @@ 
 #include "xfs_inode.h"
 #include "xfs_rtbitmap.h"
 #include "xfs_rtgroup.h"
+#include "xfs_zone_alloc.h"
 
 struct kmem_cache	*xfs_efi_cache;
 struct kmem_cache	*xfs_efd_cache;
@@ -767,21 +768,35 @@  xfs_rtextent_free_finish_item(
 
 	trace_xfs_extent_free_deferred(mp, xefi);
 
-	if (!(xefi->xefi_flags & XFS_EFI_CANCELLED)) {
-		if (*rtgp != to_rtg(xefi->xefi_group)) {
-			*rtgp = to_rtg(xefi->xefi_group);
-			xfs_rtgroup_lock(*rtgp, XFS_RTGLOCK_BITMAP);
-			xfs_rtgroup_trans_join(tp, *rtgp,
-					XFS_RTGLOCK_BITMAP);
-		}
-		error = xfs_rtfree_blocks(tp, *rtgp,
-				xefi->xefi_startblock, xefi->xefi_blockcount);
+	if (xefi->xefi_flags & XFS_EFI_CANCELLED)
+		goto done;
+
+	if (*rtgp != to_rtg(xefi->xefi_group)) {
+		unsigned int		lock_flags;
+
+		if (xfs_has_zoned(mp))
+			lock_flags = XFS_RTGLOCK_RMAP;
+		else
+			lock_flags = XFS_RTGLOCK_BITMAP;
+
+		*rtgp = to_rtg(xefi->xefi_group);
+		xfs_rtgroup_lock(*rtgp, lock_flags);
+		xfs_rtgroup_trans_join(tp, *rtgp, lock_flags);
 	}
+
+	if (xfs_has_zoned(mp)) {
+		error = xfs_zone_free_blocks(tp, *rtgp, xefi->xefi_startblock,
+				xefi->xefi_blockcount);
+	} else {
+		error = xfs_rtfree_blocks(tp, *rtgp, xefi->xefi_startblock,
+				xefi->xefi_blockcount);
+	}
+
 	if (error == -EAGAIN) {
 		xfs_efd_from_efi(efdp);
 		return error;
 	}
-
+done:
 	xfs_efd_add_extent(efdp, xefi);
 	xfs_extent_free_cancel_item(item);
 	return error;