1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef __XFS_RTALLOC_H__
19#define __XFS_RTALLOC_H__
20
21struct xfs_mount;
22struct xfs_trans;
23
24
25#define XFS_MAX_RTEXTSIZE (1024 * 1024 * 1024)
26#define XFS_DFL_RTEXTSIZE (64 * 1024)
27#define XFS_MIN_RTEXTSIZE (4 * 1024)
28
29
30
31
32#define XFS_NBBYLOG 3
33#define XFS_WORDLOG 2
34#define XFS_NBWORDLOG (XFS_NBBYLOG + XFS_WORDLOG)
35#define XFS_NBWORD (1 << XFS_NBWORDLOG)
36#define XFS_WORDMASK ((1 << XFS_WORDLOG) - 1)
37
38#define XFS_BLOCKSIZE(mp) ((mp)->m_sb.sb_blocksize)
39#define XFS_BLOCKMASK(mp) ((mp)->m_blockmask)
40#define XFS_BLOCKWSIZE(mp) ((mp)->m_blockwsize)
41#define XFS_BLOCKWMASK(mp) ((mp)->m_blockwmask)
42
43
44
45
46#define XFS_SUMOFFS(mp,ls,bb) ((int)((ls) * (mp)->m_sb.sb_rbmblocks + (bb)))
47#define XFS_SUMOFFSTOBLOCK(mp,s) \
48 (((s) * (uint)sizeof(xfs_suminfo_t)) >> (mp)->m_sb.sb_blocklog)
49#define XFS_SUMPTR(mp,bp,so) \
50 ((xfs_suminfo_t *)((bp)->b_addr + \
51 (((so) * (uint)sizeof(xfs_suminfo_t)) & XFS_BLOCKMASK(mp))))
52
53#define XFS_BITTOBLOCK(mp,bi) ((bi) >> (mp)->m_blkbit_log)
54#define XFS_BLOCKTOBIT(mp,bb) ((bb) << (mp)->m_blkbit_log)
55#define XFS_BITTOWORD(mp,bi) \
56 ((int)(((bi) >> XFS_NBWORDLOG) & XFS_BLOCKWMASK(mp)))
57
58#define XFS_RTMIN(a,b) ((a) < (b) ? (a) : (b))
59#define XFS_RTMAX(a,b) ((a) > (b) ? (a) : (b))
60
61#define XFS_RTLOBIT(w) xfs_lowbit32(w)
62#define XFS_RTHIBIT(w) xfs_highbit32(w)
63
64#if XFS_BIG_BLKNOS
65#define XFS_RTBLOCKLOG(b) xfs_highbit64(b)
66#else
67#define XFS_RTBLOCKLOG(b) xfs_highbit32(b)
68#endif
69
70
71#ifdef __KERNEL__
72
73#ifdef CONFIG_XFS_RT
74
75
76
77
78
79
80
81
82
83int
84xfs_rtallocate_extent(
85 struct xfs_trans *tp,
86 xfs_rtblock_t bno,
87 xfs_extlen_t minlen,
88 xfs_extlen_t maxlen,
89 xfs_extlen_t *len,
90 xfs_alloctype_t type,
91 int wasdel,
92 xfs_extlen_t prod,
93 xfs_rtblock_t *rtblock);
94
95
96
97
98
99int
100xfs_rtfree_extent(
101 struct xfs_trans *tp,
102 xfs_rtblock_t bno,
103 xfs_extlen_t len);
104
105
106
107
108int
109xfs_rtmount_init(
110 struct xfs_mount *mp);
111void
112xfs_rtunmount_inodes(
113 struct xfs_mount *mp);
114
115
116
117
118
119int
120xfs_rtmount_inodes(
121 struct xfs_mount *mp);
122
123
124
125
126
127
128
129
130int
131xfs_rtpick_extent(
132 struct xfs_mount *mp,
133 struct xfs_trans *tp,
134 xfs_extlen_t len,
135 xfs_rtblock_t *pick);
136
137
138
139
140int
141xfs_growfs_rt(
142 struct xfs_mount *mp,
143 xfs_growfs_rt_t *in);
144
145#else
146# define xfs_rtallocate_extent(t,b,min,max,l,a,f,p,rb) (ENOSYS)
147# define xfs_rtfree_extent(t,b,l) (ENOSYS)
148# define xfs_rtpick_extent(m,t,l,rb) (ENOSYS)
149# define xfs_growfs_rt(mp,in) (ENOSYS)
150static inline int
151xfs_rtmount_init(
152 xfs_mount_t *mp)
153{
154 if (mp->m_sb.sb_rblocks == 0)
155 return 0;
156
157 xfs_warn(mp, "Not built with CONFIG_XFS_RT");
158 return ENOSYS;
159}
160# define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS))
161# define xfs_rtunmount_inodes(m)
162#endif
163
164#endif
165
166#endif
167