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