Dave Chinner | 0b61f8a | 2018-06-05 19:42:14 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2000-2006 Silicon Graphics, Inc. |
| 4 | * All Rights Reserved. |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __XFS_BMAP_UTIL_H__ |
| 7 | #define __XFS_BMAP_UTIL_H__ |
| 8 | |
| 9 | /* Kernel only BMAP related definitions and functions */ |
| 10 | |
| 11 | struct xfs_bmbt_irec; |
Darrick J. Wong | 310a75a | 2016-08-03 11:18:10 +1000 | [diff] [blame] | 12 | struct xfs_extent_free_item; |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 13 | struct xfs_ifork; |
| 14 | struct xfs_inode; |
| 15 | struct xfs_mount; |
| 16 | struct xfs_trans; |
Dave Chinner | 9799b43 | 2015-01-09 10:46:49 +1100 | [diff] [blame] | 17 | struct xfs_bmalloca; |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 18 | |
Dave Chinner | bb9c2e5 | 2017-10-09 11:37:22 -0700 | [diff] [blame] | 19 | #ifdef CONFIG_XFS_RT |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 20 | int xfs_bmap_rtalloc(struct xfs_bmalloca *ap); |
Dave Chinner | bb9c2e5 | 2017-10-09 11:37:22 -0700 | [diff] [blame] | 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 | */ |
| 26 | static inline int |
| 27 | xfs_bmap_rtalloc(struct xfs_bmalloca *ap) |
| 28 | { |
| 29 | return -EFSCORRUPTED; |
| 30 | } |
| 31 | #endif /* CONFIG_XFS_RT */ |
| 32 | |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 33 | int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip, |
| 34 | xfs_fileoff_t start_fsb, xfs_fileoff_t length); |
| 35 | |
Christoph Hellwig | 232b5194 | 2017-10-17 14:16:19 -0700 | [diff] [blame] | 36 | struct 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 Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 42 | int xfs_getbmap(struct xfs_inode *ip, struct getbmapx *bmv, |
Christoph Hellwig | 232b5194 | 2017-10-17 14:16:19 -0700 | [diff] [blame] | 43 | struct kgetbmap *out); |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 44 | |
| 45 | /* functions in xfs_bmap.c that are only needed by xfs_bmap_util.c */ |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 46 | int 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); |
| 50 | void xfs_bmap_adjacent(struct xfs_bmalloca *ap); |
| 51 | int 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 Chinner | c24b5df | 2013-08-12 20:49:45 +1000 | [diff] [blame] | 55 | /* preallocation and hole punch interface */ |
Christoph Hellwig | 83aee9e | 2013-10-12 00:55:07 -0700 | [diff] [blame] | 56 | int xfs_alloc_file_space(struct xfs_inode *ip, xfs_off_t offset, |
| 57 | xfs_off_t len, int alloc_type); |
| 58 | int xfs_free_file_space(struct xfs_inode *ip, xfs_off_t offset, |
| 59 | xfs_off_t len); |
Namjae Jeon | e1d8fb8 | 2014-02-24 10:58:19 +1100 | [diff] [blame] | 60 | int xfs_collapse_file_space(struct xfs_inode *, xfs_off_t offset, |
| 61 | xfs_off_t len); |
Namjae Jeon | a904b1c | 2015-03-25 15:08:56 +1100 | [diff] [blame] | 62 | int xfs_insert_file_space(struct xfs_inode *, xfs_off_t offset, |
| 63 | xfs_off_t len); |
Dave Chinner | c24b5df | 2013-08-12 20:49:45 +1000 | [diff] [blame] | 64 | |
| 65 | /* EOF block manipulation functions */ |
| 66 | bool xfs_can_free_eofblocks(struct xfs_inode *ip, bool force); |
Brian Foster | a36b926 | 2017-01-27 23:22:55 -0800 | [diff] [blame] | 67 | int xfs_free_eofblocks(struct xfs_inode *ip); |
Dave Chinner | c24b5df | 2013-08-12 20:49:45 +1000 | [diff] [blame] | 68 | |
Dave Chinner | a133d95 | 2013-08-12 20:49:48 +1000 | [diff] [blame] | 69 | int xfs_swap_extents(struct xfs_inode *ip, struct xfs_inode *tip, |
| 70 | struct xfs_swapext *sx); |
| 71 | |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 72 | xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb); |
| 73 | |
Christoph Hellwig | e17a5c6 | 2017-08-29 15:44:14 -0700 | [diff] [blame] | 74 | xfs_extnum_t xfs_bmap_count_leaves(struct xfs_ifork *ifp, xfs_filblks_t *count); |
Darrick J. Wong | e7f5d5c | 2017-06-16 11:00:12 -0700 | [diff] [blame] | 75 | int 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 Chinner | 2c30717 | 2018-11-19 13:31:10 -0800 | [diff] [blame] | 79 | int xfs_flush_unmap_range(struct xfs_inode *ip, xfs_off_t offset, |
| 80 | xfs_off_t len); |
| 81 | |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 82 | #endif /* __XFS_BMAP_UTIL_H__ */ |