1*0b61f8a4SDave 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; 28baf4bcacSDarrick J. Wong struct kmem_zone; 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 * Define CUI flag bits. Manipulated by set/clear/test_bit operators. 37baf4bcacSDarrick J. Wong */ 38baf4bcacSDarrick J. Wong #define XFS_CUI_RECOVERED 1 39baf4bcacSDarrick J. Wong 40baf4bcacSDarrick J. Wong /* 41baf4bcacSDarrick J. Wong * This is the "refcount update intent" log item. It is used to log 42baf4bcacSDarrick J. Wong * the fact that some reverse mappings need to change. It is used in 43baf4bcacSDarrick J. Wong * conjunction with the "refcount update done" log item described 44baf4bcacSDarrick J. Wong * below. 45baf4bcacSDarrick J. Wong * 46baf4bcacSDarrick J. Wong * These log items follow the same rules as struct xfs_efi_log_item; 47baf4bcacSDarrick J. Wong * see the comments about that structure (in xfs_extfree_item.h) for 48baf4bcacSDarrick J. Wong * more details. 49baf4bcacSDarrick J. Wong */ 50baf4bcacSDarrick J. Wong struct xfs_cui_log_item { 51baf4bcacSDarrick J. Wong struct xfs_log_item cui_item; 52baf4bcacSDarrick J. Wong atomic_t cui_refcount; 53baf4bcacSDarrick J. Wong atomic_t cui_next_extent; 54baf4bcacSDarrick J. Wong unsigned long cui_flags; /* misc flags */ 55baf4bcacSDarrick J. Wong struct xfs_cui_log_format cui_format; 56baf4bcacSDarrick J. Wong }; 57baf4bcacSDarrick J. Wong 58baf4bcacSDarrick J. Wong static inline size_t 59baf4bcacSDarrick J. Wong xfs_cui_log_item_sizeof( 60baf4bcacSDarrick J. Wong unsigned int nr) 61baf4bcacSDarrick J. Wong { 62baf4bcacSDarrick J. Wong return offsetof(struct xfs_cui_log_item, cui_format) + 63baf4bcacSDarrick J. Wong xfs_cui_log_format_sizeof(nr); 64baf4bcacSDarrick J. Wong } 65baf4bcacSDarrick J. Wong 66baf4bcacSDarrick J. Wong /* 67baf4bcacSDarrick J. Wong * This is the "refcount update done" log item. It is used to log the 68baf4bcacSDarrick J. Wong * fact that some refcountbt updates mentioned in an earlier cui item 69baf4bcacSDarrick J. Wong * have been performed. 70baf4bcacSDarrick J. Wong */ 71baf4bcacSDarrick J. Wong struct xfs_cud_log_item { 72baf4bcacSDarrick J. Wong struct xfs_log_item cud_item; 73baf4bcacSDarrick J. Wong struct xfs_cui_log_item *cud_cuip; 74baf4bcacSDarrick J. Wong struct xfs_cud_log_format cud_format; 75baf4bcacSDarrick J. Wong }; 76baf4bcacSDarrick J. Wong 77baf4bcacSDarrick J. Wong extern struct kmem_zone *xfs_cui_zone; 78baf4bcacSDarrick J. Wong extern struct kmem_zone *xfs_cud_zone; 79baf4bcacSDarrick J. Wong 80baf4bcacSDarrick J. Wong struct xfs_cui_log_item *xfs_cui_init(struct xfs_mount *, uint); 81baf4bcacSDarrick J. Wong struct xfs_cud_log_item *xfs_cud_init(struct xfs_mount *, 82baf4bcacSDarrick J. Wong struct xfs_cui_log_item *); 83baf4bcacSDarrick J. Wong void xfs_cui_item_free(struct xfs_cui_log_item *); 84baf4bcacSDarrick J. Wong void xfs_cui_release(struct xfs_cui_log_item *); 8550995582SDarrick J. Wong int xfs_cui_recover(struct xfs_mount *mp, struct xfs_cui_log_item *cuip, 8650995582SDarrick J. Wong struct xfs_defer_ops *dfops); 87baf4bcacSDarrick J. Wong 88baf4bcacSDarrick J. Wong #endif /* __XFS_REFCOUNT_ITEM_H__ */ 89