diff options
author | Dave Chinner <dchinner@redhat.com> | 2013-08-12 06:49:42 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-08-12 17:45:17 -0400 |
commit | 6898811459ff523ed256c07d1d5c54ba915d51ac (patch) | |
tree | 3079fecb7b8420aef10673d4d6b08d69645feacc /fs/xfs/xfs_bmap_util.h | |
parent | ff55068c2010f39bcd899ca14b0a3d401d14da54 (diff) |
xfs: create xfs_bmap_util.[ch]
There is a bunch of code in xfs_bmap.c that is kernel specific and
not shared with userspace. To minimise the difference between the
kernel and userspace code, shift this unshared code to
xfs_bmap_util.c, and the declarations to xfs_bmap_util.h.
The biggest issue here is xfs_bmap_finish() - userspace has it's own
definition of this function, and so we need to move it out of
xfs_bmap.[ch]. This means several other files need to include
xfs_bmap_util.h as well.
It also introduces and interesting dance for the stack switching
code in xfs_bmapi_allocate(). The stack switching/workqueue code is
actually moved to xfs_bmap_util.c, so that userspace can simply use
a #define in a header file to connect the dots without needing to
know about the stack switch code at all.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_bmap_util.h')
-rw-r--r-- | fs/xfs/xfs_bmap_util.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/fs/xfs/xfs_bmap_util.h b/fs/xfs/xfs_bmap_util.h new file mode 100644 index 000000000000..004fe4b28d49 --- /dev/null +++ b/fs/xfs/xfs_bmap_util.h | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
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 | |||
23 | struct xfs_bmbt_irec; | ||
24 | struct xfs_ifork; | ||
25 | struct xfs_inode; | ||
26 | struct xfs_mount; | ||
27 | struct xfs_trans; | ||
28 | |||
29 | /* | ||
30 | * Argument structure for xfs_bmap_alloc. | ||
31 | */ | ||
32 | struct 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 | |||
64 | int xfs_bmap_finish(struct xfs_trans **tp, struct xfs_bmap_free *flist, | ||
65 | int *committed); | ||
66 | int xfs_bmap_rtalloc(struct xfs_bmalloca *ap); | ||
67 | int xfs_bmapi_allocate(struct xfs_bmalloca *args); | ||
68 | int __xfs_bmapi_allocate(struct xfs_bmalloca *args); | ||
69 | int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff, | ||
70 | int whichfork, int *eof); | ||
71 | int xfs_bmap_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip, | ||
72 | int whichfork, int *count); | ||
73 | int 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 */ | ||
77 | typedef int (*xfs_bmap_format_t)(void **, struct getbmapx *, int *); | ||
78 | int 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 */ | ||
82 | void xfs_bmap_del_free(struct xfs_bmap_free *flist, | ||
83 | struct xfs_bmap_free_item *prev, | ||
84 | struct xfs_bmap_free_item *free); | ||
85 | int 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); | ||
89 | void xfs_bmap_adjacent(struct xfs_bmalloca *ap); | ||
90 | int 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 | |||
94 | xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb); | ||
95 | |||
96 | #endif /* __XFS_BMAP_UTIL_H__ */ | ||