Dave Chinner | 0b61f8a | 2018-06-05 19:42:14 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Darrick J. Wong | 3993bae | 2016-10-03 09:11:32 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016 Oracle. All Rights Reserved. |
Darrick J. Wong | 3993bae | 2016-10-03 09:11:32 -0700 | [diff] [blame] | 4 | * Author: Darrick J. Wong <darrick.wong@oracle.com> |
Darrick J. Wong | 3993bae | 2016-10-03 09:11:32 -0700 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __XFS_REFLINK_H |
| 7 | #define __XFS_REFLINK_H 1 |
| 8 | |
Christoph Hellwig | 66ae56a | 2019-02-18 09:38:49 -0800 | [diff] [blame] | 9 | static inline bool xfs_is_always_cow_inode(struct xfs_inode *ip) |
| 10 | { |
| 11 | return ip->i_mount->m_always_cow && |
| 12 | xfs_sb_version_hasreflink(&ip->i_mount->m_sb); |
| 13 | } |
| 14 | |
| 15 | static inline bool xfs_is_cow_inode(struct xfs_inode *ip) |
| 16 | { |
| 17 | return xfs_is_reflink_inode(ip) || xfs_is_always_cow_inode(ip); |
| 18 | } |
| 19 | |
Darrick J. Wong | 92ff728 | 2017-06-16 11:00:10 -0700 | [diff] [blame] | 20 | extern int xfs_reflink_find_shared(struct xfs_mount *mp, struct xfs_trans *tp, |
| 21 | xfs_agnumber_t agno, xfs_agblock_t agbno, xfs_extlen_t aglen, |
| 22 | xfs_agblock_t *fbno, xfs_extlen_t *flen, bool find_maximal); |
Darrick J. Wong | 2a06705 | 2016-10-03 09:11:33 -0700 | [diff] [blame] | 23 | extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip, |
Christoph Hellwig | d392bc8 | 2018-10-18 17:19:48 +1100 | [diff] [blame] | 24 | struct xfs_bmbt_irec *irec, bool *shared); |
Christoph Hellwig | 66ae56a | 2019-02-18 09:38:49 -0800 | [diff] [blame] | 25 | bool xfs_inode_need_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap, |
| 26 | bool *shared); |
Darrick J. Wong | 2a06705 | 2016-10-03 09:11:33 -0700 | [diff] [blame] | 27 | |
Christoph Hellwig | 3c68d44 | 2017-02-06 10:51:03 -0800 | [diff] [blame] | 28 | extern int xfs_reflink_allocate_cow(struct xfs_inode *ip, |
Christoph Hellwig | 78f0cc9 | 2019-02-18 09:38:46 -0800 | [diff] [blame] | 29 | struct xfs_bmbt_irec *imap, bool *shared, uint *lockmode, |
Darrick J. Wong | affe250 | 2019-02-21 16:26:35 -0800 | [diff] [blame] | 30 | bool convert_now); |
Darrick J. Wong | 5eda430 | 2017-02-02 15:14:02 -0800 | [diff] [blame] | 31 | extern int xfs_reflink_convert_cow(struct xfs_inode *ip, xfs_off_t offset, |
| 32 | xfs_off_t count); |
Darrick J. Wong | 2a06705 | 2016-10-03 09:11:33 -0700 | [diff] [blame] | 33 | |
Darrick J. Wong | 43caeb1 | 2016-10-03 09:11:35 -0700 | [diff] [blame] | 34 | extern int xfs_reflink_cancel_cow_blocks(struct xfs_inode *ip, |
| 35 | struct xfs_trans **tpp, xfs_fileoff_t offset_fsb, |
Christoph Hellwig | 3802a34 | 2017-03-07 16:45:58 -0800 | [diff] [blame] | 36 | xfs_fileoff_t end_fsb, bool cancel_real); |
Darrick J. Wong | 43caeb1 | 2016-10-03 09:11:35 -0700 | [diff] [blame] | 37 | extern int xfs_reflink_cancel_cow_range(struct xfs_inode *ip, xfs_off_t offset, |
Christoph Hellwig | 3802a34 | 2017-03-07 16:45:58 -0800 | [diff] [blame] | 38 | xfs_off_t count, bool cancel_real); |
Darrick J. Wong | 43caeb1 | 2016-10-03 09:11:35 -0700 | [diff] [blame] | 39 | extern int xfs_reflink_end_cow(struct xfs_inode *ip, xfs_off_t offset, |
| 40 | xfs_off_t count); |
Darrick J. Wong | 174edb0 | 2016-10-03 09:11:39 -0700 | [diff] [blame] | 41 | extern int xfs_reflink_recover_cow(struct xfs_mount *mp); |
Darrick J. Wong | 3f68c1f | 2018-10-30 10:47:06 +1100 | [diff] [blame] | 42 | extern loff_t xfs_reflink_remap_range(struct file *file_in, loff_t pos_in, |
Darrick J. Wong | 42ec3d4 | 2018-10-30 10:41:49 +1100 | [diff] [blame] | 43 | struct file *file_out, loff_t pos_out, loff_t len, |
Darrick J. Wong | a91ae49b | 2018-10-30 10:41:28 +1100 | [diff] [blame] | 44 | unsigned int remap_flags); |
Darrick J. Wong | ea7cdd7 | 2017-06-16 11:00:11 -0700 | [diff] [blame] | 45 | extern int xfs_reflink_inode_has_shared_extents(struct xfs_trans *tp, |
| 46 | struct xfs_inode *ip, bool *has_shared); |
Darrick J. Wong | 98cc2db | 2016-10-03 09:11:43 -0700 | [diff] [blame] | 47 | extern int xfs_reflink_clear_inode_flag(struct xfs_inode *ip, |
| 48 | struct xfs_trans **tpp); |
| 49 | extern int xfs_reflink_unshare(struct xfs_inode *ip, xfs_off_t offset, |
| 50 | xfs_off_t len); |
Darrick J. Wong | 3fc9f5e | 2018-10-30 10:47:26 +1100 | [diff] [blame] | 51 | extern int xfs_reflink_remap_prep(struct file *file_in, loff_t pos_in, |
| 52 | struct file *file_out, loff_t pos_out, loff_t *len, |
| 53 | unsigned int remap_flags); |
| 54 | extern int xfs_reflink_remap_blocks(struct xfs_inode *src, loff_t pos_in, |
| 55 | struct xfs_inode *dest, loff_t pos_out, loff_t remap_len, |
| 56 | loff_t *remapped); |
| 57 | extern int xfs_reflink_update_dest(struct xfs_inode *dest, xfs_off_t newlen, |
| 58 | xfs_extlen_t cowextsize, unsigned int remap_flags); |
| 59 | extern void xfs_reflink_remap_unlock(struct file *file_in, |
| 60 | struct file *file_out); |
Darrick J. Wong | 43caeb1 | 2016-10-03 09:11:35 -0700 | [diff] [blame] | 61 | |
Darrick J. Wong | 3993bae | 2016-10-03 09:11:32 -0700 | [diff] [blame] | 62 | #endif /* __XFS_REFLINK_H */ |