xref: /linux/fs/xfs/xfs_exchmaps_item.h (revision 249ebf3f65f8530beb2cbfb91bff1d83ba88d23c)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (c) 2020-2024 Oracle.  All Rights Reserved.
4  * Author: Darrick J. Wong <djwong@kernel.org>
5  */
6 #ifndef	__XFS_EXCHMAPS_ITEM_H__
7 #define	__XFS_EXCHMAPS_ITEM_H__
8 
9 /*
10  * The file mapping exchange intent item helps us exchange multiple file
11  * mappings between two inode forks.  It does this by tracking the range of
12  * file block offsets that still need to be exchanged, and relogs as progress
13  * happens.
14  *
15  * *I items should be recorded in the *first* of a series of rolled
16  * transactions, and the *D items should be recorded in the same transaction
17  * that records the associated bmbt updates.
18  *
19  * Should the system crash after the commit of the first transaction but
20  * before the commit of the final transaction in a series, log recovery will
21  * use the redo information recorded by the intent items to replay the
22  * rest of the mapping exchanges.
23  */
24 
25 /* kernel only XMI/XMD definitions */
26 
27 struct xfs_mount;
28 struct kmem_cache;
29 
30 /*
31  * This is the incore file mapping exchange intent log item.  It is used to log
32  * the fact that we are exchanging mappings between two files.  It is used in
33  * conjunction with the incore file mapping exchange done log item described
34  * below.
35  *
36  * These log items follow the same rules as struct xfs_efi_log_item; see the
37  * comments about that structure (in xfs_extfree_item.h) for more details.
38  */
39 struct xfs_xmi_log_item {
40 	struct xfs_log_item		xmi_item;
41 	atomic_t			xmi_refcount;
42 	struct xfs_xmi_log_format	xmi_format;
43 };
44 
45 /*
46  * This is the incore file mapping exchange done log item.  It is used to log
47  * the fact that an exchange mentioned in an earlier xmi item have been
48  * performed.
49  */
50 struct xfs_xmd_log_item {
51 	struct xfs_log_item		xmd_item;
52 	struct xfs_xmi_log_item		*xmd_intent_log_item;
53 	struct xfs_xmd_log_format	xmd_format;
54 };
55 
56 extern struct kmem_cache	*xfs_xmi_cache;
57 extern struct kmem_cache	*xfs_xmd_cache;
58 
59 struct xfs_exchmaps_intent;
60 
61 void xfs_exchmaps_defer_add(struct xfs_trans *tp,
62 		struct xfs_exchmaps_intent *xmi);
63 
64 #endif	/* __XFS_EXCHMAPS_ITEM_H__ */
65