Commit 980faece authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: convert "skip_discard" to a proper flags bitset



Convert the boolean to skip discard on free into a proper flags field so
that we can add more flags in the next patch.

Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 4e0e2c0f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1008,7 +1008,7 @@ xfs_ag_shrink_space(
			goto resv_err;

		err2 = xfs_free_extent_later(*tpp, args.fsbno, delta, NULL,
				XFS_AG_RESV_NONE, true);
				XFS_AG_RESV_NONE, XFS_FREE_EXTENT_SKIP_DISCARD);
		if (err2)
			goto resv_err;

+7 −6
Original line number Diff line number Diff line
@@ -2562,7 +2562,7 @@ xfs_defer_extent_free(
	xfs_filblks_t			len,
	const struct xfs_owner_info	*oinfo,
	enum xfs_ag_resv_type		type,
	bool				skip_discard,
	unsigned int			free_flags,
	struct xfs_defer_pending	**dfpp)
{
	struct xfs_extent_free_item	*xefi;
@@ -2582,6 +2582,7 @@ xfs_defer_extent_free(
	ASSERT(len < mp->m_sb.sb_agblocks);
	ASSERT(agbno + len <= mp->m_sb.sb_agblocks);
#endif
	ASSERT(!(free_flags & ~XFS_FREE_EXTENT_ALL_FLAGS));
	ASSERT(xfs_extfree_item_cache != NULL);
	ASSERT(type != XFS_AG_RESV_AGFL);

@@ -2593,7 +2594,7 @@ xfs_defer_extent_free(
	xefi->xefi_startblock = bno;
	xefi->xefi_blockcount = (xfs_extlen_t)len;
	xefi->xefi_agresv = type;
	if (skip_discard)
	if (free_flags & XFS_FREE_EXTENT_SKIP_DISCARD)
		xefi->xefi_flags |= XFS_EFI_SKIP_DISCARD;
	if (oinfo) {
		ASSERT(oinfo->oi_offset == 0);
@@ -2621,11 +2622,11 @@ xfs_free_extent_later(
	xfs_filblks_t			len,
	const struct xfs_owner_info	*oinfo,
	enum xfs_ag_resv_type		type,
	bool				skip_discard)
	unsigned int			free_flags)
{
	struct xfs_defer_pending	*dontcare = NULL;

	return xfs_defer_extent_free(tp, bno, len, oinfo, type, skip_discard,
	return xfs_defer_extent_free(tp, bno, len, oinfo, type, free_flags,
			&dontcare);
}

@@ -2650,13 +2651,13 @@ xfs_free_extent_later(
int
xfs_alloc_schedule_autoreap(
	const struct xfs_alloc_arg	*args,
	bool				skip_discard,
	unsigned int			free_flags,
	struct xfs_alloc_autoreap	*aarp)
{
	int				error;

	error = xfs_defer_extent_free(args->tp, args->fsbno, args->len,
			&args->oinfo, args->resv, skip_discard, &aarp->dfp);
			&args->oinfo, args->resv, free_flags, &aarp->dfp);
	if (error)
		return error;

+7 −2
Original line number Diff line number Diff line
@@ -235,7 +235,12 @@ xfs_buf_to_agfl_bno(

int xfs_free_extent_later(struct xfs_trans *tp, xfs_fsblock_t bno,
		xfs_filblks_t len, const struct xfs_owner_info *oinfo,
		enum xfs_ag_resv_type type, bool skip_discard);
		enum xfs_ag_resv_type type, unsigned int free_flags);

/* Don't issue a discard for the blocks freed. */
#define XFS_FREE_EXTENT_SKIP_DISCARD	(1U << 0)

#define XFS_FREE_EXTENT_ALL_FLAGS	(XFS_FREE_EXTENT_SKIP_DISCARD)

/*
 * List of extents to be free "later".
@@ -264,7 +269,7 @@ struct xfs_alloc_autoreap {
};

int xfs_alloc_schedule_autoreap(const struct xfs_alloc_arg *args,
		bool skip_discard, struct xfs_alloc_autoreap *aarp);
		unsigned int free_flags, struct xfs_alloc_autoreap *aarp);
void xfs_alloc_cancel_autoreap(struct xfs_trans *tp,
		struct xfs_alloc_autoreap *aarp);
void xfs_alloc_commit_autoreap(struct xfs_trans *tp,
+8 −4
Original line number Diff line number Diff line
@@ -605,7 +605,7 @@ xfs_bmap_btree_to_extents(

	xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork);
	error = xfs_free_extent_later(cur->bc_tp, cbno, 1, &oinfo,
			XFS_AG_RESV_NONE, false);
			XFS_AG_RESV_NONE, 0);
	if (error)
		return error;

@@ -5381,11 +5381,15 @@ xfs_bmap_del_extent_real(
			error = xfs_rtfree_blocks(tp, del->br_startblock,
					del->br_blockcount);
		} else {
			unsigned int	efi_flags = 0;

			if ((bflags & XFS_BMAPI_NODISCARD) ||
			    del->br_state == XFS_EXT_UNWRITTEN)
				efi_flags |= XFS_FREE_EXTENT_SKIP_DISCARD;

			error = xfs_free_extent_later(tp, del->br_startblock,
					del->br_blockcount, NULL,
					XFS_AG_RESV_NONE,
					((bflags & XFS_BMAPI_NODISCARD) ||
					del->br_state == XFS_EXT_UNWRITTEN));
					XFS_AG_RESV_NONE, efi_flags);
		}
		if (error)
			return error;
+1 −1
Original line number Diff line number Diff line
@@ -282,7 +282,7 @@ xfs_bmbt_free_block(

	xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_ino.whichfork);
	error = xfs_free_extent_later(cur->bc_tp, fsbno, 1, &oinfo,
			XFS_AG_RESV_NONE, false);
			XFS_AG_RESV_NONE, 0);
	if (error)
		return error;

Loading