blob: 50198b6c3bb20c3376e5acf83b96b7a23bbe171c [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0
Darrick J. Wong035e00a2016-08-03 11:36:07 +10002/*
3 * Copyright (c) 2014 Red Hat, Inc.
4 * All Rights Reserved.
Darrick J. Wong035e00a2016-08-03 11:36:07 +10005 */
6#ifndef __XFS_RMAP_BTREE_H__
7#define __XFS_RMAP_BTREE_H__
8
9struct xfs_buf;
10struct xfs_btree_cur;
11struct xfs_mount;
12
13/* rmaps only exist on crc enabled filesystems */
14#define XFS_RMAP_BLOCK_LEN XFS_BTREE_SBLOCK_CRC_LEN
15
16/*
17 * Record, key, and pointer address macros for btree blocks.
18 *
19 * (note that some of these may appear unused, but they are used in userspace)
20 */
21#define XFS_RMAP_REC_ADDR(block, index) \
22 ((struct xfs_rmap_rec *) \
23 ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
24 (((index) - 1) * sizeof(struct xfs_rmap_rec))))
25
26#define XFS_RMAP_KEY_ADDR(block, index) \
27 ((struct xfs_rmap_key *) \
28 ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
Darrick J. Wongcfed56a2016-08-03 11:40:56 +100029 ((index) - 1) * 2 * sizeof(struct xfs_rmap_key)))
30
31#define XFS_RMAP_HIGH_KEY_ADDR(block, index) \
32 ((struct xfs_rmap_key *) \
33 ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
34 sizeof(struct xfs_rmap_key) + \
35 ((index) - 1) * 2 * sizeof(struct xfs_rmap_key)))
Darrick J. Wong035e00a2016-08-03 11:36:07 +100036
37#define XFS_RMAP_PTR_ADDR(block, index, maxrecs) \
38 ((xfs_rmap_ptr_t *) \
39 ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
Darrick J. Wongcfed56a2016-08-03 11:40:56 +100040 (maxrecs) * 2 * sizeof(struct xfs_rmap_key) + \
Darrick J. Wong035e00a2016-08-03 11:36:07 +100041 ((index) - 1) * sizeof(xfs_rmap_ptr_t)))
42
43struct xfs_btree_cur *xfs_rmapbt_init_cursor(struct xfs_mount *mp,
44 struct xfs_trans *tp, struct xfs_buf *bp,
45 xfs_agnumber_t agno);
Eric Sandeena1f69412018-04-06 10:09:42 -070046int xfs_rmapbt_maxrecs(int blocklen, int leaf);
Darrick J. Wong035e00a2016-08-03 11:36:07 +100047extern void xfs_rmapbt_compute_maxlevels(struct xfs_mount *mp);
48
Darrick J. Wong84d69612016-10-03 09:11:44 -070049extern xfs_extlen_t xfs_rmapbt_calc_size(struct xfs_mount *mp,
50 unsigned long long len);
Darrick J. Wong20e73b02017-01-03 18:39:33 -080051extern xfs_extlen_t xfs_rmapbt_max_size(struct xfs_mount *mp,
52 xfs_agblock_t agblocks);
Darrick J. Wong84d69612016-10-03 09:11:44 -070053
54extern int xfs_rmapbt_calc_reserves(struct xfs_mount *mp,
55 xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);
56
Darrick J. Wong035e00a2016-08-03 11:36:07 +100057#endif /* __XFS_RMAP_BTREE_H__ */