162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2016 Oracle. All Rights Reserved. 462306a36Sopenharmony_ci * Author: Darrick J. Wong <darrick.wong@oracle.com> 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci#ifndef __XFS_REFCOUNT_ITEM_H__ 762306a36Sopenharmony_ci#define __XFS_REFCOUNT_ITEM_H__ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci/* 1062306a36Sopenharmony_ci * There are (currently) two pairs of refcount btree redo item types: 1162306a36Sopenharmony_ci * increase and decrease. The log items for these are CUI (refcount 1262306a36Sopenharmony_ci * update intent) and CUD (refcount update done). The redo item type 1362306a36Sopenharmony_ci * is encoded in the flags field of each xfs_map_extent. 1462306a36Sopenharmony_ci * 1562306a36Sopenharmony_ci * *I items should be recorded in the *first* of a series of rolled 1662306a36Sopenharmony_ci * transactions, and the *D items should be recorded in the same 1762306a36Sopenharmony_ci * transaction that records the associated refcountbt updates. 1862306a36Sopenharmony_ci * 1962306a36Sopenharmony_ci * Should the system crash after the commit of the first transaction 2062306a36Sopenharmony_ci * but before the commit of the final transaction in a series, log 2162306a36Sopenharmony_ci * recovery will use the redo information recorded by the intent items 2262306a36Sopenharmony_ci * to replay the refcountbt metadata updates. 2362306a36Sopenharmony_ci */ 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci/* kernel only CUI/CUD definitions */ 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_cistruct xfs_mount; 2862306a36Sopenharmony_cistruct kmem_cache; 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci/* 3162306a36Sopenharmony_ci * Max number of extents in fast allocation path. 3262306a36Sopenharmony_ci */ 3362306a36Sopenharmony_ci#define XFS_CUI_MAX_FAST_EXTENTS 16 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* 3662306a36Sopenharmony_ci * This is the "refcount update intent" log item. It is used to log 3762306a36Sopenharmony_ci * the fact that some reverse mappings need to change. It is used in 3862306a36Sopenharmony_ci * conjunction with the "refcount update done" log item described 3962306a36Sopenharmony_ci * below. 4062306a36Sopenharmony_ci * 4162306a36Sopenharmony_ci * These log items follow the same rules as struct xfs_efi_log_item; 4262306a36Sopenharmony_ci * see the comments about that structure (in xfs_extfree_item.h) for 4362306a36Sopenharmony_ci * more details. 4462306a36Sopenharmony_ci */ 4562306a36Sopenharmony_cistruct xfs_cui_log_item { 4662306a36Sopenharmony_ci struct xfs_log_item cui_item; 4762306a36Sopenharmony_ci atomic_t cui_refcount; 4862306a36Sopenharmony_ci atomic_t cui_next_extent; 4962306a36Sopenharmony_ci struct xfs_cui_log_format cui_format; 5062306a36Sopenharmony_ci}; 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_cistatic inline size_t 5362306a36Sopenharmony_cixfs_cui_log_item_sizeof( 5462306a36Sopenharmony_ci unsigned int nr) 5562306a36Sopenharmony_ci{ 5662306a36Sopenharmony_ci return offsetof(struct xfs_cui_log_item, cui_format) + 5762306a36Sopenharmony_ci xfs_cui_log_format_sizeof(nr); 5862306a36Sopenharmony_ci} 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci/* 6162306a36Sopenharmony_ci * This is the "refcount update done" log item. It is used to log the 6262306a36Sopenharmony_ci * fact that some refcountbt updates mentioned in an earlier cui item 6362306a36Sopenharmony_ci * have been performed. 6462306a36Sopenharmony_ci */ 6562306a36Sopenharmony_cistruct xfs_cud_log_item { 6662306a36Sopenharmony_ci struct xfs_log_item cud_item; 6762306a36Sopenharmony_ci struct xfs_cui_log_item *cud_cuip; 6862306a36Sopenharmony_ci struct xfs_cud_log_format cud_format; 6962306a36Sopenharmony_ci}; 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ciextern struct kmem_cache *xfs_cui_cache; 7262306a36Sopenharmony_ciextern struct kmem_cache *xfs_cud_cache; 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci#endif /* __XFS_REFCOUNT_ITEM_H__ */ 75