^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) 2016 Oracle. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Author: Darrick J. Wong <darrick.wong@oracle.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef __XFS_REFLINK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define __XFS_REFLINK_H 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) static inline bool xfs_is_always_cow_inode(struct xfs_inode *ip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) return ip->i_mount->m_always_cow &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) xfs_sb_version_hasreflink(&ip->i_mount->m_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) static inline bool xfs_is_cow_inode(struct xfs_inode *ip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) return xfs_is_reflink_inode(ip) || xfs_is_always_cow_inode(ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) extern int xfs_reflink_find_shared(struct xfs_mount *mp, struct xfs_trans *tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) xfs_agnumber_t agno, xfs_agblock_t agbno, xfs_extlen_t aglen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) xfs_agblock_t *fbno, xfs_extlen_t *flen, bool find_maximal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct xfs_bmbt_irec *irec, bool *shared);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) int xfs_bmap_trim_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) bool *shared);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) int xfs_reflink_allocate_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct xfs_bmbt_irec *cmap, bool *shared, uint *lockmode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) bool convert_now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) extern int xfs_reflink_convert_cow(struct xfs_inode *ip, xfs_off_t offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) xfs_off_t count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) extern int xfs_reflink_cancel_cow_blocks(struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct xfs_trans **tpp, xfs_fileoff_t offset_fsb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) xfs_fileoff_t end_fsb, bool cancel_real);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) extern int xfs_reflink_cancel_cow_range(struct xfs_inode *ip, xfs_off_t offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) xfs_off_t count, bool cancel_real);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) extern int xfs_reflink_end_cow(struct xfs_inode *ip, xfs_off_t offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) xfs_off_t count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) extern int xfs_reflink_recover_cow(struct xfs_mount *mp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) extern loff_t xfs_reflink_remap_range(struct file *file_in, loff_t pos_in,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct file *file_out, loff_t pos_out, loff_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) unsigned int remap_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) extern int xfs_reflink_inode_has_shared_extents(struct xfs_trans *tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct xfs_inode *ip, bool *has_shared);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) extern int xfs_reflink_clear_inode_flag(struct xfs_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct xfs_trans **tpp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) extern int xfs_reflink_unshare(struct xfs_inode *ip, xfs_off_t offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) xfs_off_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) extern int xfs_reflink_remap_prep(struct file *file_in, loff_t pos_in,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct file *file_out, loff_t pos_out, loff_t *len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) unsigned int remap_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) extern int xfs_reflink_remap_blocks(struct xfs_inode *src, loff_t pos_in,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct xfs_inode *dest, loff_t pos_out, loff_t remap_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) loff_t *remapped);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) extern int xfs_reflink_update_dest(struct xfs_inode *dest, xfs_off_t newlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) xfs_extlen_t cowextsize, unsigned int remap_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #endif /* __XFS_REFLINK_H */