10b61f8a4SDave Chinner // SPDX-License-Identifier: GPL-2.0+ 2baf4bcacSDarrick J. Wong /* 3baf4bcacSDarrick J. Wong * Copyright (C) 2016 Oracle. All Rights Reserved. 4baf4bcacSDarrick J. Wong * Author: Darrick J. Wong <darrick.wong@oracle.com> 5baf4bcacSDarrick J. Wong */ 6baf4bcacSDarrick J. Wong #ifndef __XFS_REFCOUNT_ITEM_H__ 7baf4bcacSDarrick J. Wong #define __XFS_REFCOUNT_ITEM_H__ 8baf4bcacSDarrick J. Wong 9baf4bcacSDarrick J. Wong /* 10baf4bcacSDarrick J. Wong * There are (currently) two pairs of refcount btree redo item types: 11baf4bcacSDarrick J. Wong * increase and decrease. The log items for these are CUI (refcount 12baf4bcacSDarrick J. Wong * update intent) and CUD (refcount update done). The redo item type 13baf4bcacSDarrick J. Wong * is encoded in the flags field of each xfs_map_extent. 14baf4bcacSDarrick J. Wong * 15baf4bcacSDarrick J. Wong * *I items should be recorded in the *first* of a series of rolled 16baf4bcacSDarrick J. Wong * transactions, and the *D items should be recorded in the same 17baf4bcacSDarrick J. Wong * transaction that records the associated refcountbt updates. 18baf4bcacSDarrick J. Wong * 19baf4bcacSDarrick J. Wong * Should the system crash after the commit of the first transaction 20baf4bcacSDarrick J. Wong * but before the commit of the final transaction in a series, log 21baf4bcacSDarrick J. Wong * recovery will use the redo information recorded by the intent items 22baf4bcacSDarrick J. Wong * to replay the refcountbt metadata updates. 23baf4bcacSDarrick J. Wong */ 24baf4bcacSDarrick J. Wong 25baf4bcacSDarrick J. Wong /* kernel only CUI/CUD definitions */ 26baf4bcacSDarrick J. Wong 27baf4bcacSDarrick J. Wong struct xfs_mount; 28e7720afaSDarrick J. Wong struct kmem_cache; 29baf4bcacSDarrick J. Wong 30baf4bcacSDarrick J. Wong /* 31baf4bcacSDarrick J. Wong * Max number of extents in fast allocation path. 32baf4bcacSDarrick J. Wong */ 33baf4bcacSDarrick J. Wong #define XFS_CUI_MAX_FAST_EXTENTS 16 34baf4bcacSDarrick J. Wong 35baf4bcacSDarrick J. Wong /* 36baf4bcacSDarrick J. Wong * This is the "refcount update intent" log item. It is used to log 37baf4bcacSDarrick J. Wong * the fact that some reverse mappings need to change. It is used in 38baf4bcacSDarrick J. Wong * conjunction with the "refcount update done" log item described 39baf4bcacSDarrick J. Wong * below. 40baf4bcacSDarrick J. Wong * 41baf4bcacSDarrick J. Wong * These log items follow the same rules as struct xfs_efi_log_item; 42baf4bcacSDarrick J. Wong * see the comments about that structure (in xfs_extfree_item.h) for 43baf4bcacSDarrick J. Wong * more details. 44baf4bcacSDarrick J. Wong */ 45baf4bcacSDarrick J. Wong struct xfs_cui_log_item { 46baf4bcacSDarrick J. Wong struct xfs_log_item cui_item; 47baf4bcacSDarrick J. Wong atomic_t cui_refcount; 48baf4bcacSDarrick J. Wong atomic_t cui_next_extent; 49baf4bcacSDarrick J. Wong struct xfs_cui_log_format cui_format; 50baf4bcacSDarrick J. Wong }; 51baf4bcacSDarrick J. Wong 52baf4bcacSDarrick J. Wong static inline size_t xfs_cui_log_item_sizeof(unsigned int nr)53baf4bcacSDarrick J. Wongxfs_cui_log_item_sizeof( 54baf4bcacSDarrick J. Wong unsigned int nr) 55baf4bcacSDarrick J. Wong { 56baf4bcacSDarrick J. Wong return offsetof(struct xfs_cui_log_item, cui_format) + 57baf4bcacSDarrick J. Wong xfs_cui_log_format_sizeof(nr); 58baf4bcacSDarrick J. Wong } 59baf4bcacSDarrick J. Wong 60baf4bcacSDarrick J. Wong /* 61baf4bcacSDarrick J. Wong * This is the "refcount update done" log item. It is used to log the 62baf4bcacSDarrick J. Wong * fact that some refcountbt updates mentioned in an earlier cui item 63baf4bcacSDarrick J. Wong * have been performed. 64baf4bcacSDarrick J. Wong */ 65baf4bcacSDarrick J. Wong struct xfs_cud_log_item { 66baf4bcacSDarrick J. Wong struct xfs_log_item cud_item; 67baf4bcacSDarrick J. Wong struct xfs_cui_log_item *cud_cuip; 68baf4bcacSDarrick J. Wong struct xfs_cud_log_format cud_format; 69baf4bcacSDarrick J. Wong }; 70baf4bcacSDarrick J. Wong 71182696fbSDarrick J. Wong extern struct kmem_cache *xfs_cui_cache; 72182696fbSDarrick J. Wong extern struct kmem_cache *xfs_cud_cache; 73baf4bcacSDarrick J. Wong 74*783e8a7cSDarrick J. Wong struct xfs_refcount_intent; 75*783e8a7cSDarrick J. Wong 76*783e8a7cSDarrick J. Wong void xfs_refcount_defer_add(struct xfs_trans *tp, 77*783e8a7cSDarrick J. Wong struct xfs_refcount_intent *ri); 78*783e8a7cSDarrick J. Wong 79baf4bcacSDarrick J. Wong #endif /* __XFS_REFCOUNT_ITEM_H__ */ 80