]>
Commit | Line | Data |
---|---|---|
2bd0ea18 | 1 | /* |
f302e9e4 NS |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | |
2bd0ea18 | 4 | * |
f302e9e4 NS |
5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License as | |
2bd0ea18 NS |
7 | * published by the Free Software Foundation. |
8 | * | |
f302e9e4 NS |
9 | * This program is distributed in the hope that it would be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
2bd0ea18 | 13 | * |
f302e9e4 NS |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write the Free Software Foundation, | |
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
2bd0ea18 | 17 | */ |
5e656dbb | 18 | |
2bd0ea18 NS |
19 | #ifndef __LIBXFS_H__ |
20 | #define __LIBXFS_H__ | |
21 | ||
2e542de0 | 22 | #include <xfs/platform_defs.h> |
2bd0ea18 | 23 | |
f5015c24 | 24 | #include <xfs/list.h> |
c40bdaa2 | 25 | #include <xfs/hlist.h> |
f1b058f9 | 26 | #include <xfs/cache.h> |
5e656dbb BN |
27 | #include <xfs/bitops.h> |
28 | #include <xfs/kmem.h> | |
e9416bd3 | 29 | #include <xfs/radix-tree.h> |
5e656dbb | 30 | #include <xfs/swab.h> |
c40bdaa2 | 31 | #include <xfs/atomic.h> |
f1b058f9 | 32 | |
2e542de0 | 33 | #include <xfs/xfs_types.h> |
a2ceac1f | 34 | #include <xfs/xfs_fs.h> |
2e542de0 | 35 | #include <xfs/xfs_arch.h> |
2d4bfb91 | 36 | |
4b1bcf96 | 37 | #include <xfs/xfs_shared.h> |
dcbc51df | 38 | #include <xfs/xfs_format.h> |
2d4bfb91 | 39 | #include <xfs/xfs_log_format.h> |
a3149b81 | 40 | #include <xfs/xfs_quota_defs.h> |
364e85ec | 41 | #include <xfs/xfs_trans_resv.h> |
2d4bfb91 | 42 | |
2e542de0 | 43 | #include <xfs/xfs_bit.h> |
f302e9e4 | 44 | #include <xfs/xfs_sb.h> |
ff105f75 DC |
45 | #include <xfs/xfs_da_format.h> |
46 | #include <xfs/xfs_da_btree.h> | |
47 | #include <xfs/xfs_dir2.h> | |
2e542de0 NS |
48 | #include <xfs/xfs_bmap_btree.h> |
49 | #include <xfs/xfs_alloc_btree.h> | |
50 | #include <xfs/xfs_ialloc_btree.h> | |
2e542de0 | 51 | #include <xfs/xfs_attr_sf.h> |
5dcd1db5 | 52 | #include <xfs/xfs_inode_fork.h> |
1d519883 | 53 | #include <xfs/xfs_inode_buf.h> |
f302e9e4 NS |
54 | #include <xfs/xfs_alloc.h> |
55 | #include <xfs/xfs_btree.h> | |
b194c7d8 | 56 | #include <xfs/xfs_btree_trace.h> |
2e542de0 | 57 | #include <xfs/xfs_bmap.h> |
c40bdaa2 | 58 | #include <xfs/xfs_trace.h> |
f302e9e4 | 59 | |
cc085d77 | 60 | |
1167ddc4 AE |
61 | #ifndef ARRAY_SIZE |
62 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | |
63 | #endif | |
2bd0ea18 | 64 | |
b391b7cd NS |
65 | #ifndef XFS_SUPER_MAGIC |
66 | #define XFS_SUPER_MAGIC 0x58465342 | |
67 | #endif | |
68 | ||
a580302f ES |
69 | #define xfs_isset(a,i) ((a)[(i)/(sizeof((a))*NBBY)] & (1<<((i)%(sizeof((a))*NBBY)))) |
70 | ||
c40bdaa2 DC |
71 | #define __round_mask(x, y) ((__typeof__(x))((y)-1)) |
72 | #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) | |
73 | #define round_down(x, y) ((x) & ~__round_mask(x, y)) | |
74 | ||
2bd0ea18 NS |
75 | /* |
76 | * Argument structure for libxfs_init(). | |
77 | */ | |
78 | typedef struct { | |
dfc130f3 RC |
79 | /* input parameters */ |
80 | char *volname; /* pathname of volume */ | |
81 | char *dname; /* pathname of data "subvolume" */ | |
82 | char *logname; /* pathname of log "subvolume" */ | |
83 | char *rtname; /* pathname of realtime "subvolume" */ | |
84 | int isreadonly; /* filesystem is only read in applic */ | |
b74a1f6a | 85 | int isdirect; /* we can attempt to use direct I/O */ |
d0572de5 BN |
86 | int disfile; /* data "subvolume" is a regular file */ |
87 | int dcreat; /* try to create data subvolume */ | |
dfc130f3 RC |
88 | int lisfile; /* log "subvolume" is a regular file */ |
89 | int lcreat; /* try to create log subvolume */ | |
d0572de5 BN |
90 | int risfile; /* realtime "subvolume" is a reg file */ |
91 | int rcreat; /* try to create realtime subvolume */ | |
74668075 | 92 | int setblksize; /* attempt to set device blksize */ |
d0572de5 | 93 | int usebuflock; /* lock xfs_buf_t's - for MT usage */ |
dfc130f3 RC |
94 | /* output results */ |
95 | dev_t ddev; /* device for data subvolume */ | |
96 | dev_t logdev; /* device for log subvolume */ | |
97 | dev_t rtdev; /* device for realtime subvolume */ | |
98 | long long dsize; /* size of data subvolume (BBs) */ | |
99 | long long logBBsize; /* size of log subvolume (BBs) */ | |
100 | /* (blocks allocated for use as | |
101 | * log is stored in mount structure) */ | |
74668075 NS |
102 | long long logBBstart; /* start block of log subvolume (BBs) */ |
103 | long long rtsize; /* size of realtime subvolume (BBs) */ | |
104 | int dbsize; /* data subvolume device blksize */ | |
105 | int lbsize; /* log subvolume device blksize */ | |
106 | int rtbsize; /* realtime subvolume device blksize */ | |
dfc130f3 RC |
107 | int dfd; /* data subvolume file descriptor */ |
108 | int logfd; /* log subvolume file descriptor */ | |
109 | int rtfd; /* realtime subvolume file descriptor */ | |
ba9ecd40 DC |
110 | int icache_flags; /* cache init flags */ |
111 | int bcache_flags; /* cache init flags */ | |
2bd0ea18 NS |
112 | } libxfs_init_t; |
113 | ||
9440d84d NS |
114 | #define LIBXFS_EXIT_ON_FAILURE 0x0001 /* exit the program if a call fails */ |
115 | #define LIBXFS_ISREADONLY 0x0002 /* disallow all mounted filesystems */ | |
116 | #define LIBXFS_ISINACTIVE 0x0004 /* allow mounted only if mounted ro */ | |
7eb6693f NS |
117 | #define LIBXFS_DANGEROUSLY 0x0008 /* repairing a device mounted ro */ |
118 | #define LIBXFS_EXCLUSIVELY 0x0010 /* disallow other accesses (O_EXCL) */ | |
b74a1f6a | 119 | #define LIBXFS_DIRECT 0x0020 /* can use direct I/O, not buffered */ |
2bd0ea18 | 120 | |
75c8b434 DC |
121 | /* |
122 | * IO verifier callbacks need the xfs_mount pointer, so we have to behave | |
123 | * somewhat like the kernel now for userspace IO in terms of having buftarg | |
124 | * based devices... | |
125 | */ | |
126 | struct xfs_buftarg { | |
127 | struct xfs_mount *bt_mount; | |
128 | dev_t dev; | |
129 | }; | |
130 | ||
131 | extern void libxfs_buftarg_init(struct xfs_mount *mp, dev_t ddev, | |
132 | dev_t logdev, dev_t rtdev); | |
133 | ||
2bd0ea18 NS |
134 | extern char *progname; |
135 | extern int libxfs_init (libxfs_init_t *); | |
f1b058f9 | 136 | extern void libxfs_destroy (void); |
2bd0ea18 | 137 | extern int libxfs_device_to_fd (dev_t); |
c5907b96 | 138 | extern dev_t libxfs_device_open (char *, int, int, int); |
75c8b434 | 139 | extern void libxfs_device_zero(struct xfs_buftarg *, xfs_daddr_t, uint); |
2bd0ea18 | 140 | extern void libxfs_device_close (dev_t); |
b74a1f6a | 141 | extern int libxfs_device_alignment (void); |
b6281496 | 142 | extern void libxfs_report(FILE *); |
fd5eda53 | 143 | extern void platform_findsizes(char *path, int fd, long long *sz, int *bsz); |
12b55baf | 144 | extern int platform_nproc(void); |
2bd0ea18 NS |
145 | |
146 | /* check or write log footer: specify device, log size in blocks & uuid */ | |
989b74bc NS |
147 | typedef xfs_caddr_t (libxfs_get_block_t)(xfs_caddr_t, int, void *); |
148 | ||
75c8b434 DC |
149 | extern int libxfs_log_clear (struct xfs_buftarg *, xfs_daddr_t, uint, |
150 | uuid_t *, int, int, int); | |
989b74bc NS |
151 | extern int libxfs_log_header (xfs_caddr_t, uuid_t *, int, int, int, |
152 | libxfs_get_block_t *, void *); | |
153 | ||
75c8b434 | 154 | |
dfc130f3 | 155 | /* |
2bd0ea18 NS |
156 | * Define a user-level mount structure with all we need |
157 | * in order to make use of the numerous XFS_* macros. | |
158 | */ | |
2bd0ea18 NS |
159 | typedef struct xfs_mount { |
160 | xfs_sb_t m_sb; /* copy of fs superblock */ | |
062998e3 | 161 | char *m_fsname; /* filesystem name */ |
2bd0ea18 NS |
162 | int m_bsize; /* fs logical block size */ |
163 | xfs_agnumber_t m_agfrotor; /* last ag where space found */ | |
164 | xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */ | |
b391b7cd | 165 | xfs_agnumber_t m_maxagi; /* highest inode alloc group */ |
2bd0ea18 NS |
166 | uint m_rsumlevels; /* rt summary levels */ |
167 | uint m_rsumsize; /* size of rt summary, bytes */ | |
168 | struct xfs_inode *m_rbmip; /* pointer to bitmap inode */ | |
169 | struct xfs_inode *m_rsumip; /* pointer to summary inode */ | |
75c8b434 DC |
170 | struct xfs_buftarg *m_ddev_targp; |
171 | struct xfs_buftarg *m_logdev_targp; | |
172 | struct xfs_buftarg *m_rtdev_targp; | |
173 | #define m_dev m_ddev_targp | |
174 | #define m_logdev m_logdev_targp | |
175 | #define m_rtdev m_rtdev_targp | |
2bd0ea18 NS |
176 | __uint8_t m_dircook_elog; /* log d-cookie entry bits */ |
177 | __uint8_t m_blkbit_log; /* blocklog + NBBY */ | |
178 | __uint8_t m_blkbb_log; /* blocklog - BBSHIFT */ | |
9440d84d | 179 | __uint8_t m_sectbb_log; /* sectorlog - BBSHIFT */ |
2bd0ea18 NS |
180 | __uint8_t m_agno_log; /* log #ag's */ |
181 | __uint8_t m_agino_log; /* #bits for agino in inum */ | |
7b5f9801 | 182 | uint m_inode_cluster_size;/* min inode buf size */ |
2bd0ea18 NS |
183 | uint m_blockmask; /* sb_blocksize-1 */ |
184 | uint m_blockwsize; /* sb_blocksize in words */ | |
185 | uint m_blockwmask; /* blockwsize-1 */ | |
186 | uint m_alloc_mxr[2]; /* XFS_ALLOC_BLOCK_MAXRECS */ | |
187 | uint m_alloc_mnr[2]; /* XFS_ALLOC_BLOCK_MINRECS */ | |
188 | uint m_bmap_dmxr[2]; /* XFS_BMAP_BLOCK_DMAXRECS */ | |
189 | uint m_bmap_dmnr[2]; /* XFS_BMAP_BLOCK_DMINRECS */ | |
190 | uint m_inobt_mxr[2]; /* XFS_INOBT_BLOCK_MAXRECS */ | |
191 | uint m_inobt_mnr[2]; /* XFS_INOBT_BLOCK_MINRECS */ | |
192 | uint m_ag_maxlevels; /* XFS_AG_MAXLEVELS */ | |
193 | uint m_bm_maxlevels[2]; /* XFS_BM_MAXLEVELS */ | |
194 | uint m_in_maxlevels; /* XFS_IN_MAXLEVELS */ | |
56b2de80 | 195 | struct radix_tree_root m_perag_tree; |
2bd0ea18 NS |
196 | uint m_flags; /* global mount flags */ |
197 | uint m_qflags; /* quota status flags */ | |
198 | uint m_attroffset; /* inode attribute offset */ | |
2bd0ea18 NS |
199 | int m_ialloc_inos; /* inodes in inode allocation */ |
200 | int m_ialloc_blks; /* blocks in inode allocation */ | |
201 | int m_litino; /* size of inode union area */ | |
202 | int m_inoalign_mask;/* mask sb_inoalignmt if used */ | |
cf52c730 | 203 | struct xfs_trans_resv m_resv; /* precomputed res values */ |
2bd0ea18 NS |
204 | __uint64_t m_maxicount; /* maximum inode count */ |
205 | int m_dalign; /* stripe unit */ | |
206 | int m_swidth; /* stripe width */ | |
207 | int m_sinoalign; /* stripe unit inode alignmnt */ | |
51ca7008 | 208 | const struct xfs_nameops *m_dirnameops; /* vector of dir name ops */ |
ff105f75 DC |
209 | |
210 | struct xfs_da_geometry *m_dir_geo; /* directory block geometry */ | |
211 | struct xfs_da_geometry *m_attr_geo; /* attribute block geometry */ | |
212 | const struct xfs_dir_ops *m_dir_inode_ops; /* vector of dir inode ops */ | |
213 | const struct xfs_dir_ops *m_nondir_inode_ops; /* !dir inode ops */ | |
214 | #define M_DIROPS(mp) ((mp)->m_dir_inode_ops) | |
32390f05 DC |
215 | |
216 | /* | |
217 | * anonymous struct to allow xfs_dquot_buf.c to compile. | |
218 | * Pointer is always null in userspace, so code does not use it at all | |
219 | */ | |
220 | struct { | |
221 | int qi_dqperchunk; | |
222 | } *m_quotainfo; | |
223 | ||
2bd0ea18 NS |
224 | } xfs_mount_t; |
225 | ||
d43bc409 DC |
226 | /* |
227 | * Per-ag incore structure, copies of information in agf and agi, | |
228 | * to improve the performance of allocation group selection. | |
229 | */ | |
230 | typedef struct xfs_perag { | |
231 | struct xfs_mount *pag_mount; /* owner filesystem */ | |
232 | xfs_agnumber_t pag_agno; /* AG this structure belongs to */ | |
233 | atomic_t pag_ref; /* perag reference count */ | |
234 | char pagf_init; /* this agf's entry is initialized */ | |
235 | char pagi_init; /* this agi's entry is initialized */ | |
236 | char pagf_metadata; /* the agf is preferred to be metadata */ | |
237 | char pagi_inodeok; /* The agi is ok for inodes */ | |
238 | __uint8_t pagf_levels[XFS_BTNUM_AGF]; | |
239 | /* # of levels in bno & cnt btree */ | |
240 | __uint32_t pagf_flcount; /* count of blocks in freelist */ | |
241 | xfs_extlen_t pagf_freeblks; /* total free blocks */ | |
242 | xfs_extlen_t pagf_longest; /* longest free space */ | |
243 | __uint32_t pagf_btreeblks; /* # of blocks held in AGF btrees */ | |
244 | xfs_agino_t pagi_freecount; /* number of free inodes */ | |
245 | xfs_agino_t pagi_count; /* number of allocated inodes */ | |
246 | ||
247 | /* | |
248 | * Inode allocation search lookup optimisation. | |
249 | * If the pagino matches, the search for new inodes | |
250 | * doesn't need to search the near ones again straight away | |
251 | */ | |
252 | xfs_agino_t pagl_pagino; | |
253 | xfs_agino_t pagl_leftrec; | |
254 | xfs_agino_t pagl_rightrec; | |
255 | int pagb_count; /* pagb slots in use */ | |
256 | } xfs_perag_t; | |
a2ceac1f | 257 | |
9aa57116 DC |
258 | #define LIBXFS_MOUNT_DEBUGGER 0x0001 |
259 | #define LIBXFS_MOUNT_32BITINODES 0x0002 | |
260 | #define LIBXFS_MOUNT_32BITINOOPT 0x0004 | |
261 | #define LIBXFS_MOUNT_COMPAT_ATTR 0x0008 | |
262 | #define LIBXFS_MOUNT_ATTR2 0x0010 | |
2bd0ea18 | 263 | |
2556c98b | 264 | #define LIBXFS_BHASHSIZE(sbp) (1<<10) |
f1b058f9 | 265 | |
2bd0ea18 NS |
266 | extern xfs_mount_t *libxfs_mount (xfs_mount_t *, xfs_sb_t *, |
267 | dev_t, dev_t, dev_t, int); | |
2bd0ea18 | 268 | extern void libxfs_umount (xfs_mount_t *); |
f1b058f9 | 269 | extern void libxfs_rtmount_destroy (xfs_mount_t *); |
2bd0ea18 | 270 | |
2bd0ea18 NS |
271 | /* |
272 | * Simple I/O interface | |
273 | */ | |
a2ceac1f DC |
274 | #define XB_PAGES 2 |
275 | ||
276 | struct xfs_buf_map { | |
277 | xfs_daddr_t bm_bn; /* block number for I/O */ | |
278 | int bm_len; /* size of I/O */ | |
279 | }; | |
280 | ||
281 | #define DEFINE_SINGLE_BUF_MAP(map, blkno, numblk) \ | |
282 | struct xfs_buf_map (map) = { .bm_bn = (blkno), .bm_len = (numblk) }; | |
283 | ||
284 | struct xfs_buf_ops { | |
285 | void (*verify_read)(struct xfs_buf *); | |
286 | void (*verify_write)(struct xfs_buf *); | |
287 | }; | |
288 | ||
2bd0ea18 | 289 | typedef struct xfs_buf { |
f1b058f9 NS |
290 | struct cache_node b_node; |
291 | unsigned int b_flags; | |
5dfa5cd2 | 292 | xfs_daddr_t b_bn; |
f1b058f9 | 293 | unsigned b_bcount; |
a2ceac1f | 294 | unsigned int b_length; |
75c8b434 DC |
295 | struct xfs_buftarg *b_target; |
296 | #define b_dev b_target->dev | |
2556c98b | 297 | pthread_mutex_t b_lock; |
50722af1 CH |
298 | pthread_t b_holder; |
299 | unsigned int b_recur; | |
5dfa5cd2 | 300 | void *b_fspriv; |
f1b058f9 NS |
301 | void *b_fsprivate2; |
302 | void *b_fsprivate3; | |
a2ceac1f | 303 | void *b_addr; |
a6a7776a | 304 | int b_error; |
a2ceac1f | 305 | const struct xfs_buf_ops *b_ops; |
a2ceac1f DC |
306 | struct xfs_perag *b_pag; |
307 | struct xfs_buf_map *b_map; | |
308 | int b_nmaps; | |
2556c98b BN |
309 | #ifdef XFS_BUF_TRACING |
310 | struct list_head b_lock_list; | |
311 | const char *b_func; | |
312 | const char *b_file; | |
313 | int b_line; | |
314 | #endif | |
2bd0ea18 | 315 | } xfs_buf_t; |
f1b058f9 NS |
316 | |
317 | enum xfs_buf_flags_t { /* b_flags bits */ | |
318 | LIBXFS_B_EXIT = 0x0001, /* ==LIBXFS_EXIT_ON_FAILURE */ | |
319 | LIBXFS_B_DIRTY = 0x0002, /* buffer has been modified */ | |
320 | LIBXFS_B_STALE = 0x0004, /* buffer marked as invalid */ | |
a2ceac1f DC |
321 | LIBXFS_B_UPTODATE = 0x0008, /* buffer is sync'd to disk */ |
322 | LIBXFS_B_DISCONTIG = 0x0010, /* discontiguous buffer */ | |
b511ff41 | 323 | LIBXFS_B_UNCHECKED = 0x0020, /* needs verification */ |
f1b058f9 NS |
324 | }; |
325 | ||
5dfa5cd2 DC |
326 | #define XFS_BUF_DADDR_NULL ((xfs_daddr_t) (-1LL)) |
327 | ||
a2ceac1f | 328 | #define XFS_BUF_PTR(bp) ((char *)(bp)->b_addr) |
2bd0ea18 | 329 | #define xfs_buf_offset(bp, offset) (XFS_BUF_PTR(bp) + (offset)) |
5dfa5cd2 | 330 | #define XFS_BUF_ADDR(bp) ((bp)->b_bn) |
57c9fccb | 331 | #define XFS_BUF_SIZE(bp) ((bp)->b_bcount) |
2bd0ea18 NS |
332 | #define XFS_BUF_COUNT(bp) ((bp)->b_bcount) |
333 | #define XFS_BUF_TARGET(bp) ((bp)->b_dev) | |
c40bdaa2 DC |
334 | #define XFS_BUF_SET_PTR(bp,p,cnt) ({ \ |
335 | (bp)->b_addr = (char *)(p); \ | |
336 | XFS_BUF_SET_COUNT(bp,cnt); \ | |
337 | }) | |
338 | ||
5dfa5cd2 | 339 | #define XFS_BUF_SET_ADDR(bp,blk) ((bp)->b_bn = (blk)) |
2aa2e7b9 | 340 | #define XFS_BUF_SET_COUNT(bp,cnt) ((bp)->b_bcount = (cnt)) |
2bd0ea18 | 341 | |
5dfa5cd2 DC |
342 | #define XFS_BUF_FSPRIVATE(bp,type) ((type)(bp)->b_fspriv) |
343 | #define XFS_BUF_SET_FSPRIVATE(bp,val) (bp)->b_fspriv = (void *)(val) | |
2bd0ea18 NS |
344 | #define XFS_BUF_FSPRIVATE2(bp,type) ((type)(bp)->b_fsprivate2) |
345 | #define XFS_BUF_SET_FSPRIVATE2(bp,val) (bp)->b_fsprivate2 = (void *)(val) | |
346 | #define XFS_BUF_FSPRIVATE3(bp,type) ((type)(bp)->b_fsprivate3) | |
347 | #define XFS_BUF_SET_FSPRIVATE3(bp,val) (bp)->b_fsprivate3 = (void *)(val) | |
348 | ||
69ec88b5 BN |
349 | #define XFS_BUF_SET_PRIORITY(bp,pri) cache_node_set_priority( \ |
350 | libxfs_bcache, \ | |
351 | (struct cache_node *)(bp), \ | |
352 | (pri)) | |
353 | #define XFS_BUF_PRIORITY(bp) (cache_node_get_priority( \ | |
354 | (struct cache_node *)(bp))) | |
a2ceac1f | 355 | #define xfs_buf_set_ref(bp,ref) ((void) 0) |
45922933 | 356 | #define xfs_buf_ioerror(bp,err) ((bp)->b_error = (err)) |
69ec88b5 | 357 | |
4896e6c8 DC |
358 | #define xfs_daddr_to_agno(mp,d) \ |
359 | ((xfs_agnumber_t)(XFS_BB_TO_FSBT(mp, d) / (mp)->m_sb.sb_agblocks)) | |
360 | #define xfs_daddr_to_agbno(mp,d) \ | |
361 | ((xfs_agblock_t)(XFS_BB_TO_FSBT(mp, d) % (mp)->m_sb.sb_agblocks)) | |
362 | ||
f1b058f9 | 363 | /* Buffer Cache Interfaces */ |
2556c98b | 364 | |
f1b058f9 NS |
365 | extern struct cache *libxfs_bcache; |
366 | extern struct cache_operations libxfs_bcache_operations; | |
2556c98b | 367 | |
2ae22647 CH |
368 | #define LIBXFS_GETBUF_TRYLOCK (1 << 0) |
369 | ||
2556c98b BN |
370 | #ifdef XFS_BUF_TRACING |
371 | ||
75c8b434 | 372 | #define libxfs_readbuf(dev, daddr, len, flags, ops) \ |
2ae22647 | 373 | libxfs_trace_readbuf(__FUNCTION__, __FILE__, __LINE__, \ |
75c8b434 DC |
374 | (dev), (daddr), (len), (flags), (ops)) |
375 | #define libxfs_readbuf_map(dev, map, nmaps, flags, ops) \ | |
a2ceac1f | 376 | libxfs_trace_readbuf_map(__FUNCTION__, __FILE__, __LINE__, \ |
75c8b434 | 377 | (dev), (map), (nmaps), (flags), (ops)) |
2556c98b | 378 | #define libxfs_writebuf(buf, flags) \ |
2ae22647 CH |
379 | libxfs_trace_writebuf(__FUNCTION__, __FILE__, __LINE__, \ |
380 | (buf), (flags)) | |
2556c98b | 381 | #define libxfs_getbuf(dev, daddr, len) \ |
2ae22647 CH |
382 | libxfs_trace_getbuf(__FUNCTION__, __FILE__, __LINE__, \ |
383 | (dev), (daddr), (len)) | |
7e3ab890 | 384 | #define libxfs_getbuf_map(dev, map, nmaps, flags) \ |
a2ceac1f | 385 | libxfs_trace_getbuf_map(__FUNCTION__, __FILE__, __LINE__, \ |
7e3ab890 | 386 | (dev), (map), (nmaps), (flags)) |
2ae22647 | 387 | #define libxfs_getbuf_flags(dev, daddr, len, flags) \ |
a2ceac1f | 388 | libxfs_trace_getbuf_flags(__FUNCTION__, __FILE__, __LINE__, \ |
2ae22647 | 389 | (dev), (daddr), (len), (flags)) |
2556c98b | 390 | #define libxfs_putbuf(buf) \ |
2ae22647 | 391 | libxfs_trace_putbuf(__FUNCTION__, __FILE__, __LINE__, (buf)) |
2556c98b | 392 | |
2ae22647 | 393 | extern xfs_buf_t *libxfs_trace_readbuf(const char *, const char *, int, |
75c8b434 DC |
394 | struct xfs_buftarg *, xfs_daddr_t, int, int, |
395 | const struct xfs_buf_ops *); | |
a2ceac1f | 396 | extern xfs_buf_t *libxfs_trace_readbuf_map(const char *, const char *, int, |
75c8b434 DC |
397 | struct xfs_buftarg *, struct xfs_buf_map *, int, int, |
398 | const struct xfs_buf_ops *); | |
2ae22647 CH |
399 | extern int libxfs_trace_writebuf(const char *, const char *, int, |
400 | xfs_buf_t *, int); | |
a2ceac1f | 401 | extern xfs_buf_t *libxfs_trace_getbuf(const char *, const char *, int, |
75c8b434 | 402 | struct xfs_buftarg *, xfs_daddr_t, int); |
a2ceac1f | 403 | extern xfs_buf_t *libxfs_trace_getbuf_map(const char *, const char *, int, |
7e3ab890 | 404 | struct xfs_buftarg *, struct xfs_buf_map *, int, int); |
2ae22647 | 405 | extern xfs_buf_t *libxfs_trace_getbuf_flags(const char *, const char *, int, |
75c8b434 | 406 | struct xfs_buftarg *, xfs_daddr_t, int, unsigned int); |
2ae22647 CH |
407 | extern void libxfs_trace_putbuf (const char *, const char *, int, |
408 | xfs_buf_t *); | |
2556c98b BN |
409 | |
410 | #else | |
411 | ||
75c8b434 DC |
412 | extern xfs_buf_t *libxfs_readbuf(struct xfs_buftarg *, xfs_daddr_t, int, int, |
413 | const struct xfs_buf_ops *); | |
414 | extern xfs_buf_t *libxfs_readbuf_map(struct xfs_buftarg *, struct xfs_buf_map *, | |
415 | int, int, const struct xfs_buf_ops *); | |
2556c98b | 416 | extern int libxfs_writebuf(xfs_buf_t *, int); |
75c8b434 DC |
417 | extern xfs_buf_t *libxfs_getbuf(struct xfs_buftarg *, xfs_daddr_t, int); |
418 | extern xfs_buf_t *libxfs_getbuf_map(struct xfs_buftarg *, | |
7e3ab890 | 419 | struct xfs_buf_map *, int, int); |
75c8b434 DC |
420 | extern xfs_buf_t *libxfs_getbuf_flags(struct xfs_buftarg *, xfs_daddr_t, |
421 | int, unsigned int); | |
2bd0ea18 | 422 | extern void libxfs_putbuf (xfs_buf_t *); |
2556c98b BN |
423 | |
424 | #endif | |
425 | ||
adbb3573 DC |
426 | extern void libxfs_readbuf_verify(struct xfs_buf *bp, |
427 | const struct xfs_buf_ops *ops); | |
2556c98b BN |
428 | extern xfs_buf_t *libxfs_getsb(xfs_mount_t *, int); |
429 | extern void libxfs_bcache_purge(void); | |
430 | extern void libxfs_bcache_flush(void); | |
431 | extern void libxfs_purgebuf(xfs_buf_t *); | |
432 | extern int libxfs_bcache_overflowed(void); | |
433 | extern int libxfs_bcache_usage(void); | |
2bd0ea18 | 434 | |
e6b359b3 | 435 | /* Buffer (Raw) Interfaces */ |
75c8b434 | 436 | extern xfs_buf_t *libxfs_getbufr(struct xfs_buftarg *, xfs_daddr_t, int); |
2556c98b BN |
437 | extern void libxfs_putbufr(xfs_buf_t *); |
438 | ||
439 | extern int libxfs_writebuf_int(xfs_buf_t *, int); | |
800db1c1 | 440 | extern int libxfs_writebufr(struct xfs_buf *); |
75c8b434 | 441 | extern int libxfs_readbufr(struct xfs_buftarg *, xfs_daddr_t, xfs_buf_t *, int, int); |
6d5e5ee0 | 442 | extern int libxfs_readbufr_map(struct xfs_buftarg *, struct xfs_buf *, int); |
e6b359b3 | 443 | |
9f38f08d | 444 | extern int libxfs_bhash_size; |
9f38f08d | 445 | |
57c9fccb NS |
446 | #define LIBXFS_BREAD 0x1 |
447 | #define LIBXFS_BWRITE 0x2 | |
448 | #define LIBXFS_BZERO 0x4 | |
449 | ||
450 | extern void libxfs_iomove (xfs_buf_t *, uint, int, void *, int); | |
451 | ||
2bd0ea18 NS |
452 | /* |
453 | * Transaction interface | |
454 | */ | |
455 | ||
456 | typedef struct xfs_log_item { | |
457 | struct xfs_log_item_desc *li_desc; /* ptr to current desc*/ | |
458 | struct xfs_mount *li_mountp; /* ptr to fs mount */ | |
459 | uint li_type; /* item type */ | |
5dfa5cd2 | 460 | xfs_lsn_t li_lsn; |
2bd0ea18 NS |
461 | } xfs_log_item_t; |
462 | ||
463 | typedef struct xfs_inode_log_item { | |
464 | xfs_log_item_t ili_item; /* common portion */ | |
465 | struct xfs_inode *ili_inode; /* inode pointer */ | |
466 | unsigned short ili_flags; /* misc flags */ | |
a2ceac1f | 467 | unsigned int ili_fields; /* fields to be logged */ |
2bd0ea18 NS |
468 | unsigned int ili_last_fields; /* fields when flushed*/ |
469 | xfs_inode_log_format_t ili_format; /* logged structure */ | |
470 | } xfs_inode_log_item_t; | |
471 | ||
472 | typedef struct xfs_buf_log_item { | |
473 | xfs_log_item_t bli_item; /* common item structure */ | |
474 | struct xfs_buf *bli_buf; /* real buffer pointer */ | |
475 | unsigned int bli_flags; /* misc flags */ | |
476 | unsigned int bli_recur; /* recursion count */ | |
477 | xfs_buf_log_format_t bli_format; /* in-log header */ | |
478 | } xfs_buf_log_item_t; | |
479 | ||
47fe8b7e DC |
480 | #define XFS_BLI_DIRTY (1<<0) |
481 | #define XFS_BLI_HOLD (1<<1) | |
482 | #define XFS_BLI_STALE (1<<2) | |
483 | #define XFS_BLI_INODE_ALLOC_BUF (1<<3) | |
484 | ||
364e85ec DC |
485 | typedef struct xfs_dq_logitem { |
486 | xfs_log_item_t qli_item; /* common portion */ | |
487 | struct xfs_dquot *qli_dquot; /* dquot ptr */ | |
488 | xfs_lsn_t qli_flush_lsn; /* lsn at last flush */ | |
489 | xfs_dq_logformat_t qli_format; /* logged structure */ | |
490 | } xfs_dq_logitem_t; | |
491 | ||
492 | typedef struct xfs_qoff_logitem { | |
493 | xfs_log_item_t qql_item; /* common portion */ | |
494 | struct xfs_qoff_logitem *qql_start_lip; /* qoff-start logitem, if any */ | |
495 | xfs_qoff_logformat_t qql_format; /* logged structure */ | |
496 | } xfs_qoff_logitem_t; | |
2bd0ea18 NS |
497 | |
498 | typedef struct xfs_trans { | |
499 | unsigned int t_type; /* transaction type */ | |
ca86e759 NS |
500 | unsigned int t_log_res; /* amt of log space resvd */ |
501 | unsigned int t_log_count; /* count for perm log res */ | |
2bd0ea18 NS |
502 | xfs_mount_t *t_mountp; /* ptr to fs mount struct */ |
503 | unsigned int t_flags; /* misc flags */ | |
504 | long t_icount_delta; /* superblock icount change */ | |
505 | long t_ifree_delta; /* superblock ifree change */ | |
506 | long t_fdblocks_delta; /* superblock fdblocks chg */ | |
507 | long t_frextents_delta; /* superblock freextents chg */ | |
c40bdaa2 | 508 | struct list_head t_items; /* first log item desc chunk */ |
2bd0ea18 NS |
509 | } xfs_trans_t; |
510 | ||
364e85ec DC |
511 | extern void xfs_trans_init(struct xfs_mount *); |
512 | extern int xfs_trans_roll(struct xfs_trans **, struct xfs_inode *); | |
513 | ||
2bd0ea18 NS |
514 | extern xfs_trans_t *libxfs_trans_alloc (xfs_mount_t *, int); |
515 | extern xfs_trans_t *libxfs_trans_dup (xfs_trans_t *); | |
48ea6cb9 DC |
516 | extern int libxfs_trans_reserve(struct xfs_trans *, struct xfs_trans_res *, |
517 | uint, uint); | |
5e656dbb | 518 | extern int libxfs_trans_commit (xfs_trans_t *, uint); |
2bd0ea18 | 519 | extern void libxfs_trans_cancel (xfs_trans_t *, int); |
f1b058f9 | 520 | extern xfs_buf_t *libxfs_trans_getsb (xfs_trans_t *, xfs_mount_t *, int); |
2bd0ea18 NS |
521 | |
522 | extern int libxfs_trans_iget (xfs_mount_t *, xfs_trans_t *, xfs_ino_t, | |
46eca962 | 523 | uint, uint, struct xfs_inode **); |
2bd0ea18 | 524 | extern void libxfs_trans_ijoin (xfs_trans_t *, struct xfs_inode *, uint); |
56b2de80 | 525 | extern void libxfs_trans_ijoin_ref(xfs_trans_t *, struct xfs_inode *, int); |
2bd0ea18 NS |
526 | extern void libxfs_trans_log_inode (xfs_trans_t *, struct xfs_inode *, |
527 | uint); | |
528 | ||
529 | extern void libxfs_trans_brelse (xfs_trans_t *, struct xfs_buf *); | |
530 | extern void libxfs_trans_binval (xfs_trans_t *, struct xfs_buf *); | |
531 | extern void libxfs_trans_bjoin (xfs_trans_t *, struct xfs_buf *); | |
532 | extern void libxfs_trans_bhold (xfs_trans_t *, struct xfs_buf *); | |
533 | extern void libxfs_trans_log_buf (xfs_trans_t *, struct xfs_buf *, | |
534 | uint, uint); | |
a2ceac1f | 535 | /* |
2bd0ea18 NS |
536 | extern xfs_buf_t *libxfs_trans_get_buf (xfs_trans_t *, dev_t, |
537 | xfs_daddr_t, int, uint); | |
538 | extern int libxfs_trans_read_buf (xfs_mount_t *, xfs_trans_t *, dev_t, | |
539 | xfs_daddr_t, int, uint, struct xfs_buf **); | |
a2ceac1f DC |
540 | */ |
541 | ||
75c8b434 DC |
542 | struct xfs_buf *libxfs_trans_get_buf_map(struct xfs_trans *tp, |
543 | struct xfs_buftarg *btp, | |
544 | struct xfs_buf_map *map, int nmaps, | |
545 | uint flags); | |
a2ceac1f DC |
546 | |
547 | static inline struct xfs_buf * | |
548 | libxfs_trans_get_buf( | |
549 | struct xfs_trans *tp, | |
75c8b434 | 550 | struct xfs_buftarg *btp, |
a2ceac1f DC |
551 | xfs_daddr_t blkno, |
552 | int numblks, | |
553 | uint flags) | |
554 | { | |
555 | DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); | |
75c8b434 | 556 | return libxfs_trans_get_buf_map(tp, btp, &map, 1, flags); |
a2ceac1f DC |
557 | } |
558 | ||
559 | int libxfs_trans_read_buf_map(struct xfs_mount *mp, | |
75c8b434 DC |
560 | struct xfs_trans *tp, |
561 | struct xfs_buftarg *btp, | |
a2ceac1f DC |
562 | struct xfs_buf_map *map, int nmaps, |
563 | uint flags, struct xfs_buf **bpp, | |
564 | const struct xfs_buf_ops *ops); | |
565 | ||
566 | static inline int | |
567 | libxfs_trans_read_buf( | |
568 | struct xfs_mount *mp, | |
569 | struct xfs_trans *tp, | |
75c8b434 | 570 | struct xfs_buftarg *btp, |
a2ceac1f DC |
571 | xfs_daddr_t blkno, |
572 | int numblks, | |
573 | uint flags, | |
574 | struct xfs_buf **bpp, | |
575 | const struct xfs_buf_ops *ops) | |
576 | { | |
577 | DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); | |
75c8b434 | 578 | return libxfs_trans_read_buf_map(mp, tp, btp, &map, 1, |
a2ceac1f DC |
579 | flags, bpp, ops); |
580 | } | |
2bd0ea18 | 581 | |
2bd0ea18 NS |
582 | /* |
583 | * Inode interface | |
584 | */ | |
2bd0ea18 | 585 | typedef struct xfs_inode { |
f1b058f9 | 586 | struct cache_node i_node; |
2bd0ea18 NS |
587 | xfs_mount_t *i_mount; /* fs mount struct ptr */ |
588 | xfs_ino_t i_ino; /* inode number (agno/agino) */ | |
56b2de80 | 589 | struct xfs_imap i_imap; /* location for xfs_imap() */ |
f756f80c | 590 | struct xfs_buftarg i_dev; /* dev for this inode */ |
2bd0ea18 NS |
591 | xfs_ifork_t *i_afp; /* attribute fork pointer */ |
592 | xfs_ifork_t i_df; /* data fork */ | |
f1b058f9 NS |
593 | xfs_trans_t *i_transp; /* ptr to owning transaction */ |
594 | xfs_inode_log_item_t *i_itemp; /* logging information */ | |
2bd0ea18 | 595 | unsigned int i_delayed_blks; /* count of delay alloc blks */ |
5e656dbb BN |
596 | xfs_icdinode_t i_d; /* most of ondisk inode */ |
597 | xfs_fsize_t i_size; /* in-memory size */ | |
ff105f75 | 598 | const struct xfs_dir_ops *d_ops; /* directory ops vector */ |
2bd0ea18 NS |
599 | } xfs_inode_t; |
600 | ||
57c9fccb NS |
601 | #define LIBXFS_ATTR_ROOT 0x0002 /* use attrs in root namespace */ |
602 | #define LIBXFS_ATTR_SECURE 0x0008 /* use attrs in security namespace */ | |
603 | #define LIBXFS_ATTR_CREATE 0x0010 /* create, but fail if attr exists */ | |
604 | #define LIBXFS_ATTR_REPLACE 0x0020 /* set, but fail if attr not exists */ | |
605 | ||
a2ceac1f DC |
606 | /* |
607 | * Project quota id helpers (previously projid was 16bit only and using two | |
608 | * 16bit values to hold new 32bit projid was chosen to retain compatibility with | |
609 | * "old" filesystems). | |
610 | * | |
611 | * Copied here from xfs_inode.h because it has to be defined after the struct | |
612 | * xfs_inode... | |
613 | */ | |
614 | static inline prid_t | |
615 | xfs_get_projid(struct xfs_icdinode *id) | |
616 | { | |
617 | return (prid_t)id->di_projid_hi << 16 | id->di_projid_lo; | |
618 | } | |
619 | ||
620 | static inline void | |
621 | xfs_set_projid(struct xfs_icdinode *id, prid_t projid) | |
622 | { | |
623 | id->di_projid_hi = (__uint16_t) (projid >> 16); | |
624 | id->di_projid_lo = (__uint16_t) (projid & 0xffff); | |
625 | } | |
626 | ||
9f064b7e | 627 | typedef struct cred { |
14290264 NS |
628 | uid_t cr_uid; |
629 | gid_t cr_gid; | |
630 | } cred_t; | |
631 | ||
2bd0ea18 | 632 | extern int libxfs_inode_alloc (xfs_trans_t **, xfs_inode_t *, mode_t, |
9f064b7e NS |
633 | nlink_t, xfs_dev_t, struct cred *, |
634 | struct fsxattr *, xfs_inode_t **); | |
2bd0ea18 NS |
635 | extern void libxfs_trans_inode_alloc_buf (xfs_trans_t *, xfs_buf_t *); |
636 | ||
56b2de80 DC |
637 | extern void libxfs_trans_ichgtime(struct xfs_trans *, |
638 | struct xfs_inode *, int); | |
2bd0ea18 | 639 | extern int libxfs_iflush_int (xfs_inode_t *, xfs_buf_t *); |
f1b058f9 NS |
640 | |
641 | /* Inode Cache Interfaces */ | |
2bd0ea18 NS |
642 | extern int libxfs_iget (xfs_mount_t *, xfs_trans_t *, xfs_ino_t, |
643 | uint, xfs_inode_t **, xfs_daddr_t); | |
dd2c21d2 MT |
644 | extern void libxfs_iput (xfs_inode_t *); |
645 | ||
646 | #define IRELE(ip) libxfs_iput(ip) | |
2bd0ea18 | 647 | |
5e656dbb BN |
648 | /* Shared utility routines */ |
649 | extern unsigned int libxfs_log2_roundup(unsigned int i); | |
2bd0ea18 | 650 | |
2bd0ea18 NS |
651 | extern int libxfs_alloc_file_space (xfs_inode_t *, xfs_off_t, |
652 | xfs_off_t, int, int); | |
5e656dbb | 653 | extern int libxfs_bmap_finish(xfs_trans_t **, xfs_bmap_free_t *, int *); |
2bd0ea18 | 654 | |
5e656dbb BN |
655 | extern void libxfs_fs_repair_cmn_err(int, struct xfs_mount *, char *, ...); |
656 | extern void libxfs_fs_cmn_err(int, struct xfs_mount *, char *, ...); | |
2bd0ea18 | 657 | |
1552a820 NS |
658 | extern void cmn_err(int, char *, ...); |
659 | enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC }; | |
f302e9e4 | 660 | |
cb5b3ef4 MV |
661 | |
662 | #define LIBXFS_BBTOOFF64(bbs) (((xfs_off_t)(bbs)) << BBSHIFT) | |
2556c98b BN |
663 | extern int libxfs_nproc(void); |
664 | extern unsigned long libxfs_physmem(void); /* in kilobytes */ | |
cb5b3ef4 | 665 | |
f302e9e4 | 666 | #include <xfs/xfs_ialloc.h> |
f302e9e4 NS |
667 | |
668 | #include <xfs/xfs_attr_leaf.h> | |
9d6fabc0 | 669 | #include <xfs/xfs_attr_remote.h> |
f302e9e4 | 670 | #include <xfs/xfs_trans_space.h> |
f302e9e4 | 671 | |
5e656dbb BN |
672 | #define XFS_INOBT_IS_FREE_DISK(rp,i) \ |
673 | ((be64_to_cpu((rp)->ir_free) & XFS_INOBT_MASK(i)) != 0) | |
56b2de80 | 674 | |
f616e2bf DC |
675 | #define xfs_notice(mp,fmt,args...) cmn_err(CE_NOTE,fmt, ## args) |
676 | #define xfs_warn(mp,fmt,args...) cmn_err(CE_WARN,fmt, ## args) | |
677 | #define xfs_alert(mp,fmt,args...) cmn_err(CE_ALERT,fmt, ## args) | |
678 | #define xfs_hex_dump(d,n) ((void) 0) | |
679 | ||
680 | /* CRC wrappers */ | |
681 | ||
682 | extern uint32_t crc32_le(uint32_t crc, unsigned char const *p, size_t len); | |
683 | extern uint32_t crc32c_le(uint32_t crc, unsigned char const *p, size_t len); | |
684 | ||
685 | #define crc32(c,p,l) crc32_le((c),(unsigned char const *)(p),(l)) | |
686 | #define crc32c(c,p,l) crc32c_le((c),(unsigned char const *)(p),(l)) | |
687 | ||
688 | #include <xfs/xfs_cksum.h> | |
689 | ||
690 | static inline int | |
691 | xfs_buf_verify_cksum(struct xfs_buf *bp, unsigned long cksum_offset) | |
692 | { | |
693 | return xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length), | |
694 | cksum_offset); | |
695 | } | |
696 | ||
697 | static inline void | |
698 | xfs_buf_update_cksum(struct xfs_buf *bp, unsigned long cksum_offset) | |
699 | { | |
700 | xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), | |
701 | cksum_offset); | |
702 | } | |
703 | ||
5e656dbb BN |
704 | /* |
705 | * public xfs kernel routines to be called as libxfs_* | |
f616e2bf DC |
706 | * |
707 | * These are all present in the xfs_* namespace but we don't want that namespace | |
708 | * to be used or even exposed, and hence we declare them here explicitly if we | |
709 | * aren't directly building the libxfs code itself. | |
710 | * | |
711 | * XXX: This needs to be more formalised in the shared header files so that | |
712 | * these declarations can go away, and so there's documentation in the kernel | |
713 | * code base that certain functions are shared with userspace. | |
5e656dbb | 714 | */ |
f616e2bf DC |
715 | #ifndef __LIBXFS_INTERNAL_XFS_H |
716 | ||
717 | /* xfs_sb.h */ | |
718 | void libxfs_mod_sb(struct xfs_trans *, __int64_t); | |
719 | void libxfs_sb_from_disk(struct xfs_sb *, struct xfs_dsb *); | |
720 | void libxfs_sb_to_disk(struct xfs_dsb *, struct xfs_sb *, __int64_t); | |
721 | void libxfs_sb_quota_from_disk(struct xfs_sb *sbp); | |
722 | ||
723 | /* xfs_bmap.h */ | |
724 | int libxfs_bmapi_write(struct xfs_trans *tp, struct xfs_inode *ip, | |
725 | xfs_fileoff_t bno, xfs_filblks_t len, int flags, | |
726 | xfs_fsblock_t *firstblock, xfs_extlen_t total, | |
727 | struct xfs_bmbt_irec *mval, int *nmap, | |
728 | struct xfs_bmap_free *flist); | |
729 | int libxfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip, | |
730 | xfs_fileoff_t bno, xfs_filblks_t len, int flags, | |
731 | xfs_extnum_t nexts, xfs_fsblock_t *firstblock, | |
732 | struct xfs_bmap_free *flist, int *done); | |
733 | void libxfs_bmap_cancel(struct xfs_bmap_free *flist); | |
ff105f75 | 734 | int libxfs_bmap_last_offset(struct xfs_inode *ip, |
f616e2bf DC |
735 | xfs_fileoff_t *unused, int whichfork); |
736 | ||
737 | /* xfs_dir2.h */ | |
738 | int libxfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp, | |
739 | struct xfs_inode *pdp); | |
740 | int libxfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp, | |
741 | struct xfs_name *name, xfs_ino_t inum, | |
742 | xfs_fsblock_t *first, | |
743 | struct xfs_bmap_free *flist, xfs_extlen_t tot); | |
744 | int libxfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp, | |
745 | struct xfs_name *name, xfs_ino_t *inum, | |
746 | struct xfs_name *ci_name); | |
747 | int libxfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp, | |
748 | struct xfs_name *name, xfs_ino_t inum, | |
749 | xfs_fsblock_t *first, | |
750 | struct xfs_bmap_free *flist, xfs_extlen_t tot); | |
751 | ||
ff105f75 DC |
752 | int libxfs_dir2_isblock(struct xfs_da_args *args, int *r); |
753 | int libxfs_dir2_isleaf(struct xfs_da_args *args, int *r); | |
f616e2bf DC |
754 | int libxfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db, |
755 | struct xfs_buf *bp); | |
ff105f75 DC |
756 | |
757 | void libxfs_dir2_data_freescan(struct xfs_da_geometry *geo, | |
758 | const struct xfs_dir_ops *ops, | |
f616e2bf | 759 | struct xfs_dir2_data_hdr *hdr, int *loghead); |
ff105f75 DC |
760 | void libxfs_dir2_data_log_entry(struct xfs_da_args *args, |
761 | struct xfs_buf *bp, struct xfs_dir2_data_entry *dep); | |
762 | void libxfs_dir2_data_log_header(struct xfs_da_args *args, | |
f616e2bf | 763 | struct xfs_buf *bp); |
ff105f75 DC |
764 | void libxfs_dir2_data_log_unused(struct xfs_da_args *args, |
765 | struct xfs_buf *bp, struct xfs_dir2_data_unused *dup); | |
766 | void libxfs_dir2_data_make_free(struct xfs_da_args *args, | |
767 | struct xfs_buf *bp, xfs_dir2_data_aoff_t offset, | |
768 | xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp); | |
769 | void libxfs_dir2_data_use_free(struct xfs_da_args *args, | |
770 | struct xfs_buf *bp, struct xfs_dir2_data_unused *dup, | |
f616e2bf DC |
771 | xfs_dir2_data_aoff_t offset, xfs_dir2_data_aoff_t len, |
772 | int *needlogp, int *needscanp); | |
f616e2bf DC |
773 | |
774 | /* xfs_da_btree.h */ | |
775 | uint libxfs_da_hashname(const __uint8_t *name_string, int name_length); | |
776 | int libxfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno, | |
777 | struct xfs_buf *dead_buf); | |
778 | int libxfs_da_read_buf(struct xfs_trans *trans, struct xfs_inode *dp, | |
779 | xfs_dablk_t bno, xfs_daddr_t mappedbno, | |
780 | struct xfs_buf **bpp, int whichfork, | |
781 | const struct xfs_buf_ops *ops); | |
782 | ||
783 | ||
784 | /* xfs_inode_buf.h */ | |
785 | void libxfs_dinode_calc_crc(struct xfs_mount *, struct xfs_dinode *); | |
786 | ||
787 | /* xfs_inode_fork.h */ | |
788 | void libxfs_idata_realloc(struct xfs_inode *, int, int); | |
789 | ||
ff105f75 | 790 | /* xfs_symlink_remote.h */ |
f616e2bf | 791 | int libxfs_symlink_blocks(struct xfs_mount *mp, int pathlen); |
ff105f75 | 792 | bool libxfs_symlink_hdr_ok(xfs_ino_t ino, uint32_t offset, uint32_t size, |
f616e2bf DC |
793 | struct xfs_buf *bp); |
794 | ||
795 | /* xfs_bit.h */ | |
796 | /* XXX: these are special as they are static inline functions in the header */ | |
797 | #define libxfs_highbit32 xfs_highbit32 | |
798 | #define libxfs_highbit64 xfs_highbit64 | |
5e656dbb BN |
799 | |
800 | /* xfs_alloc.c */ | |
801 | int libxfs_alloc_fix_freelist(xfs_alloc_arg_t *, int); | |
802 | ||
803 | /* xfs_attr.c */ | |
56b2de80 DC |
804 | int libxfs_attr_get(struct xfs_inode *, const unsigned char *, |
805 | unsigned char *, int *, int); | |
806 | int libxfs_attr_set(struct xfs_inode *, const unsigned char *, | |
807 | unsigned char *, int, int); | |
808 | int libxfs_attr_remove(struct xfs_inode *, const unsigned char *, int); | |
5e656dbb BN |
809 | |
810 | /* xfs_bmap.c */ | |
811 | xfs_bmbt_rec_host_t *xfs_bmap_search_extents(xfs_inode_t *, xfs_fileoff_t, | |
812 | int, int *, xfs_extnum_t *, xfs_bmbt_irec_t *, | |
49f693fa | 813 | xfs_bmbt_irec_t *); |
ff105f75 DC |
814 | void libxfs_bmbt_get_all(struct xfs_bmbt_rec_host *r, struct xfs_bmbt_irec *s); |
815 | ||
816 | static inline void | |
817 | libxfs_bmbt_disk_get_all( | |
818 | struct xfs_bmbt_rec *rp, | |
819 | struct xfs_bmbt_irec *irec) | |
820 | { | |
821 | struct xfs_bmbt_rec_host hrec; | |
822 | ||
823 | hrec.l0 = be64_to_cpu(rp->l0); | |
824 | hrec.l1 = be64_to_cpu(rp->l1); | |
825 | libxfs_bmbt_get_all(&hrec, irec); | |
826 | } | |
5e656dbb | 827 | |
f616e2bf | 828 | void libxfs_dinode_from_disk(struct xfs_icdinode *, |
a2ceac1f | 829 | struct xfs_dinode *); |
f616e2bf | 830 | bool libxfs_dinode_verify(struct xfs_mount *mp, xfs_ino_t ino, |
a73b88f2 DC |
831 | struct xfs_dinode *dip); |
832 | ||
f616e2bf DC |
833 | /* this file */ |
834 | /* XXX: this needs cleanup like the xfs_bit.h stuff */ | |
835 | #define libxfs_verify_cksum xfs_verify_cksum | |
836 | #define libxfs_buf_verify_cksum xfs_buf_verify_cksum | |
837 | #define libxfs_buf_update_cksum xfs_buf_update_cksum | |
e0607266 | 838 | |
f616e2bf | 839 | #endif /* __LIBXFS_INTERNAL_XFS_H */ |
364e85ec | 840 | |
f616e2bf | 841 | /* XXX: this is clearly a bug - a shared header needs to export this */ |
5e656dbb BN |
842 | /* xfs_rtalloc.c */ |
843 | int libxfs_rtfree_extent(struct xfs_trans *, xfs_rtblock_t, xfs_extlen_t); | |
844 | ||
2bd0ea18 | 845 | #endif /* __LIBXFS_H__ */ |