blob: bea65f2fe657687cb954c998b9275aeb1a430837 [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0+
Darrick J. Wong3993bae2016-10-03 09:11:32 -07002/*
3 * Copyright (C) 2016 Oracle. All Rights Reserved.
Darrick J. Wong3993bae2016-10-03 09:11:32 -07004 * Author: Darrick J. Wong <darrick.wong@oracle.com>
Darrick J. Wong3993bae2016-10-03 09:11:32 -07005 */
6#ifndef __XFS_REFLINK_H
7#define __XFS_REFLINK_H 1
8
Christoph Hellwig66ae56a2019-02-18 09:38:49 -08009static inline bool xfs_is_always_cow_inode(struct xfs_inode *ip)
10{
Dave Chinnerebd90272021-08-18 18:46:55 -070011 return ip->i_mount->m_always_cow && xfs_has_reflink(ip->i_mount);
Christoph Hellwig66ae56a2019-02-18 09:38:49 -080012}
13
14static 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
Darrick J. Wong92ff7282017-06-16 11:00:10 -070019extern 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);
Darrick J. Wong2a067052016-10-03 09:11:33 -070022extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip,
Christoph Hellwigd392bc82018-10-18 17:19:48 +110023 struct xfs_bmbt_irec *irec, bool *shared);
zhengbinaa124432020-01-20 14:34:47 -080024int xfs_bmap_trim_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
Christoph Hellwig66ae56a2019-02-18 09:38:49 -080025 bool *shared);
Darrick J. Wong2a067052016-10-03 09:11:33 -070026
Christoph Hellwigffb375a2019-10-19 09:09:43 -070027int xfs_reflink_allocate_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
28 struct xfs_bmbt_irec *cmap, bool *shared, uint *lockmode,
Darrick J. Wongaffe2502019-02-21 16:26:35 -080029 bool convert_now);
Darrick J. Wong5eda4302017-02-02 15:14:02 -080030extern int xfs_reflink_convert_cow(struct xfs_inode *ip, xfs_off_t offset,
31 xfs_off_t count);
Darrick J. Wong2a067052016-10-03 09:11:33 -070032
Darrick J. Wong43caeb12016-10-03 09:11:35 -070033extern int xfs_reflink_cancel_cow_blocks(struct xfs_inode *ip,
34 struct xfs_trans **tpp, xfs_fileoff_t offset_fsb,
Christoph Hellwig3802a342017-03-07 16:45:58 -080035 xfs_fileoff_t end_fsb, bool cancel_real);
Darrick J. Wong43caeb12016-10-03 09:11:35 -070036extern int xfs_reflink_cancel_cow_range(struct xfs_inode *ip, xfs_off_t offset,
Christoph Hellwig3802a342017-03-07 16:45:58 -080037 xfs_off_t count, bool cancel_real);
Darrick J. Wong43caeb12016-10-03 09:11:35 -070038extern int xfs_reflink_end_cow(struct xfs_inode *ip, xfs_off_t offset,
39 xfs_off_t count);
Darrick J. Wong174edb02016-10-03 09:11:39 -070040extern int xfs_reflink_recover_cow(struct xfs_mount *mp);
Darrick J. Wong3f68c1f2018-10-30 10:47:06 +110041extern loff_t xfs_reflink_remap_range(struct file *file_in, loff_t pos_in,
Darrick J. Wong42ec3d42018-10-30 10:41:49 +110042 struct file *file_out, loff_t pos_out, loff_t len,
Darrick J. Wonga91ae49b2018-10-30 10:41:28 +110043 unsigned int remap_flags);
Darrick J. Wongea7cdd72017-06-16 11:00:11 -070044extern int xfs_reflink_inode_has_shared_extents(struct xfs_trans *tp,
45 struct xfs_inode *ip, bool *has_shared);
Darrick J. Wong98cc2db2016-10-03 09:11:43 -070046extern int xfs_reflink_clear_inode_flag(struct xfs_inode *ip,
47 struct xfs_trans **tpp);
48extern int xfs_reflink_unshare(struct xfs_inode *ip, xfs_off_t offset,
49 xfs_off_t len);
Darrick J. Wong3fc9f5e2018-10-30 10:47:26 +110050extern 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);
53extern 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);
56extern int xfs_reflink_update_dest(struct xfs_inode *dest, xfs_off_t newlen,
57 xfs_extlen_t cowextsize, unsigned int remap_flags);
Darrick J. Wong43caeb12016-10-03 09:11:35 -070058
Darrick J. Wong3993bae2016-10-03 09:11:32 -070059#endif /* __XFS_REFLINK_H */