xfs_reflink.h 2.5 KB
Newer Older
D
Dave Chinner 已提交
1
// SPDX-License-Identifier: GPL-2.0+
D
Darrick J. Wong 已提交
2 3 4 5 6 7 8
/*
 * Copyright (C) 2016 Oracle.  All Rights Reserved.
 * Author: Darrick J. Wong <darrick.wong@oracle.com>
 */
#ifndef __XFS_REFLINK_H
#define __XFS_REFLINK_H 1

9 10 11 12 13 14 15 16 17 18 19
static inline bool xfs_is_always_cow_inode(struct xfs_inode *ip)
{
	return ip->i_mount->m_always_cow &&
		xfs_sb_version_hasreflink(&ip->i_mount->m_sb);
}

static inline bool xfs_is_cow_inode(struct xfs_inode *ip)
{
	return xfs_is_reflink_inode(ip) || xfs_is_always_cow_inode(ip);
}

20 21 22
extern int xfs_reflink_find_shared(struct xfs_mount *mp, struct xfs_trans *tp,
		xfs_agnumber_t agno, xfs_agblock_t agbno, xfs_extlen_t aglen,
		xfs_agblock_t *fbno, xfs_extlen_t *flen, bool find_maximal);
23
extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip,
24
		struct xfs_bmbt_irec *irec, bool *shared);
25
int xfs_bmap_trim_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
26
		bool *shared);
27

28 29
int xfs_reflink_allocate_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
		struct xfs_bmbt_irec *cmap, bool *shared, uint *lockmode,
30
		bool convert_now);
31 32
extern int xfs_reflink_convert_cow(struct xfs_inode *ip, xfs_off_t offset,
		xfs_off_t count);
33

34 35
extern int xfs_reflink_cancel_cow_blocks(struct xfs_inode *ip,
		struct xfs_trans **tpp, xfs_fileoff_t offset_fsb,
36
		xfs_fileoff_t end_fsb, bool cancel_real);
37
extern int xfs_reflink_cancel_cow_range(struct xfs_inode *ip, xfs_off_t offset,
38
		xfs_off_t count, bool cancel_real);
39 40
extern int xfs_reflink_end_cow(struct xfs_inode *ip, xfs_off_t offset,
		xfs_off_t count);
41
extern int xfs_reflink_recover_cow(struct xfs_mount *mp);
42
extern loff_t xfs_reflink_remap_range(struct file *file_in, loff_t pos_in,
43
		struct file *file_out, loff_t pos_out, loff_t len,
44
		unsigned int remap_flags);
45 46
extern int xfs_reflink_inode_has_shared_extents(struct xfs_trans *tp,
		struct xfs_inode *ip, bool *has_shared);
47 48 49 50
extern int xfs_reflink_clear_inode_flag(struct xfs_inode *ip,
		struct xfs_trans **tpp);
extern int xfs_reflink_unshare(struct xfs_inode *ip, xfs_off_t offset,
		xfs_off_t len);
51 52 53 54 55 56 57 58 59 60
extern int xfs_reflink_remap_prep(struct file *file_in, loff_t pos_in,
		struct file *file_out, loff_t pos_out, loff_t *len,
		unsigned int remap_flags);
extern int xfs_reflink_remap_blocks(struct xfs_inode *src, loff_t pos_in,
		struct xfs_inode *dest, loff_t pos_out, loff_t remap_len,
		loff_t *remapped);
extern int xfs_reflink_update_dest(struct xfs_inode *dest, xfs_off_t newlen,
		xfs_extlen_t cowextsize, unsigned int remap_flags);
extern void xfs_reflink_remap_unlock(struct file *file_in,
		struct file *file_out);
61

D
Darrick J. Wong 已提交
62
#endif /* __XFS_REFLINK_H */