Linux 3.16-rc2
[linux/fpc-iii.git] / fs / xfs / xfs_bmap_util.h
blob075f72232a64a92de08665d348dd09a7ad6bd1d4
1 /*
2 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
3 * All Rights Reserved.
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
7 * published by the Free Software Foundation.
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.
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
18 #ifndef __XFS_BMAP_UTIL_H__
19 #define __XFS_BMAP_UTIL_H__
21 /* Kernel only BMAP related definitions and functions */
23 struct xfs_bmbt_irec;
24 struct xfs_bmap_free_item;
25 struct xfs_ifork;
26 struct xfs_inode;
27 struct xfs_mount;
28 struct xfs_trans;
31 * Argument structure for xfs_bmap_alloc.
33 struct xfs_bmalloca {
34 xfs_fsblock_t *firstblock; /* i/o first block allocated */
35 struct xfs_bmap_free *flist; /* bmap freelist */
36 struct xfs_trans *tp; /* transaction pointer */
37 struct xfs_inode *ip; /* incore inode pointer */
38 struct xfs_bmbt_irec prev; /* extent before the new one */
39 struct xfs_bmbt_irec got; /* extent after, or delayed */
41 xfs_fileoff_t offset; /* offset in file filling in */
42 xfs_extlen_t length; /* i/o length asked/allocated */
43 xfs_fsblock_t blkno; /* starting block of new extent */
45 struct xfs_btree_cur *cur; /* btree cursor */
46 xfs_extnum_t idx; /* current extent index */
47 int nallocs;/* number of extents alloc'd */
48 int logflags;/* flags for transaction logging */
50 xfs_extlen_t total; /* total blocks needed for xaction */
51 xfs_extlen_t minlen; /* minimum allocation size (blocks) */
52 xfs_extlen_t minleft; /* amount must be left after alloc */
53 bool eof; /* set if allocating past last extent */
54 bool wasdel; /* replacing a delayed allocation */
55 bool userdata;/* set if is user data */
56 bool aeof; /* allocated space at eof */
57 bool conv; /* overwriting unwritten extents */
58 bool stack_switch;
59 bool kswapd; /* allocation in kswapd context */
60 int flags;
61 struct completion *done;
62 struct work_struct work;
63 int result;
66 int xfs_bmap_finish(struct xfs_trans **tp, struct xfs_bmap_free *flist,
67 int *committed);
68 int xfs_bmap_rtalloc(struct xfs_bmalloca *ap);
69 int xfs_bmapi_allocate(struct xfs_bmalloca *args);
70 int __xfs_bmapi_allocate(struct xfs_bmalloca *args);
71 int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff,
72 int whichfork, int *eof);
73 int xfs_bmap_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip,
74 int whichfork, int *count);
75 int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip,
76 xfs_fileoff_t start_fsb, xfs_fileoff_t length);
78 /* bmap to userspace formatter - copy to user & advance pointer */
79 typedef int (*xfs_bmap_format_t)(void **, struct getbmapx *, int *);
80 int xfs_getbmap(struct xfs_inode *ip, struct getbmapx *bmv,
81 xfs_bmap_format_t formatter, void *arg);
83 /* functions in xfs_bmap.c that are only needed by xfs_bmap_util.c */
84 void xfs_bmap_del_free(struct xfs_bmap_free *flist,
85 struct xfs_bmap_free_item *prev,
86 struct xfs_bmap_free_item *free);
87 int xfs_bmap_extsize_align(struct xfs_mount *mp, struct xfs_bmbt_irec *gotp,
88 struct xfs_bmbt_irec *prevp, xfs_extlen_t extsz,
89 int rt, int eof, int delay, int convert,
90 xfs_fileoff_t *offp, xfs_extlen_t *lenp);
91 void xfs_bmap_adjacent(struct xfs_bmalloca *ap);
92 int xfs_bmap_last_extent(struct xfs_trans *tp, struct xfs_inode *ip,
93 int whichfork, struct xfs_bmbt_irec *rec,
94 int *is_empty);
96 /* preallocation and hole punch interface */
97 int xfs_alloc_file_space(struct xfs_inode *ip, xfs_off_t offset,
98 xfs_off_t len, int alloc_type);
99 int xfs_free_file_space(struct xfs_inode *ip, xfs_off_t offset,
100 xfs_off_t len);
101 int xfs_zero_file_space(struct xfs_inode *ip, xfs_off_t offset,
102 xfs_off_t len);
103 int xfs_collapse_file_space(struct xfs_inode *, xfs_off_t offset,
104 xfs_off_t len);
106 /* EOF block manipulation functions */
107 bool xfs_can_free_eofblocks(struct xfs_inode *ip, bool force);
108 int xfs_free_eofblocks(struct xfs_mount *mp, struct xfs_inode *ip,
109 bool need_iolock);
111 int xfs_swap_extents(struct xfs_inode *ip, struct xfs_inode *tip,
112 struct xfs_swapext *sx);
114 xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb);
116 #endif /* __XFS_BMAP_UTIL_H__ */