xref: /OK3568_Linux_fs/kernel/fs/xfs/xfs_rmap_item.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0+
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (C) 2016 Oracle.  All Rights Reserved.
4*4882a593Smuzhiyun  * Author: Darrick J. Wong <darrick.wong@oracle.com>
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun #ifndef	__XFS_RMAP_ITEM_H__
7*4882a593Smuzhiyun #define	__XFS_RMAP_ITEM_H__
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun /*
10*4882a593Smuzhiyun  * There are (currently) three pairs of rmap btree redo item types: map, unmap,
11*4882a593Smuzhiyun  * and convert.  The common abbreviations for these are RUI (rmap update
12*4882a593Smuzhiyun  * intent) and RUD (rmap update done).  The redo item type is encoded in the
13*4882a593Smuzhiyun  * flags field of each xfs_map_extent.
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * *I items should be recorded in the *first* of a series of rolled
16*4882a593Smuzhiyun  * transactions, and the *D items should be recorded in the same transaction
17*4882a593Smuzhiyun  * that records the associated rmapbt updates.  Typically, the first
18*4882a593Smuzhiyun  * transaction will record a bmbt update, followed by some number of
19*4882a593Smuzhiyun  * transactions containing rmapbt updates, and finally transactions with any
20*4882a593Smuzhiyun  * bnobt/cntbt updates.
21*4882a593Smuzhiyun  *
22*4882a593Smuzhiyun  * Should the system crash after the commit of the first transaction but
23*4882a593Smuzhiyun  * before the commit of the final transaction in a series, log recovery will
24*4882a593Smuzhiyun  * use the redo information recorded by the intent items to replay the
25*4882a593Smuzhiyun  * (rmapbt/bnobt/cntbt) metadata updates in the non-first transaction.
26*4882a593Smuzhiyun  */
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun /* kernel only RUI/RUD definitions */
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun struct xfs_mount;
31*4882a593Smuzhiyun struct kmem_zone;
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun /*
34*4882a593Smuzhiyun  * Max number of extents in fast allocation path.
35*4882a593Smuzhiyun  */
36*4882a593Smuzhiyun #define	XFS_RUI_MAX_FAST_EXTENTS	16
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun /*
39*4882a593Smuzhiyun  * This is the "rmap update intent" log item.  It is used to log the fact that
40*4882a593Smuzhiyun  * some reverse mappings need to change.  It is used in conjunction with the
41*4882a593Smuzhiyun  * "rmap update done" log item described below.
42*4882a593Smuzhiyun  *
43*4882a593Smuzhiyun  * These log items follow the same rules as struct xfs_efi_log_item; see the
44*4882a593Smuzhiyun  * comments about that structure (in xfs_extfree_item.h) for more details.
45*4882a593Smuzhiyun  */
46*4882a593Smuzhiyun struct xfs_rui_log_item {
47*4882a593Smuzhiyun 	struct xfs_log_item		rui_item;
48*4882a593Smuzhiyun 	atomic_t			rui_refcount;
49*4882a593Smuzhiyun 	atomic_t			rui_next_extent;
50*4882a593Smuzhiyun 	struct xfs_rui_log_format	rui_format;
51*4882a593Smuzhiyun };
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun static inline size_t
xfs_rui_log_item_sizeof(unsigned int nr)54*4882a593Smuzhiyun xfs_rui_log_item_sizeof(
55*4882a593Smuzhiyun 	unsigned int		nr)
56*4882a593Smuzhiyun {
57*4882a593Smuzhiyun 	return offsetof(struct xfs_rui_log_item, rui_format) +
58*4882a593Smuzhiyun 			xfs_rui_log_format_sizeof(nr);
59*4882a593Smuzhiyun }
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun /*
62*4882a593Smuzhiyun  * This is the "rmap update done" log item.  It is used to log the fact that
63*4882a593Smuzhiyun  * some rmapbt updates mentioned in an earlier rui item have been performed.
64*4882a593Smuzhiyun  */
65*4882a593Smuzhiyun struct xfs_rud_log_item {
66*4882a593Smuzhiyun 	struct xfs_log_item		rud_item;
67*4882a593Smuzhiyun 	struct xfs_rui_log_item		*rud_ruip;
68*4882a593Smuzhiyun 	struct xfs_rud_log_format	rud_format;
69*4882a593Smuzhiyun };
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun extern struct kmem_zone	*xfs_rui_zone;
72*4882a593Smuzhiyun extern struct kmem_zone	*xfs_rud_zone;
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun #endif	/* __XFS_RMAP_ITEM_H__ */
75