blob: 004fe4b28d495d6c74a1273db0d7ec601180965d [file] [log] [blame]
Dave Chinner68988112013-08-12 20:49:42 +10001/*
2 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
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.
8 *
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.
13 *
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
17 */
18#ifndef __XFS_BMAP_UTIL_H__
19#define __XFS_BMAP_UTIL_H__
20
21/* Kernel only BMAP related definitions and functions */
22
23struct xfs_bmbt_irec;
24struct xfs_ifork;
25struct xfs_inode;
26struct xfs_mount;
27struct xfs_trans;
28
29/*
30 * Argument structure for xfs_bmap_alloc.
31 */
32struct xfs_bmalloca {
33 xfs_fsblock_t *firstblock; /* i/o first block allocated */
34 struct xfs_bmap_free *flist; /* bmap freelist */
35 struct xfs_trans *tp; /* transaction pointer */
36 struct xfs_inode *ip; /* incore inode pointer */
37 struct xfs_bmbt_irec prev; /* extent before the new one */
38 struct xfs_bmbt_irec got; /* extent after, or delayed */
39
40 xfs_fileoff_t offset; /* offset in file filling in */
41 xfs_extlen_t length; /* i/o length asked/allocated */
42 xfs_fsblock_t blkno; /* starting block of new extent */
43
44 struct xfs_btree_cur *cur; /* btree cursor */
45 xfs_extnum_t idx; /* current extent index */
46 int nallocs;/* number of extents alloc'd */
47 int logflags;/* flags for transaction logging */
48
49 xfs_extlen_t total; /* total blocks needed for xaction */
50 xfs_extlen_t minlen; /* minimum allocation size (blocks) */
51 xfs_extlen_t minleft; /* amount must be left after alloc */
52 char eof; /* set if allocating past last extent */
53 char wasdel; /* replacing a delayed allocation */
54 char userdata;/* set if is user data */
55 char aeof; /* allocated space at eof */
56 char conv; /* overwriting unwritten extents */
57 char stack_switch;
58 int flags;
59 struct completion *done;
60 struct work_struct work;
61 int result;
62};
63
64int xfs_bmap_finish(struct xfs_trans **tp, struct xfs_bmap_free *flist,
65 int *committed);
66int xfs_bmap_rtalloc(struct xfs_bmalloca *ap);
67int xfs_bmapi_allocate(struct xfs_bmalloca *args);
68int __xfs_bmapi_allocate(struct xfs_bmalloca *args);
69int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff,
70 int whichfork, int *eof);
71int xfs_bmap_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip,
72 int whichfork, int *count);
73int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip,
74 xfs_fileoff_t start_fsb, xfs_fileoff_t length);
75
76/* bmap to userspace formatter - copy to user & advance pointer */
77typedef int (*xfs_bmap_format_t)(void **, struct getbmapx *, int *);
78int xfs_getbmap(struct xfs_inode *ip, struct getbmapx *bmv,
79 xfs_bmap_format_t formatter, void *arg);
80
81/* functions in xfs_bmap.c that are only needed by xfs_bmap_util.c */
82void xfs_bmap_del_free(struct xfs_bmap_free *flist,
83 struct xfs_bmap_free_item *prev,
84 struct xfs_bmap_free_item *free);
85int xfs_bmap_extsize_align(struct xfs_mount *mp, struct xfs_bmbt_irec *gotp,
86 struct xfs_bmbt_irec *prevp, xfs_extlen_t extsz,
87 int rt, int eof, int delay, int convert,
88 xfs_fileoff_t *offp, xfs_extlen_t *lenp);
89void xfs_bmap_adjacent(struct xfs_bmalloca *ap);
90int xfs_bmap_last_extent(struct xfs_trans *tp, struct xfs_inode *ip,
91 int whichfork, struct xfs_bmbt_irec *rec,
92 int *is_empty);
93
94xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb);
95
96#endif /* __XFS_BMAP_UTIL_H__ */