Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
0004  * All Rights Reserved.
0005  */
0006 #ifndef __XFS_ALLOC_BTREE_H__
0007 #define __XFS_ALLOC_BTREE_H__
0008 
0009 /*
0010  * Freespace on-disk structures
0011  */
0012 
0013 struct xfs_buf;
0014 struct xfs_btree_cur;
0015 struct xfs_mount;
0016 struct xfs_perag;
0017 struct xbtree_afakeroot;
0018 
0019 /*
0020  * Btree block header size depends on a superblock flag.
0021  */
0022 #define XFS_ALLOC_BLOCK_LEN(mp) \
0023     (xfs_has_crc(((mp))) ? \
0024         XFS_BTREE_SBLOCK_CRC_LEN : XFS_BTREE_SBLOCK_LEN)
0025 
0026 /*
0027  * Record, key, and pointer address macros for btree blocks.
0028  *
0029  * (note that some of these may appear unused, but they are used in userspace)
0030  */
0031 #define XFS_ALLOC_REC_ADDR(mp, block, index) \
0032     ((xfs_alloc_rec_t *) \
0033         ((char *)(block) + \
0034          XFS_ALLOC_BLOCK_LEN(mp) + \
0035          (((index) - 1) * sizeof(xfs_alloc_rec_t))))
0036 
0037 #define XFS_ALLOC_KEY_ADDR(mp, block, index) \
0038     ((xfs_alloc_key_t *) \
0039         ((char *)(block) + \
0040          XFS_ALLOC_BLOCK_LEN(mp) + \
0041          ((index) - 1) * sizeof(xfs_alloc_key_t)))
0042 
0043 #define XFS_ALLOC_PTR_ADDR(mp, block, index, maxrecs) \
0044     ((xfs_alloc_ptr_t *) \
0045         ((char *)(block) + \
0046          XFS_ALLOC_BLOCK_LEN(mp) + \
0047          (maxrecs) * sizeof(xfs_alloc_key_t) + \
0048          ((index) - 1) * sizeof(xfs_alloc_ptr_t)))
0049 
0050 extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *mp,
0051         struct xfs_trans *tp, struct xfs_buf *bp,
0052         struct xfs_perag *pag, xfs_btnum_t btnum);
0053 struct xfs_btree_cur *xfs_allocbt_stage_cursor(struct xfs_mount *mp,
0054         struct xbtree_afakeroot *afake, struct xfs_perag *pag,
0055         xfs_btnum_t btnum);
0056 extern int xfs_allocbt_maxrecs(struct xfs_mount *, int, int);
0057 extern xfs_extlen_t xfs_allocbt_calc_size(struct xfs_mount *mp,
0058         unsigned long long len);
0059 
0060 void xfs_allocbt_commit_staged_btree(struct xfs_btree_cur *cur,
0061         struct xfs_trans *tp, struct xfs_buf *agbp);
0062 
0063 unsigned int xfs_allocbt_maxlevels_ondisk(void);
0064 
0065 int __init xfs_allocbt_init_cur_cache(void);
0066 void xfs_allocbt_destroy_cur_cache(void);
0067 
0068 #endif  /* __XFS_ALLOC_BTREE_H__ */