+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
* All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <libxfs.h>
+#include "libxfs.h"
#include "avl.h"
#include "btree.h"
#include "globals.h"
* reused. the duplicate and bno/bcnt extent trees for each AG
* are recycled after they're no longer needed to save memory
*/
-void
+static void
release_extent_tree(avltree_desc_t *tree)
{
extent_tree_node_t *ext;
return;
}
-/*
- * normalizing constant for bcnt size -> address conversion (see avl ops)
- * used by the AVL tree code to convert sizes and must be used when
- * doing an AVL search in the tree (e.g. avl_findrange(s))
- */
-#define MAXBCNT 0xFFFFFFFF
-#define BCNT_ADDR(cnt) ((unsigned int) MAXBCNT - (cnt))
-
/*
* the next 4 routines manage the trees of free extents -- 2 trees
* per AG. The first tree is sorted by block number. The second
extent_tree_node_t *
findbiggest_bcnt_extent(xfs_agnumber_t agno)
{
- extern avlnode_t *avl_lastino(avlnode_t *root);
-
ASSERT(extent_bcnt_ptrs != NULL);
ASSERT(extent_bcnt_ptrs[agno] != NULL);
return(ext);
}
-static __psunsigned_t
+static uintptr_t
avl_ext_start(avlnode_t *node)
{
- return((__psunsigned_t)
+ return((uintptr_t)
((extent_tree_node_t *) node)->ex_startblock);
}
-static __psunsigned_t
+static uintptr_t
avl_ext_end(avlnode_t *node)
{
- return((__psunsigned_t) (
+ return((uintptr_t) (
((extent_tree_node_t *) node)->ex_startblock +
((extent_tree_node_t *) node)->ex_blockcount));
}
* convert size to an address for the AVL tree code -- the bigger the size,
* the lower the address so the biggest extent will be first in the tree
*/
-static __psunsigned_t
+static uintptr_t
avl_ext_bcnt_start(avlnode_t *node)
{
/*
- return((__psunsigned_t) (BCNT_ADDR(((extent_tree_node_t *)
+ return((uintptr_t) (BCNT_ADDR(((extent_tree_node_t *)
node)->ex_blockcount)));
*/
- return((__psunsigned_t) ((extent_tree_node_t *)node)->ex_blockcount);
+ return((uintptr_t) ((extent_tree_node_t *)node)->ex_blockcount);
}
-static __psunsigned_t
+static uintptr_t
avl_ext_bcnt_end(avlnode_t *node)
{
/*
- return((__psunsigned_t) (BCNT_ADDR(((extent_tree_node_t *)
+ return((uintptr_t) (BCNT_ADDR(((extent_tree_node_t *)
node)->ex_blockcount)));
*/
- return((__psunsigned_t) ((extent_tree_node_t *)node)->ex_blockcount);
+ return((uintptr_t) ((extent_tree_node_t *)node)->ex_blockcount);
}
-avlops_t avl_extent_bcnt_tree_ops = {
+static avlops_t avl_extent_bcnt_tree_ops = {
avl_ext_bcnt_start,
avl_ext_bcnt_end
};
-avlops_t avl_extent_tree_ops = {
+static avlops_t avl_extent_tree_ops = {
avl_ext_start,
avl_ext_end
};
* startblocks can be 64-bit values.
*/
static rt_extent_tree_node_t *
-mk_rt_extent_tree_nodes(xfs_drtbno_t new_startblock,
+mk_rt_extent_tree_nodes(xfs_rtblock_t new_startblock,
xfs_extlen_t new_blockcount, extent_state_t new_state)
{
rt_extent_tree_node_t *new;
* add a duplicate real-time extent
*/
void
-add_rt_dup_extent(xfs_drtbno_t startblock, xfs_extlen_t blockcount)
+add_rt_dup_extent(xfs_rtblock_t startblock, xfs_extlen_t blockcount)
{
rt_extent_tree_node_t *first, *last, *ext, *next_ext;
- xfs_drtbno_t new_startblock;
+ xfs_rtblock_t new_startblock;
xfs_extlen_t new_blockcount;
pthread_mutex_lock(&rt_ext_tree_lock);
*/
/* ARGSUSED */
int
-search_rt_dup_extent(xfs_mount_t *mp, xfs_drtbno_t bno)
+search_rt_dup_extent(xfs_mount_t *mp, xfs_rtblock_t bno)
{
int ret;
return(ret);
}
-static __uint64_t
+static uint64_t
avl64_rt_ext_start(avl64node_t *node)
{
return(((rt_extent_tree_node_t *) node)->rt_startblock);
}
-static __uint64_t
+static uint64_t
avl64_ext_end(avl64node_t *node)
{
return(((rt_extent_tree_node_t *) node)->rt_startblock +
((rt_extent_tree_node_t *) node)->rt_blockcount);
}
-avl64ops_t avl64_extent_tree_ops = {
+static avl64ops_t avl64_extent_tree_ops = {
avl64_rt_ext_start,
avl64_ext_end
};
avl_init_tree(extent_bcnt_ptrs[i], &avl_extent_bcnt_tree_ops);
}
- if ((rt_ext_tree_ptr = malloc(sizeof(avltree_desc_t))) == NULL)
+ if ((rt_ext_tree_ptr = malloc(sizeof(avl64tree_desc_t))) == NULL)
do_error(_("couldn't malloc dup rt extent tree descriptor\n"));
avl64_init_tree(rt_ext_tree_ptr, &avl64_extent_tree_ops);
extent_bno_ptrs = NULL;
}
-int
+static int
count_extents(xfs_agnumber_t agno, avltree_desc_t *tree, int whichtree)
{
extent_tree_node_t *node;
int
count_bno_extents_blocks(xfs_agnumber_t agno, uint *numblocks)
{
- __uint64_t nblocks;
+ uint64_t nblocks;
extent_tree_node_t *node;
int i = 0;