blob: 28a43b7f581d00fa5623e2b5f0b0730ddb6b0e1e [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001// 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
David Brazdil0f672f62019-12-10 10:32:29 +00009static 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
15static 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
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000020extern 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);
23extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip,
David Brazdil0f672f62019-12-10 10:32:29 +000024 struct xfs_bmbt_irec *irec, bool *shared);
25bool xfs_inode_need_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
26 bool *shared);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000027
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000028extern int xfs_reflink_allocate_cow(struct xfs_inode *ip,
David Brazdil0f672f62019-12-10 10:32:29 +000029 struct xfs_bmbt_irec *imap, bool *shared, uint *lockmode,
30 bool convert_now);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000031extern int xfs_reflink_convert_cow(struct xfs_inode *ip, xfs_off_t offset,
32 xfs_off_t count);
33
34extern int xfs_reflink_cancel_cow_blocks(struct xfs_inode *ip,
35 struct xfs_trans **tpp, xfs_fileoff_t offset_fsb,
36 xfs_fileoff_t end_fsb, bool cancel_real);
37extern int xfs_reflink_cancel_cow_range(struct xfs_inode *ip, xfs_off_t offset,
38 xfs_off_t count, bool cancel_real);
39extern int xfs_reflink_end_cow(struct xfs_inode *ip, xfs_off_t offset,
40 xfs_off_t count);
41extern int xfs_reflink_recover_cow(struct xfs_mount *mp);
David Brazdil0f672f62019-12-10 10:32:29 +000042extern 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);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000045extern int xfs_reflink_inode_has_shared_extents(struct xfs_trans *tp,
46 struct xfs_inode *ip, bool *has_shared);
47extern int xfs_reflink_clear_inode_flag(struct xfs_inode *ip,
48 struct xfs_trans **tpp);
49extern int xfs_reflink_unshare(struct xfs_inode *ip, xfs_off_t offset,
50 xfs_off_t len);
David Brazdil0f672f62019-12-10 10:32:29 +000051extern 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);
54extern 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);
57extern int xfs_reflink_update_dest(struct xfs_inode *dest, xfs_off_t newlen,
58 xfs_extlen_t cowextsize, unsigned int remap_flags);
59extern void xfs_reflink_remap_unlock(struct file *file_in,
60 struct file *file_out);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000061
62#endif /* __XFS_REFLINK_H */