Loading...
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
23struct xfs_bmbt_irec;
24struct xfs_extent_free_item;
25struct xfs_ifork;
26struct xfs_inode;
27struct xfs_mount;
28struct xfs_trans;
29struct xfs_bmalloca;
30
31#ifdef CONFIG_XFS_RT
32int xfs_bmap_rtalloc(struct xfs_bmalloca *ap);
33#else /* !CONFIG_XFS_RT */
34/*
35 * Attempts to allocate RT extents when RT is disable indicates corruption and
36 * should trigger a shutdown.
37 */
38static inline int
39xfs_bmap_rtalloc(struct xfs_bmalloca *ap)
40{
41 return -EFSCORRUPTED;
42}
43#endif /* CONFIG_XFS_RT */
44
45int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff,
46 int whichfork, int *eof);
47int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip,
48 xfs_fileoff_t start_fsb, xfs_fileoff_t length);
49
50struct kgetbmap {
51 __s64 bmv_offset; /* file offset of segment in blocks */
52 __s64 bmv_block; /* starting block (64-bit daddr_t) */
53 __s64 bmv_length; /* length of segment, blocks */
54 __s32 bmv_oflags; /* output flags */
55};
56int xfs_getbmap(struct xfs_inode *ip, struct getbmapx *bmv,
57 struct kgetbmap *out);
58
59/* functions in xfs_bmap.c that are only needed by xfs_bmap_util.c */
60int xfs_bmap_extsize_align(struct xfs_mount *mp, struct xfs_bmbt_irec *gotp,
61 struct xfs_bmbt_irec *prevp, xfs_extlen_t extsz,
62 int rt, int eof, int delay, int convert,
63 xfs_fileoff_t *offp, xfs_extlen_t *lenp);
64void xfs_bmap_adjacent(struct xfs_bmalloca *ap);
65int xfs_bmap_last_extent(struct xfs_trans *tp, struct xfs_inode *ip,
66 int whichfork, struct xfs_bmbt_irec *rec,
67 int *is_empty);
68
69/* preallocation and hole punch interface */
70int xfs_alloc_file_space(struct xfs_inode *ip, xfs_off_t offset,
71 xfs_off_t len, int alloc_type);
72int xfs_free_file_space(struct xfs_inode *ip, xfs_off_t offset,
73 xfs_off_t len);
74int xfs_zero_file_space(struct xfs_inode *ip, xfs_off_t offset,
75 xfs_off_t len);
76int xfs_collapse_file_space(struct xfs_inode *, xfs_off_t offset,
77 xfs_off_t len);
78int xfs_insert_file_space(struct xfs_inode *, xfs_off_t offset,
79 xfs_off_t len);
80
81/* EOF block manipulation functions */
82bool xfs_can_free_eofblocks(struct xfs_inode *ip, bool force);
83int xfs_free_eofblocks(struct xfs_inode *ip);
84
85int xfs_swap_extents(struct xfs_inode *ip, struct xfs_inode *tip,
86 struct xfs_swapext *sx);
87
88xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb);
89
90xfs_extnum_t xfs_bmap_count_leaves(struct xfs_ifork *ifp, xfs_filblks_t *count);
91int xfs_bmap_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip,
92 int whichfork, xfs_extnum_t *nextents,
93 xfs_filblks_t *count);
94
95#endif /* __XFS_BMAP_UTIL_H__ */
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6#ifndef __XFS_BMAP_UTIL_H__
7#define __XFS_BMAP_UTIL_H__
8
9/* Kernel only BMAP related definitions and functions */
10
11struct xfs_bmbt_irec;
12struct xfs_extent_free_item;
13struct xfs_ifork;
14struct xfs_inode;
15struct xfs_mount;
16struct xfs_trans;
17struct xfs_bmalloca;
18
19#ifdef CONFIG_XFS_RT
20int xfs_bmap_rtalloc(struct xfs_bmalloca *ap);
21#else /* !CONFIG_XFS_RT */
22/*
23 * Attempts to allocate RT extents when RT is disable indicates corruption and
24 * should trigger a shutdown.
25 */
26static inline int
27xfs_bmap_rtalloc(struct xfs_bmalloca *ap)
28{
29 return -EFSCORRUPTED;
30}
31#endif /* CONFIG_XFS_RT */
32
33void xfs_bmap_punch_delalloc_range(struct xfs_inode *ip, int whichfork,
34 xfs_off_t start_byte, xfs_off_t end_byte);
35
36struct kgetbmap {
37 __s64 bmv_offset; /* file offset of segment in blocks */
38 __s64 bmv_block; /* starting block (64-bit daddr_t) */
39 __s64 bmv_length; /* length of segment, blocks */
40 __s32 bmv_oflags; /* output flags */
41};
42int xfs_getbmap(struct xfs_inode *ip, struct getbmapx *bmv,
43 struct kgetbmap *out);
44
45/* functions in xfs_bmap.c that are only needed by xfs_bmap_util.c */
46int xfs_bmap_extsize_align(struct xfs_mount *mp, struct xfs_bmbt_irec *gotp,
47 struct xfs_bmbt_irec *prevp, xfs_extlen_t extsz,
48 int rt, int eof, int delay, int convert,
49 xfs_fileoff_t *offp, xfs_extlen_t *lenp);
50bool xfs_bmap_adjacent(struct xfs_bmalloca *ap);
51int xfs_bmap_last_extent(struct xfs_trans *tp, struct xfs_inode *ip,
52 int whichfork, struct xfs_bmbt_irec *rec,
53 int *is_empty);
54
55/* preallocation and hole punch interface */
56int xfs_alloc_file_space(struct xfs_inode *ip, xfs_off_t offset,
57 xfs_off_t len);
58int xfs_free_file_space(struct xfs_inode *ip, xfs_off_t offset,
59 xfs_off_t len);
60int xfs_collapse_file_space(struct xfs_inode *, xfs_off_t offset,
61 xfs_off_t len);
62int xfs_insert_file_space(struct xfs_inode *, xfs_off_t offset,
63 xfs_off_t len);
64
65/* EOF block manipulation functions */
66bool xfs_can_free_eofblocks(struct xfs_inode *ip);
67int xfs_free_eofblocks(struct xfs_inode *ip);
68
69int xfs_swap_extents(struct xfs_inode *ip, struct xfs_inode *tip,
70 struct xfs_swapext *sx);
71
72xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb);
73
74xfs_extnum_t xfs_bmap_count_leaves(struct xfs_ifork *ifp, xfs_filblks_t *count);
75int xfs_bmap_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip,
76 int whichfork, xfs_extnum_t *nextents,
77 xfs_filblks_t *count);
78
79int xfs_flush_unmap_range(struct xfs_inode *ip, xfs_off_t offset,
80 xfs_off_t len);
81
82#endif /* __XFS_BMAP_UTIL_H__ */