summaryrefslogtreecommitdiff
path: root/fs/xfs/scrub/xfbtree.h
blob: 6bca9c8f4c3def21fdd57aebf1a25d1f25a8c6da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 2021 Oracle.  All Rights Reserved.
 * Author: Darrick J. Wong <djwong@kernel.org>
 */
#ifndef XFS_SCRUB_XFBTREE_H__
#define XFS_SCRUB_XFBTREE_H__

/* Root block for an in-memory btree. */
struct xfs_btree_mem_head {
	__be32				mh_magic;
	__be32				mh_nlevels;
	__be64				mh_root;
};

#define XFS_BTREE_MEM_HEAD_MAGIC		0x4341544D	/* "CATM" */

/* in-memory btree header is always block 0 in the backing store */
#define XFS_BTREE_MEM_HEAD_DADDR		0

int xfs_btree_mem_head_read_buf(struct xfs_buftarg *btp, struct xfs_trans *tp,
		struct xfs_buf **head_bpp);

/* xfile-backed in-memory btrees */

struct xfbtree {
	struct xfs_buftarg		*target;
	struct xfile			*xfile;
	struct xbitmap			*freespace;
};

/* in-memory btrees are always created with an empty leaf block at block 1 */
#define XFBTREE_NEW_LEAF_FILEOFF		1

void xfbtree_destroy(struct xfbtree *xfbt);
int xfbtree_trans_commit(struct xfbtree *xfbt, struct xfs_trans *tp);
void xfbtree_trans_cancel(struct xfbtree *xfbt, struct xfs_trans *tp);

#endif /* XFS_SCRUB_XFBTREE_H__ */