blob: f1005393785c07107ab2b6bf94334ff5e6bbca16 [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;
Darrick J. Wong310a75a2016-08-03 11:18:10 +100024struct xfs_extent_free_item;
Dave Chinner68988112013-08-12 20:49:42 +100025struct xfs_ifork;
26struct xfs_inode;
27struct xfs_mount;
28struct xfs_trans;
Dave Chinner9799b432015-01-09 10:46:49 +110029struct xfs_bmalloca;
Dave Chinner68988112013-08-12 20:49:42 +100030
Dave Chinner68988112013-08-12 20:49:42 +100031int xfs_bmap_rtalloc(struct xfs_bmalloca *ap);
Dave Chinner68988112013-08-12 20:49:42 +100032int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff,
33 int whichfork, int *eof);
Dave Chinner68988112013-08-12 20:49:42 +100034int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip,
35 xfs_fileoff_t start_fsb, xfs_fileoff_t length);
36
37/* bmap to userspace formatter - copy to user & advance pointer */
38typedef int (*xfs_bmap_format_t)(void **, struct getbmapx *, int *);
39int xfs_getbmap(struct xfs_inode *ip, struct getbmapx *bmv,
40 xfs_bmap_format_t formatter, void *arg);
41
42/* functions in xfs_bmap.c that are only needed by xfs_bmap_util.c */
Dave Chinner68988112013-08-12 20:49:42 +100043int xfs_bmap_extsize_align(struct xfs_mount *mp, struct xfs_bmbt_irec *gotp,
44 struct xfs_bmbt_irec *prevp, xfs_extlen_t extsz,
45 int rt, int eof, int delay, int convert,
46 xfs_fileoff_t *offp, xfs_extlen_t *lenp);
47void xfs_bmap_adjacent(struct xfs_bmalloca *ap);
48int xfs_bmap_last_extent(struct xfs_trans *tp, struct xfs_inode *ip,
49 int whichfork, struct xfs_bmbt_irec *rec,
50 int *is_empty);
51
Dave Chinnerc24b5df2013-08-12 20:49:45 +100052/* preallocation and hole punch interface */
Christoph Hellwig83aee9e2013-10-12 00:55:07 -070053int xfs_alloc_file_space(struct xfs_inode *ip, xfs_off_t offset,
54 xfs_off_t len, int alloc_type);
55int xfs_free_file_space(struct xfs_inode *ip, xfs_off_t offset,
56 xfs_off_t len);
Christoph Hellwig865e9442013-10-12 00:55:08 -070057int xfs_zero_file_space(struct xfs_inode *ip, xfs_off_t offset,
58 xfs_off_t len);
Namjae Jeone1d8fb82014-02-24 10:58:19 +110059int xfs_collapse_file_space(struct xfs_inode *, xfs_off_t offset,
60 xfs_off_t len);
Namjae Jeona904b1c2015-03-25 15:08:56 +110061int xfs_insert_file_space(struct xfs_inode *, xfs_off_t offset,
62 xfs_off_t len);
Dave Chinnerc24b5df2013-08-12 20:49:45 +100063
64/* EOF block manipulation functions */
65bool xfs_can_free_eofblocks(struct xfs_inode *ip, bool force);
Brian Foster798b1dc2017-01-27 23:22:55 -080066int xfs_free_eofblocks(struct xfs_inode *ip);
Dave Chinnerc24b5df2013-08-12 20:49:45 +100067
Dave Chinnera133d952013-08-12 20:49:48 +100068int xfs_swap_extents(struct xfs_inode *ip, struct xfs_inode *tip,
69 struct xfs_swapext *sx);
70
Dave Chinner68988112013-08-12 20:49:42 +100071xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb);
72
73#endif /* __XFS_BMAP_UTIL_H__ */