Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 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; |
Darrick J. Wong | 310a75a | 2016-08-03 11:18:10 +1000 | [diff] [blame] | 24 | struct xfs_extent_free_item; |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 25 | struct xfs_ifork; |
| 26 | struct xfs_inode; |
| 27 | struct xfs_mount; |
| 28 | struct xfs_trans; |
Dave Chinner | 9799b43 | 2015-01-09 10:46:49 +1100 | [diff] [blame] | 29 | struct xfs_bmalloca; |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 30 | |
Dave Chinner | 3a5a338 | 2017-10-09 11:37:22 -0700 | [diff] [blame] | 31 | #ifdef CONFIG_XFS_RT |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 32 | int xfs_bmap_rtalloc(struct xfs_bmalloca *ap); |
Dave Chinner | 3a5a338 | 2017-10-09 11:37:22 -0700 | [diff] [blame] | 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 | */ |
| 38 | static inline int |
| 39 | xfs_bmap_rtalloc(struct xfs_bmalloca *ap) |
| 40 | { |
| 41 | return -EFSCORRUPTED; |
| 42 | } |
| 43 | #endif /* CONFIG_XFS_RT */ |
| 44 | |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 45 | int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff, |
| 46 | int whichfork, int *eof); |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 47 | int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip, |
| 48 | xfs_fileoff_t start_fsb, xfs_fileoff_t length); |
| 49 | |
| 50 | /* bmap to userspace formatter - copy to user & advance pointer */ |
| 51 | typedef int (*xfs_bmap_format_t)(void **, struct getbmapx *, int *); |
| 52 | int xfs_getbmap(struct xfs_inode *ip, struct getbmapx *bmv, |
| 53 | xfs_bmap_format_t formatter, void *arg); |
| 54 | |
| 55 | /* 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] | 56 | int xfs_bmap_extsize_align(struct xfs_mount *mp, struct xfs_bmbt_irec *gotp, |
| 57 | struct xfs_bmbt_irec *prevp, xfs_extlen_t extsz, |
| 58 | int rt, int eof, int delay, int convert, |
| 59 | xfs_fileoff_t *offp, xfs_extlen_t *lenp); |
| 60 | void xfs_bmap_adjacent(struct xfs_bmalloca *ap); |
| 61 | int xfs_bmap_last_extent(struct xfs_trans *tp, struct xfs_inode *ip, |
| 62 | int whichfork, struct xfs_bmbt_irec *rec, |
| 63 | int *is_empty); |
| 64 | |
Dave Chinner | c24b5df | 2013-08-12 20:49:45 +1000 | [diff] [blame] | 65 | /* preallocation and hole punch interface */ |
Christoph Hellwig | 83aee9e | 2013-10-12 00:55:07 -0700 | [diff] [blame] | 66 | int xfs_alloc_file_space(struct xfs_inode *ip, xfs_off_t offset, |
| 67 | xfs_off_t len, int alloc_type); |
| 68 | int xfs_free_file_space(struct xfs_inode *ip, xfs_off_t offset, |
| 69 | xfs_off_t len); |
Christoph Hellwig | 865e944 | 2013-10-12 00:55:08 -0700 | [diff] [blame] | 70 | int xfs_zero_file_space(struct xfs_inode *ip, xfs_off_t offset, |
| 71 | xfs_off_t len); |
Namjae Jeon | e1d8fb8 | 2014-02-24 10:58:19 +1100 | [diff] [blame] | 72 | int xfs_collapse_file_space(struct xfs_inode *, xfs_off_t offset, |
| 73 | xfs_off_t len); |
Namjae Jeon | a904b1c | 2015-03-25 15:08:56 +1100 | [diff] [blame] | 74 | int xfs_insert_file_space(struct xfs_inode *, xfs_off_t offset, |
| 75 | xfs_off_t len); |
Dave Chinner | c24b5df | 2013-08-12 20:49:45 +1000 | [diff] [blame] | 76 | |
| 77 | /* EOF block manipulation functions */ |
| 78 | bool xfs_can_free_eofblocks(struct xfs_inode *ip, bool force); |
Brian Foster | 798b1dc | 2017-01-27 23:22:55 -0800 | [diff] [blame] | 79 | int xfs_free_eofblocks(struct xfs_inode *ip); |
Dave Chinner | c24b5df | 2013-08-12 20:49:45 +1000 | [diff] [blame] | 80 | |
Dave Chinner | a133d95 | 2013-08-12 20:49:48 +1000 | [diff] [blame] | 81 | int xfs_swap_extents(struct xfs_inode *ip, struct xfs_inode *tip, |
| 82 | struct xfs_swapext *sx); |
| 83 | |
Dave Chinner | 6898811 | 2013-08-12 20:49:42 +1000 | [diff] [blame] | 84 | xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb); |
| 85 | |
| 86 | #endif /* __XFS_BMAP_UTIL_H__ */ |