xref: /OK3568_Linux_fs/kernel/fs/xfs/xfs_bmap_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_BMAP_ITEM_H__
7*4882a593Smuzhiyun #define	__XFS_BMAP_ITEM_H__
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun /*
10*4882a593Smuzhiyun  * There are (currently) two pairs of bmap btree redo item types: map & unmap.
11*4882a593Smuzhiyun  * The common abbreviations for these are BUI (bmap update intent) and BUD
12*4882a593Smuzhiyun  * (bmap update done).  The redo item type is encoded in the flags field of
13*4882a593Smuzhiyun  * 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 bmbt updates.
18*4882a593Smuzhiyun  *
19*4882a593Smuzhiyun  * Should the system crash after the commit of the first transaction but
20*4882a593Smuzhiyun  * before the commit of the final transaction in a series, log recovery will
21*4882a593Smuzhiyun  * use the redo information recorded by the intent items to replay the
22*4882a593Smuzhiyun  * bmbt metadata updates in the non-first transaction.
23*4882a593Smuzhiyun  */
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun /* kernel only BUI/BUD definitions */
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun struct xfs_mount;
28*4882a593Smuzhiyun struct kmem_zone;
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun /*
31*4882a593Smuzhiyun  * Max number of extents in fast allocation path.
32*4882a593Smuzhiyun  */
33*4882a593Smuzhiyun #define	XFS_BUI_MAX_FAST_EXTENTS	1
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun /*
36*4882a593Smuzhiyun  * This is the "bmap update intent" log item.  It is used to log the fact that
37*4882a593Smuzhiyun  * some reverse mappings need to change.  It is used in conjunction with the
38*4882a593Smuzhiyun  * "bmap update done" log item described below.
39*4882a593Smuzhiyun  *
40*4882a593Smuzhiyun  * These log items follow the same rules as struct xfs_efi_log_item; see the
41*4882a593Smuzhiyun  * comments about that structure (in xfs_extfree_item.h) for more details.
42*4882a593Smuzhiyun  */
43*4882a593Smuzhiyun struct xfs_bui_log_item {
44*4882a593Smuzhiyun 	struct xfs_log_item		bui_item;
45*4882a593Smuzhiyun 	atomic_t			bui_refcount;
46*4882a593Smuzhiyun 	atomic_t			bui_next_extent;
47*4882a593Smuzhiyun 	struct xfs_bui_log_format	bui_format;
48*4882a593Smuzhiyun };
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun static inline size_t
xfs_bui_log_item_sizeof(unsigned int nr)51*4882a593Smuzhiyun xfs_bui_log_item_sizeof(
52*4882a593Smuzhiyun 	unsigned int		nr)
53*4882a593Smuzhiyun {
54*4882a593Smuzhiyun 	return offsetof(struct xfs_bui_log_item, bui_format) +
55*4882a593Smuzhiyun 			xfs_bui_log_format_sizeof(nr);
56*4882a593Smuzhiyun }
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun /*
59*4882a593Smuzhiyun  * This is the "bmap update done" log item.  It is used to log the fact that
60*4882a593Smuzhiyun  * some bmbt updates mentioned in an earlier bui item have been performed.
61*4882a593Smuzhiyun  */
62*4882a593Smuzhiyun struct xfs_bud_log_item {
63*4882a593Smuzhiyun 	struct xfs_log_item		bud_item;
64*4882a593Smuzhiyun 	struct xfs_bui_log_item		*bud_buip;
65*4882a593Smuzhiyun 	struct xfs_bud_log_format	bud_format;
66*4882a593Smuzhiyun };
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun extern struct kmem_zone	*xfs_bui_zone;
69*4882a593Smuzhiyun extern struct kmem_zone	*xfs_bud_zone;
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun #endif	/* __XFS_BMAP_ITEM_H__ */
72