Commit 42297cd9 authored by Long Li's avatar Long Li
Browse files

xfs: factor out xfs_destroy_perag()

Offering: HULK
hulk inclusion
category: bugfix
bugzilla: 188878, https://gitee.com/openeuler/kernel/issues/I76JSK



--------------------------------

Factor out xfs_destroy_perag() from xfs_initialize_perag() for error
handle, delete perag from radix tree requires lock protection, just like
any other places where perag tree are modified.

Signed-off-by: default avatarLong Li <leo.lilong@huawei.com>
parent 28ce0ae2
Loading
Loading
Loading
Loading
+22 −8
Original line number Diff line number Diff line
@@ -173,6 +173,27 @@ xfs_sb_validate_fsb_count(
	return 0;
}

void
xfs_destroy_perag(
	xfs_mount_t	*mp,
	xfs_agnumber_t	agstart,
	xfs_agnumber_t	agend)
{
	xfs_agnumber_t  index;
	xfs_perag_t	*pag;

	for (index = agstart; index < agend; index++) {
		spin_lock(&mp->m_perag_lock);
		pag = radix_tree_delete(&mp->m_perag_tree, index);
		spin_unlock(&mp->m_perag_lock);
		if (!pag)
			break;
		xfs_buf_hash_destroy(pag);
		xfs_iunlink_destroy(pag);
		kmem_free(pag);
	}
}

int
xfs_initialize_perag(
	xfs_mount_t	*mp,
@@ -252,14 +273,7 @@ xfs_initialize_perag(
	kmem_free(pag);
out_unwind_new_pags:
	/* unwind any prior newly initialized pags */
	for (index = first_initialised; index < agcount; index++) {
		pag = radix_tree_delete(&mp->m_perag_tree, index);
		if (!pag)
			break;
		xfs_buf_hash_destroy(pag);
		xfs_iunlink_destroy(pag);
		kmem_free(pag);
	}
	xfs_destroy_perag(mp, first_initialised, agcount);
	return error;
}