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_REFCOUNT_ITEM_H__ 7*4882a593Smuzhiyun #define __XFS_REFCOUNT_ITEM_H__ 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun /* 10*4882a593Smuzhiyun * There are (currently) two pairs of refcount btree redo item types: 11*4882a593Smuzhiyun * increase and decrease. The log items for these are CUI (refcount 12*4882a593Smuzhiyun * update intent) and CUD (refcount update done). The redo item type 13*4882a593Smuzhiyun * is encoded in the 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 17*4882a593Smuzhiyun * transaction that records the associated refcountbt updates. 18*4882a593Smuzhiyun * 19*4882a593Smuzhiyun * Should the system crash after the commit of the first transaction 20*4882a593Smuzhiyun * but before the commit of the final transaction in a series, log 21*4882a593Smuzhiyun * recovery will use the redo information recorded by the intent items 22*4882a593Smuzhiyun * to replay the refcountbt metadata updates. 23*4882a593Smuzhiyun */ 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun /* kernel only CUI/CUD 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_CUI_MAX_FAST_EXTENTS 16 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun /* 36*4882a593Smuzhiyun * This is the "refcount update intent" log item. It is used to log 37*4882a593Smuzhiyun * the fact that some reverse mappings need to change. It is used in 38*4882a593Smuzhiyun * conjunction with the "refcount update done" log item described 39*4882a593Smuzhiyun * below. 40*4882a593Smuzhiyun * 41*4882a593Smuzhiyun * These log items follow the same rules as struct xfs_efi_log_item; 42*4882a593Smuzhiyun * see the comments about that structure (in xfs_extfree_item.h) for 43*4882a593Smuzhiyun * more details. 44*4882a593Smuzhiyun */ 45*4882a593Smuzhiyun struct xfs_cui_log_item { 46*4882a593Smuzhiyun struct xfs_log_item cui_item; 47*4882a593Smuzhiyun atomic_t cui_refcount; 48*4882a593Smuzhiyun atomic_t cui_next_extent; 49*4882a593Smuzhiyun struct xfs_cui_log_format cui_format; 50*4882a593Smuzhiyun }; 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun static inline size_t xfs_cui_log_item_sizeof(unsigned int nr)53*4882a593Smuzhiyunxfs_cui_log_item_sizeof( 54*4882a593Smuzhiyun unsigned int nr) 55*4882a593Smuzhiyun { 56*4882a593Smuzhiyun return offsetof(struct xfs_cui_log_item, cui_format) + 57*4882a593Smuzhiyun xfs_cui_log_format_sizeof(nr); 58*4882a593Smuzhiyun } 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun /* 61*4882a593Smuzhiyun * This is the "refcount update done" log item. It is used to log the 62*4882a593Smuzhiyun * fact that some refcountbt updates mentioned in an earlier cui item 63*4882a593Smuzhiyun * have been performed. 64*4882a593Smuzhiyun */ 65*4882a593Smuzhiyun struct xfs_cud_log_item { 66*4882a593Smuzhiyun struct xfs_log_item cud_item; 67*4882a593Smuzhiyun struct xfs_cui_log_item *cud_cuip; 68*4882a593Smuzhiyun struct xfs_cud_log_format cud_format; 69*4882a593Smuzhiyun }; 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun extern struct kmem_zone *xfs_cui_zone; 72*4882a593Smuzhiyun extern struct kmem_zone *xfs_cud_zone; 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun #endif /* __XFS_REFCOUNT_ITEM_H__ */ 75