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