]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - libxfs/xfs_ialloc.h
xfsprogs: Release v6.15.0
[thirdparty/xfsprogs-dev.git] / libxfs / xfs_ialloc.h
CommitLineData
37b3b4d6 1// SPDX-License-Identifier: GPL-2.0
2bd0ea18 2/*
f302e9e4
NS
3 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
2bd0ea18
NS
5 */
6#ifndef __XFS_IALLOC_H__
dfc130f3 7#define __XFS_IALLOC_H__
2bd0ea18
NS
8
9struct xfs_buf;
10struct xfs_dinode;
56b2de80 11struct xfs_imap;
2bd0ea18
NS
12struct xfs_mount;
13struct xfs_trans;
34b8c759 14struct xfs_btree_cur;
e7722e28 15struct xfs_perag;
2bd0ea18 16
ff105f75 17/* Move inodes in clusters of this size */
dfc130f3 18#define XFS_INODE_BIG_CLUSTER_SIZE 8192
ff105f75 19
5a3b2e0a
BF
20struct xfs_icluster {
21 bool deleted; /* record is deleted */
22 xfs_ino_t first_ino; /* first inode number */
23 uint64_t alloc; /* inode phys. allocation bitmap for
24 * sparse chunks */
25};
26
2bd0ea18
NS
27/*
28 * Make an inode pointer out of the buffer/offset.
29 */
f302e9e4
NS
30static inline struct xfs_dinode *
31xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o)
32{
92acb899 33 return xfs_buf_offset(b, o << (mp)->m_sb.sb_inodelog);
f302e9e4 34}
2bd0ea18 35
bca9de39
DW
36struct xfs_icreate_args;
37
2bd0ea18 38/*
51b1e167
DC
39 * Allocate an inode on disk. Mode is used to tell whether the new inode will
40 * need space, and whether it is a directory.
2bd0ea18 41 */
bca9de39 42int xfs_dialloc(struct xfs_trans **tpp, const struct xfs_icreate_args *args,
51b1e167 43 xfs_ino_t *new_ino);
2bd0ea18 44
b8268cdd
DC
45int xfs_difree(struct xfs_trans *tp, struct xfs_perag *pag,
46 xfs_ino_t ino, struct xfs_icluster *ifree);
2bd0ea18
NS
47
48/*
56b2de80 49 * Return the location of the inode in imap, for mapping it into a buffer.
2bd0ea18
NS
50 */
51int
56b2de80 52xfs_imap(
e7722e28 53 struct xfs_perag *pag,
2bd0ea18
NS
54 struct xfs_trans *tp, /* transaction pointer */
55 xfs_ino_t ino, /* inode to locate */
56b2de80 56 struct xfs_imap *imap, /* location map structure */
2bd0ea18
NS
57 uint flags); /* flags for inode btree lookup */
58
2bd0ea18
NS
59/*
60 * Log specified fields for the ag hdr (inode section)
61 */
62void
63xfs_ialloc_log_agi(
64 struct xfs_trans *tp, /* transaction pointer */
65 struct xfs_buf *bp, /* allocation group header buffer */
a8f712a6 66 uint32_t fields); /* bitmask of fields to log */
2bd0ea18 67
fd841d7c 68int xfs_read_agi(struct xfs_perag *pag, struct xfs_trans *tp, xfs_buf_flags_t flags,
bc87af99
DC
69 struct xfs_buf **agibpp);
70int xfs_ialloc_read_agi(struct xfs_perag *pag, struct xfs_trans *tp,
fd841d7c
DW
71 int flags, struct xfs_buf **agibpp);
72#define XFS_IALLOC_FLAG_TRYLOCK (1U << 0) /* use trylock for buffer locking */
2bd0ea18 73
b194c7d8 74/*
56b2de80 75 * Lookup a record by ino in the btree given by cur.
b194c7d8 76 */
56b2de80
DC
77int xfs_inobt_lookup(struct xfs_btree_cur *cur, xfs_agino_t ino,
78 xfs_lookup_t dir, int *stat);
b194c7d8
BN
79
80/*
81 * Get the data from the pointed-to record.
82 */
a2ceac1f 83int xfs_inobt_get_rec(struct xfs_btree_cur *cur,
56b2de80 84 xfs_inobt_rec_incore_t *rec, int *stat);
5f8e3af0 85uint8_t xfs_inobt_rec_freecount(const struct xfs_inobt_rec_incore *irec);
b194c7d8 86
e9d35108
DC
87/*
88 * Inode chunk initialisation routine
89 */
90int xfs_ialloc_inode_init(struct xfs_mount *mp, struct xfs_trans *tp,
fe8d48ac 91 struct list_head *buffer_list, int icount,
e9d35108
DC
92 xfs_agnumber_t agno, xfs_agblock_t agbno,
93 xfs_agblock_t length, unsigned int gen);
94
5a35bf2c 95
b5f6747c 96union xfs_btree_rec;
e62318a3
DW
97void xfs_inobt_btrec_to_irec(struct xfs_mount *mp,
98 const union xfs_btree_rec *rec,
b5f6747c 99 struct xfs_inobt_rec_incore *irec);
5f8e3af0 100xfs_failaddr_t xfs_inobt_check_irec(struct xfs_perag *pag,
349aa687 101 const struct xfs_inobt_rec_incore *irec);
9deb7f65 102int xfs_ialloc_has_inodes_at_extent(struct xfs_btree_cur *cur,
fc78c405
DW
103 xfs_agblock_t bno, xfs_extlen_t len,
104 enum xbtree_recpacking *outcome);
9deb7f65
DW
105int xfs_ialloc_count_inodes(struct xfs_btree_cur *cur, xfs_agino_t *count,
106 xfs_agino_t *freecount);
aa465192
DW
107int xfs_inobt_insert_rec(struct xfs_btree_cur *cur, uint16_t holemask,
108 uint8_t count, int32_t freecount, xfs_inofree_t free,
109 int *stat);
b5f6747c
DW
110
111int xfs_ialloc_cluster_alignment(struct xfs_mount *mp);
3a05ab22 112void xfs_ialloc_setup_geometry(struct xfs_mount *mp);
1b0819ed 113xfs_ino_t xfs_ialloc_calc_rootino(struct xfs_mount *mp, int sunit);
5a35bf2c 114
90e549b5 115int xfs_ialloc_check_shrink(struct xfs_perag *pag, struct xfs_trans *tp,
23435e3c
DW
116 struct xfs_buf *agibp, xfs_agblock_t new_length);
117
2bd0ea18 118#endif /* __XFS_IALLOC_H__ */