1*1946b91cSDarrick J. Wong /* 2*1946b91cSDarrick J. Wong * Copyright (C) 2016 Oracle. All Rights Reserved. 3*1946b91cSDarrick J. Wong * 4*1946b91cSDarrick J. Wong * Author: Darrick J. Wong <darrick.wong@oracle.com> 5*1946b91cSDarrick J. Wong * 6*1946b91cSDarrick J. Wong * This program is free software; you can redistribute it and/or 7*1946b91cSDarrick J. Wong * modify it under the terms of the GNU General Public License 8*1946b91cSDarrick J. Wong * as published by the Free Software Foundation; either version 2 9*1946b91cSDarrick J. Wong * of the License, or (at your option) any later version. 10*1946b91cSDarrick J. Wong * 11*1946b91cSDarrick J. Wong * This program is distributed in the hope that it would be useful, 12*1946b91cSDarrick J. Wong * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*1946b91cSDarrick J. Wong * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*1946b91cSDarrick J. Wong * GNU General Public License for more details. 15*1946b91cSDarrick J. Wong * 16*1946b91cSDarrick J. Wong * You should have received a copy of the GNU General Public License 17*1946b91cSDarrick J. Wong * along with this program; if not, write the Free Software Foundation, 18*1946b91cSDarrick J. Wong * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 19*1946b91cSDarrick J. Wong */ 20*1946b91cSDarrick J. Wong #ifndef __XFS_REFCOUNT_BTREE_H__ 21*1946b91cSDarrick J. Wong #define __XFS_REFCOUNT_BTREE_H__ 22*1946b91cSDarrick J. Wong 23*1946b91cSDarrick J. Wong /* 24*1946b91cSDarrick J. Wong * Reference Count Btree on-disk structures 25*1946b91cSDarrick J. Wong */ 26*1946b91cSDarrick J. Wong 27*1946b91cSDarrick J. Wong struct xfs_buf; 28*1946b91cSDarrick J. Wong struct xfs_btree_cur; 29*1946b91cSDarrick J. Wong struct xfs_mount; 30*1946b91cSDarrick J. Wong 31*1946b91cSDarrick J. Wong /* 32*1946b91cSDarrick J. Wong * Btree block header size 33*1946b91cSDarrick J. Wong */ 34*1946b91cSDarrick J. Wong #define XFS_REFCOUNT_BLOCK_LEN XFS_BTREE_SBLOCK_CRC_LEN 35*1946b91cSDarrick J. Wong 36*1946b91cSDarrick J. Wong /* 37*1946b91cSDarrick J. Wong * Record, key, and pointer address macros for btree blocks. 38*1946b91cSDarrick J. Wong * 39*1946b91cSDarrick J. Wong * (note that some of these may appear unused, but they are used in userspace) 40*1946b91cSDarrick J. Wong */ 41*1946b91cSDarrick J. Wong #define XFS_REFCOUNT_REC_ADDR(block, index) \ 42*1946b91cSDarrick J. Wong ((struct xfs_refcount_rec *) \ 43*1946b91cSDarrick J. Wong ((char *)(block) + \ 44*1946b91cSDarrick J. Wong XFS_REFCOUNT_BLOCK_LEN + \ 45*1946b91cSDarrick J. Wong (((index) - 1) * sizeof(struct xfs_refcount_rec)))) 46*1946b91cSDarrick J. Wong 47*1946b91cSDarrick J. Wong #define XFS_REFCOUNT_KEY_ADDR(block, index) \ 48*1946b91cSDarrick J. Wong ((struct xfs_refcount_key *) \ 49*1946b91cSDarrick J. Wong ((char *)(block) + \ 50*1946b91cSDarrick J. Wong XFS_REFCOUNT_BLOCK_LEN + \ 51*1946b91cSDarrick J. Wong ((index) - 1) * sizeof(struct xfs_refcount_key))) 52*1946b91cSDarrick J. Wong 53*1946b91cSDarrick J. Wong #define XFS_REFCOUNT_PTR_ADDR(block, index, maxrecs) \ 54*1946b91cSDarrick J. Wong ((xfs_refcount_ptr_t *) \ 55*1946b91cSDarrick J. Wong ((char *)(block) + \ 56*1946b91cSDarrick J. Wong XFS_REFCOUNT_BLOCK_LEN + \ 57*1946b91cSDarrick J. Wong (maxrecs) * sizeof(struct xfs_refcount_key) + \ 58*1946b91cSDarrick J. Wong ((index) - 1) * sizeof(xfs_refcount_ptr_t))) 59*1946b91cSDarrick J. Wong 60*1946b91cSDarrick J. Wong extern struct xfs_btree_cur *xfs_refcountbt_init_cursor(struct xfs_mount *mp, 61*1946b91cSDarrick J. Wong struct xfs_trans *tp, struct xfs_buf *agbp, xfs_agnumber_t agno, 62*1946b91cSDarrick J. Wong struct xfs_defer_ops *dfops); 63*1946b91cSDarrick J. Wong extern int xfs_refcountbt_maxrecs(struct xfs_mount *mp, int blocklen, 64*1946b91cSDarrick J. Wong bool leaf); 65*1946b91cSDarrick J. Wong extern void xfs_refcountbt_compute_maxlevels(struct xfs_mount *mp); 66*1946b91cSDarrick J. Wong 67*1946b91cSDarrick J. Wong #endif /* __XFS_REFCOUNT_BTREE_H__ */ 68