]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - libxfs/xfs_rmap_btree.h
libfrog: move platform specific runtime support code out of libxfs
[thirdparty/xfsprogs-dev.git] / libxfs / xfs_rmap_btree.h
CommitLineData
631ac87a
DW
1/*
2 * Copyright (c) 2014 Red Hat, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18#ifndef __XFS_RMAP_BTREE_H__
19#define __XFS_RMAP_BTREE_H__
20
21struct xfs_buf;
b3a96b46
DW
22struct xfs_btree_cur;
23struct xfs_mount;
24
25/* rmaps only exist on crc enabled filesystems */
26#define XFS_RMAP_BLOCK_LEN XFS_BTREE_SBLOCK_CRC_LEN
27
28/*
29 * Record, key, and pointer address macros for btree blocks.
30 *
31 * (note that some of these may appear unused, but they are used in userspace)
32 */
33#define XFS_RMAP_REC_ADDR(block, index) \
34 ((struct xfs_rmap_rec *) \
35 ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
36 (((index) - 1) * sizeof(struct xfs_rmap_rec))))
37
38#define XFS_RMAP_KEY_ADDR(block, index) \
39 ((struct xfs_rmap_key *) \
40 ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
634b234e
DW
41 ((index) - 1) * 2 * sizeof(struct xfs_rmap_key)))
42
43#define XFS_RMAP_HIGH_KEY_ADDR(block, index) \
44 ((struct xfs_rmap_key *) \
45 ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
46 sizeof(struct xfs_rmap_key) + \
47 ((index) - 1) * 2 * sizeof(struct xfs_rmap_key)))
b3a96b46
DW
48
49#define XFS_RMAP_PTR_ADDR(block, index, maxrecs) \
50 ((xfs_rmap_ptr_t *) \
51 ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
634b234e 52 (maxrecs) * 2 * sizeof(struct xfs_rmap_key) + \
b3a96b46
DW
53 ((index) - 1) * sizeof(xfs_rmap_ptr_t)))
54
55struct xfs_btree_cur *xfs_rmapbt_init_cursor(struct xfs_mount *mp,
56 struct xfs_trans *tp, struct xfs_buf *bp,
57 xfs_agnumber_t agno);
1421de38 58int xfs_rmapbt_maxrecs(int blocklen, int leaf);
b3a96b46 59extern void xfs_rmapbt_compute_maxlevels(struct xfs_mount *mp);
631ac87a 60
02cc8b2a
DW
61extern xfs_extlen_t xfs_rmapbt_calc_size(struct xfs_mount *mp,
62 unsigned long long len);
f21c57ed
DW
63extern xfs_extlen_t xfs_rmapbt_max_size(struct xfs_mount *mp,
64 xfs_agblock_t agblocks);
02cc8b2a
DW
65
66extern int xfs_rmapbt_calc_reserves(struct xfs_mount *mp,
67 xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);
68
631ac87a 69#endif /* __XFS_RMAP_BTREE_H__ */