]>
Commit | Line | Data |
---|---|---|
2bd0ea18 | 1 | /* |
0d3e0b37 | 2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. |
5000d01d | 3 | * |
2bd0ea18 NS |
4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms of version 2 of the GNU General Public License as | |
6 | * published by the Free Software Foundation. | |
5000d01d | 7 | * |
2bd0ea18 NS |
8 | * This program is distributed in the hope that it would be useful, but |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
5000d01d | 11 | * |
2bd0ea18 NS |
12 | * Further, this software is distributed without any warranty that it is |
13 | * free of the rightful claim of any third person regarding infringement | |
5000d01d | 14 | * or the like. Any license provided herein, whether implied or |
2bd0ea18 NS |
15 | * otherwise, applies only to this software file. Patent licenses, if |
16 | * any, provided herein do not apply to combinations of this program with | |
17 | * other software, or any other product whatsoever. | |
5000d01d | 18 | * |
2bd0ea18 NS |
19 | * You should have received a copy of the GNU General Public License along |
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | |
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | |
5000d01d | 22 | * |
2bd0ea18 NS |
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
24 | * Mountain View, CA 94043, or: | |
5000d01d SL |
25 | * |
26 | * http://www.sgi.com | |
27 | * | |
28 | * For further information regarding this notice, see: | |
29 | * | |
2bd0ea18 NS |
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ |
31 | */ | |
32 | #ifndef __XFS_ALLOC_H__ | |
5000d01d | 33 | #define __XFS_ALLOC_H__ |
2bd0ea18 NS |
34 | |
35 | struct xfs_buf; | |
36 | struct xfs_mount; | |
37 | struct xfs_perag; | |
38 | struct xfs_trans; | |
39 | ||
40 | /* | |
5000d01d | 41 | * Freespace allocation types. Argument to xfs_alloc_[v]extent. |
2bd0ea18 NS |
42 | */ |
43 | typedef enum xfs_alloctype | |
44 | { | |
45 | XFS_ALLOCTYPE_ANY_AG, /* allocate anywhere, use rotor */ | |
46 | XFS_ALLOCTYPE_FIRST_AG, /* ... start at ag 0 */ | |
47 | XFS_ALLOCTYPE_START_AG, /* anywhere, start in this a.g. */ | |
48 | XFS_ALLOCTYPE_THIS_AG, /* anywhere in this a.g. */ | |
49 | XFS_ALLOCTYPE_START_BNO, /* near this block else anywhere */ | |
50 | XFS_ALLOCTYPE_NEAR_BNO, /* in this a.g. and near this block */ | |
51 | XFS_ALLOCTYPE_THIS_BNO /* at exactly this block */ | |
52 | } xfs_alloctype_t; | |
53 | ||
54 | /* | |
55 | * Flags for xfs_alloc_fix_freelist. | |
56 | */ | |
5000d01d | 57 | #define XFS_ALLOC_FLAG_TRYLOCK 0x00000001 /* use trylock for buffer locking */ |
2bd0ea18 NS |
58 | |
59 | /* | |
60 | * Argument structure for xfs_alloc routines. | |
61 | * This is turned into a structure to avoid having 20 arguments passed | |
62 | * down several levels of the stack. | |
63 | */ | |
64 | typedef struct xfs_alloc_arg { | |
65 | struct xfs_trans *tp; /* transaction pointer */ | |
66 | struct xfs_mount *mp; /* file system mount point */ | |
67 | struct xfs_buf *agbp; /* buffer for a.g. freelist header */ | |
68 | struct xfs_perag *pag; /* per-ag struct for this agno */ | |
69 | xfs_fsblock_t fsbno; /* file system block number */ | |
70 | xfs_agnumber_t agno; /* allocation group number */ | |
71 | xfs_agblock_t agbno; /* allocation group-relative block # */ | |
72 | xfs_extlen_t minlen; /* minimum size of extent */ | |
73 | xfs_extlen_t maxlen; /* maximum size of extent */ | |
74 | xfs_extlen_t mod; /* mod value for extent size */ | |
75 | xfs_extlen_t prod; /* prod value for extent size */ | |
76 | xfs_extlen_t minleft; /* min blocks must be left after us */ | |
77 | xfs_extlen_t total; /* total blocks needed in xaction */ | |
78 | xfs_extlen_t alignment; /* align answer to multiple of this */ | |
79 | xfs_extlen_t minalignslop; /* slop for minlen+alignment calcs */ | |
80 | xfs_extlen_t len; /* output: actual size of extent */ | |
5000d01d SL |
81 | xfs_alloctype_t type; /* allocation type XFS_ALLOCTYPE_... */ |
82 | xfs_alloctype_t otype; /* original allocation type */ | |
2bd0ea18 NS |
83 | char wasdel; /* set if allocation was prev delayed */ |
84 | char wasfromfl; /* set if allocation is from freelist */ | |
85 | char isfl; /* set if is freelist blocks - !actg */ | |
86 | char userdata; /* set if this is user data */ | |
87 | } xfs_alloc_arg_t; | |
88 | ||
34317449 NS |
89 | /* |
90 | * Defines for userdata | |
91 | */ | |
92 | #define XFS_ALLOC_USERDATA 1 /* allocation is for user data*/ | |
93 | #define XFS_ALLOC_INITIAL_USER_DATA 2 /* special case start of file */ | |
94 | ||
2bd0ea18 NS |
95 | |
96 | #ifdef __KERNEL__ | |
97 | ||
98 | /* | |
99 | * Types for alloc tracing. | |
100 | */ | |
5000d01d SL |
101 | #define XFS_ALLOC_KTRACE_ALLOC 1 |
102 | #define XFS_ALLOC_KTRACE_FREE 2 | |
103 | #define XFS_ALLOC_KTRACE_MODAGF 3 | |
104 | #define XFS_ALLOC_KTRACE_BUSY 4 | |
105 | #define XFS_ALLOC_KTRACE_UNBUSY 5 | |
106 | #define XFS_ALLOC_KTRACE_BUSYSEARCH 6 | |
3e535bba NS |
107 | |
108 | ||
2bd0ea18 NS |
109 | /* |
110 | * Allocation tracing buffer size. | |
111 | */ | |
5000d01d | 112 | #define XFS_ALLOC_TRACE_SIZE 4096 |
2bd0ea18 NS |
113 | |
114 | #ifdef XFS_ALL_TRACE | |
5000d01d | 115 | #define XFS_ALLOC_TRACE |
2bd0ea18 NS |
116 | #endif |
117 | ||
118 | #if !defined(DEBUG) | |
119 | #undef XFS_ALLOC_TRACE | |
120 | #endif | |
121 | ||
122 | /* | |
123 | * Prototypes for visible xfs_alloc.c routines | |
124 | */ | |
125 | ||
126 | /* | |
127 | * Compute and fill in value of m_ag_maxlevels. | |
128 | */ | |
129 | void | |
130 | xfs_alloc_compute_maxlevels( | |
131 | struct xfs_mount *mp); /* file system mount structure */ | |
132 | ||
2bd0ea18 NS |
133 | /* |
134 | * Get a block from the freelist. | |
135 | * Returns with the buffer for the block gotten. | |
136 | */ | |
137 | int /* error */ | |
138 | xfs_alloc_get_freelist( | |
139 | struct xfs_trans *tp, /* transaction pointer */ | |
140 | struct xfs_buf *agbp, /* buffer containing the agf structure */ | |
5000d01d | 141 | xfs_agblock_t *bnop); /* block address retrieved from freelist */ |
2bd0ea18 NS |
142 | |
143 | /* | |
144 | * Log the given fields from the agf structure. | |
145 | */ | |
146 | void | |
147 | xfs_alloc_log_agf( | |
148 | struct xfs_trans *tp, /* transaction pointer */ | |
149 | struct xfs_buf *bp, /* buffer for a.g. freelist header */ | |
150 | int fields);/* mask of fields to be logged (XFS_AGF_...) */ | |
151 | ||
152 | /* | |
153 | * Interface for inode allocation to force the pag data to be initialized. | |
154 | */ | |
155 | int /* error */ | |
156 | xfs_alloc_pagf_init( | |
157 | struct xfs_mount *mp, /* file system mount structure */ | |
158 | struct xfs_trans *tp, /* transaction pointer */ | |
159 | xfs_agnumber_t agno, /* allocation group number */ | |
5000d01d | 160 | int flags); /* XFS_ALLOC_FLAGS_... */ |
2bd0ea18 NS |
161 | |
162 | /* | |
163 | * Put the block on the freelist for the allocation group. | |
164 | */ | |
165 | int /* error */ | |
166 | xfs_alloc_put_freelist( | |
167 | struct xfs_trans *tp, /* transaction pointer */ | |
168 | struct xfs_buf *agbp, /* buffer for a.g. freelist header */ | |
169 | struct xfs_buf *agflbp,/* buffer for a.g. free block array */ | |
170 | xfs_agblock_t bno); /* block being freed */ | |
171 | ||
172 | /* | |
173 | * Read in the allocation group header (free/alloc section). | |
174 | */ | |
175 | int /* error */ | |
176 | xfs_alloc_read_agf( | |
177 | struct xfs_mount *mp, /* mount point structure */ | |
178 | struct xfs_trans *tp, /* transaction pointer */ | |
179 | xfs_agnumber_t agno, /* allocation group number */ | |
180 | int flags, /* XFS_ALLOC_FLAG_... */ | |
181 | struct xfs_buf **bpp); /* buffer for the ag freelist header */ | |
182 | ||
183 | /* | |
184 | * Allocate an extent (variable-size). | |
185 | */ | |
186 | int /* error */ | |
187 | xfs_alloc_vextent( | |
5000d01d | 188 | xfs_alloc_arg_t *args); /* allocation argument structure */ |
2bd0ea18 NS |
189 | |
190 | /* | |
191 | * Free an extent. | |
192 | */ | |
193 | int /* error */ | |
194 | xfs_free_extent( | |
195 | struct xfs_trans *tp, /* transaction pointer */ | |
196 | xfs_fsblock_t bno, /* starting block number of extent */ | |
197 | xfs_extlen_t len); /* length of extent */ | |
198 | ||
3e535bba NS |
199 | void |
200 | xfs_alloc_mark_busy(xfs_trans_t *tp, | |
201 | xfs_agnumber_t agno, | |
202 | xfs_agblock_t bno, | |
203 | xfs_extlen_t len); | |
204 | ||
205 | void | |
206 | xfs_alloc_clear_busy(xfs_trans_t *tp, | |
207 | xfs_agnumber_t ag, | |
208 | int idx); | |
209 | ||
210 | ||
2bd0ea18 NS |
211 | #endif /* __KERNEL__ */ |
212 | ||
213 | #endif /* __XFS_ALLOC_H__ */ |