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