blob: 9f993168b55b8b2b8063e7211e13f4158df55fa0 [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0
Dave Chinner68988112013-08-12 20:49:42 +10002/*
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
4 * All Rights Reserved.
Dave Chinner68988112013-08-12 20:49:42 +10005 */
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;
Darrick J. Wong310a75a2016-08-03 11:18:10 +100012struct xfs_extent_free_item;
Dave Chinner68988112013-08-12 20:49:42 +100013struct xfs_ifork;
14struct xfs_inode;
15struct xfs_mount;
16struct xfs_trans;
Dave Chinner9799b432015-01-09 10:46:49 +110017struct xfs_bmalloca;
Dave Chinner68988112013-08-12 20:49:42 +100018
Dave Chinnerbb9c2e52017-10-09 11:37:22 -070019#ifdef CONFIG_XFS_RT
Dave Chinner68988112013-08-12 20:49:42 +100020int xfs_bmap_rtalloc(struct xfs_bmalloca *ap);
Dave Chinnerbb9c2e52017-10-09 11:37:22 -070021#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
Dave Chinner68988112013-08-12 20:49:42 +100033int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip,
34 xfs_fileoff_t start_fsb, xfs_fileoff_t length);
35
Christoph Hellwig232b51942017-10-17 14:16:19 -070036struct 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};
Dave Chinner68988112013-08-12 20:49:42 +100042int xfs_getbmap(struct xfs_inode *ip, struct getbmapx *bmv,
Christoph Hellwig232b51942017-10-17 14:16:19 -070043 struct kgetbmap *out);
Dave Chinner68988112013-08-12 20:49:42 +100044
45/* functions in xfs_bmap.c that are only needed by xfs_bmap_util.c */
Dave Chinner68988112013-08-12 20:49:42 +100046int 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);
50void 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
Dave Chinnerc24b5df2013-08-12 20:49:45 +100055/* preallocation and hole punch interface */
Christoph Hellwig83aee9e2013-10-12 00:55:07 -070056int xfs_alloc_file_space(struct xfs_inode *ip, xfs_off_t offset,
57 xfs_off_t len, int alloc_type);
58int xfs_free_file_space(struct xfs_inode *ip, xfs_off_t offset,
59 xfs_off_t len);
Namjae Jeone1d8fb82014-02-24 10:58:19 +110060int xfs_collapse_file_space(struct xfs_inode *, xfs_off_t offset,
61 xfs_off_t len);
Namjae Jeona904b1c2015-03-25 15:08:56 +110062int xfs_insert_file_space(struct xfs_inode *, xfs_off_t offset,
63 xfs_off_t len);
Dave Chinnerc24b5df2013-08-12 20:49:45 +100064
65/* EOF block manipulation functions */
66bool xfs_can_free_eofblocks(struct xfs_inode *ip, bool force);
Brian Fostera36b9262017-01-27 23:22:55 -080067int xfs_free_eofblocks(struct xfs_inode *ip);
Dave Chinnerc24b5df2013-08-12 20:49:45 +100068
Dave Chinnera133d952013-08-12 20:49:48 +100069int xfs_swap_extents(struct xfs_inode *ip, struct xfs_inode *tip,
70 struct xfs_swapext *sx);
71
Dave Chinner68988112013-08-12 20:49:42 +100072xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb);
73
Christoph Hellwige17a5c62017-08-29 15:44:14 -070074xfs_extnum_t xfs_bmap_count_leaves(struct xfs_ifork *ifp, xfs_filblks_t *count);
Darrick J. Wonge7f5d5c2017-06-16 11:00:12 -070075int 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
Dave Chinner2c307172018-11-19 13:31:10 -080079int xfs_flush_unmap_range(struct xfs_inode *ip, xfs_off_t offset,
80 xfs_off_t len);
81
Dave Chinner68988112013-08-12 20:49:42 +100082#endif /* __XFS_BMAP_UTIL_H__ */