Linux Audio

Check our new training course

Loading...
v4.17
 
 1/*
 2 * Copyright (C) 2016 Oracle.  All Rights Reserved.
 3 *
 4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
 5 *
 6 * This program is free software; you can redistribute it and/or
 7 * modify it under the terms of the GNU General Public License
 8 * as published by the Free Software Foundation; either version 2
 9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it would be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write the Free Software Foundation,
18 * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20#ifndef __XFS_REFLINK_H
21#define __XFS_REFLINK_H 1
22
23extern int xfs_reflink_find_shared(struct xfs_mount *mp, struct xfs_trans *tp,
24		xfs_agnumber_t agno, xfs_agblock_t agbno, xfs_extlen_t aglen,
25		xfs_agblock_t *fbno, xfs_extlen_t *flen, bool find_maximal);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip,
27		struct xfs_bmbt_irec *irec, bool *shared, bool *trimmed);
 
 
28
29extern int xfs_reflink_reserve_cow(struct xfs_inode *ip,
30		struct xfs_bmbt_irec *imap, bool *shared);
31extern int xfs_reflink_allocate_cow(struct xfs_inode *ip,
32		struct xfs_bmbt_irec *imap, bool *shared, uint *lockmode);
33extern int xfs_reflink_convert_cow(struct xfs_inode *ip, xfs_off_t offset,
34		xfs_off_t count);
35extern bool xfs_reflink_find_cow_mapping(struct xfs_inode *ip, xfs_off_t offset,
36		struct xfs_bmbt_irec *imap);
37extern void xfs_reflink_trim_irec_to_next_cow(struct xfs_inode *ip,
38		xfs_fileoff_t offset_fsb, struct xfs_bmbt_irec *imap);
39
40extern int xfs_reflink_cancel_cow_blocks(struct xfs_inode *ip,
41		struct xfs_trans **tpp, xfs_fileoff_t offset_fsb,
42		xfs_fileoff_t end_fsb, bool cancel_real);
43extern int xfs_reflink_cancel_cow_range(struct xfs_inode *ip, xfs_off_t offset,
44		xfs_off_t count, bool cancel_real);
45extern int xfs_reflink_end_cow(struct xfs_inode *ip, xfs_off_t offset,
46		xfs_off_t count);
47extern int xfs_reflink_recover_cow(struct xfs_mount *mp);
48extern int xfs_reflink_remap_range(struct file *file_in, loff_t pos_in,
49		struct file *file_out, loff_t pos_out, u64 len, bool is_dedupe);
 
50extern int xfs_reflink_inode_has_shared_extents(struct xfs_trans *tp,
51		struct xfs_inode *ip, bool *has_shared);
52extern int xfs_reflink_clear_inode_flag(struct xfs_inode *ip,
53		struct xfs_trans **tpp);
54extern int xfs_reflink_unshare(struct xfs_inode *ip, xfs_off_t offset,
55		xfs_off_t len);
 
 
 
 
 
 
 
 
56
57#endif /* __XFS_REFLINK_H */
v6.13.7
 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/*
10 * Check whether it is safe to free COW fork blocks from an inode. It is unsafe
11 * to do so when an inode has dirty cache or I/O in-flight, even if no shared
12 * extents exist in the data fork, because outstanding I/O may target blocks
13 * that were speculatively allocated to the COW fork.
14 */
15static inline bool
16xfs_can_free_cowblocks(struct xfs_inode *ip)
17{
18	struct inode *inode = VFS_I(ip);
19
20	if ((inode->i_state & I_DIRTY_PAGES) ||
21	    mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY) ||
22	    mapping_tagged(inode->i_mapping, PAGECACHE_TAG_WRITEBACK) ||
23	    atomic_read(&inode->i_dio_count))
24		return false;
25	return true;
26}
27
28extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip,
29		struct xfs_bmbt_irec *irec, bool *shared);
30int xfs_bmap_trim_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
31		bool *shared);
32
33int xfs_reflink_allocate_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
34		struct xfs_bmbt_irec *cmap, bool *shared, uint *lockmode,
35		bool convert_now);
 
36extern int xfs_reflink_convert_cow(struct xfs_inode *ip, xfs_off_t offset,
37		xfs_off_t count);
 
 
 
 
38
39extern int xfs_reflink_cancel_cow_blocks(struct xfs_inode *ip,
40		struct xfs_trans **tpp, xfs_fileoff_t offset_fsb,
41		xfs_fileoff_t end_fsb, bool cancel_real);
42extern int xfs_reflink_cancel_cow_range(struct xfs_inode *ip, xfs_off_t offset,
43		xfs_off_t count, bool cancel_real);
44extern int xfs_reflink_end_cow(struct xfs_inode *ip, xfs_off_t offset,
45		xfs_off_t count);
46extern int xfs_reflink_recover_cow(struct xfs_mount *mp);
47extern loff_t xfs_reflink_remap_range(struct file *file_in, loff_t pos_in,
48		struct file *file_out, loff_t pos_out, loff_t len,
49		unsigned int remap_flags);
50extern int xfs_reflink_inode_has_shared_extents(struct xfs_trans *tp,
51		struct xfs_inode *ip, bool *has_shared);
52extern int xfs_reflink_clear_inode_flag(struct xfs_inode *ip,
53		struct xfs_trans **tpp);
54extern int xfs_reflink_unshare(struct xfs_inode *ip, xfs_off_t offset,
55		xfs_off_t len);
56extern int xfs_reflink_remap_prep(struct file *file_in, loff_t pos_in,
57		struct file *file_out, loff_t pos_out, loff_t *len,
58		unsigned int remap_flags);
59extern int xfs_reflink_remap_blocks(struct xfs_inode *src, loff_t pos_in,
60		struct xfs_inode *dest, loff_t pos_out, loff_t remap_len,
61		loff_t *remapped);
62extern int xfs_reflink_update_dest(struct xfs_inode *dest, xfs_off_t newlen,
63		xfs_extlen_t cowextsize, unsigned int remap_flags);
64
65#endif /* __XFS_REFLINK_H */